Input: joystick: xpad: Add X-Box Adaptive Controller support
Subsystems (2)
v3 cover Input: joystick: xpad: Add X-Box Adaptive Controller support
Adds support for the X-Box Adaptive Controller, which is protocol compatible with the XTYPE_XBOXONE support in the driver with two deltas:
- The X-Box button sets 0x02 as its activation ID, where others set 0x01
- The controller has an additional "Layer" button with 4 active states, which this change maps to an Axis control with 4 possible values
Patch series adds device to the supported table, adds support for the Layer button, and adds support for the X-Box button as distinct changes.
Nate Yocom (3):
Input: joystick: xpad: Add X-Box Adaptive Controller support
Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
Input: joystick: xpad: Add X-Box Adaptive Controller XBox button
v2: Fix warning Reported-by: kernel test robot <[email protected]>
v3: Break into multi-part and remove VID/PID check for XBox button
drivers/input/joystick/xpad.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
base-commit: 15205c2829ca2cbb5ece5ceaafe1171a8470e62b
Signature · 1 line
2.30.2
PATCH v3 1/3 Input: joystick: xpad: Add X-Box Adaptive Controller support
Adds correct VID/PID for this XTYPE_XBOXONE compatible controller to xpad_device[] table.
--- drivers/input/joystick/xpad.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/joystick/xpad.c +1 -0
@@ -131,6 +131,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, + { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0, XTYPE_XBOXONE }, { 0x045e, 0x0b12, "Microsoft Xbox Series S|X Controller", MAP_SELECT_BUTTON, XTYPE_XBOXONE }, { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 }, { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
Signature · 1 line
2.30.2
Quoted 4 lines · Nate Yocom
Adds correct VID/PID for this
XTYPE_XBOXONEcompatible controller to xpad_device[] table.Signed-off-by Nate Yocom <[email protected]>
Have you tested the device in Bluetooth mode? My controller's battery is still charging.
Quoted 24 lines
---
drivers/input/joystick/xpad.c | 1 +1 file changed, 1 insertion(+)drivers/input/joystick/xpad.c +1
-0@@ -131,6 +131,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, + { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0,
XTYPE_XBOXONE},
{0x045e,0x0b12, "Microsoft Xbox Series S|X Controller",MAP_SELECT_BUTTON,XTYPE_XBOXONE},
{0x046d,0xc21d, "Logitech Gamepad F310", 0,XTYPE_XBOX360},
{0x046d,0xc21e, "Logitech Gamepad F510", 0,XTYPE_XBOX360},
Quoted 8 lines · Bastien Nocera
Quoted 4 lines · Nate Yocom
Adds correct VID/PID for this
XTYPE_XBOXONEcompatible controller to xpad_device[] table.Signed-off-by Nate Yocom <[email protected]>Have you tested the device in Bluetooth mode? My controller's battery is still charging.
I have tried, but haven't been successful in getting it connected with, or without my changes (i.e. no change), so was focused on cabled support first.
Quoted 1 line
Tested-by Bastien Nocera <[email protected]>
Thanks!
Quoted 26 lines
Quoted 25 lines
---
drivers/input/joystick/xpad.c | 1 +1 file changed, 1 insertion(+)drivers/input/joystick/xpad.c +1
-0@@ -131,6 +131,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, + { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0,
XTYPE_XBOXONE},
{0x045e,0x0b12, "Microsoft Xbox Series S|X Controller",MAP_SELECT_BUTTON,XTYPE_XBOXONE},
{0x046d,0xc21d, "Logitech Gamepad F310", 0,XTYPE_XBOX360},
{0x046d,0xc21e, "Logitech Gamepad F510", 0,XTYPE_XBOX360},
PATCH v3 2/3 Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
In reply to Nate YocomAdds a new quirk for controllers that have a Layer button which has 4 states, reflected as an ABS_MISC axis with 4 values.
--- drivers/input/joystick/xpad.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/input/joystick/xpad.c +13 -1
@@ -80,6 +80,7 @@#define MAP_TRIGGERS_TO_BUTTONS (1 << 1)#define MAP_STICKS_TO_NULL (1 << 2)#define MAP_SELECT_BUTTON (1 << 3) +#define MAP_LAYER_BUTTON (1 << 4)#define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
@@ -131,7 +132,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, - { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0, XTYPE_XBOXONE }, + { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_LAYER_BUTTON, XTYPE_XBOXONE }, { 0x045e, 0x0b12, "Microsoft Xbox Series S|X Controller", MAP_SELECT_BUTTON, XTYPE_XBOXONE }, { 0x046d, 0xc21d, "Logitech Gamepad F310", 0, XTYPE_XBOX360 }, { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
@@ -927,6 +928,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char (__u16) le16_to_cpup((__le16 *)(data + 8))); } +/* Layer button has a value of 0-4, so it is reported as an axis */ +if (xpad->mapping &MAP_LAYER_BUTTON ) +input_report_abs (dev,ABS_MISC , data[34 ]); +input_sync (dev); }
@@ -1623,6 +1628,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)case ABS_HAT0Y :/* the d-pad (only if dpad is mapped to axes */ input_set_abs_params (input_dev, abs,-1 ,1 ,0 ,0 );break ; +case ABS_MISC :/* 4 value layer button (such as on XAC) */ +input_set_abs_params (input_dev, abs,0 ,4 ,0 ,0 ); +break ;default :input_set_abs_params (input_dev, abs,0 ,0 ,0 ,0 );break ;
@@ -1715,6 +1723,10 @@ static int xpad_init_input(struct usb_xpad *xpad)xpad_set_up_abs (input_dev, xpad_abs_triggers[i]); } +/* setup layer button as an axis with 4 possible values */ +if (xpad->mapping &MAP_LAYER_BUTTON ) +xpad_set_up_abs (input_dev,ABS_MISC ); + error =xpad_init_ff (xpad);if (error) goto err_free_input;
Signature · 1 line
2.30.2
Re: [PATCH v3 2/3] Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
Quoted 2 lines · Nate Yocom
Adds a new quirk for controllers that have a Layer button which has 4 states, reflected as an
ABS_MISCaxis with 4 values.
It's called the "Profile Button" in the official documentation:
https://support.xbox.com/en-US/help/account-profile/accessibility/get-to-know-adaptive-controller
so best to call it that.
I wonder we have any other examples of profile handling in input drivers. The xpadneo driver implements the profiles in the kernel driver directly.
Benjamin?
Quoted 77 lines
Signed-off-by Nate Yocom <[email protected]>---
drivers/input/joystick/xpad.c | 14 +++++++++++++-1 file changed, 13 insertions(+), 1 deletion(-)drivers/input/joystick/xpad.c +1
-0@@ -80,6 +80,7 @@ #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) #define MAP_STICKS_TO_NULL (1 << 2) #define MAP_SELECT_BUTTON (1 << 3) +#define MAP_LAYER_BUTTON (1 << 4) #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \MAP_TRIGGERS_TO_BUTTONS |
MAP_STICKS_TO_NULL)drivers/input/joystick/xpad.c +0
-1@@ -131,7 +132,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, - { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0,
XTYPE_XBOXONE},
+ {0x045e,0x0b0a, "Microsoft X-Box Adaptive Controller",MAP_LAYER_BUTTON,XTYPE_XBOXONE},
{0x045e,0x0b12, "Microsoft Xbox Series S|X Controller",MAP_SELECT_BUTTON,XTYPE_XBOXONE},
{0x046d,0xc21d, "Logitech Gamepad F310", 0,XTYPE_XBOX360},
{0x046d,0xc21e, "Logitech Gamepad F510", 0,XTYPE_XBOX360},drivers/input/joystick/xpad.c +0
-0@@ -927,6 +928,10 @@ static void xpadone_process_packet(struct
usb_xpad*xpad, u16 cmd, unsigned char
(__u16) le16_to_cpup((__le16 *)(data
+ 8)));
}
+ /* Layer button has a value of 0-4, so it is reported as an axis */
+ if (xpad->mapping&MAP_LAYER_BUTTON)
+ input_report_abs(dev,ABS_MISC, data[34]); +
input_sync(dev);
}drivers/input/joystick/xpad.c +0
-0@@ -1623,6 +1628,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
input_set_abs_params(input_dev, abs, -1, 1, 0, 0); break;
+ caseABS_MISC: /* 4 value layer button (such as on XAC) */ + input_set_abs_params(input_dev, abs, 0, 4, 0, 0); + break;
default:
input_set_abs_params(input_dev, abs, 0, 0, 0, 0); break;drivers/input/joystick/xpad.c +0
-0@@ -1715,6 +1723,10 @@ static int xpad_init_input(struct usb_xpad *xpad) xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); }
+ /* setup layer button as an axis with 4 possible values */ + if (xpad->mapping&MAP_LAYER_BUTTON)
+ xpad_set_up_abs(input_dev,ABS_MISC);
+
error =xpad_init_ff(xpad);
if (error)
gotoerr_free_input;
Re: [PATCH v3 2/3] Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
Quoted 7 lines · Bastien Nocera
Quoted 2 lines · Nate Yocom
Adds a new quirk for controllers that have a Layer button which has 4 states, reflected as an
ABS_MISCaxis with 4 values.It's called the "Profile Button" in the official documentation:
https://support.xbox.com/en-US/help/account-profile/accessibility/get-to-know-adaptive-controller
so best to call it that.
Agreed - thanks for the pointer, will send a v4 shortly.
Quoted 86 lines
I wonder we have any other examples of profile handling in input drivers. The xpadneo driver implements the profiles in the kernel driver directly.
Benjamin?
Tested-by Bastien Nocera <[email protected]>Quoted 77 lines
Signed-off-by Nate Yocom <[email protected]>---
drivers/input/joystick/xpad.c | 14 +++++++++++++-1 file changed, 13 insertions(+), 1 deletion(-)drivers/input/joystick/xpad.c +1
-0@@ -80,6 +80,7 @@ #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) #define MAP_STICKS_TO_NULL (1 << 2) #define MAP_SELECT_BUTTON (1 << 3) +#define MAP_LAYER_BUTTON (1 << 4) #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \MAP_TRIGGERS_TO_BUTTONS |
MAP_STICKS_TO_NULL)drivers/input/joystick/xpad.c +0
-1@@ -131,7 +132,7 @@ static const struct xpad_device { { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE }, { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, - { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", 0,
XTYPE_XBOXONE},
+ {0x045e,0x0b0a, "Microsoft X-Box Adaptive Controller",MAP_LAYER_BUTTON,XTYPE_XBOXONE},
{0x045e,0x0b12, "Microsoft Xbox Series S|X Controller",MAP_SELECT_BUTTON,XTYPE_XBOXONE},
{0x046d,0xc21d, "Logitech Gamepad F310", 0,XTYPE_XBOX360},
{0x046d,0xc21e, "Logitech Gamepad F510", 0,XTYPE_XBOX360},drivers/input/joystick/xpad.c +0
-0@@ -927,6 +928,10 @@ static void xpadone_process_packet(struct
usb_xpad*xpad, u16 cmd, unsigned char
(__u16) le16_to_cpup((__le16 *)(data
+ 8)));
}
+ /* Layer button has a value of 0-4, so it is reported as an axis */
+ if (xpad->mapping&MAP_LAYER_BUTTON)
+ input_report_abs(dev,ABS_MISC, data[34]); +
input_sync(dev);
}drivers/input/joystick/xpad.c +0
-0@@ -1623,6 +1628,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
input_set_abs_params(input_dev, abs, -1, 1, 0, 0); break;
+ caseABS_MISC: /* 4 value layer button (such as on XAC) */ + input_set_abs_params(input_dev, abs, 0, 4, 0, 0); + break;
default:
input_set_abs_params(input_dev, abs, 0, 0, 0, 0); break;drivers/input/joystick/xpad.c +0
-0@@ -1715,6 +1723,10 @@ static int xpad_init_input(struct usb_xpad *xpad) xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); }
+ /* setup layer button as an axis with 4 possible values */ + if (xpad->mapping&MAP_LAYER_BUTTON)
+ xpad_set_up_abs(input_dev,ABS_MISC);
+
error =xpad_init_ff(xpad);
if (error)
gotoerr_free_input;
Re: [PATCH v3 2/3] Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
In reply to Bastien NoceraQuoted 9 lines · Bastien Nocera
Quoted 3 lines · Nate Yocom
Adds a new quirk for controllers that have a Layer button which has 4
states, reflected as anABS_MISCaxis with 4 values.It's called the "Profile Button" in the official documentation:
https://support.xbox.com/en-US/help/account-profile/accessibility/get-to-know-adaptive-controller
so best to call it that.
Quoted 5 lines
I wonder we have any other examples of profile handling in input drivers. The xpadneo driver implements the profiles in the kernel driver directly.
Benjamin?
After speaking to Benjamin, it was clear that ABS_MISC wasn't the right absolute axis to use.
I think that adding a new ABS_* axes in include/uapi/linux/input-event- codes.h would be the best, for example ABS_PROFILE as 0x21.
Dmitry, what do you think?
The idea here is to encode a hardware controlled switch that has 4 possible values. Its state will be sent with every input event in order for user-space to (maybe) apply a specific profile to the events.
This would also be used by the XBox Elite 2 controller driver.
Cheers
Re: [PATCH v3 2/3] Input: joystick: xpad: Add X-Box Adaptive Controller Layer button
Quoted 14 lines · Bastien Nocera
Quoted 13 lines · Bastien Nocera
Quoted 3 lines · Nate Yocom
Adds a new quirk for controllers that have a Layer button which has 4
states, reflected as anABS_MISCaxis with 4 values.It's called the "Profile Button" in the official documentation:
https://support.xbox.com/en-US/help/account-profile/accessibility/get-to-know-adaptive-controller
so best to call it that.I wonder we have any other examples of profile handling in input drivers. The xpadneo driver implements the profiles in the kernel driver directly.
Quoted 7 lines
Quoted 1 line
Benjamin?
After speaking to Benjamin, it was clear that
ABS_MISCwasn't the right absolute axis to use.I think that adding a new ABS_* axes in
include/uapi/linux/input-event-codes.hwould be the best, for exampleABS_PROFILEas0x21.
Makes sense to me.
Quoted 1 line
Dmitry, what do you think?
I'll submit a v5 with ABS_PROFILE defined jic.
Quoted 8 lines
The idea here is to encode a hardware controlled switch that has 4 possible values. Its state will be sent with every input event in order for user-space to (maybe) apply a specific profile to the events.
This would also be used by the XBox Elite 2 controller driver.
Cheers
PATCH v3 3/3 Input: joystick: xpad: Add X-Box Adaptive Controller XBox button
In reply to Nate YocomAdaptive controller sets 0x02 bit for this button, all others set 0x01 so presence of either is used for BTN_MODE.
--- drivers/input/joystick/xpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/joystick/xpad.c +1 -1
@@ -859,7 +859,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned charif (data[1 ] ==0x30 )xpadone_ack_mode_report (xpad, data[2 ]); -input_report_key (dev,BTN_MODE , data[4 ] &0x01 ); +input_report_key (dev,BTN_MODE , data[4 ] &0x03 );input_sync (dev);return ; }
Signature · 1 line
2.30.2
Re: [PATCH v3 3/3] Input: joystick: xpad: Add X-Box Adaptive Controller XBox button
Quoted 5 lines · Nate Yocom
Adaptive controller sets
0x02bit for this button, all others set0x01
so presence of either is used forBTN_MODE.Signed-off-by Nate Yocom <[email protected]>
Quoted 19 lines
---
drivers/input/joystick/xpad.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/joystick/xpad.c +0
-0@@ -859,7 +859,7 @@ static void xpadone_process_packet(struct
usb_xpad*xpad, u16 cmd, unsigned char
if (data[1] ==0x30)xpadone_ack_mode_report(xpad, data[2]);
- input_report_key(dev,BTN_MODE, data[4] &0x01); + input_report_key(dev,BTN_MODE, data[4] &0x03);input_sync(dev);
return;
}