Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: OIS mouse bugs with focus/unfocusing  (Read 573 times)

fantasia

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 4
    • View Profile
OIS mouse bugs with focus/unfocusing
« on: November 23, 2009, 02:42:34 AM »

I traced out some bugs with OIS when focusing/unfocusing the application's window. They are always reproducable on Windows7, don't know about other versions.

The bug is this : if you unfocus your app by clicking anywhere outside the window with, say, mouse button 1, then refocus by clicking on the window with mouse button != 1, mouse->capture() will report that mouse button 1 is CONTINUOUSLY pressed down. To stop it, you must re-click the window with mouse button 1.

I hacked this bug around like this :
1) Check when your app gains or loses focus.
2) When regaining focus, execute the following lines :
...
if (weHaveJustRegainedFocus) {
   // KEEP THE FOLLOWING ORDER
   mouse->capture(); // this line prevents reporting "buttons=1" when regaining focus.
   const_cast<OIS::MouseState &>(mouse->getMouseState()).clear(); // prevent bug of reporting falsely that mouse button X is contiously pressed
   return; // don't report any mouse buttons pressed to my app, last click is considered to be for regaining application focus
}
...

Hope I wasn't too unclear. I am sure this could easily be fixed from the OIS source code, but I don't have the time to check it out.

Cheers,
Bill Kotsias
Logged