Reversing mouse movement

Started by
12 comments, last by Headkaze 13 years, 3 months ago
Say I have a global mouse hook using WH_MOUSE_LL is it possible to reverse mouse movement (left is right, up is down etc.)?

[Edited by - Headkaze on October 21, 2010 1:39:39 AM]
Advertisement
I'm not aware of any mechanism to change the input provided to you via a hook, no.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

I thought so. I wonder if it's possible to use RawInput and SetCursorPos to position it in reverse. Or would it have to be on a lower level than that? I guess what I'm asking is does anyone know of any way to reverse mouse movement?
This is for an app I'm writing to help the disabled. So if anyone has any ideas on how to implement this it would be greatly appreciated.
Quote:Original post by Headkaze
So if anyone has any ideas on how to implement this it would be greatly appreciated.
On older mice you could do this kind of thing very easily.

Buy an older mouse. Open it up. Reattach the horizontal and vertical sensors. Put the screws back in.

You can also use an older trackball circuit and stuff the guts into a mouse body for the same effect.

Since you can have multiple mice controlling a PC's cursor just fine, hook up both your regular mouse and reversed mouse.

Thanks frob but there are new mice that you that allow you to reverse movement via software anyway but it's only for that particular hardware.

I was hoping for a universal solution via software. I'm starting to think it's not possible though.
Quote:Original post by Headkaze
I thought so. I wonder if it's possible to use RawInput and SetCursorPos to position it in reverse. Or would it have to be on a lower level than that? I guess what I'm asking is does anyone know of any way to reverse mouse movement?
Actually, out of curiosity, I quickly checked your approach, with DirectInput though. The device gives me relative coordinates, bookkeeping and a simple calculation (screensize - absolutecoords) "inverts" the mouse globally when feeding it to SetScreenPos. Checked if I can "work" with such a mouse (clicking buttons, menus, selecting text, writing this post). Seems fine. But can't say if this will be sane for everything (e.g. login screen behaves normal).
Resurrecting thread at Headkaze's request for an update post.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

If you return nonzero from the hook procedure of a low-level mouse hook, doesn't the mouse event get filtered out? So couldn't the OP block all mouse movement messages with a low-level mouse hook and then invert cursor movement by fabricating synthetic mouse events with SendInput() or mouse_event()?
(from PM):
Quote:I tried setting the input mode to DIPROPAXISMODE_REL and using screensize - coords but it is not reversing the mouse movements.
Ok, here we go. You probably missed the "bookkeeping" part, which should be something like (pseudo code)
coords = clamp(coords + relative_coords, screensize)
where relative_coords is what you receive from DirectX or raw input. Just make sure the numbers make sense, e.g. by logging. Show your code if it still does not work.

This topic is closed to new replies.

Advertisement