bsnes-plus icon indicating copy to clipboard operation
bsnes-plus copied to clipboard

Unable to regain keyboard focus after sleep/lock

Open qwertymodo opened this issue 8 years ago • 12 comments

If my computer goes to sleep or I lock it while bsnes-plus is running, when I return, it refuses to accept any input unless I completely close the program and reopen. It doesn't crash, emulation resumes normally when you click on the window, but you can't press any keys.

qwertymodo avatar Jun 13 '16 18:06 qwertymodo

Interesting. I assume this is under Windows?

devinacker avatar Jun 13 '16 19:06 devinacker

Sorry, yes. Windows 7 x64.

qwertymodo avatar Jun 13 '16 19:06 qwertymodo

Funny, I was going to report a similar issue: This also applies when disconnecting and reconnecting the mouse/keyboard while bsnes-plus is running. (I use a KVM switch on a regular basis so I tripped over this.) All the dialogues work fine (debugger, settings, etc.) but the main emulation window doesn't pick up any keyboard events anymore. (Windows 10 x64)

mrehkopf avatar Jun 13 '16 20:06 mrehkopf

Yes, I guess I wasn't very clear about the symptoms. Input into all of the secondary windows, config dialogs, etc works fine, I can click things, the UI responds, etc. It's just the emulation itself that stops responding to input.

qwertymodo avatar Jun 13 '16 20:06 qwertymodo

In both cases, does it make a difference which input driver you're using (directinput / rawinput)?

devinacker avatar Jun 13 '16 20:06 devinacker

Just tested, it happens on both input drivers.

qwertymodo avatar Jun 13 '16 20:06 qwertymodo

Good point. For me only RawInput is affected. (Changing the input driver only "took" after restarting bsnes-plus)

mrehkopf avatar Jun 13 '16 20:06 mrehkopf

Took a look now that I'm at home, seems to happen to me with both input drivers, so the actual issue may be somewhere else.

I don't have the same issue with higan v098, so I'll do a quick comparison in a bit.

devinacker avatar Jun 14 '16 01:06 devinacker

I just looked into this a bit more, and I actually think I know what's happening. It's not actually losing keyboard focus, it thinks one of the modifier keys is held down when it isn't. After locking my computer and returning to find these symptoms, I opened up the input configuration and tried binding a key, only to find that it registered Ctrl+(the key I pressed) even though Ctrl wasn't pressed at all. Another time, same thing except with Super instead of Ctrl. So it's still registering input just fine, it's just borking the modifier state, resulting in keypresses not being processed as expected.

qwertymodo avatar Sep 15 '17 22:09 qwertymodo

Interesting, good catch. I'll see what I can do about that.

devinacker avatar Sep 16 '17 00:09 devinacker

In the meantime, at least I can work around the issue by mashing all of my modifier keys until they register properly. Before, I was just having to savestate and then close/reopen the emulator.

qwertymodo avatar Sep 16 '17 00:09 qwertymodo

Testing it more, rawinput and DirectX both continue to indicate that whatever modifier keys were down when locking are still down when unlocking, for some reason, so something is missing key release events once the lock happens. Not really sure what or why though.

devinacker avatar Sep 16 '17 07:09 devinacker