Get Controller plugin to update at request

This commit is contained in:
zilmar 2021-06-15 14:30:38 +09:30
parent 2850cc78c8
commit bfd206e0a7
7 changed files with 30 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,6 +60,7 @@ enum SettingID
Setting_SyncViaAudioEnabled,
Setting_Enhancement,
Setting_DiskSaveType,
Setting_UpdateControllerOnRefresh,
// Default settings
Default_RDRamSize,