From 8483811b398f9156a08565825cbf138cb3697039 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 16 Feb 2014 23:13:01 +0100 Subject: [PATCH 1/3] Add a hotkey for disabling the framelimit. Atm this is hardcoded to '\t'. --- Source/Core/AudioCommon/Mixer.cpp | 4 ++-- Source/Core/Core/ConfigManager.cpp | 1 + Source/Core/Core/Core.cpp | 2 +- Source/Core/Core/Core.h | 2 +- Source/Core/Core/CoreParameter.h | 1 + Source/Core/Core/HW/SystemTimers.cpp | 5 +++-- Source/Core/DolphinWX/Frame.cpp | 17 ++++++++++++++++- Source/Core/DolphinWX/HotkeyDlg.cpp | 1 + Source/Core/VideoCommon/VideoConfig.cpp | 2 +- 9 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index fa43baeb99..83bdc537ed 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -7,7 +7,7 @@ #include "Common/Atomic.h" #include "Common/CPUDetect.h" #include "Core/ConfigManager.h" -#include "Core/Host.h" +#include "Core/Core.h" #include "Core/HW/AudioInterface.h" #include "Core/HW/VideoInterface.h" @@ -124,7 +124,7 @@ void CMixer::PushSamples(const short *samples, unsigned int num_samples) if (*PowerPC::GetStatePtr() != PowerPC::CPU_RUNNING || soundStream->IsMuted()) break; // Shortcut key for Throttle Skipping - if (Host_GetKeyState('\t')) + if (Core::IsFramelimiterTempDisabled) break; SLEEP(1); soundStream->Update(); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 13f551f5ca..e5491fdae5 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -71,6 +71,7 @@ static const struct { "ToggleAspectRatio", 0, 0 /* wxMOD_NONE */ }, { "ToggleEFBCopies", 0, 0 /* wxMOD_NONE */ }, { "ToggleFog", 0, 0 /* wxMOD_NONE */ }, + { "ToggleThrottle", 9 /* '\t' */, 0 /* wxMOD_NONE */ }, { "IncreaseFrameLimit", 0, 0 /* wxMOD_NONE */ }, { "DecreaseFrameLimit", 0, 0 /* wxMOD_NONE */ }, { "LoadStateSlot1", 340 /* WXK_F1 */, 0 /* wxMOD_NONE */ }, diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index a4d4a6fdda..90b6f1f4d1 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -90,7 +90,7 @@ static bool g_requestRefreshInfo = false; static int g_pauseAndLockDepth = 0; SCoreStartupParameter g_CoreStartupParameter; -bool isTabPressed = false; +bool IsFramelimiterTempDisabled = false; std::string GetStateFileName() { return g_stateFileName; } void SetStateFileName(std::string val) { g_stateFileName = val; } diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index c841fac08e..44d558bd90 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -24,7 +24,7 @@ namespace Core // TODO: kill, use SConfig instead extern SCoreStartupParameter g_CoreStartupParameter; -extern bool isTabPressed; +extern bool IsFramelimiterTempDisabled; void Callback_VideoCopiedToXFB(bool video_update); diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index fc8386b5bb..46ec3976fe 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -38,6 +38,7 @@ enum Hotkey HK_TOGGLE_AR, HK_TOGGLE_EFBCOPIES, HK_TOGGLE_FOG, + HK_TOGGLE_THROTTLE, HK_INCREASE_FRAME_LIMIT, HK_DECREASE_FRAME_LIMIT, diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 4e51ba8585..f584455d8a 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -62,9 +62,9 @@ IPC_HLE_PERIOD: For the Wiimote this is the call schedule: #include "Common/Timer.h" #include "Core/ConfigManager.h" +#include "Core/Core.h" #include "Core/CoreTiming.h" #include "Core/DSPEmulator.h" -#include "Core/Host.h" #include "Core/PatchEngine.h" #include "Core/HW/AudioInterface.h" #include "Core/HW/DSP.h" @@ -237,7 +237,8 @@ void ThrottleCallback(u64 last_time, int cyclesLate) u32 time = Common::Timer::GetTimeMs(); int diff = (u32)last_time - time; - bool frame_limiter = SConfig::GetInstance().m_Framelimit && SConfig::GetInstance().m_Framelimit != 2 && !Host_GetKeyState('\t'); + const SConfig& config = SConfig::GetInstance(); + bool frame_limiter = config.m_Framelimit && config.m_Framelimit != 2 && !Core::IsFramelimiterTempDisabled; u32 next_event = GetTicksPerSecond()/1000; if (SConfig::GetInstance().m_Framelimit > 2) { diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 87fb799616..191d5c0086 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -940,6 +940,10 @@ void CFrame::OnKeyDown(wxKeyEvent& event) OSDChoice = 4; g_Config.bDisableFog = !g_Config.bDisableFog; } + else if (IsHotkey(event, HK_TOGGLE_THROTTLE)) + { + Core::IsFramelimiterTempDisabled = true; + } else if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT)) { if (++SConfig::GetInstance().m_Framelimit > 0x19) @@ -1040,7 +1044,18 @@ void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyUp(wxKeyEvent& event) { - event.Skip(); + if(Core::GetState() != Core::CORE_UNINITIALIZED && + (RendererHasFocus() || TASInputHasFocus())) + { + if (IsHotkey(event, HK_TOGGLE_THROTTLE)) + { + Core::IsFramelimiterTempDisabled = false; + } + } + else + { + event.Skip(); + } } void CFrame::OnMouse(wxMouseEvent& event) diff --git a/Source/Core/DolphinWX/HotkeyDlg.cpp b/Source/Core/DolphinWX/HotkeyDlg.cpp index 87f7f2a3bc..d990ac1f21 100644 --- a/Source/Core/DolphinWX/HotkeyDlg.cpp +++ b/Source/Core/DolphinWX/HotkeyDlg.cpp @@ -233,6 +233,7 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void) _("Toggle Aspect Ratio"), _("Toggle EFB Copies"), _("Toggle Fog"), + _("Toggle Frame limit"), _("Increase Frame limit"), _("Decrease Frame limit"), diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index c12fe9b419..7eb6835747 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -276,5 +276,5 @@ void VideoConfig::Save(const std::string& ini_file) bool VideoConfig::IsVSync() { - return Core::isTabPressed ? false : bVSync; + return Core::IsFramelimiterTempDisabled ? false : bVSync; } From 30586f4d29537835b4a06b52e3c6f23a9e8c2c29 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 30 Apr 2014 12:50:29 +0200 Subject: [PATCH 2/3] Add set/get functions for IsFramelimiterTempDisabled --- Source/Core/AudioCommon/Mixer.cpp | 2 +- Source/Core/Core/Core.cpp | 12 +++++++++++- Source/Core/Core/Core.h | 3 ++- Source/Core/Core/HW/SystemTimers.cpp | 2 +- Source/Core/DolphinWX/Frame.cpp | 4 ++-- Source/Core/VideoCommon/VideoConfig.cpp | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index 83bdc537ed..c1ff49dd03 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -124,7 +124,7 @@ void CMixer::PushSamples(const short *samples, unsigned int num_samples) if (*PowerPC::GetStatePtr() != PowerPC::CPU_RUNNING || soundStream->IsMuted()) break; // Shortcut key for Throttle Skipping - if (Core::IsFramelimiterTempDisabled) + if (Core::GetIsFramelimiterTempDisabled()) break; SLEEP(1); soundStream->Update(); diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 90b6f1f4d1..87d6cdd9c0 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -90,7 +90,17 @@ static bool g_requestRefreshInfo = false; static int g_pauseAndLockDepth = 0; SCoreStartupParameter g_CoreStartupParameter; -bool IsFramelimiterTempDisabled = false; +static bool IsFramelimiterTempDisabled = false; + +bool GetIsFramelimiterTempDisabled() +{ + return IsFramelimiterTempDisabled; +} + +void SetIsFramelimiterTempDisabled(bool disable) +{ + IsFramelimiterTempDisabled = disable; +} std::string GetStateFileName() { return g_stateFileName; } void SetStateFileName(std::string val) { g_stateFileName = val; } diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index 44d558bd90..862160daf0 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -24,7 +24,8 @@ namespace Core // TODO: kill, use SConfig instead extern SCoreStartupParameter g_CoreStartupParameter; -extern bool IsFramelimiterTempDisabled; +bool GetIsFramelimiterTempDisabled(); +void SetIsFramelimiterTempDisabled(bool disable); void Callback_VideoCopiedToXFB(bool video_update); diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index f584455d8a..2e11422a91 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -238,7 +238,7 @@ void ThrottleCallback(u64 last_time, int cyclesLate) int diff = (u32)last_time - time; const SConfig& config = SConfig::GetInstance(); - bool frame_limiter = config.m_Framelimit && config.m_Framelimit != 2 && !Core::IsFramelimiterTempDisabled; + bool frame_limiter = config.m_Framelimit && config.m_Framelimit != 2 && !Core::GetIsFramelimiterTempDisabled(); u32 next_event = GetTicksPerSecond()/1000; if (SConfig::GetInstance().m_Framelimit > 2) { diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 191d5c0086..26627d2340 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -942,7 +942,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) } else if (IsHotkey(event, HK_TOGGLE_THROTTLE)) { - Core::IsFramelimiterTempDisabled = true; + Core::SetIsFramelimiterTempDisabled(true); } else if (IsHotkey(event, HK_INCREASE_FRAME_LIMIT)) { @@ -1049,7 +1049,7 @@ void CFrame::OnKeyUp(wxKeyEvent& event) { if (IsHotkey(event, HK_TOGGLE_THROTTLE)) { - Core::IsFramelimiterTempDisabled = false; + Core::SetIsFramelimiterTempDisabled(false); } } else diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 7eb6835747..7adecfdebf 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -276,5 +276,5 @@ void VideoConfig::Save(const std::string& ini_file) bool VideoConfig::IsVSync() { - return Core::IsFramelimiterTempDisabled ? false : bVSync; + return bVSync && !Core::GetIsFramelimiterTempDisabled(); } From f254fdfd965c0d860e2e457de24fb4aa1b00a957 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 16 Feb 2014 23:22:11 +0100 Subject: [PATCH 3/3] drop Host_GetKeyState This function isn't used any more and it shouldn't be used at all as it generates a sync request to the x11 server. So it has to wait for a complete round trip time. --- Source/Core/Core/Host.h | 1 - Source/Core/DolphinWX/Main.cpp | 19 ------------------- Source/Core/DolphinWX/MainAndroid.cpp | 5 ----- Source/Core/DolphinWX/MainNoGUI.cpp | 5 ----- 4 files changed, 30 deletions(-) diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index ffb638be5d..0f68338d25 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -25,7 +25,6 @@ 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_NotifyMapLoaded(); diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 60574d9820..76f001b180 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -620,25 +620,6 @@ void Host_UpdateBreakPointView() } } -bool Host_GetKeyState(int keycode) -{ -#ifdef _WIN32 - return (0 != GetAsyncKeyState(keycode)); -#elif defined __WXGTK__ - std::unique_lock lk(main_frame->keystate_lock, std::try_to_lock); - if (!lk.owns_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 -} - void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { main_frame->GetRenderWindowSize(x, y, width, height); diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index ab82e7def1..d103589ea5 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -85,11 +85,6 @@ void Host_UpdateMainFrame() void Host_UpdateBreakPointView(){} -bool Host_GetKeyState(int keycode) -{ - return false; -} - void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos; diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index cfd176e27a..76e7608e15 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -79,11 +79,6 @@ void Host_UpdateMainFrame() void Host_UpdateBreakPointView(){} -bool Host_GetKeyState(int keycode) -{ - return false; -} - void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) { x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;