diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 1b97b1dea..ff8b8d36c 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -2232,6 +2232,19 @@ bool CN64System::LoadState(const char * FileName) return true; } +uint32_t CN64System::GetButtons(int32_t Control) const +{ + CControl_Plugin::fnGetKeys GetKeys = g_Plugins->Control()->GetKeys; + if (!UpdateControllerOnRefresh() && GetKeys != nullptr) + { + BUTTONS Keys; + memset(&Keys, 0, sizeof(Keys)); + GetKeys(Control, &Keys); + return Keys.Value; + } + return m_Buttons[Control]; +} + void CN64System::DisplayRSPListCount() { g_Notify->DisplayMessage(0, stdstr_f("Dlist: %d Alist: %d Unknown: %d", m_DlistCount, m_AlistCount, m_UnknownCount).c_str()); @@ -2365,7 +2378,7 @@ void CN64System::RefreshScreen() { g_Audio->SetViIntr(VI_INTR_TIME); } - if (g_Plugins->Control()->GetKeys) + if (UpdateControllerOnRefresh() && g_Plugins->Control()->GetKeys != nullptr) { BUTTONS Keys; memset(&Keys, 0, sizeof(Keys)); diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index ed4527dc3..72b894874 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -68,15 +68,15 @@ public: void PluginReset(); void ApplyGSButton(void); - void Pause(); - void RunRSP(); - bool SaveState(); - bool LoadState(const char * FileName); - bool LoadState(); + void Pause(); + void RunRSP(); + bool SaveState(); + bool LoadState(const char * FileName); + bool LoadState(); + uint32_t GetButtons(int32_t Control) const; bool DmaUsed() const { return m_DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } - uint32_t GetButtons(int32_t Control) const { return m_Buttons[Control]; } CPlugins * GetPlugins() { return m_Plugins; } // Variable used to track that the SP is being handled and stays the same as the real SP in sync core diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h index 0efdf8552..0eed72391 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.h +++ b/Source/Project64-core/Plugins/ControllerPlugin.h @@ -85,6 +85,8 @@ private: class CControl_Plugin : public CPlugin { public: + typedef void(CALL * fnGetKeys) (int32_t Control, BUTTONS * Keys); + CControl_Plugin(void); ~CControl_Plugin(); @@ -95,7 +97,7 @@ public: void(CALL *WM_KeyDown) (uint32_t wParam, uint32_t lParam); void(CALL *WM_KeyUp) (uint32_t wParam, uint32_t lParam); void(CALL *RumbleCommand) (int32_t Control, int32_t bRumble); - void(CALL *GetKeys) (int32_t Control, BUTTONS * Keys); + fnGetKeys GetKeys; void(CALL *ReadController) (int32_t Control, uint8_t * Command); void(CALL *ControllerCommand) (int32_t Control, uint8_t * Command); diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 948201554..6393b6296 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -125,6 +125,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Lang Directory", "Directory", Setting_LanguageDirDefault)); AddHandler(Setting_SyncViaAudioEnabled, new CSettingTypeTempBool(false, "SyncViaAudioEnabled")); AddHandler(Setting_DiskSaveType, new CSettingTypeApplication("Settings", "Disk Save Type", (uint32_t)1)); + AddHandler(Setting_UpdateControllerOnRefresh, new CSettingTypeTempBool(false)); AddHandler(Default_RDRamSize, new CSettingTypeApplication("Defaults", "RDRAM Size", 0x800000u)); AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX Default", true)); diff --git a/Source/Project64-core/Settings/N64SystemSettings.cpp b/Source/Project64-core/Settings/N64SystemSettings.cpp index 72ff1b31b..e22b5b124 100644 --- a/Source/Project64-core/Settings/N64SystemSettings.cpp +++ b/Source/Project64-core/Settings/N64SystemSettings.cpp @@ -8,6 +8,7 @@ bool CN64SystemSettings::m_bBasicMode; bool CN64SystemSettings::m_bLimitFPS; bool CN64SystemSettings::m_bShowDListAListCount; bool CN64SystemSettings::m_bDisplayFrameRate; +bool CN64SystemSettings::m_UpdateControllerOnRefresh; CN64SystemSettings::CN64SystemSettings() { @@ -44,4 +45,5 @@ void CN64SystemSettings::RefreshSettings(void *) m_bShowCPUPer = g_Settings->LoadBool(UserInterface_ShowCPUPer); m_bShowDListAListCount = g_Settings->LoadBool(Debugger_ShowDListAListCount); m_bLimitFPS = g_Settings->LoadBool(GameRunning_LimitFPS); + m_UpdateControllerOnRefresh = g_Settings->LoadBool(Setting_UpdateControllerOnRefresh); } \ No newline at end of file diff --git a/Source/Project64-core/Settings/N64SystemSettings.h b/Source/Project64-core/Settings/N64SystemSettings.h index 73d32dba4..02bf1ee3d 100644 --- a/Source/Project64-core/Settings/N64SystemSettings.h +++ b/Source/Project64-core/Settings/N64SystemSettings.h @@ -11,6 +11,7 @@ protected: inline static bool bShowCPUPer(void) { return m_bShowCPUPer; } inline static bool bShowDListAListCount(void) { return m_bShowDListAListCount; } inline static bool bLimitFPS(void) { return m_bLimitFPS; } + inline static bool UpdateControllerOnRefresh(void) { return m_UpdateControllerOnRefresh; } private: static void RefreshSettings(void *); @@ -20,6 +21,7 @@ private: static bool m_bLimitFPS; static bool m_bShowDListAListCount; static bool m_bDisplayFrameRate; + static bool m_UpdateControllerOnRefresh; - static int32_t m_RefCount; + static int32_t m_RefCount; }; diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index 7962130a5..f16a8533f 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -60,6 +60,7 @@ enum SettingID Setting_SyncViaAudioEnabled, Setting_Enhancement, Setting_DiskSaveType, + Setting_UpdateControllerOnRefresh, // Default settings Default_RDRamSize,