Project64-input: Cancel should reset buttons
This commit is contained in:
parent
878725490b
commit
6417eaf866
|
@ -113,16 +113,11 @@ std::wstring CProject64Input::ButtonAssignment(BUTTON & Button)
|
||||||
return L"Unknown";
|
return L"Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CProject64Input::ControllerDevices(uint32_t ControlIndex)
|
std::wstring CProject64Input::ControllerDevices(const N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
if (ControlIndex >= sizeof(m_Controllers) / sizeof(m_Controllers[0]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DirectInput.get() != NULL)
|
if (m_DirectInput.get() != NULL)
|
||||||
{
|
{
|
||||||
return m_DirectInput->ControllerDevices(m_Controllers[ControlIndex]);
|
return m_DirectInput->ControllerDevices(Controller);
|
||||||
}
|
}
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
|
@ -140,15 +135,9 @@ bool CProject64Input::SaveController(uint32_t ControlIndex)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CProject64Input::ResetController(uint32_t ControlIndex)
|
bool CProject64Input::ResetController(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
CGuard guard(m_CS);
|
g_Settings->ResetController(ControlIndex, ControlInfo, Controller);
|
||||||
|
m_DirectInput->MapControllerDevice(Controller);
|
||||||
if (ControlIndex >= sizeof(m_Controllers) / sizeof(m_Controllers[0]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
g_Settings->ResetController(ControlIndex, m_ControlInfo.Controls[ControlIndex], m_Controllers[ControlIndex]);
|
|
||||||
m_DirectInput->MapControllerDevice(m_Controllers[ControlIndex]);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ public:
|
||||||
void EndScanDevices(void);
|
void EndScanDevices(void);
|
||||||
CDirectInput::ScanResult ScanDevices(BUTTON & Button);
|
CDirectInput::ScanResult ScanDevices(BUTTON & Button);
|
||||||
std::wstring ButtonAssignment(BUTTON & Button);
|
std::wstring ButtonAssignment(BUTTON & Button);
|
||||||
std::wstring ControllerDevices(uint32_t ControlIndex);
|
std::wstring ControllerDevices(const N64CONTROLLER & Controller);
|
||||||
bool SaveController(uint32_t ControlIndex);
|
bool SaveController(uint32_t ControlIndex);
|
||||||
bool ResetController(uint32_t ControlIndex);
|
bool ResetController(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller);
|
||||||
|
|
||||||
inline HINSTANCE hInst(void) const { return m_hinst; }
|
inline HINSTANCE hInst(void) const { return m_hinst; }
|
||||||
inline bool IsScanning(void) const { return m_Scanning; }
|
inline bool IsScanning(void) const { return m_Scanning; }
|
||||||
|
|
|
@ -285,9 +285,9 @@ std::wstring CDirectInput::ButtonAssignment(BUTTON & Button)
|
||||||
return L"Unknown";
|
return L"Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CDirectInput::ControllerDevices(N64CONTROLLER & Controller)
|
std::wstring CDirectInput::ControllerDevices(const N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
BUTTON * Buttons[] =
|
const BUTTON * Buttons[] =
|
||||||
{
|
{
|
||||||
&Controller.U_DPAD,
|
&Controller.U_DPAD,
|
||||||
&Controller.D_DPAD,
|
&Controller.D_DPAD,
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
void MapControllerDevice(N64CONTROLLER & Controller);
|
void MapControllerDevice(N64CONTROLLER & Controller);
|
||||||
ScanResult ScanDevices(BUTTON & Button);
|
ScanResult ScanDevices(BUTTON & Button);
|
||||||
std::wstring ButtonAssignment(BUTTON & Button);
|
std::wstring ButtonAssignment(BUTTON & Button);
|
||||||
std::wstring ControllerDevices(N64CONTROLLER & Controller);
|
std::wstring ControllerDevices(const N64CONTROLLER & Controller);
|
||||||
bool IsButtonPressed(BUTTON & Button);
|
bool IsButtonPressed(BUTTON & Button);
|
||||||
void GetAxis(N64CONTROLLER & Controller, BUTTONS * Keys);
|
void GetAxis(N64CONTROLLER & Controller, BUTTONS * Keys);
|
||||||
void UpdateDeviceData(void);
|
void UpdateDeviceData(void);
|
||||||
|
|
|
@ -7,9 +7,13 @@
|
||||||
#include <Common\StdString.h>
|
#include <Common\StdString.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
class CInputConfigUI;
|
||||||
|
|
||||||
class CControllerSettings :
|
class CControllerSettings :
|
||||||
public CPropertyPageImpl<CControllerSettings>
|
public CPropertyPageImpl<CControllerSettings>
|
||||||
{
|
{
|
||||||
|
friend CInputConfigUI;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DETECT_KEY_TIMER = 1
|
DETECT_KEY_TIMER = 1
|
||||||
|
@ -51,6 +55,8 @@ private:
|
||||||
uint32_t m_ControllerNumber;
|
uint32_t m_ControllerNumber;
|
||||||
uint32_t m_ScanCount;
|
uint32_t m_ScanCount;
|
||||||
int32_t m_SetupIndex;
|
int32_t m_SetupIndex;
|
||||||
|
N64CONTROLLER m_Controller;
|
||||||
|
CONTROL m_ControlInfo;
|
||||||
CBitmapPicture m_ControllerImg;
|
CBitmapPicture m_ControllerImg;
|
||||||
CButton m_PluggedIn;
|
CButton m_PluggedIn;
|
||||||
CTrackBarCtrl m_Range;
|
CTrackBarCtrl m_Range;
|
||||||
|
@ -66,24 +72,26 @@ CControllerSettings::CControllerSettings(uint32_t ControllerNumber) :
|
||||||
m_ControllerNumber(ControllerNumber),
|
m_ControllerNumber(ControllerNumber),
|
||||||
m_ScanCount(0),
|
m_ScanCount(0),
|
||||||
m_SetupIndex(-1),
|
m_SetupIndex(-1),
|
||||||
m_ButtonUDPad(g_InputPlugin->Controllers(ControllerNumber).U_DPAD, IDC_EDIT_DIGITIAL_UP, IDC_BTN_DIGITIAL_UP),
|
m_Controller(g_InputPlugin->Controllers(ControllerNumber)),
|
||||||
m_ButtonDDPad(g_InputPlugin->Controllers(ControllerNumber).D_DPAD, IDC_EDIT_DIGITIAL_DOWN, IDC_BTN_DIGITIAL_DOWN),
|
m_ControlInfo(g_InputPlugin->ControlInfo(ControllerNumber)),
|
||||||
m_ButtonLDPad(g_InputPlugin->Controllers(ControllerNumber).L_DPAD, IDC_EDIT_DIGITIAL_LEFT, IDC_BTN_DIGITIAL_LEFT),
|
m_ButtonUDPad(m_Controller.U_DPAD, IDC_EDIT_DIGITIAL_UP, IDC_BTN_DIGITIAL_UP),
|
||||||
m_ButtonRDPad(g_InputPlugin->Controllers(ControllerNumber).R_DPAD, IDC_EDIT_DIGITIAL_RIGHT, IDC_BTN_DIGITIAL_RIGHT),
|
m_ButtonDDPad(m_Controller.D_DPAD, IDC_EDIT_DIGITIAL_DOWN, IDC_BTN_DIGITIAL_DOWN),
|
||||||
m_ButtonA(g_InputPlugin->Controllers(ControllerNumber).A_BUTTON, IDC_EDIT_BUTTON_A, IDC_BTN_BUTTON_A),
|
m_ButtonLDPad(m_Controller.L_DPAD, IDC_EDIT_DIGITIAL_LEFT, IDC_BTN_DIGITIAL_LEFT),
|
||||||
m_ButtonB(g_InputPlugin->Controllers(ControllerNumber).B_BUTTON, IDC_EDIT_BUTTON_B, IDC_BTN_BUTTON_B),
|
m_ButtonRDPad(m_Controller.R_DPAD, IDC_EDIT_DIGITIAL_RIGHT, IDC_BTN_DIGITIAL_RIGHT),
|
||||||
m_ButtonCUp(g_InputPlugin->Controllers(ControllerNumber).U_CBUTTON, IDC_EDIT_CBUTTON_UP, IDC_BTN_CBUTTON_UP),
|
m_ButtonA(m_Controller.A_BUTTON, IDC_EDIT_BUTTON_A, IDC_BTN_BUTTON_A),
|
||||||
m_ButtonCDown(g_InputPlugin->Controllers(ControllerNumber).D_CBUTTON, IDC_EDIT_CBUTTON_DOWN, IDC_BTN_CBUTTON_DOWN),
|
m_ButtonB(m_Controller.B_BUTTON, IDC_EDIT_BUTTON_B, IDC_BTN_BUTTON_B),
|
||||||
m_ButtonCLeft(g_InputPlugin->Controllers(ControllerNumber).L_CBUTTON, IDC_EDIT_CBUTTON_LEFT, IDC_BTN_CBUTTON_LEFT),
|
m_ButtonCUp(m_Controller.U_CBUTTON, IDC_EDIT_CBUTTON_UP, IDC_BTN_CBUTTON_UP),
|
||||||
m_ButtonCRight(g_InputPlugin->Controllers(ControllerNumber).R_CBUTTON, IDC_EDIT_CBUTTON_RIGHT, IDC_BTN_CBUTTON_RIGHT),
|
m_ButtonCDown(m_Controller.D_CBUTTON, IDC_EDIT_CBUTTON_DOWN, IDC_BTN_CBUTTON_DOWN),
|
||||||
m_ButtonStart(g_InputPlugin->Controllers(ControllerNumber).START_BUTTON, IDC_EDIT_BUTTON_START, IDC_BTN_BUTTON_START),
|
m_ButtonCLeft(m_Controller.L_CBUTTON, IDC_EDIT_CBUTTON_LEFT, IDC_BTN_CBUTTON_LEFT),
|
||||||
m_ButtonZtrigger(g_InputPlugin->Controllers(ControllerNumber).Z_TRIG, IDC_EDIT_BUTTON_Z, IDC_BTN_BUTTON_Z),
|
m_ButtonCRight(m_Controller.R_CBUTTON, IDC_EDIT_CBUTTON_RIGHT, IDC_BTN_CBUTTON_RIGHT),
|
||||||
m_ButtonRTrigger(g_InputPlugin->Controllers(ControllerNumber).R_TRIG, IDC_EDIT_RTRIGGER, IDC_BTN_RTRIGGER),
|
m_ButtonStart(m_Controller.START_BUTTON, IDC_EDIT_BUTTON_START, IDC_BTN_BUTTON_START),
|
||||||
m_ButtonLTrigger(g_InputPlugin->Controllers(ControllerNumber).L_TRIG, IDC_EDIT_LTRIGGER, IDC_BTN_LTRIGGER),
|
m_ButtonZtrigger(m_Controller.Z_TRIG, IDC_EDIT_BUTTON_Z, IDC_BTN_BUTTON_Z),
|
||||||
m_ButtonAnalogU(g_InputPlugin->Controllers(ControllerNumber).U_ANALOG, IDC_EDIT_ANALOG_UP, IDC_BTN_ANALOG_UP),
|
m_ButtonRTrigger(m_Controller.R_TRIG, IDC_EDIT_RTRIGGER, IDC_BTN_RTRIGGER),
|
||||||
m_ButtonAnalogD(g_InputPlugin->Controllers(ControllerNumber).D_ANALOG, IDC_EDIT_ANALOG_DOWN, IDC_BTN_ANALOG_DOWN),
|
m_ButtonLTrigger(m_Controller.L_TRIG, IDC_EDIT_LTRIGGER, IDC_BTN_LTRIGGER),
|
||||||
m_ButtonAnalogL(g_InputPlugin->Controllers(ControllerNumber).L_ANALOG, IDC_EDIT_ANALOG_LEFT, IDC_BTN_ANALOG_LEFT),
|
m_ButtonAnalogU(m_Controller.U_ANALOG, IDC_EDIT_ANALOG_UP, IDC_BTN_ANALOG_UP),
|
||||||
m_ButtonAnalogR(g_InputPlugin->Controllers(ControllerNumber).R_ANALOG, IDC_EDIT_ANALOG_RIGHT, IDC_BTN_ANALOG_RIGHT)
|
m_ButtonAnalogD(m_Controller.D_ANALOG, IDC_EDIT_ANALOG_DOWN, IDC_BTN_ANALOG_DOWN),
|
||||||
|
m_ButtonAnalogL(m_Controller.L_ANALOG, IDC_EDIT_ANALOG_LEFT, IDC_BTN_ANALOG_LEFT),
|
||||||
|
m_ButtonAnalogR(m_Controller.R_ANALOG, IDC_EDIT_ANALOG_RIGHT, IDC_BTN_ANALOG_RIGHT)
|
||||||
{
|
{
|
||||||
m_Title = stdstr_f("Player %d", ControllerNumber + 1).ToUTF16();
|
m_Title = stdstr_f("Player %d", ControllerNumber + 1).ToUTF16();
|
||||||
SetTitle(m_Title.c_str());
|
SetTitle(m_Title.c_str());
|
||||||
|
@ -135,11 +143,11 @@ HBRUSH CControllerSettings::OnCtlColorStatic(CDCHandle dc, CWindow wndStatic)
|
||||||
bool CControllerSettings::OnApply()
|
bool CControllerSettings::OnApply()
|
||||||
{
|
{
|
||||||
N64CONTROLLER & Controller = g_InputPlugin->Controllers(m_ControllerNumber);
|
N64CONTROLLER & Controller = g_InputPlugin->Controllers(m_ControllerNumber);
|
||||||
CONTROL & ControlInfo = g_InputPlugin->ControlInfo(m_ControllerNumber);
|
Controller = m_Controller;
|
||||||
Controller.Range = (uint8_t)m_Range.GetPos();
|
Controller.Range = (uint8_t)m_Range.GetPos();
|
||||||
Controller.DeadZone = (uint8_t)m_DeadZone.GetPos();
|
Controller.DeadZone = (uint8_t)m_DeadZone.GetPos();
|
||||||
|
CONTROL & ControlInfo = g_InputPlugin->ControlInfo(m_ControllerNumber);
|
||||||
ControlInfo.Present = (m_PluggedIn.GetCheck() == BST_CHECKED) ? 1 : 0;
|
ControlInfo.Present = (m_PluggedIn.GetCheck() == BST_CHECKED) ? 1 : 0;
|
||||||
|
|
||||||
return g_InputPlugin->SaveController(m_ControllerNumber);
|
return g_InputPlugin->SaveController(m_ControllerNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +198,7 @@ LRESULT CControllerSettings::OnScanCanceled(UINT /*uMsg*/, WPARAM /*wParam*/, LP
|
||||||
|
|
||||||
void CControllerSettings::DefaultBtnClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
void CControllerSettings::DefaultBtnClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
||||||
{
|
{
|
||||||
g_InputPlugin->ResetController(m_ControllerNumber);
|
g_InputPlugin->ResetController(m_ControllerNumber, m_ControlInfo, m_Controller);
|
||||||
DisplayController();
|
DisplayController();
|
||||||
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
||||||
}
|
}
|
||||||
|
@ -214,11 +222,9 @@ LRESULT CControllerSettings::ItemChangedNotify(NMHDR* /*pNMHDR*/)
|
||||||
|
|
||||||
void CControllerSettings::DisplayController(void)
|
void CControllerSettings::DisplayController(void)
|
||||||
{
|
{
|
||||||
N64CONTROLLER & Controller = g_InputPlugin->Controllers(m_ControllerNumber);
|
m_PluggedIn.SetCheck(m_ControlInfo.Present != 0 ? BST_CHECKED : BST_UNCHECKED);
|
||||||
CONTROL & ControlInfo = g_InputPlugin->ControlInfo(m_ControllerNumber);
|
m_Range.SetPos(m_Controller.Range);
|
||||||
m_PluggedIn.SetCheck(ControlInfo.Present != 0 ? BST_CHECKED : BST_UNCHECKED);
|
m_DeadZone.SetPos(m_Controller.DeadZone);
|
||||||
m_Range.SetPos(Controller.Range);
|
|
||||||
m_DeadZone.SetPos(Controller.DeadZone);
|
|
||||||
CWindow(GetDlgItem(IDC_LABEL_RANGE)).SetWindowText(stdstr_f("%d%%", m_Range.GetPos()).ToUTF16().c_str());
|
CWindow(GetDlgItem(IDC_LABEL_RANGE)).SetWindowText(stdstr_f("%d%%", m_Range.GetPos()).ToUTF16().c_str());
|
||||||
CWindow(GetDlgItem(IDC_GROUP_DEADZONE)).SetWindowText(stdstr_f("Deadzone: %d%%", m_DeadZone.GetPos()).ToUTF16().c_str());
|
CWindow(GetDlgItem(IDC_GROUP_DEADZONE)).SetWindowText(stdstr_f("Deadzone: %d%%", m_DeadZone.GetPos()).ToUTF16().c_str());
|
||||||
CScanButton * Buttons[] = {
|
CScanButton * Buttons[] = {
|
||||||
|
@ -232,12 +238,12 @@ void CControllerSettings::DisplayController(void)
|
||||||
{
|
{
|
||||||
Buttons[i]->DisplayButton();
|
Buttons[i]->DisplayButton();
|
||||||
}
|
}
|
||||||
GetDlgItem(IDC_BOUND_DEVICE).SetWindowText(g_InputPlugin->ControllerDevices(m_ControllerNumber).c_str());
|
GetDlgItem(IDC_BOUND_DEVICE).SetWindowText(g_InputPlugin->ControllerDevices(m_Controller).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CControllerSettings::ButtonChannged(void)
|
void CControllerSettings::ButtonChannged(void)
|
||||||
{
|
{
|
||||||
GetDlgItem(IDC_BOUND_DEVICE).SetWindowText(g_InputPlugin->ControllerDevices(m_ControllerNumber).c_str());
|
GetDlgItem(IDC_BOUND_DEVICE).SetWindowText(g_InputPlugin->ControllerDevices(m_Controller).c_str());
|
||||||
CPropertySheetWindow(GetParent()).SetModified(m_hWnd);
|
CPropertySheetWindow(GetParent()).SetModified(m_hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,12 +295,20 @@ void CInputConfigUI::OnSheetInitialized()
|
||||||
|
|
||||||
void CInputConfigUI::UpdateDeviceMapping(void)
|
void CInputConfigUI::UpdateDeviceMapping(void)
|
||||||
{
|
{
|
||||||
|
CControllerSettings * Pages[] = {
|
||||||
|
&m_pgController0,
|
||||||
|
&m_pgController1,
|
||||||
|
&m_pgController2,
|
||||||
|
&m_pgController3
|
||||||
|
};
|
||||||
|
|
||||||
for (size_t i = 0, n = GetPageCount(); i < n; i++)
|
for (size_t i = 0, n = GetPageCount(); i < n; i++)
|
||||||
{
|
{
|
||||||
HWND hPage = IndexToHwnd(i);
|
HWND hPage = IndexToHwnd(i);
|
||||||
if (hPage != nullptr)
|
if (hPage != nullptr && i < (sizeof(Pages) / sizeof(Pages[0])))
|
||||||
{
|
{
|
||||||
CWindow(::GetDlgItem(hPage, IDC_BOUND_DEVICE)).SetWindowText(g_InputPlugin->ControllerDevices(i).c_str());
|
N64CONTROLLER & Controller = Pages[i]->m_Controller;
|
||||||
|
CWindow(::GetDlgItem(hPage, IDC_BOUND_DEVICE)).SetWindowText(g_InputPlugin->ControllerDevices(Controller).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,28 @@
|
||||||
|
|
||||||
CInputSettings * g_Settings = nullptr;
|
CInputSettings * g_Settings = nullptr;
|
||||||
|
|
||||||
|
static char * Control0_U_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 17 0 5";
|
||||||
|
static char * Control0_D_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 25 0 5";
|
||||||
|
static char * Control0_L_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 24 0 5";
|
||||||
|
static char * Control0_R_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 26 0 5";
|
||||||
|
static char * Control0_A_BUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2D 0 5";
|
||||||
|
static char * Control0_B_BUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2E 0 5";
|
||||||
|
static char * Control0_U_CBUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} C7 0 5";
|
||||||
|
static char * Control0_D_CBUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CF 0 5";
|
||||||
|
static char * Control0_L_CBUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D1 0 5";
|
||||||
|
static char * Control0_R_CBUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D3 0 5";
|
||||||
|
static char * Control0_START_BUTTON_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1C 0 5";
|
||||||
|
static char * Control0_Z_TRIG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2C 0 5";
|
||||||
|
static char * Control0_R_TRIG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1F 0 5";
|
||||||
|
static char * Control0_L_TRIG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1E 0 5";
|
||||||
|
static char * Control0_U_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} C8 0 5";
|
||||||
|
static char * Control0_D_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D0 0 5";
|
||||||
|
static char * Control0_L_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CB 0 5";
|
||||||
|
static char * Control0_R_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CD 0 5";
|
||||||
|
static const uint32_t Default_DeadZone = 25;
|
||||||
|
static const uint32_t Default_Range = 100;
|
||||||
|
static const uint32_t Default_Plugin = PLUGIN_MEMPAK;
|
||||||
|
|
||||||
CInputSettings::CInputSettings()
|
CInputSettings::CInputSettings()
|
||||||
{
|
{
|
||||||
RegisterSettings();
|
RegisterSettings();
|
||||||
|
@ -16,7 +38,8 @@ CInputSettings::~CInputSettings()
|
||||||
|
|
||||||
void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller)
|
void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
BUTTON & Button;
|
BUTTON & Button;
|
||||||
InputSettingID SettingId;
|
InputSettingID SettingId;
|
||||||
uint32_t ControlIndex;
|
uint32_t ControlIndex;
|
||||||
|
@ -69,7 +92,8 @@ void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerI
|
||||||
|
|
||||||
void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller)
|
void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
const BUTTON & Button;
|
const BUTTON & Button;
|
||||||
InputSettingID SettingId;
|
InputSettingID SettingId;
|
||||||
uint32_t ControlIndex;
|
uint32_t ControlIndex;
|
||||||
|
@ -133,39 +157,46 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr
|
||||||
|
|
||||||
void CInputSettings::ResetController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller)
|
void CInputSettings::ResetController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller)
|
||||||
{
|
{
|
||||||
struct {
|
struct
|
||||||
const BUTTON & Button;
|
{
|
||||||
InputSettingID SettingId;
|
BUTTON & Button;
|
||||||
|
const char * DefaultValue;
|
||||||
uint32_t ControlIndex;
|
uint32_t ControlIndex;
|
||||||
}
|
}
|
||||||
Buttons[] =
|
Buttons[] =
|
||||||
{
|
{
|
||||||
{ Controller.U_DPAD, Set_Control0_U_DPAD, 0 },
|
{ Controller.U_DPAD, Control0_U_DPAD_Default, 0 },
|
||||||
{ Controller.D_DPAD, Set_Control0_D_DPAD, 0 },
|
{ Controller.D_DPAD, Control0_D_DPAD_Default, 0 },
|
||||||
{ Controller.L_DPAD, Set_Control0_L_DPAD, 0 },
|
{ Controller.L_DPAD, Control0_L_DPAD_Default, 0 },
|
||||||
{ Controller.R_DPAD, Set_Control0_R_DPAD, 0 },
|
{ Controller.R_DPAD, Control0_R_DPAD_Default, 0 },
|
||||||
{ Controller.A_BUTTON, Set_Control0_A_BUTTON, 0 },
|
{ Controller.A_BUTTON, Control0_A_BUTTON_Default, 0 },
|
||||||
{ Controller.B_BUTTON, Set_Control0_B_BUTTON, 0 },
|
{ Controller.B_BUTTON, Control0_B_BUTTON_Default, 0 },
|
||||||
{ Controller.U_CBUTTON, Set_Control0_U_CBUTTON, 0 },
|
{ Controller.U_CBUTTON, Control0_U_CBUTTON_Default, 0 },
|
||||||
{ Controller.D_CBUTTON, Set_Control0_D_CBUTTON, 0 },
|
{ Controller.D_CBUTTON, Control0_D_CBUTTON_Default, 0 },
|
||||||
{ Controller.L_CBUTTON, Set_Control0_L_CBUTTON, 0 },
|
{ Controller.L_CBUTTON, Control0_L_CBUTTON_Default, 0 },
|
||||||
{ Controller.R_CBUTTON, Set_Control0_R_CBUTTON, 0 },
|
{ Controller.R_CBUTTON, Control0_R_CBUTTON_Default, 0 },
|
||||||
{ Controller.START_BUTTON, Set_Control0_START_BUTTON, 0 },
|
{ Controller.START_BUTTON, Control0_START_BUTTON_Default, 0 },
|
||||||
{ Controller.Z_TRIG, Set_Control0_Z_TRIG, 0 },
|
{ Controller.Z_TRIG, Control0_Z_TRIG_Default, 0 },
|
||||||
{ Controller.R_TRIG, Set_Control0_R_TRIG, 0 },
|
{ Controller.R_TRIG, Control0_R_TRIG_Default, 0 },
|
||||||
{ Controller.L_TRIG, Set_Control0_L_TRIG, 0 },
|
{ Controller.L_TRIG, Control0_L_TRIG_Default, 0 },
|
||||||
{ Controller.U_ANALOG, Set_Control0_U_ANALOG, 0 },
|
{ Controller.U_ANALOG, Control0_U_ANALOG_Default, 0 },
|
||||||
{ Controller.D_ANALOG, Set_Control0_D_ANALOG, 0 },
|
{ Controller.D_ANALOG, Control0_D_ANALOG_Default, 0 },
|
||||||
{ Controller.L_ANALOG, Set_Control0_L_ANALOG, 0 },
|
{ Controller.L_ANALOG, Control0_L_ANALOG_Default, 0 },
|
||||||
{ Controller.R_ANALOG, Set_Control0_R_ANALOG, 0 },
|
{ Controller.R_ANALOG, Control0_R_ANALOG_Default, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++)
|
for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++)
|
||||||
{
|
{
|
||||||
SetSettingSz((short)Buttons[i].SettingId, NULL);
|
if (Buttons[i].ControlIndex != ControlIndex)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
FlushSettings();
|
Buttons[i].Button = StrToButton(Buttons[i].DefaultValue);
|
||||||
LoadController(ControlIndex, ControllerInfo, Controller);
|
}
|
||||||
|
Controller.Range = Default_Range;
|
||||||
|
Controller.DeadZone = Default_DeadZone;
|
||||||
|
ControllerInfo.Present = ControlIndex == 0 ? 1 : 0;
|
||||||
|
ControllerInfo.Plugin = Default_Plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUTTON CInputSettings::StrToButton(const char * Buffer)
|
BUTTON CInputSettings::StrToButton(const char * Buffer)
|
||||||
|
@ -199,27 +230,27 @@ void CInputSettings::RegisterSettings(void)
|
||||||
{
|
{
|
||||||
SetModuleName("Input");
|
SetModuleName("Input");
|
||||||
RegisterSetting(Set_Control0_Present, Data_DWORD_General, "Present", "Controller 1", 1, nullptr);
|
RegisterSetting(Set_Control0_Present, Data_DWORD_General, "Present", "Controller 1", 1, nullptr);
|
||||||
RegisterSetting(Set_Control0_Plugin, Data_DWORD_General, "Plugin", "Controller 1", PLUGIN_MEMPAK, nullptr);
|
RegisterSetting(Set_Control0_Plugin, Data_DWORD_General, "Plugin", "Controller 1", Default_Plugin, nullptr);
|
||||||
RegisterSetting(Set_Control0_Range, Data_DWORD_General, "Range", "Controller 1", 100, nullptr);
|
RegisterSetting(Set_Control0_Range, Data_DWORD_General, "Range", "Controller 1", Default_Range, nullptr);
|
||||||
RegisterSetting(Set_Control0_Deadzone, Data_DWORD_General, "Deadzone", "Controller 1", 25, nullptr);
|
RegisterSetting(Set_Control0_Deadzone, Data_DWORD_General, "Deadzone", "Controller 1", Default_DeadZone, nullptr);
|
||||||
RegisterSetting(Set_Control0_U_DPAD, Data_String_General, "DPadUp", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 17 0 5");
|
RegisterSetting(Set_Control0_U_DPAD, Data_String_General, "DPadUp", "Controller 1", 0, Control0_U_DPAD_Default);
|
||||||
RegisterSetting(Set_Control0_D_DPAD, Data_String_General, "DPadDown", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 25 0 5");
|
RegisterSetting(Set_Control0_D_DPAD, Data_String_General, "DPadDown", "Controller 1", 0, Control0_D_DPAD_Default);
|
||||||
RegisterSetting(Set_Control0_L_DPAD, Data_String_General, "DPadLeft", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 24 0 5");
|
RegisterSetting(Set_Control0_L_DPAD, Data_String_General, "DPadLeft", "Controller 1", 0, Control0_L_DPAD_Default);
|
||||||
RegisterSetting(Set_Control0_R_DPAD, Data_String_General, "DPadRight", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 26 0 5");
|
RegisterSetting(Set_Control0_R_DPAD, Data_String_General, "DPadRight", "Controller 1", 0, Control0_R_DPAD_Default);
|
||||||
RegisterSetting(Set_Control0_A_BUTTON, Data_String_General, "ButtonA", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2D 0 5");
|
RegisterSetting(Set_Control0_A_BUTTON, Data_String_General, "ButtonA", "Controller 1", 0, Control0_A_BUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_B_BUTTON, Data_String_General, "ButtonB", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2E 0 5");
|
RegisterSetting(Set_Control0_B_BUTTON, Data_String_General, "ButtonB", "Controller 1", 0, Control0_B_BUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_U_CBUTTON, Data_String_General, "CButtonUp", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} C7 0 5");
|
RegisterSetting(Set_Control0_U_CBUTTON, Data_String_General, "CButtonUp", "Controller 1", 0, Control0_U_CBUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_D_CBUTTON, Data_String_General, "CButtonDown", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CF 0 5");
|
RegisterSetting(Set_Control0_D_CBUTTON, Data_String_General, "CButtonDown", "Controller 1", 0, Control0_D_CBUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_L_CBUTTON, Data_String_General, "CButtonLeft", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D1 0 5");
|
RegisterSetting(Set_Control0_L_CBUTTON, Data_String_General, "CButtonLeft", "Controller 1", 0, Control0_L_CBUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_R_CBUTTON, Data_String_General, "CButtonRight", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D3 0 5");
|
RegisterSetting(Set_Control0_R_CBUTTON, Data_String_General, "CButtonRight", "Controller 1", 0, Control0_R_CBUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_START_BUTTON, Data_String_General, "ButtonStart", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1C 0 5");
|
RegisterSetting(Set_Control0_START_BUTTON, Data_String_General, "ButtonStart", "Controller 1", 0, Control0_START_BUTTON_Default);
|
||||||
RegisterSetting(Set_Control0_Z_TRIG, Data_String_General, "ButtonZ", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 2C 0 5");
|
RegisterSetting(Set_Control0_Z_TRIG, Data_String_General, "ButtonZ", "Controller 1", 0, Control0_Z_TRIG_Default);
|
||||||
RegisterSetting(Set_Control0_R_TRIG, Data_String_General, "ButtonR", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1F 0 5");
|
RegisterSetting(Set_Control0_R_TRIG, Data_String_General, "ButtonR", "Controller 1", 0, Control0_R_TRIG_Default);
|
||||||
RegisterSetting(Set_Control0_L_TRIG, Data_String_General, "ButtonL", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 1E 0 5");
|
RegisterSetting(Set_Control0_L_TRIG, Data_String_General, "ButtonL", "Controller 1", 0, Control0_L_TRIG_Default);
|
||||||
RegisterSetting(Set_Control0_U_ANALOG, Data_String_General, "AnalogUp", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} C8 0 5");
|
RegisterSetting(Set_Control0_U_ANALOG, Data_String_General, "AnalogUp", "Controller 1", 0, Control0_U_ANALOG_Default);
|
||||||
RegisterSetting(Set_Control0_D_ANALOG, Data_String_General, "AnalogDown", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} D0 0 5");
|
RegisterSetting(Set_Control0_D_ANALOG, Data_String_General, "AnalogDown", "Controller 1", 0, Control0_D_ANALOG_Default);
|
||||||
RegisterSetting(Set_Control0_L_ANALOG, Data_String_General, "AnalogLeft", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CB 0 5");
|
RegisterSetting(Set_Control0_L_ANALOG, Data_String_General, "AnalogLeft", "Controller 1", 0, Control0_L_ANALOG_Default);
|
||||||
RegisterSetting(Set_Control0_R_ANALOG, Data_String_General, "AnalogRight", "Controller 1", 0, "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CD 0 5");
|
RegisterSetting(Set_Control0_R_ANALOG, Data_String_General, "AnalogRight", "Controller 1", 0, Control0_R_ANALOG_Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupInputSettings(void)
|
void SetupInputSettings(void)
|
||||||
|
|
Loading…
Reference in New Issue