From 5d59156ee4b40721c132c931e5e32826cef09756 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 7 Jul 2020 11:59:49 +0930 Subject: [PATCH] Project64-input: Add selecting of device --- Source/Project64-input/InputConfigUI.cpp | 16 ++++++++++++++++ Source/Project64-input/InputSettings.cpp | 8 ++++++++ Source/Project64-input/InputSettingsID.h | 1 + 3 files changed, 25 insertions(+) diff --git a/Source/Project64-input/InputConfigUI.cpp b/Source/Project64-input/InputConfigUI.cpp index 5e8610239..ca554f582 100644 --- a/Source/Project64-input/InputConfigUI.cpp +++ b/Source/Project64-input/InputConfigUI.cpp @@ -21,6 +21,7 @@ public: MSG_WM_INITDIALOG(OnInitDialog) MSG_WM_CTLCOLORSTATIC(OnCtlColorStatic) COMMAND_HANDLER_EX(IDC_CHK_PLUGGED_IN, BN_CLICKED, ItemChanged) + COMMAND_HANDLER_EX(IDC_CMB_DEVICE, CBN_SELCHANGE, ItemChanged) NOTIFY_HANDLER_EX(IDC_TACK_RANGE, NM_RELEASEDCAPTURE, ItemChangedNotify); MESSAGE_HANDLER(WM_HSCROLL, OnScroll) CHAIN_MSG_MAP(CPropertyPageImpl) @@ -43,6 +44,7 @@ private: uint32_t m_ScanCount; CBitmapPicture m_ControllerImg; CButton m_PluggedIn; + CComboBox m_cmbDevice; CTrackBarCtrl m_Range; CScanButton m_ButtonUDPad, m_ButtonDDPad, m_ButtonLDPad, m_ButtonRDPad; CScanButton m_ButtonCUp, m_ButtonCDown, m_ButtonCLeft, m_ButtonCRight; @@ -93,6 +95,19 @@ BOOL CControllerSettings::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam CWindow(GetDlgItem(IDC_LABEL_RANGE)).SetWindowText(stdstr_f("%d%%", m_Range.GetPos()).ToUTF16().c_str()); m_PluggedIn.Attach(GetDlgItem(IDC_CHK_PLUGGED_IN)); m_PluggedIn.SetCheck(ControlInfo.Present != 0 ? BST_CHECKED : BST_UNCHECKED); + m_cmbDevice.Attach(GetDlgItem(IDC_CMB_DEVICE)); + m_cmbDevice.SetItemData(m_cmbDevice.AddString(L"None"), PLUGIN_NONE); + m_cmbDevice.SetItemData(m_cmbDevice.AddString(L"Mem Pak"), PLUGIN_MEMPAK); + m_cmbDevice.SetItemData(m_cmbDevice.AddString(L"Rumble Pak"), PLUGIN_RUMBLE_PAK); + m_cmbDevice.SetCurSel(0); + for (DWORD i = 0, n = m_cmbDevice.GetCount(); i < n; i++) + { + if (m_cmbDevice.GetItemData(i) == (DWORD)ControlInfo.Plugin) + { + m_cmbDevice.SetCurSel(i); + break; + } + } m_ControllerImg.SubclassWindow(GetDlgItem(IDC_BMP_CONTROLLER)); m_ControllerImg.SetBitmap(MAKEINTRESOURCE(IDB_CONTROLLER)); @@ -130,6 +145,7 @@ bool CControllerSettings::OnApply() CONTROL & ControlInfo = g_InputPlugin->ControlInfo(m_ControllerNumber); Controller.Range = (uint8_t)m_Range.GetPos(); ControlInfo.Present = (m_PluggedIn.GetCheck() == BST_CHECKED) ? 1 : 0; + ControlInfo.Plugin = m_cmbDevice.GetItemData(m_cmbDevice.GetCurSel()); return g_InputPlugin->SaveController(m_ControllerNumber); } diff --git a/Source/Project64-input/InputSettings.cpp b/Source/Project64-input/InputSettings.cpp index af4c31cdf..0ce9413a9 100644 --- a/Source/Project64-input/InputSettings.cpp +++ b/Source/Project64-input/InputSettings.cpp @@ -54,9 +54,11 @@ void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerI } InputSettingID PresentSettings[] = { Set_Control0_Present }; + InputSettingID PluginSettings[] = { Set_Control0_Plugin }; InputSettingID RangeSettings[] = { Set_Control0_Range }; ControllerInfo.Present = ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0])) ? GetSetting((short)PresentSettings[ControlIndex]) != 0 : 0; + ControllerInfo.Plugin = ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0])) ? GetSetting((short)PluginSettings[ControlIndex]) : PLUGIN_NONE; 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; } @@ -105,6 +107,11 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr { SetSetting((short)PresentSettings[ControlIndex], ControllerInfo.Present); } + InputSettingID PluginSettings[] = { Set_Control0_Plugin }; + if (ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0]))) + { + SetSetting((short)PluginSettings[ControlIndex], ControllerInfo.Plugin); + } InputSettingID RangeSettings[] = { Set_Control0_Range }; if (ControlIndex < (sizeof(RangeSettings) / sizeof(RangeSettings[0]))) @@ -145,6 +152,7 @@ void CInputSettings::RegisterSettings(void) { SetModuleName("Input"); 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_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/InputSettingsID.h b/Source/Project64-input/InputSettingsID.h index d381df4f9..a1ea5ae44 100644 --- a/Source/Project64-input/InputSettingsID.h +++ b/Source/Project64-input/InputSettingsID.h @@ -3,6 +3,7 @@ enum InputSettingID { Set_Control0_Present, + Set_Control0_Plugin, Set_Control0_Range, Set_Control0_U_DPAD, Set_Control0_D_DPAD,