Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a8b3b5d

Browse files
Terry Trittonlag-google
authored andcommitted
FROMLIST: input: fix generic desktop D-Pad controls
The addition of the "System Do Not Disturb" event code caused the Generic Desktop D-Pad configuration to be skipped. This commit allows both to be configured without conflicting with each other. Fixes: 22d6d06 ("input: Add support for "Do Not Disturb"") Signed-off-by: Terry Tritton <[email protected]> Reviewed-by: Aseda Aboagye <[email protected]> Bug: 372138922 Link: https://lore.kernel.org/all/[email protected]/ Change-Id: I9e3de9508b2e2aa68283de30478f1f8c8e25a166 Signed-off-by: Carlos Llamas <[email protected]>
1 parent 931594b commit a8b3b5d

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

drivers/hid/hid-input.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,23 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
810810
break;
811811
}
812812

813-
if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
814-
switch (usage->hid & 0xf) {
815-
case 0xb: map_key_clear(KEY_DO_NOT_DISTURB); break;
816-
default: goto ignore;
813+
if ((usage->hid & 0xf0) == 0x90) { /* SystemControl & D-pad */
814+
switch (usage->hid) {
815+
case HID_GD_UP: usage->hat_dir = 1; break;
816+
case HID_GD_DOWN: usage->hat_dir = 5; break;
817+
case HID_GD_RIGHT: usage->hat_dir = 3; break;
818+
case HID_GD_LEFT: usage->hat_dir = 7; break;
819+
case HID_GD_DO_NOT_DISTURB:
820+
map_key_clear(KEY_DO_NOT_DISTURB); break;
821+
default: goto unknown;
822+
}
823+
824+
if (usage->hid <= HID_GD_LEFT) {
825+
if (field->dpad) {
826+
map_abs(field->dpad);
827+
goto ignore;
828+
}
829+
map_abs(ABS_HAT0X);
817830
}
818831
break;
819832
}
@@ -844,22 +857,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
844857
if (field->application == HID_GD_SYSTEM_CONTROL)
845858
goto ignore;
846859

847-
if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
848-
switch (usage->hid) {
849-
case HID_GD_UP: usage->hat_dir = 1; break;
850-
case HID_GD_DOWN: usage->hat_dir = 5; break;
851-
case HID_GD_RIGHT: usage->hat_dir = 3; break;
852-
case HID_GD_LEFT: usage->hat_dir = 7; break;
853-
default: goto unknown;
854-
}
855-
if (field->dpad) {
856-
map_abs(field->dpad);
857-
goto ignore;
858-
}
859-
map_abs(ABS_HAT0X);
860-
break;
861-
}
862-
863860
switch (usage->hid) {
864861
/* These usage IDs map directly to the usage codes. */
865862
case HID_GD_X: case HID_GD_Y: case HID_GD_Z:

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ struct hid_item {
219219
#define HID_GD_DOWN 0x00010091
220220
#define HID_GD_RIGHT 0x00010092
221221
#define HID_GD_LEFT 0x00010093
222+
#define HID_GD_DO_NOT_DISTURB 0x0001009b
222223
/* Microsoft Win8 Wireless Radio Controls CA usage codes */
223224
#define HID_GD_RFKILL_BTN 0x000100c6
224225
#define HID_GD_RFKILL_LED 0x000100c7

0 commit comments

Comments
 (0)