]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: xpad - change buttons the D-Pad gets mapped as to BTN_DPAD_*
authorVicki Pfau <vi@endrift.com>
Sun, 27 Jul 2025 08:13:42 +0000 (01:13 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 27 Jul 2025 08:41:19 +0000 (01:41 -0700)
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>
drivers/input/joystick/xpad.c

index 7746530da0306172f537016b956c19c819b9aa65..5e84e2be34a68b207b8cbf5e96fc446e4ad54b28 100644 (file)
@@ -438,8 +438,8 @@ static const signed short xpad_btn[] = {
 
 /* used when dpad is mapped to buttons */
 static const signed short xpad_btn_pad[] = {
-       BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2,         /* d-pad left, right */
-       BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4,         /* d-pad up, down */
+       BTN_DPAD_LEFT, BTN_DPAD_RIGHT,  /* d-pad left, right */
+       BTN_DPAD_UP, BTN_DPAD_DOWN,     /* d-pad up, down */
        -1                              /* terminating entry */
 };
 
@@ -835,10 +835,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
        /* digital pad */
        if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
                /* dpad as buttons (left, right, up, down) */
-               input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2));
-               input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3));
-               input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0));
-               input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1));
+               input_report_key(dev, BTN_DPAD_LEFT, data[2] & BIT(2));
+               input_report_key(dev, BTN_DPAD_RIGHT, data[2] & BIT(3));
+               input_report_key(dev, BTN_DPAD_UP, data[2] & BIT(0));
+               input_report_key(dev, BTN_DPAD_DOWN, data[2] & BIT(1));
        } else {
                input_report_abs(dev, ABS_HAT0X,
                                 !!(data[2] & 0x08) - !!(data[2] & 0x04));
@@ -886,10 +886,10 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
        /* digital pad */
        if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
                /* dpad as buttons (left, right, up, down) */
-               input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2));
-               input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3));
-               input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0));
-               input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1));
+               input_report_key(dev, BTN_DPAD_LEFT, data[2] & BIT(2));
+               input_report_key(dev, BTN_DPAD_RIGHT, data[2] & BIT(3));
+               input_report_key(dev, BTN_DPAD_UP, data[2] & BIT(0));
+               input_report_key(dev, BTN_DPAD_DOWN, data[2] & BIT(1));
        }
 
        /*
@@ -1108,10 +1108,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
                /* digital pad */
                if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
                        /* dpad as buttons (left, right, up, down) */
-                       input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & BIT(2));
-                       input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & BIT(3));
-                       input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & BIT(0));
-                       input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & BIT(1));
+                       input_report_key(dev, BTN_DPAD_LEFT, data[5] & BIT(2));
+                       input_report_key(dev, BTN_DPAD_RIGHT, data[5] & BIT(3));
+                       input_report_key(dev, BTN_DPAD_UP, data[5] & BIT(0));
+                       input_report_key(dev, BTN_DPAD_DOWN, data[5] & BIT(1));
                } else {
                        input_report_abs(dev, ABS_HAT0X,
                                        !!(data[5] & 0x08) - !!(data[5] & 0x04));