Author Topic: Very strange problem with mouse input  (Read 1492 times)

0 Members and 1 Guest are viewing this topic.

Offline Sushi

  • Art Critic
  • 211
Very strange problem with mouse input
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?

 

Offline Sushi

  • Art Critic
  • 211
Re: Very strange problem with mouse input
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...
« Last Edit: November 16, 2010, 01:45:30 pm by Jeff Vader »

 

Offline Iss Mneur

  • 210
  • TODO:
Re: Very strange problem with mouse input
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...
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments