* [PATCH] Input: joystick: xpad: Add X-Box Adaptive Controller support
@ 2022-08-10 0:20 Nate Yocom
2022-08-10 6:08 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Nate Yocom @ 2022-08-10 0:20 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel, nate
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
Signed-off-by: Nate Yocom <nate@yocom.org>
---
drivers/input/joystick/xpad.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 18190b529bca..0d02d88790b6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -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,6 +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", 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 },
@@ -857,7 +859,17 @@ 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);
+ /*
+ * X-Box Adaptive controller sets 0x02 when x-box button is pressed,
+ * we could probably condense into just data[4] != 0, but explicitly
+ * checking here ensures no regression if other devices set other bits.
+ */
+ if (le16_to_cpu(xpad->dev->id.vendor) == 0x045e &&
+ le16_to_cpu(xpad->dev->id.product) == 0x0b0a)
+ input_report_key(dev, BTN_MODE, data[4] & 0x02);
+ else
+ input_report_key(dev, BTN_MODE, data[4] & 0x01);
+
input_sync(dev);
return;
}
@@ -926,6 +938,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 its reported as an axis */
+ if (xpad->mapping & MAP_LAYER_BUTTON)
+ input_report_abs(dev, ABS_MISC, data[34]);
+
input_sync(dev);
}
@@ -1622,6 +1638,8 @@ 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 the XAC) */
+ input_set_abs_params(input_dev, abs, 0, 4, 0, 0);
default:
input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
break;
@@ -1714,6 +1732,10 @@ static int xpad_init_input(struct usb_xpad *xpad)
xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
}
+ /* setup layer buton 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;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: joystick: xpad: Add X-Box Adaptive Controller support
2022-08-10 0:20 [PATCH] Input: joystick: xpad: Add X-Box Adaptive Controller support Nate Yocom
@ 2022-08-10 6:08 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-08-10 6:08 UTC (permalink / raw)
To: Nate Yocom, dmitry.torokhov
Cc: llvm, kbuild-all, linux-input, linux-kernel, nate
Hi Nate,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on hid/for-next linus/master v5.19 next-20220810]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nate-Yocom/Input-joystick-xpad-Add-X-Box-Adaptive-Controller-support/20220810-082302
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-a016 (https://download.01.org/0day-ci/archive/20220810/202208101406.tS1Uz1FD-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/4c3757fab74082cf845405ba8d8b2d60e06572cd
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nate-Yocom/Input-joystick-xpad-Add-X-Box-Adaptive-Controller-support/20220810-082302
git checkout 4c3757fab74082cf845405ba8d8b2d60e06572cd
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/entry/ drivers/input/joystick/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/input/joystick/xpad.c:1643:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
default:
^
drivers/input/joystick/xpad.c:1643:2: note: insert '__attribute__((fallthrough));' to silence this warning
default:
^
__attribute__((fallthrough));
drivers/input/joystick/xpad.c:1643:2: note: insert 'break;' to avoid fall-through
default:
^
break;
1 warning generated.
vim +1643 drivers/input/joystick/xpad.c
^1da177e4c3f41 drivers/usb/input/xpad.c Linus Torvalds 2005-04-16 1618
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1619 static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1620 {
1a48ff81b3912b drivers/input/joystick/xpad.c Ted Mielczarek 2014-08-08 1621 struct usb_xpad *xpad = input_get_drvdata(input_dev);
68c78d0155e379 drivers/input/joystick/xpad.c Leo Sperling 2016-08-03 1622
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1623 switch (abs) {
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1624 case ABS_X:
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1625 case ABS_Y:
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1626 case ABS_RX:
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1627 case ABS_RY: /* the two sticks */
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1628 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1629 break;
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1630 case ABS_Z:
b45d44e7e00c17 drivers/input/joystick/xpad.c Nicolas Léveillé 2009-12-29 1631 case ABS_RZ: /* the triggers (if mapped to axes) */
1a48ff81b3912b drivers/input/joystick/xpad.c Ted Mielczarek 2014-08-08 1632 if (xpad->xtype == XTYPE_XBOXONE)
1a48ff81b3912b drivers/input/joystick/xpad.c Ted Mielczarek 2014-08-08 1633 input_set_abs_params(input_dev, abs, 0, 1023, 0, 0);
1a48ff81b3912b drivers/input/joystick/xpad.c Ted Mielczarek 2014-08-08 1634 else
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1635 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1636 break;
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1637 case ABS_HAT0X:
b45d44e7e00c17 drivers/input/joystick/xpad.c Nicolas Léveillé 2009-12-29 1638 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1639 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1640 break;
4c3757fab74082 drivers/input/joystick/xpad.c Nate Yocom 2022-08-09 1641 case ABS_MISC: /* 4 value layer button (such as on the XAC) */
4c3757fab74082 drivers/input/joystick/xpad.c Nate Yocom 2022-08-09 1642 input_set_abs_params(input_dev, abs, 0, 4, 0, 0);
a01308031c2647 drivers/input/joystick/xpad.c Marcus Folkesson 2018-05-08 @1643 default:
a01308031c2647 drivers/input/joystick/xpad.c Marcus Folkesson 2018-05-08 1644 input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
a01308031c2647 drivers/input/joystick/xpad.c Marcus Folkesson 2018-05-08 1645 break;
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1646 }
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1647 }
deb8ee43a23d48 drivers/usb/input/xpad.c Dominic Cerquetti 2006-10-10 1648
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-10 6:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10 0:20 [PATCH] Input: joystick: xpad: Add X-Box Adaptive Controller support Nate Yocom
2022-08-10 6:08 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.