Fix Host_GetKeyState in a more effective way.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7308 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-03-06 04:31:43 +00:00
parent 9095dad009
commit ec7e160bdc
4 changed files with 15 additions and 20 deletions

View File

@ -595,11 +595,15 @@ bool Host_GetKeyState(int keycode)
#ifdef _WIN32
return GetAsyncKeyState(keycode);
#elif defined __WXGTK__
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_KEYSTATE);
event.SetInt(keycode);
main_frame->GetEventHandler()->AddPendingEvent(event);
main_frame->keystate_event.Wait();
return main_frame->bKeyStateResult;
std::unique_lock<std::mutex> lk(main_frame->keystate_lock, std::defer_lock);
if (!lk.try_lock())
return false;
bool key_pressed;
if (!wxIsMainThread()) wxMutexGuiEnter();
key_pressed = wxGetKeyState(wxKeyCode(keycode));
if (!wxIsMainThread()) wxMutexGuiLeave();
return key_pressed;
#else
return wxGetKeyState(wxKeyCode(keycode));
#endif