Framerate-Dependent Mouse Turn Speed?

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.
Post Reply
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Framerate-Dependent Mouse Turn Speed?

Post by jitspoe »

I'm not sure if this is specific to Windows 7, but I just noticed that, when running at 60+fps, everything seems to be fine - the mouse does not have accel and appears to turn the player consistently. If I run at a lower framerate, however, the player turns slower, especially when moving the mouse rapidly.

I'm using this:

SystemParametersInfo(SPI_SETMOUSE, 0, newmouseparms_noaccel, 0);

to make sure accel is disabled. I'm pretty sure I have accel disabled in the windows settings as well.

Is there a better way to get mouse input than the old GetCursorPos()/SetCursorPos()? I know it can be done with Direct Input somehow, but I seem to recall something about DirectInput not working in some cases, rendering the mouse movement not functional.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Framerate-Dependent Mouse Turn Speed?

Post by jitspoe »

Figured out what the issue is. When running with a low framerate, the mouse cursor can reach the edge of the screen, causing "negative accel" because the cursor is clipped to the window size.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Framerate-Dependent Mouse Turn Speed?

Post by Spike »

your newmouseparms_noaccel should be {0,0,0}.
some quake-derived engines use {1,0,0} which will double the speed without any acceleration on xp, but still allows a small amount of acceleration in vista+.

last I heard rawinput is the favoured input api on windows, but is only available from XP upwards (not 2k/9x).
you can query all sorts of devices, but beware that a few are reported twice as amalgamations of other devices.
multitouch devices on tablets can be supported with it too, but you need to parse the HID messages yourself.
I've no idea what apis they've left uncrippled in winrt, I don't really care either.
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Framerate-Dependent Mouse Turn Speed?

Post by jitspoe »

Yeah, the params are 0, 0, 0. Like I said, the problem turned out to be the cursor clipping since I was playing in a small window with a low framerate. I'm still going to investigate implementing raw input, though. On Windows, this is done with WM_INPUT and GetRawInputData: http://msdn.microsoft.com/en-us/library/ee418864(VS.85).aspx#WM_INPUT

Anybody know the best way to get raw mouse input on linux natively (without SDL or other libraries)?

Reading around, I'm kind of curious what Valve did wrong with their raw input implementation. I see a lot of complaints about it, ex: http://www.reddit.com/r/GlobalOffensive ... ut_faulty/
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Framerate-Dependent Mouse Turn Speed?

Post by jitspoe »

Using the code from the msdn link in my previous post seemed to work just fine. Still need to find a Linux solution.
Post Reply