Skip to content

Commit a43a503

Browse files
endriftdtor
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 3b19c9e commit a43a503

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/input/joystick/xpad.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ static const signed short xpad_btn[] = {
438438

439439
/* used when dpad is mapped to buttons */
440440
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 */
443443
-1 /* terminating entry */
444444
};
445445

@@ -835,10 +835,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
835835
/* digital pad */
836836
if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
837837
/* 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));
842842
} else {
843843
input_report_abs(dev, ABS_HAT0X,
844844
!!(data[2] & 0x08) - !!(data[2] & 0x04));
@@ -886,10 +886,10 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,
886886
/* digital pad */
887887
if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
888888
/* 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));
893893
}
894894

895895
/*
@@ -1108,10 +1108,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
11081108
/* digital pad */
11091109
if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
11101110
/* 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));
11151115
} else {
11161116
input_report_abs(dev, ABS_HAT0X,
11171117
!!(data[5] & 0x08) - !!(data[5] & 0x04));

0 commit comments

Comments
 (0)