zeth / inputs

Cross-platform Python support for keyboards, mice and gamepads
BSD 3-Clause "New" or "Revised" License
268 stars 88 forks source link

Allow one to only get input when a spacific window is focused #61

Open frastlin opened 5 years ago

frastlin commented 5 years ago

Hello, I don't want to log all key commands to my game when the user is not focused on the game window. There should be an attribute of inputs that one can set to only capture input of a specific window. Here is what I found: The second answer claims to be cross-platform Getting Window Title on Windows OSX get active window

The problem is that all these require something like win32. I know pygame can tell if the game window is focused without these dependencies. I wonder if the same process can let inputs know that the window has changed focus? Thanks,

Sartek commented 5 years ago

inputs doesn't bind to a specific window as far as I am aware, it accesses the input directly. you could check if your window is active/in focus and ignore input if it isn't. If you want to only track mouse input that is in an active window you will need to calculate when the mouse is in the mouse window yourself.

I'm fairly sure this is out of the scope of inputs