From e864569d0cc2c3d7e1a6d7b6895c51c6ebfdfbbe Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 16 Apr 2013 17:34:20 +0300 Subject: [PATCH] Windows: add Force Input Device option; --- Core/Config.cpp | 3 +++ Core/Config.h | 1 + Windows/DinputDevice.cpp | 2 ++ Windows/WndMainWindow.cpp | 26 ++++++++++++++++++++++---- Windows/XinputDevice.cpp | 2 ++ Windows/ppsspp.rc | 4 +++- Windows/resource.h | 1 + 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 9c67300f1d..df352fdeb9 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -113,6 +113,7 @@ void Config::Load(const char *iniFileName) control->Get("LargeControls", &bLargeControls, false); control->Get("KeyMapping",iMappingMap); control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false); + control->Get("ForceInputDevice", &iForceInputDevice, -1); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Get("Language", &ilanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH); @@ -179,6 +180,8 @@ void Config::Save() control->Set("LargeControls", bLargeControls); control->Set("KeyMapping",iMappingMap); control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz); + control->Set("ForceInputDevice", iForceInputDevice); + IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Set("Language", ilanguage); diff --git a/Core/Config.h b/Core/Config.h index c2ec1a53a1..8b9e5cfb53 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -83,6 +83,7 @@ public: // Control std::map iMappingMap; // Can be used differently depending on systems + int iForceInputDevice; // SystemParam int ilanguage; diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index 1c8a71feda..11c402f8c1 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -17,6 +17,7 @@ #include #include "DinputDevice.h" +#include "Core/Config.h" #include "input/input_state.h" #include "Core/Reporting.h" #include "Xinput.h" @@ -114,6 +115,7 @@ DinputDevice::~DinputDevice() int DinputDevice::UpdateState(InputState &input_state) { + if (g_Config.iForceInputDevice == 0) return -1; if (!pJoystick) return -1; DIJOYSTATE2 js; diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 19ee41f086..1fe4d5f6f9 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -776,7 +776,7 @@ namespace MainWindow "Rapid Fire\tShift", }; - // Message handler for about box. + // Message handler for controls box. LRESULT CALLBACK Controls(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -791,14 +791,32 @@ namespace MainWindow for (int i = 0; i < sizeof(controllist)/sizeof(controllist[0]); i++) { SendMessage(list, LB_INSERTSTRING, -1, (LPARAM)controllist[i]); } + + ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "None"); + ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "XInput"); + ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "DirectInput"); + if ((g_Config.iForceInputDevice < 0) || (g_Config.iForceInputDevice > 1)) + { + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), 0); + } + else + { + ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), (g_Config.iForceInputDevice + 1)); + } } return TRUE; case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) + switch (LOWORD(wParam)) { - EndDialog(hDlg, LOWORD(wParam)); - return TRUE; + case IDOK: + g_Config.iForceInputDevice = (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE)) - 1); + EndDialog(hDlg, IDOK); + return TRUE; + + case IDCANCEL: + EndDialog(hDlg, IDCANCEL); + return TRUE; } break; } diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index 34b4883155..63be6da75e 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -1,5 +1,6 @@ #include #include "XinputDevice.h" +#include "Core/Config.h" #include "input/input_state.h" #ifndef XUSER_MAX_COUNT @@ -19,6 +20,7 @@ struct Stick { static Stick NormalizedDeadzoneFilter(short x, short y); int XinputDevice::UpdateState(InputState &input_state) { + if (g_Config.iForceInputDevice > 0) return -1; if (this->check_delay-- > 0) return -1; XINPUT_STATE state; ZeroMemory( &state, sizeof(XINPUT_STATE) ); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 0a3a3736c6..f6a667b777 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -171,7 +171,9 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,176,217,50,14 PUSHBUTTON "Cancel",IDCANCEL,230,217,50,14 LTEXT "NOTE: Currently controls are NOT configurable.\nHowever: Xbox 360 controllers are supported! Just plug one in and use it!",IDC_STATIC,7,7,188,30 - LISTBOX IDC_LISTCONTROLS,7,39,273,164,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_LISTCONTROLS,7,39,273,176,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LTEXT "Force device:",IDC_STATIC,10,220,45,11 + COMBOBOX IDC_FORCE_INPUT_DEVICE,59,219,84,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END diff --git a/Windows/resource.h b/Windows/resource.h index 57ded8dd45..b710526f01 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -122,6 +122,7 @@ #define IDC_BROWSE 1159 #define IDC_SHOWVFPU 1161 #define IDC_LISTCONTROLS 1162 +#define IDC_FORCE_INPUT_DEVICE 1163 #define ID_FILE_EXIT 40002 #define ID_CONFIG_SELECT_PLUGINS 40003 #define ID_BUTTON40013 40013