citra-qt: release all buttons when render window focus is lost

This commit is contained in:
Aidan Noll 2017-01-27 15:22:45 -05:00
parent 372db835f4
commit 218ad5c89e
4 changed files with 23 additions and 0 deletions

View File

@ -230,6 +230,10 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
motion_emu->EndTilt();
}
void GRenderWindow::focusOutEvent(QFocusEvent* event) {
KeyMap::ReleaseAllKeys(*this);
}
void GRenderWindow::ReloadSetKeymaps() {
KeyMap::ClearKeyMapping(keyboard_id);
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {

View File

@ -127,6 +127,8 @@ public:
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void focusOutEvent(QFocusEvent* event) override;
void ReloadSetKeymaps() override;
void OnClientAreaResized(unsigned width, unsigned height);

View File

@ -149,4 +149,16 @@ void ReleaseKey(EmuWindow& emu_window, HostDeviceKey key) {
}
}
}
void ReleaseAllKeys(EmuWindow& emu_window) {
// Release "all" of the buttons.
emu_window.ButtonReleased({0xFFFFFFFF});
circle_pad_up = false;
circle_pad_right = false;
circle_pad_left = false;
circle_pad_right = false;
circle_pad_modifier = false;
UpdateCirclePad(emu_window);
}
}

View File

@ -90,4 +90,9 @@ void PressKey(EmuWindow& emu_window, HostDeviceKey key);
* Maps a key release action and call the corresponding function in EmuWindow
*/
void ReleaseKey(EmuWindow& emu_window, HostDeviceKey key);
/**
* Releases all pressed keys and resets the circle pad state to the center.
*/
void ReleaseAllKeys(EmuWindow& emu_window);
}