diff --git a/Source/Project64-input/CProject64Input.cpp b/Source/Project64-input/CProject64Input.cpp index 0b193d71d7..e831fc4899 100644 --- a/Source/Project64-input/CProject64Input.cpp +++ b/Source/Project64-input/CProject64Input.cpp @@ -26,7 +26,7 @@ void CProject64Input::InitiateControllers(CONTROL_INFO * ControlInfo) m_DirectInput->Initiate(ControlInfo); for (size_t i = 0, n = sizeof(m_Controllers) / sizeof(m_Controllers[0]); i < n; i++) { - g_Settings->LoadController(0, m_Controllers[i]); + g_Settings->LoadController(i, m_ControlInfo.Controls[i], m_Controllers[i]); m_DirectInput->MapControllerDevice(m_Controllers[i]); } } @@ -96,6 +96,6 @@ bool CProject64Input::SaveController(uint32_t ControlIndex) { return false; } - g_Settings->SaveController(ControlIndex, m_Controllers[ControlIndex]); + g_Settings->SaveController(ControlIndex, m_ControlInfo.Controls[ControlIndex], m_Controllers[ControlIndex]); return true; } diff --git a/Source/Project64-input/InputSettings.cpp b/Source/Project64-input/InputSettings.cpp index bdae4d1ba7..af4c31cdf3 100644 --- a/Source/Project64-input/InputSettings.cpp +++ b/Source/Project64-input/InputSettings.cpp @@ -14,7 +14,7 @@ CInputSettings::~CInputSettings() { } -void CInputSettings::LoadController(uint32_t ControlIndex, N64CONTROLLER & Controller) +void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller) { struct { BUTTON & Button; @@ -53,14 +53,16 @@ void CInputSettings::LoadController(uint32_t ControlIndex, N64CONTROLLER & Contr Buttons[i].Button = StrToButton(GetSettingSz((short)Buttons[i].SettingId, Buffer, sizeof(Buffer) / sizeof(Buffer[0]))); } + InputSettingID PresentSettings[] = { Set_Control0_Present }; InputSettingID RangeSettings[] = { Set_Control0_Range }; + ControllerInfo.Present = ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0])) ? GetSetting((short)PresentSettings[ControlIndex]) != 0 : 0; Controller.Range = (uint8_t)(ControlIndex < (sizeof(RangeSettings) / sizeof(RangeSettings[0])) ? GetSetting((short)RangeSettings[ControlIndex]) : 100); if (Controller.Range == 0) { Controller.Range = 1; } if (Controller.Range > 100) { Controller.Range = 100; } } -void CInputSettings::SaveController(uint32_t ControlIndex, const N64CONTROLLER & Controller) +void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller) { struct { const BUTTON & Button; @@ -98,6 +100,12 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const N64CONTROLLER & SetSettingSz((short)Buttons[i].SettingId, ButtonToStr(Buttons[i].Button).c_str()); } + InputSettingID PresentSettings[] = { Set_Control0_Present }; + if (ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0]))) + { + SetSetting((short)PresentSettings[ControlIndex], ControllerInfo.Present); + } + InputSettingID RangeSettings[] = { Set_Control0_Range }; if (ControlIndex < (sizeof(RangeSettings) / sizeof(RangeSettings[0]))) { @@ -136,6 +144,7 @@ std::string CInputSettings::GUIDtoString(const GUID & guid) void CInputSettings::RegisterSettings(void) { SetModuleName("Input"); + RegisterSetting(Set_Control0_Present, Data_DWORD_General, "Present", "Controller 1", 1, nullptr); RegisterSetting(Set_Control0_Range, Data_DWORD_General, "Range", "Controller 1", 100, nullptr); RegisterSetting(Set_Control0_U_DPAD, Data_String_General, "DPadUp", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 17 0 5"); RegisterSetting(Set_Control0_D_DPAD, Data_String_General, "DPadDown", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 25 0 5"); diff --git a/Source/Project64-input/InputSettings.h b/Source/Project64-input/InputSettings.h index 275b84acdb..d727a85e83 100644 --- a/Source/Project64-input/InputSettings.h +++ b/Source/Project64-input/InputSettings.h @@ -2,6 +2,7 @@ #include #include #include "N64Controller.h" +#include "ControllerSpec1.1.h" class CInputSettings { @@ -9,8 +10,8 @@ class CInputSettings CInputSettings(); ~CInputSettings(); - void LoadController(uint32_t ControlIndex, N64CONTROLLER & Controller); - void SaveController(uint32_t ControlIndex, const N64CONTROLLER & Controller); + void LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller); + void SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller); private: CInputSettings(const CInputSettings&); diff --git a/Source/Project64-input/InputSettingsID.h b/Source/Project64-input/InputSettingsID.h index cdb9491c9f..d381df4f91 100644 --- a/Source/Project64-input/InputSettingsID.h +++ b/Source/Project64-input/InputSettingsID.h @@ -2,6 +2,7 @@ enum InputSettingID { + Set_Control0_Present, Set_Control0_Range, Set_Control0_U_DPAD, Set_Control0_D_DPAD,