From b60a2fb8199e81b7bf58f31612c985f4b56e9b90 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 11 Jun 2013 21:29:55 +0200 Subject: [PATCH] x360 temporary right stick hard bind now configurable in ini file. --- Core/Config.cpp | 4 +++- Core/Config.h | 6 ++++++ Core/HLE/sceNet.cpp | 4 ++-- Windows/XinputDevice.cpp | 27 +++++++++++++++++++++------ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 0f436e1710..ab159f20ae 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -145,6 +145,7 @@ void Config::Load(const char *iniFileName) control->Get("KeyMapping",iMappingMap); control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false); control->Get("ForceInputDevice", &iForceInputDevice, -1); + control->Get("RightStickBind", &iRightStickBind, 0); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Get("NickName", &sNickName, "shadow"); @@ -236,7 +237,8 @@ void Config::Save() control->Set("KeyMapping",iMappingMap); control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz); control->Set("ForceInputDevice", iForceInputDevice); - + control->Set("RightStickBind", iRightStickBind); + IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Set("NickName", sNickName.c_str()); diff --git a/Core/Config.h b/Core/Config.h index 6c407df697..43a9f61239 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -98,6 +98,12 @@ public: bool bShowDebugStats; bool bLargeControls; bool bAccelerometerToAnalogHoriz; + // Temporary until control mapping rewrite + // 0 = none + // 1 = arrow buttons + // 2 = face buttons + // 3 = L/R + int iRightStickBind; // Control std::map iMappingMap; // Can be used differently depending on systems diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index a7089fcc08..bb32fc8e6a 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -53,7 +53,7 @@ enum { }; //these might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc -typedef struct SceNetAdhocctlParams +struct SceNetAdhocctlParams { int channel; //which ad-hoc channel to connect to char name[8]; //connection name @@ -61,7 +61,7 @@ typedef struct SceNetAdhocctlParams char nickname[128]; //PSP's nickname? }; -typedef struct ProductStruct +struct ProductStruct { int unknown; //unknown, set to 0 char product[9]; //Product name? diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index 087c0653a6..90cfc0505b 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -170,15 +170,30 @@ void XinputDevice::ApplyDiff(XINPUT_STATE &state, InputState &input_state) { state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) { input_state.pad_buttons |= xinput_ctrl_map[i + 1]; } - } + const SHORT rthreshold = 22000; - if (state.Gamepad.sThumbRX > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RIGHT; - else if (state.Gamepad.sThumbRX < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LEFT; - - if (state.Gamepad.sThumbRY > rthreshold) input_state.pad_buttons |= PAD_BUTTON_UP; - else if (state.Gamepad.sThumbRY < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_DOWN; + switch (g_Config.iRightStickBind) { + case 0: + break; + case 1: + if (state.Gamepad.sThumbRX > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RIGHT; + else if (state.Gamepad.sThumbRX < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LEFT; + if (state.Gamepad.sThumbRY > rthreshold) input_state.pad_buttons |= PAD_BUTTON_UP; + else if (state.Gamepad.sThumbRY < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_DOWN; + break; + case 2: + if (state.Gamepad.sThumbRX > rthreshold) input_state.pad_buttons |= PAD_BUTTON_B; + else if (state.Gamepad.sThumbRX < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_X; + if (state.Gamepad.sThumbRY > rthreshold) input_state.pad_buttons |= PAD_BUTTON_Y; + else if (state.Gamepad.sThumbRY < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_A; + break; + case 3: + if (state.Gamepad.sThumbRX > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RBUMPER; + else if (state.Gamepad.sThumbRX < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LBUMPER; + break; + } } int XinputDevice::UpdateRawStateSingle(RawInputState &rawState)