Mouse control sucks when using "pointer precision"

BlitzMax Forums/BlitzMax Programming/Mouse control sucks when using "pointer precision"

sswift(Posted 2009) [#1]
I encountered a problem with my space shooter the other day when I was demonstrating it to a friend on my laptop.

The game had become unplayable because the ship would either move really slowly, or accelerate really fast.

I traced the cause of this issue to a setting in the mouse control panel called "pointer precision" which causes the mouse's speed to be non-linear. In other words, the speed at which you move the mouse does not correspond 1:1 with the speed the cursor moves on the screen. There's a threshold speed below which the mouse moves at say half speed, and above which it moves at normal speed.

Anyway, I was wondering if there was some way to avoid this issue. I know from my days working in DOS that mice don't send screen coordinates to the PC, they send "mickeys" which used to be the little ticks of the wheel. So instead of having to hack the mouse by resetting the mouse cursor to the middle of the screen each frame to try to determine the speed of it that way, you could just read the speed on each axis directly. I would assume there is a way to do this in Windows, which commercial games use, and which is unaffected by silly settings like "pointer precision".

So, anyone got any ideas?


skidracer(Posted 2009) [#2]
The mouse is a pointing device, I've never seen any evidence that it makes an effective analog controller.

Since DirectInput was discontinued I don't think there is any way to go low level anyway,

oh, look, i'm wrong, why use google when others can do it for you :)

http://msdn.microsoft.com/en-us/library/bb206183(VS.85).aspx


sswift(Posted 2009) [#3]
Google wouldn't find me a premade blitz lib someone wrote and hasn't put in the code archives.

Well, not yet anyway. Give it a few more years. :-)


BlitzSupport(Posted 2009) [#4]
I remembered reading an article long ago about Windows' mouse acceleration algorithm, and it turned out to be linked from that page. The link is broken, but it offers a re-direct to here:

http://www.microsoft.com/whdc/archive/pointer-bal.mspx

I believe Enhanced Pointer Precision does the opposite of the acceleration thing sswift mentions, but this article would let you re-implement that acceleration with enhanced precision, since they explain the algorithm used.

If only OS X used the same algorithm... I find it almost impossible to get a decent 'feel' from the settings it offers.


sswift(Posted 2009) [#5]
Okay, I found a list of events in BlitzMax:

Const EVENT_APPMASK=$100
Const EVENT_APPSUSPEND=$101
Const EVENT_APPRESUME=$102
Const EVENT_APPTERMINATE=$103
Const EVENT_APPOPENFILE=$104
Const EVENT_APPIDLE=$105		'Reserved by Mark!

Const EVENT_KEYMASK=$200
Const EVENT_KEYDOWN=$201
Const EVENT_KEYUP=$202
Const EVENT_KEYCHAR=$203
Const EVENT_KEYREPEAT=$204

Const EVENT_MOUSEMASK=$400
Const EVENT_MOUSEDOWN=$401
Const EVENT_MOUSEUP=$402
Const EVENT_MOUSEMOVE=$403
Const EVENT_MOUSEWHEEL=$404
Const EVENT_MOUSEENTER=$405
Const EVENT_MOUSELEAVE=$406

Const EVENT_TIMERMASK=$800
Const EVENT_TIMERTICK=$801

Const EVENT_HOTKEYMASK=$1000
Const EVENT_HOTKEYHIT=$1001

Const EVENT_GADGETMASK=$2000
Const EVENT_GADGETACTION=$2001
Const EVENT_GADGETPAINT=$2002
Const EVENT_GADGETSELECT=$2003
Const EVENT_GADGETMENU=$2004
Const EVENT_GADGETOPEN=$2005
Const EVENT_GADGETCLOSE=$2006
Const EVENT_GADGETDONE=$2007
Const EVENT_GADGETLOSTFOCUS=$2008
Const EVENT_GADGETSHAPE=$2009	'reserved by Mark!

Const EVENT_WINDOWMASK=$4000
Const EVENT_WINDOWMOVE=$4001
Const EVENT_WINDOWSIZE=$4002
Const EVENT_WINDOWCLOSE=$4003
Const EVENT_WINDOWACTIVATE=$4004
Const EVENT_WINDOWACCEPT=$4005

Const EVENT_MENUMASK=$8000
Const EVENT_MENUACTION=$8001

Const EVENT_STREAMMASK=$10000
Const EVENT_STREAMEOF=$10001
Const EVENT_STREAMAVAIL=$10002

Const EVENT_PROCESSMASK=$20000
Const EVENT_PROCESSEXIT=$20001

Const EVENT_USEREVENTMASK=$80000000


But this doesn't seem to have something along the lines of WM_INPUT. Which means, I suppose, that if I want to make use of that, that I would need to get windows events some other way? And that if I did so, it would only work on Windows, and not Mac?


plash(Posted 2009) [#6]
And that if I did so, it would only work on Windows, and not Mac?
Yup. This is about Windows' precision pointer setting.. Where did the Mac come in?

http://msdn.microsoft.com/en-us/library/ms633573(VS.85).aspx
http://www.blitzbasic.com/Community/posts.php?topic=50175#558050


sswift(Posted 2009) [#7]
Yup. This is about Windows' precision pointer setting.. Where did the Mac come in?


Well, if you're going to read the speed of the mouse, then you want to read the speed of the mouse, not have a hack on the Mac to do it, and do it a different, but proper way on the PC. That would make for some messy and confusing code.

Also, I don't know if the Mac has any mouse acceleration built in, but if it is, I'd want to disable it there as well. In addition, if different Mac mice have different levels of sensitivity, you'd want to take advantage of that as well.

But even if all Mac mice are the same, and there is no acceleration built into the pointer, I'd want to read the acceleration for that as well, just so that you can have one cleanly written function that reads the acceleration on all platforms, and you don't have to kludge one of them with mouse recentering hacks.


GaryV(Posted 2009) [#8]
Since DirectInput was discontinued I don't think there is any way to go low level anyway,


It is just a mouse and not overly complex. He could write his own mouse driver.


Brucey(Posted 2009) [#9]
if different Mac mice have different levels of sensitivity

A mouse is a mouse.
I currently have a Logitech optical mouse plugged into my Mac.

My preference is for my mouse to be very sensitive - slow movements, slow mouse, faster movements very fast mouse - which is of course completely customisable via the system preferences.


sswift(Posted 2009) [#10]
"A mouse is a mouse."

Nope. Some have 300 dpi, and others have 600dpi. :-)


xlsior(Posted 2009) [#11]
...for starters. Some high-end gaming mice will support 3600 dpi..