Page 1 of 1

Reading input (keyboard, mouse) on an unfocused window?

Posted: Tue Aug 01, 2017 4:15 pm
by Moonkis
Well as the title says I'm wondering if it's at all possible within love to read keystrokes, mouse inputs when the game is unfocused (foreground)? isDown, keypressed and keyreleased seems to produce nothing when the window isn't focused.

Re: Reading input (keyboard, mouse) on an unfocused window?

Posted: Tue Aug 01, 2017 4:22 pm
by slime
love (and SDL, the library love uses for cross-platform input) don't have that capability. What sort of thing would you use it for?

Re: Reading input (keyboard, mouse) on an unfocused window?

Posted: Tue Aug 01, 2017 4:38 pm
by Moonkis
slime wrote: Tue Aug 01, 2017 4:22 pm love (and SDL, the library love uses for cross-platform input) don't have that capability. What sort of thing would you use it for?
Ah, I see. I imagine it being platform dependent. In this case I would use it to create a few graphical twitch/stream tools that are ran in the background, and needs to read the keyboard/mouse/gamepad, outside of Löve2D's scope I'm sure but I thought it was worth a shot to ask.

Re: Reading input (keyboard, mouse) on an unfocused window?

Posted: Tue Aug 01, 2017 4:45 pm
by slime
You can enable joystick/gamepad input events while the window isn't in focus, at least: https://bitbucket.org/rude/love/issues/ ... ndow-focus

Re: Reading input (keyboard, mouse) on an unfocused window?

Posted: Sun Aug 06, 2017 12:35 pm
by DarkShroom
can i add, if it's useful, that i have the same issue everywhere, it's the same on java for example

it's a security issue, it stops you from key logging, in the case of java, you need an OS specific hook, to do that keylogging :P

Re: Reading input (keyboard, mouse) on an unfocused window?

Posted: Sun Aug 06, 2017 2:35 pm
by zorg
You can also use the FFI to achieve the same thing in löve, probably; it wouldn't be a cross-platform solution though.