From 80a64430a39f306f702766525a093ac1141f7252 Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 13 Oct 2017 22:10:53 +0200 Subject: xinput: the left+right triggers combined are considered the Z Axis, not Z Axis+Z Rotation where the axis resting position was at the middle of the trigger (nw) --- src/osd/modules/input/input_xinput.cpp | 13 +++---------- src/osd/modules/input/input_xinput.h | 5 ++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp index e6ecdd4d177..fe5b50ec128 100644 --- a/src/osd/modules/input/input_xinput.cpp +++ b/src/osd/modules/input/input_xinput.cpp @@ -131,8 +131,7 @@ void xinput_joystick_device::poll() gamepad.right_thumb_y = normalize_absolute_axis(-xinput_state.xstate.Gamepad.sThumbRY, XINPUT_AXIS_MINVALUE, XINPUT_AXIS_MAXVALUE); // Now the triggers - gamepad.left_trigger = normalize_absolute_axis(xinput_state.xstate.Gamepad.bLeftTrigger, 0, 255); - gamepad.right_trigger = normalize_absolute_axis(xinput_state.xstate.Gamepad.bRightTrigger, 0, 255); + gamepad.z_axis = normalize_absolute_axis(xinput_state.xstate.Gamepad.bLeftTrigger - xinput_state.xstate.Gamepad.bRightTrigger, -255, 255); } void xinput_joystick_device::reset() @@ -179,16 +178,10 @@ void xinput_joystick_device::configure() } device()->add_item( - "Left Trigger", + "Z", ITEM_ID_ZAXIS, generic_axis_get_state, - &gamepad.left_trigger); - - device()->add_item( - "Right Trigger", - ITEM_ID_RZAXIS, - generic_axis_get_state, - &gamepad.right_trigger); + &gamepad.z_axis); m_configured = true; } diff --git a/src/osd/modules/input/input_xinput.h b/src/osd/modules/input/input_xinput.h index 2cd8f15a250..4083c7f325c 100644 --- a/src/osd/modules/input/input_xinput.h +++ b/src/osd/modules/input/input_xinput.h @@ -74,8 +74,7 @@ struct gamepad_state { BYTE buttons[XINPUT_MAX_BUTTONS]; BYTE povs[XINPUT_MAX_POV]; - LONG left_trigger; - LONG right_trigger; + LONG z_axis; LONG left_thumb_x; LONG left_thumb_y; LONG right_thumb_x; @@ -85,7 +84,7 @@ struct gamepad_state // state information for a gamepad; state must be first element struct xinput_api_state { - uint32_t player_index; + uint32_t player_index; XINPUT_STATE xstate; XINPUT_CAPABILITIES caps; }; -- cgit v1.2.3