pcsx2: always probe the ctrl/shift/alt key state

Event handling becomes messy when you press in the app but release outside of it (due to desktop change)

close #477
This commit is contained in:
Gregory Hainaut 2016-11-08 22:42:42 +01:00
parent 5b3dfc3f9e
commit 784f549339
1 changed files with 6 additions and 9 deletions

View File

@ -278,7 +278,6 @@ extern int TranslateGDKtoWXK( u32 keysym );
void Pcsx2App::PadKeyDispatch( const keyEvent& ev ) void Pcsx2App::PadKeyDispatch( const keyEvent& ev )
{ {
m_kevt.SetEventType( ( ev.evt == KEYPRESS ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ); m_kevt.SetEventType( ( ev.evt == KEYPRESS ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP );
const bool isDown = (ev.evt == KEYPRESS);
//returns 0 for normal keys and a WXK_* value for special keys //returns 0 for normal keys and a WXK_* value for special keys
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -291,14 +290,12 @@ void Pcsx2App::PadKeyDispatch( const keyEvent& ev )
# error Unsupported Target Platform. # error Unsupported Target Platform.
#endif #endif
switch (vkey) // Don't rely on current event handling to get the state of those specials keys.
{ // Typical linux bug: hit ctrl-alt key to switch the desktop. Key will be released
case WXK_SHIFT: m_kevt.m_shiftDown = isDown; return; // outside of the window so the app isn't aware of the current key state.
case WXK_CONTROL: m_kevt.m_controlDown = isDown; return; m_kevt.m_shiftDown = wxGetKeyState(WXK_SHIFT);
m_kevt.m_controlDown = wxGetKeyState(WXK_CONTROL);
case WXK_ALT: // ALT/MENU are usually the same key? I'm confused. m_kevt.m_altDown = wxGetKeyState(WXK_MENU) || wxGetKeyState(WXK_ALT);
case WXK_MENU: m_kevt.m_altDown = isDown; return;
}
m_kevt.m_keyCode = vkey? vkey : ev.key; m_kevt.m_keyCode = vkey? vkey : ev.key;