From a789b9edc26dc84567ef8283ae3833df8219219f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 21 Jun 2013 18:07:50 -0700 Subject: [PATCH] Add right stick options to DirectInput. At least, my controller uses Z axis/rotation. --- Windows/DinputDevice.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index f39e0d3bb1..cc0222578e 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -210,6 +210,35 @@ int DinputDevice::UpdateState(InputState &input_state) } } + const LONG rthreshold = 8000; + + switch (g_Config.iRightStickBind) { + case 0: + break; + case 1: + if (js.lRz > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RIGHT; + else if (js.lRz < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LEFT; + if (js.lZ > rthreshold) input_state.pad_buttons |= PAD_BUTTON_UP; + else if (js.lZ < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_DOWN; + break; + case 2: + if (js.lRz > rthreshold) input_state.pad_buttons |= PAD_BUTTON_B; + else if (js.lRz < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_X; + if (js.lZ > rthreshold) input_state.pad_buttons |= PAD_BUTTON_Y; + else if (js.lZ < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_A; + break; + case 3: + if (js.lRz > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RBUMPER; + else if (js.lRz < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LBUMPER; + break; + case 4: + if (js.lRz > rthreshold) input_state.pad_buttons |= PAD_BUTTON_RBUMPER; + else if (js.lRz < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_LBUMPER; + if (js.lZ > rthreshold) input_state.pad_buttons |= PAD_BUTTON_Y; + else if (js.lZ < -rthreshold) input_state.pad_buttons |= PAD_BUTTON_A; + break; + } + return UPDATESTATE_SKIP_PAD; }