From db1765c4256fc7990347870e0862bc764f7a7398 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sun, 30 Jan 2011 16:40:38 +0000 Subject: [PATCH] Move async checking for pressed keys into Host_GetKeyState() and use wxGetKeyState on platforms other than Windows. I am not sure if wxGetKeyState is unreliable on Windows or if the use of GetAsyncKeyState() is simply historical, but for now I've left the Windows call in there just in case. This does mean that Host_GetKeyState() is currently only valid for the small set of keycodes that overlap between wx and Win32, one of which is VK_TAB/WXK_TAB. Anyway, please test wxGetKeyState on Windows and remove the ifdef if it works, so we can extend it to the remaining hotkeys. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6988 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/AudioCommon/Src/Mixer.cpp | 6 ++--- Source/Core/Core/Src/Boot/Boot.cpp | 1 - Source/Core/Core/Src/Core.cpp | 5 +---- Source/Core/Core/Src/HW/CPU.cpp | 3 --- Source/Core/Core/Src/Host.h | 30 +++++++++++-------------- Source/Core/DolphinWX/Src/Main.cpp | 13 ++++++----- Source/Core/DolphinWX/Src/MainNoGUI.cpp | 4 +--- Source/UnitTests/UnitTests.cpp | 24 -------------------- 8 files changed, 26 insertions(+), 60 deletions(-) diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index dd08ed57af..2348b2d470 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -20,6 +20,7 @@ #include "Mixer.h" #include "AudioCommon.h" #include "CPUDetect.h" +#include "Host.h" #include "../../Core/Src/HW/AudioInterface.h" @@ -148,9 +149,8 @@ void CMixer::PushSamples(const short *samples, unsigned int num_samples) if (*PowerPC::GetStatePtr() != 0) break; // Shortcut key for Throttle Skipping -#ifdef _WIN32 - if (GetAsyncKeyState(VK_TAB)) break;; -#endif + if (Host_GetKeyState('\t')) + break; SLEEP(1); soundStream->Update(); } diff --git a/Source/Core/Core/Src/Boot/Boot.cpp b/Source/Core/Core/Src/Boot/Boot.cpp index e7e89c2ccb..743aba2c77 100644 --- a/Source/Core/Core/Src/Boot/Boot.cpp +++ b/Source/Core/Core/Src/Boot/Boot.cpp @@ -78,7 +78,6 @@ void CBoot::Load_FST(bool _bIsWii) void CBoot::UpdateDebugger_MapLoaded(const char *_gameID) { Host_NotifyMapLoaded(); - Host_UpdateMemoryView(); } std::string CBoot::GenerateMapFilename() diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index a00097d755..62e8ba1118 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -557,11 +557,8 @@ void VideoThrottle() u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 1) ? SConfig::GetInstance().m_Framelimit * 5 : VideoInterface::TargetRefreshRate; -#ifdef _WIN32 // Disable the frame-limiter when the throttle (Tab) key is held down - if (!GetAsyncKeyState(VK_TAB)) -#endif - if (SConfig::GetInstance().m_Framelimit) + if (SConfig::GetInstance().m_Framelimit && !Host_GetKeyState('\t')) { u32 frametime = ((SConfig::GetInstance().b_UseFPS)? Common::AtomicLoad(DrawnFrame) : DrawnVideo) * 1000 / TargetVPS; diff --git a/Source/Core/Core/Src/HW/CPU.cpp b/Source/Core/Core/Src/HW/CPU.cpp index c5425a4055..0b7f4ccb3b 100644 --- a/Source/Core/Core/Src/HW/CPU.cpp +++ b/Source/Core/Core/Src/HW/CPU.cpp @@ -114,13 +114,10 @@ void CCPU::EnableStepping(const bool _bStepping) if (_bStepping) { PowerPC::Pause(); - // TODO(ector): why a sleep? - Host_SetDebugMode(true); CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PAUSE); } else { - Host_SetDebugMode(false); PowerPC::Start(); m_StepEvent.Set(); CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PLAY); diff --git a/Source/Core/Core/Src/Host.h b/Source/Core/Core/Src/Host.h index b73c52c556..1c3758cd7b 100644 --- a/Source/Core/Core/Src/Host.h +++ b/Source/Core/Core/Src/Host.h @@ -36,26 +36,22 @@ // The host can be just a command line app that opens a window, or a full blown debugger // interface. +bool Host_RendererHasFocus(); +void Host_ConnectWiimote(int wm_idx, bool connect); +bool Host_GetKeyState(int keycode); +void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height); void Host_Message(int Id); -void Host_UpdateMainFrame(); -void Host_UpdateTitle(const char* title); +void Host_NotifyMapLoaded(); +void Host_RequestRenderWindowSize(int width, int height); +void Host_SetWaitCursor(bool enable); +void Host_SetWiiMoteConnectionState(int _State); +void Host_ShowJitResults(unsigned int address); +void Host_SysMessage(const char *fmt, ...); +void Host_UpdateBreakPointView(); void Host_UpdateDisasmDialog(); void Host_UpdateLogDisplay(); -void Host_UpdateMemoryView(); -void Host_NotifyMapLoaded(); -void Host_UpdateBreakPointView(); -void Host_ShowJitResults(unsigned int address); -void Host_SetDebugMode(bool enable); -void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height); -void Host_RequestRenderWindowSize(int width, int height); -bool Host_RendererHasFocus(); - -void Host_SetWaitCursor(bool enable); - +void Host_UpdateMainFrame(); void Host_UpdateStatusBar(const char* _pText, int Filed = 0); - -void Host_SysMessage(const char *fmt, ...); -void Host_SetWiiMoteConnectionState(int _State); -void Host_ConnectWiimote(int wm_idx, bool connect); +void Host_UpdateTitle(const char* title); #endif diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index c1dfccdcf0..d762badd84 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -564,11 +564,14 @@ void Host_UpdateBreakPointView() } } -void Host_UpdateMemoryView() -{} - -void Host_SetDebugMode(bool) -{} +bool Host_GetKeyState(int keycode) +{ +#ifdef _WIN32 + return GetAsyncKeyState(keycode); +#else + return wxGetKeyState(wxKeyCode(keycode)); +#endif +} void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index bb8bc67de5..1f8ef811b2 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -76,9 +76,7 @@ void Host_UpdateMainFrame() void Host_UpdateBreakPointView(){} -void Host_UpdateMemoryView(){} - -void Host_SetDebugMode(bool){} +bool Host_GetKeyState(int keycode){} void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { diff --git a/Source/UnitTests/UnitTests.cpp b/Source/UnitTests/UnitTests.cpp index e2a1975c53..5731b163e8 100644 --- a/Source/UnitTests/UnitTests.cpp +++ b/Source/UnitTests/UnitTests.cpp @@ -146,27 +146,3 @@ int main(int argc, char* argv[]) } return 0; } - - -// Pretend that we are a host so we can link to core.... urgh. -//============================================================== -void Host_UpdateMainFrame(){} -void Host_UpdateDisasmDialog(){} -void Host_UpdateLogDisplay(){} -void Host_UpdateMemoryView(){} -void Host_NotifyMapLoaded(){} -void Host_ShowJitResults(unsigned int address){} -void Host_UpdateBreakPointView(){} -void Host_SetDebugMode(bool enable){} - -void Host_SetWaitCursor(bool enable){} - -void Host_UpdateStatusBar(const char* _pText, int Filed = 0){} - -void Host_SysMessage(const char *fmt, ...){} -void Host_SetWiiMoteConnectionState(int _State){} - -void Host_UpdateLeds(int bits){} -void Host_UpdateSpeakerStatus(int index, int bits){} -void Host_UpdateStatus(){} -void Host_Message(int){}