mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 08:15:33 +01:00
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:
parent
9095dad009
commit
ec7e160bdc
@ -353,10 +353,6 @@ CFrame::CFrame(wxFrame* parent,
|
|||||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||||
bFloatWindow[i] = false;
|
bFloatWindow[i] = false;
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
bKeyStateResult = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
|
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
|
||||||
|
|
||||||
// Give it a console early to show potential messages from this onward
|
// Give it a console early to show potential messages from this onward
|
||||||
@ -663,10 +659,6 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
|
|||||||
_("Warning"), event.GetInt() ? wxYES_NO : wxOK, wxGetActiveWindow()));
|
_("Warning"), event.GetInt() ? wxYES_NO : wxOK, wxGetActiveWindow()));
|
||||||
panic_event.Set();
|
panic_event.Set();
|
||||||
break;
|
break;
|
||||||
case IDM_KEYSTATE:
|
|
||||||
bKeyStateResult = wxGetKeyState(wxKeyCode(event.GetInt()));
|
|
||||||
keystate_event.Set();
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case WM_USER_STOP:
|
case WM_USER_STOP:
|
||||||
|
@ -145,8 +145,7 @@ class CFrame : public CRenderFrame
|
|||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
Common::Event panic_event;
|
Common::Event panic_event;
|
||||||
bool bPanicResult;
|
bool bPanicResult;
|
||||||
Common::Event keystate_event;
|
std::mutex keystate_lock;
|
||||||
bool bKeyStateResult;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
|
@ -1021,6 +1021,11 @@ void CFrame::DoStop()
|
|||||||
{
|
{
|
||||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||||
{
|
{
|
||||||
|
#if defined __WXGTK__
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
std::lock_guard<std::mutex> lk(keystate_lock);
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
#endif
|
||||||
// Ask for confirmation in case the user accidentally clicked Stop / Escape
|
// Ask for confirmation in case the user accidentally clicked Stop / Escape
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
|
||||||
{
|
{
|
||||||
@ -1043,11 +1048,6 @@ void CFrame::DoStop()
|
|||||||
if(Frame::IsPlayingInput() || Frame::IsRecordingInput())
|
if(Frame::IsPlayingInput() || Frame::IsRecordingInput())
|
||||||
Frame::EndPlayInput(false);
|
Frame::EndPlayInput(false);
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
// Make sure the app doesn't hang waiting on a keystate check
|
|
||||||
keystate_event.Set();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BootManager::Stop();
|
BootManager::Stop();
|
||||||
|
|
||||||
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
@ -595,11 +595,15 @@ bool Host_GetKeyState(int keycode)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetAsyncKeyState(keycode);
|
return GetAsyncKeyState(keycode);
|
||||||
#elif defined __WXGTK__
|
#elif defined __WXGTK__
|
||||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_KEYSTATE);
|
std::unique_lock<std::mutex> lk(main_frame->keystate_lock, std::defer_lock);
|
||||||
event.SetInt(keycode);
|
if (!lk.try_lock())
|
||||||
main_frame->GetEventHandler()->AddPendingEvent(event);
|
return false;
|
||||||
main_frame->keystate_event.Wait();
|
|
||||||
return main_frame->bKeyStateResult;
|
bool key_pressed;
|
||||||
|
if (!wxIsMainThread()) wxMutexGuiEnter();
|
||||||
|
key_pressed = wxGetKeyState(wxKeyCode(keycode));
|
||||||
|
if (!wxIsMainThread()) wxMutexGuiLeave();
|
||||||
|
return key_pressed;
|
||||||
#else
|
#else
|
||||||
return wxGetKeyState(wxKeyCode(keycode));
|
return wxGetKeyState(wxKeyCode(keycode));
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user