Merge pull request #81 from degasus/skip_framelimit_hotkey

Add a hotkey for disabling the framelimit.
This commit is contained in:
Tony Wasserka 2014-05-01 12:40:01 +02:00
commit 557c3db462
13 changed files with 38 additions and 38 deletions

View File

@ -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::GetIsFramelimiterTempDisabled())
break;
SLEEP(1);
soundStream->Update();

View File

@ -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 */ },

View File

@ -90,7 +90,17 @@ static bool g_requestRefreshInfo = false;
static int g_pauseAndLockDepth = 0;
SCoreStartupParameter g_CoreStartupParameter;
bool isTabPressed = 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; }

View File

@ -24,7 +24,8 @@ namespace Core
// TODO: kill, use SConfig instead
extern SCoreStartupParameter g_CoreStartupParameter;
extern bool isTabPressed;
bool GetIsFramelimiterTempDisabled();
void SetIsFramelimiterTempDisabled(bool disable);
void Callback_VideoCopiedToXFB(bool video_update);

View File

@ -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,

View File

@ -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::GetIsFramelimiterTempDisabled();
u32 next_event = GetTicksPerSecond()/1000;
if (SConfig::GetInstance().m_Framelimit > 2)
{

View File

@ -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();

View File

@ -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::SetIsFramelimiterTempDisabled(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::SetIsFramelimiterTempDisabled(false);
}
}
else
{
event.Skip();
}
}
void CFrame::OnMouse(wxMouseEvent& event)

View File

@ -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"),

View File

@ -620,25 +620,6 @@ void Host_UpdateBreakPointView()
}
}
bool Host_GetKeyState(int keycode)
{
#ifdef _WIN32
return (0 != GetAsyncKeyState(keycode));
#elif defined __WXGTK__
std::unique_lock<std::recursive_mutex> 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);

View File

@ -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;

View File

@ -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;

View File

@ -276,5 +276,5 @@ void VideoConfig::Save(const std::string& ini_file)
bool VideoConfig::IsVSync()
{
return Core::isTabPressed ? false : bVSync;
return bVSync && !Core::GetIsFramelimiterTempDisabled();
}