Hard Light Productions Forums

General FreeSpace => FreeSpace & FreeSpace Open Support => Topic started by: Sushi on November 13, 2010, 09:58:43 am

Title: Very strange problem with mouse input
Post by: Sushi on November 13, 2010, 09:58:43 am
I've got a very weird bug going on with mouse input. Basically, If I'm moving the mouse while holding a key down, the mouse will sometimes jump much further than it should. This only seems to happen when FPS is low-ish, but it's pretty consistent: if I get any visible stutter at all and hold down a key, my mouse is liable to jump. I never had this problem on my old computer, even though it was significantly slower. (Old was 32bit XP, New is 64bit Win7). It's very aggravating to be trying to line up a shot and have the mouse suddenly jump much further than it should, especially when using the mouse script. The problem happens whether I use the mouse script, ordinary Freespace mouse support, or a PPJoy mouse-powered virtual joystick.

Anyone else seen this? Any ideas?
Title: Re: Very strange problem with mouse input
Post by: Sushi on November 16, 2010, 09:25:22 am
For the record, I've also tried switching around the default mouse drivers and even using a different (still generic) mouse. No luck.

I have, however, had some luck with undefining USE_DIRECTINPUT in mouse.cpp. This causes some other unrelated problems (mouse vertically constrained in a funny way) but fixes the jumping problem. This tells me that the problem is almost certainly solvable in code. That's heartening, I know how to handle that kind of problem.   ;7

This patch fixes the problem for me:

Code: [Select]
Index: code/io/mouse.cpp
===================================================================
--- code/io/mouse.cpp (revision 6748)
+++ code/io/mouse.cpp (working copy)
@@ -23,7 +23,7 @@
 #include "cmdline/cmdline.h"
 
 #ifdef WIN32
-#define USE_DIRECTINPUT
+//#define USE_DIRECTINPUT
 #endif
 
 #define MOUSE_MODE_DI 0
@@ -729,7 +729,7 @@
 
 #ifdef _WIN32
  GetCursorPos(pt);
- ScreenToClient((HWND)os_get_window(), pt);
+ //ScreenToClient((HWND)os_get_window(), pt);
 #else
  SDL_GetMouseState(&pt->x, &pt->y);
 #endif

It almost certainly breaks playing in a window, though, so I don't recommend it for general consumption in its current state. Especially since I am so far the only person to report having this problem. :)

I am curious, though, why we use DirectInput for the mouse when it clearly works without it...
Title: Re: Very strange problem with mouse input
Post by: Iss Mneur on November 16, 2010, 01:01:49 pm
I am curious, though, why we use DirectInput for the mouse when it clearly works without it...
Presumably DirectInput provides finer control over the mouse...