Skip to content

Commit fff1011

Browse files
nate-yocomdtor
authored andcommittedSep 29, 2022
Input: xpad - add X-Box Adaptive Profile button
Adds a new quirk for controllers that have a Profile button which has 4 states, reflected as an ABS_PROFILE axis with 4 values. Signed-off-by: Nate Yocom <nate@yocom.org> Tested-by: Bastien Nocera <hadess@hadess.net> Link: https://lore.kernel.org/r/20220908173930.28940-6-nate@yocom.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 1260cd0 commit fff1011

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎drivers/input/joystick/xpad.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
#define MAP_TRIGGERS_TO_BUTTONS (1 << 1)
8282
#define MAP_STICKS_TO_NULL (1 << 2)
8383
#define MAP_SELECT_BUTTON (1 << 3)
84-
#define MAP_PADDLES (1 << 4)
84+
#define MAP_PADDLES (1 << 4)
85+
#define MAP_PROFILE_BUTTON (1 << 5)
86+
8587
#define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \
8688
MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
8789

@@ -148,7 +150,7 @@ static const struct xpad_device {
148150
{ 0x045e, 0x0b00, "Microsoft X-Box One Elite 2 pad", MAP_PADDLES, XTYPE_XBOXONE },
149151
{ 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
150152
{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
151-
{ 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0, XTYPE_XBOXONE },
153+
{ 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_PROFILE_BUTTON, XTYPE_XBOXONE },
152154
{ 0x045e, 0x0b12, "Microsoft Xbox Series S|X Controller", MAP_SELECT_BUTTON, XTYPE_XBOXONE },
153155
{ 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 },
154156
{ 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
@@ -777,6 +779,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
777779
input_report_key(dev, BTN_C, data[8]);
778780
input_report_key(dev, BTN_Z, data[9]);
779781

782+
/* Profile button has a value of 0-3, so it is reported as an axis */
783+
if (xpad->mapping & MAP_PROFILE_BUTTON)
784+
input_report_abs(dev, ABS_PROFILE, data[34]);
785+
780786
input_sync(dev);
781787
}
782788

@@ -1800,6 +1806,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
18001806
case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
18011807
input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
18021808
break;
1809+
case ABS_PROFILE: /* 4 value profile button (such as on XAC) */
1810+
input_set_abs_params(input_dev, abs, 0, 4, 0, 0);
1811+
break;
18031812
default:
18041813
input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
18051814
break;
@@ -1898,6 +1907,10 @@ static int xpad_init_input(struct usb_xpad *xpad)
18981907
xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
18991908
}
19001909

1910+
/* setup profile button as an axis with 4 possible values */
1911+
if (xpad->mapping & MAP_PROFILE_BUTTON)
1912+
xpad_set_up_abs(input_dev, ABS_PROFILE);
1913+
19011914
error = xpad_init_ff(xpad);
19021915
if (error)
19031916
goto err_free_input;

0 commit comments

Comments
 (0)