From e8cb837db5ad63912b998b7d5b74ef9992d201ff Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 8 Jan 2010 16:24:51 +0000 Subject: [PATCH] Fix hotkeys. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2415 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/App.h | 5 +++-- pcsx2/gui/AppCoreThread.cpp | 2 +- pcsx2/gui/AppMain.cpp | 20 +++++++++++++++----- pcsx2/gui/Plugins.cpp | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 45913abe3d..989202c0cc 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -365,6 +365,7 @@ public: void SysExecute( CDVD_SourceType cdvdsrc, const wxString& elf_override=wxEmptyString ); void SysReset(); void ReloadPlugins(); + void LogicalVsync(); GSFrame& GetGSFrame() const; GSFrame* GetGSFramePtr() const { return m_gsFrame; } @@ -421,7 +422,8 @@ public: void OnProgramLogClosed(); protected: - bool SelfPostMethod( FnType_AppMethod method ); + bool SelfMethodInvoke( FnType_AppMethod method ); + bool SelfMethodPost( FnType_AppMethod method ); void InitDefaultGlobalAccelerators(); void BuildCommandHash(); @@ -442,7 +444,6 @@ protected: void OnFreezeThreadFinished( wxCommandEvent& evt ); void OnEmuKeyDown( wxKeyEvent& evt ); - void OnLogicalVsync( wxCommandEvent& evt ); void OnInvokeMethod( pxInvokeMethodEvent& evt ); diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index e8f2bee53c..799de5615e 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -153,7 +153,7 @@ void AppCoreThread::OnCleanupInThread() void AppCoreThread::PostVsyncToUI() { - wxGetApp().PostCommand( pxEvt_LogicalVsync ); + wxGetApp().LogicalVsync(); } void AppCoreThread::StateCheckInThread() diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 95420be63d..a576737311 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -200,8 +200,10 @@ void Pcsx2App::PadKeyDispatch( const keyEvent& ev ) // OnLogicalVsync - Event received from the AppCoreThread (EEcore) for each vsync, // roughly 50/60 times a second when frame limiting is enabled, and up to 10,000 // times a second if not (ok, not quite, but you get the idea... I hope.) -void Pcsx2App::OnLogicalVsync( wxCommandEvent& evt ) +void Pcsx2App::LogicalVsync() { + if( !SelfMethodPost( &Pcsx2App::LogicalVsync ) ) return; + if( !SysHasValidState() || g_plugins == NULL ) return; // Only call PADupdate here if we're using GSopen2. Legacy GSopen plugins have the @@ -609,10 +611,10 @@ void AppSaveSettings() // FALSE if the method was not posted to the main thread (meaning this IS the main thread!) // TRUE if the method was posted. // -bool Pcsx2App::SelfPostMethod( FnType_AppMethod method ) +bool Pcsx2App::SelfMethodInvoke( FnType_AppMethod method ) { if( wxThread::IsMain() ) return false; - + Semaphore sem; pxInvokeMethodEvent evt( method, sem ); AddPendingEvent( evt ); @@ -621,9 +623,17 @@ bool Pcsx2App::SelfPostMethod( FnType_AppMethod method ) return true; } +bool Pcsx2App::SelfMethodPost( FnType_AppMethod method ) +{ + if( wxThread::IsMain() ) return false; + pxInvokeMethodEvent evt( method ); + AddPendingEvent( evt ); + return true; +} + void Pcsx2App::OpenGsPanel() { - if( SelfPostMethod( &Pcsx2App::OpenGsPanel ) ) return; + if( SelfMethodInvoke( &Pcsx2App::OpenGsPanel ) ) return; if( m_gsFrame == NULL ) { @@ -642,7 +652,7 @@ void Pcsx2App::OpenGsPanel() void Pcsx2App::CloseGsPanel() { - if( SelfPostMethod( &Pcsx2App::CloseGsPanel ) ) return; + if( SelfMethodInvoke( &Pcsx2App::CloseGsPanel ) ) return; if( m_gsFrame != NULL ) { diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp index d3b8e7e30b..17e2beca3c 100644 --- a/pcsx2/gui/Plugins.cpp +++ b/pcsx2/gui/Plugins.cpp @@ -246,7 +246,7 @@ static bool plugin_load_lock = false; void Pcsx2App::ReloadPlugins() { - if( SelfPostMethod( &Pcsx2App::ReloadPlugins ) ) return; + if( SelfMethodInvoke( &Pcsx2App::ReloadPlugins ) ) return; if( plugin_load_lock ) return; CoreThread.Cancel();