Project64-input: Add controller present
This commit is contained in:
parent
8df9403bce
commit
f1d8910e5f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <Common\stdtypes.h>
|
||||
#include <string>
|
||||
#include "N64Controller.h"
|
||||
#include "ControllerSpec1.1.h"
|
||||
|
||||
class CInputSettings
|
||||
{
|
||||
|
@ -9,8 +10,8 @@ public:
|
|||
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&);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
enum InputSettingID
|
||||
{
|
||||
Set_Control0_Present,
|
||||
Set_Control0_Range,
|
||||
Set_Control0_U_DPAD,
|
||||
Set_Control0_D_DPAD,
|
||||
|
|
Loading…
Reference in New Issue