wgois / OIS

Official OIS repository. Object oriented Input System
https://wgois.github.io/OIS/
zlib License
254 stars 87 forks source link

Fixes unreliable behavior with win32 mouse #4

Closed Mikarnage closed 6 years ago

Mikarnage commented 11 years ago

(First posted here : https://bitbucket.org/cabalistic/ogredeps/pull-request/7/switched-win32mouse-to-use-getdevicestate/diff)

Detailed explanation of the bug

Context

Ogre based app under windows 7 Not fullscreen Mouse mode = non exclusive + foreground

Bug encountered

Click out of the Ogre window + alt-tab back to the Ogre window : OIS thinks that the mouse button is still pressed, even if it's not, until you click again. All other cases (alt tab out of Ogre window, or click back to the Ogre window) are OK

Diagnostic

OIS relies on GetDeviceData with DirectInput, which gives inconsistent results when focus is lost/gained.

Resolution

Using GetDeviceState() and comparing to the previous state seems to be much more reliable. Tested with OgreProcedural's ScriptInterpreter (an application where the user wants to regularly switch between an Ogre window and notepad)

Ybalrid commented 6 years ago

This is interesting. I can't merge that just yet, I will need to see if the issue you describe still exists on Win32, and if so, switch to use the GetDeviceState() API.

If you want to make this PR merge cleanly against the current master branch, it will be merged-in quicker. If not, I will get around to it soon, but I can't promise when ;-)

Ybalrid commented 6 years ago

This seems to be working fine. I'm closing the PR, will merge the branch into master ;-)