Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: xpad - change buttons the D-Pad gets mapped as to BTN_DPAD_*

Since dance pads can have both up/down or left/right pressed at the same time,
by design, they are not suitable for mapping the buttons to axes. Historically,
this driver mapped the D-pad to BTN_TRIGGER_HAPPY1-4 in these cases, and before
that as mouse buttons. However, BTN_DPAD_* exists for this and makes far more
sense than the arbitrary mapping it was before.

Signed-off-by: Vicki Pfau <vi@endrift.com>
Link: https://lore.kernel.org/r/20250702034740.124817-1-vi@endrift.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Vicki Pfau and committed by
Dmitry Torokhov
a43a503d 3b19c9ed

+14 -14
+14 -14
drivers/input/joystick/xpad.c
··· 438 438 439 439 /* used when dpad is mapped to buttons */ 440 440 static const signed short xpad_btn_pad[] = { 441 - BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */ 442 - BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */ 441 + BTN_DPAD_LEFT, BTN_DPAD_RIGHT, /* d-pad left, right */ 442 + BTN_DPAD_UP, BTN_DPAD_DOWN, /* d-pad up, down */ 443 443 -1 /* terminating entry */ 444 444 }; 445 445 ··· 835 835 /* digital pad */ 836 836 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 837 837 /* dpad as buttons (left, right, up, down) */ 838 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); 839 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); 840 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); 841 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); 838 + input_report_key(dev, BTN_DPAD_LEFT, data[2] & BIT(2)); 839 + input_report_key(dev, BTN_DPAD_RIGHT, data[2] & BIT(3)); 840 + input_report_key(dev, BTN_DPAD_UP, data[2] & BIT(0)); 841 + input_report_key(dev, BTN_DPAD_DOWN, data[2] & BIT(1)); 842 842 } else { 843 843 input_report_abs(dev, ABS_HAT0X, 844 844 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 886 886 /* digital pad */ 887 887 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 888 888 /* dpad as buttons (left, right, up, down) */ 889 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); 890 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); 891 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); 892 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); 889 + input_report_key(dev, BTN_DPAD_LEFT, data[2] & BIT(2)); 890 + input_report_key(dev, BTN_DPAD_RIGHT, data[2] & BIT(3)); 891 + input_report_key(dev, BTN_DPAD_UP, data[2] & BIT(0)); 892 + input_report_key(dev, BTN_DPAD_DOWN, data[2] & BIT(1)); 893 893 } 894 894 895 895 /* ··· 1108 1108 /* digital pad */ 1109 1109 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 1110 1110 /* dpad as buttons (left, right, up, down) */ 1111 - input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & BIT(2)); 1112 - input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & BIT(3)); 1113 - input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & BIT(0)); 1114 - input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & BIT(1)); 1111 + input_report_key(dev, BTN_DPAD_LEFT, data[5] & BIT(2)); 1112 + input_report_key(dev, BTN_DPAD_RIGHT, data[5] & BIT(3)); 1113 + input_report_key(dev, BTN_DPAD_UP, data[5] & BIT(0)); 1114 + input_report_key(dev, BTN_DPAD_DOWN, data[5] & BIT(1)); 1115 1115 } else { 1116 1116 input_report_abs(dev, ABS_HAT0X, 1117 1117 !!(data[5] & 0x08) - !!(data[5] & 0x04));