Input: Add BTN_GRIP*
Subsystems (4)
Vicki Pfau
maintainerv2 cover Input: Add BTN_GRIP*
Many controllers these days have started including grip buttons. As there has been no particular assigned BTN_* constants for these, they've been hapharzardly assigned to BTN_TRIGGER_HAPPY*. Unfortunately, the assignemnt of these has varied significantly between drivers.
This series adds, documents, and uses those buttons in the xpad and hid-steam drivers. The only other driver I was able to find that supports grip buttons was the BPF patch for the Xbox Elite 2 controller. Unfortunately, I'm not sure how to clean that up and add support in HID descriptor parsing, so I'll have to leave that to Benjamin.
Version 2 changes the hid-steam patch to use BTN_GRIPL/BTN_GRIPR for the Steam Controller, not just the Steam Deck. All other patches are unchanged.
Vicki Pfau (3):
Input: Add and document BTN_GRIP*
Input - xpad: Use new BTN_GRIP* buttons
HID: hid-steam: Use new BTN_GRIP* buttons
Documentation/input/gamepad.rst | 13 ++++++++++ drivers/hid/hid-debug.c | 2 ++ drivers/hid/hid-steam.c | 35 ++++++++++++------------- drivers/input/joystick/xpad.c | 36 +++++++++++++------------- include/uapi/linux/input-event-codes.h | 5 ++++ 5 files changed, 54 insertions(+), 37 deletions(-)
Signature · 1 line
2.49.0
Vicki Pfau
maintainerPATCH v2 1/3 Input: Add and document BTN_GRIP*
Many controllers these days have started including grip buttons. As there has been no particular assigned BTN_* constants for these, they've been hapharzardly assigned to BTN_TRIGGER_HAPPY*. Unfortunately, the assignemnt of these has varied significantly between drivers. This patch adds and documents new constants for these grip buttons.
--- Documentation/input/gamepad.rst | 13 +++++++++++++ drivers/hid/hid-debug.c | 2 ++ include/uapi/linux/input-event-codes.h | 5 +++++ 3 files changed, 20 insertions(+)
Documentation/input/gamepad.rst +13 -0
@@ -190,6 +190,19 @@ Gamepads report the following events: Rumble is advertised as FF_RUMBLE. +- Grip buttons: + + Many pads include buttons on the rear, usually referred to as either grip or + rear buttons, or paddles. These are often reprogrammable by the firmware to + appear as "normal" buttons, but are sometimes exposed to software too. Some + notable examples of this are the Steam Deck, which has R4, R5, L4, and L5 on + the back; the Xbox Elite pads, which have P1-P4; and the Switch 2 Pro + Controller, which has GL and GR. + + For these controllers, BTN_GRIPR and BTN_GRIPR2 should be used for the top + and bottom (if present) right grip button(s), and BTN_GRIPL and BTN_GRIPL2 + should be used for the top and bottom (if present) left grip button(s). + - Profile: Some pads provide a multi-value profile selection switch. An example is the
drivers/hid/hid-debug.c +2 -0
@@ -3291,6 +3291,8 @@ static const char *keys[KEY_MAX + 1] = { [BTN_TR2] = "BtnTR2", [BTN_SELECT] = "BtnSelect", [BTN_START] = "BtnStart", [BTN_MODE] = "BtnMode", [BTN_THUMBL] = "BtnThumbL", [BTN_THUMBR] = "BtnThumbR", + [BTN_GRIPL] = "BtnGripL", [BTN_GRIPR] = "BtnGripR", + [BTN_GRIPL2] = "BtnGripL2", [BTN_GRIPR2] = "BtnGripR2", [BTN_TOOL_PEN] = "ToolPen", [BTN_TOOL_RUBBER] = "ToolRubber", [BTN_TOOL_BRUSH] = "ToolBrush", [BTN_TOOL_PENCIL] = "ToolPencil", [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger",
include/uapi/linux/input-event-codes.h +5 -0
@@ -601,6 +601,11 @@#define BTN_DPAD_LEFT 0x222#define BTN_DPAD_RIGHT 0x223 +#define BTN_GRIPL 0x224 +#define BTN_GRIPR 0x225 +#define BTN_GRIPL2 0x226 +#define BTN_GRIPR2 0x227 +#define KEY_ALS_TOGGLE 0x230/* Ambient light sensor */ #define KEY_ROTATE_LOCK_TOGGLE 0x231/* Display rotation lock */ #define KEY_REFRESH_RATE_TOGGLE 0x232/* Display refresh rate toggle */
Signature · 1 line
2.49.0
Vicki Pfau
maintainerPATCH v2 2/3 Input - xpad: Use new BTN_GRIP* buttons
In reply to Vicki Pfau--- drivers/input/joystick/xpad.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/input/joystick/xpad.c +18 -18
@@ -479,8 +479,8 @@ static const signed short xpad_abs_triggers[] = {/* used when the controller has extra paddle buttons */ static const signed short xpad_btn_paddles[] = { -BTN_TRIGGER_HAPPY5 ,BTN_TRIGGER_HAPPY6 ,/* paddle upper right, lower right */ -BTN_TRIGGER_HAPPY7 ,BTN_TRIGGER_HAPPY8 ,/* paddle upper left, lower left */ +BTN_GRIPR ,BTN_GRIPR2 ,/* paddle upper right, lower right */ +BTN_GRIPL ,BTN_GRIPL2 ,/* paddle upper left, lower left */ -1 /* terminating entry */ };
@@ -1075,10 +1075,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char data[18 ] =0 ;/* Elite Series 2 split packet paddle bits */ -input_report_key (dev,BTN_TRIGGER_HAPPY5 , data[18 ] &BIT (0 )); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[18 ] &BIT (1 )); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[18 ] &BIT (2 )); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[18 ] &BIT (3 )); +input_report_key (dev,BTN_GRIPR , data[18 ] &BIT (0 )); +input_report_key (dev,BTN_GRIPR2 , data[18 ] &BIT (1 )); +input_report_key (dev,BTN_GRIPL , data[18 ] &BIT (2 )); +input_report_key (dev,BTN_GRIPL2 , data[18 ] &BIT (3 )); do_sync = true; }
@@ -1175,10 +1175,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char data[32 ] =0 ;/* OG Elite Series Controller paddle bits */ -input_report_key (dev,BTN_TRIGGER_HAPPY5 , data[32 ] &BIT (1 )); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[32 ] &BIT (3 )); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[32 ] &BIT (0 )); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[32 ] &BIT (2 )); +input_report_key (dev,BTN_GRIPR , data[32 ] &BIT (1 )); +input_report_key (dev,BTN_GRIPR2 , data[32 ] &BIT (3 )); +input_report_key (dev,BTN_GRIPL , data[32 ] &BIT (0 )); +input_report_key (dev,BTN_GRIPL2 , data[32 ] &BIT (2 )); }else if (xpad->packet_type ==PKT_XBE2_FW_OLD ) {/* Mute paddles if controller has a custom mapping applied. * Checked by comparing the current mapping
@@ -1188,10 +1188,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char data[18 ] =0 ;/* Elite Series 2 4.x firmware paddle bits */ -input_report_key (dev,BTN_TRIGGER_HAPPY5 , data[18 ] &BIT (0 )); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[18 ] &BIT (1 )); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[18 ] &BIT (2 )); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[18 ] &BIT (3 )); +input_report_key (dev,BTN_GRIPR , data[18 ] &BIT (0 )); +input_report_key (dev,BTN_GRIPR2 , data[18 ] &BIT (1 )); +input_report_key (dev,BTN_GRIPL , data[18 ] &BIT (2 )); +input_report_key (dev,BTN_GRIPL2 , data[18 ] &BIT (3 )); }else if (xpad->packet_type ==PKT_XBE2_FW_5_EARLY ) {/* Mute paddles if controller has a custom mapping applied. * Checked by comparing the current mapping
@@ -1203,10 +1203,10 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char/* Elite Series 2 5.x firmware paddle bits * (before the packet was split) */ -input_report_key (dev,BTN_TRIGGER_HAPPY5 , data[22 ] &BIT (0 )); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[22 ] &BIT (1 )); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[22 ] &BIT (2 )); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[22 ] &BIT (3 )); +input_report_key (dev,BTN_GRIPR , data[22 ] &BIT (0 )); +input_report_key (dev,BTN_GRIPR2 , data[22 ] &BIT (1 )); +input_report_key (dev,BTN_GRIPL , data[22 ] &BIT (2 )); +input_report_key (dev,BTN_GRIPL2 , data[22 ] &BIT (3 )); } }
Signature · 1 line
2.49.0
Re: [PATCH v2 2/3] Input - xpad: Use new BTN_GRIP* buttons
Quoted 1 line · Vicki Pfau
Signed-off-by Vicki Pfau <[email protected]>
Applied, thank you.
Signature · 1 line
Dmitry
Vicki Pfau
maintainerPATCH v2 3/3 HID: hid-steam: Use new BTN_GRIP* buttons
In reply to Vicki Pfau--- drivers/hid/hid-steam.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
drivers/hid/hid-steam.c +16 -19
@@ -755,15 +755,12 @@ static int steam_input_register(struct steam_device *steam)input_set_capability (input,EV_KEY ,BTN_THUMBL );input_set_capability (input,EV_KEY ,BTN_THUMB );input_set_capability (input,EV_KEY ,BTN_THUMB2 ); +input_set_capability (input,EV_KEY ,BTN_GRIPL ); +input_set_capability (input,EV_KEY ,BTN_GRIPR );if (steam->quirks &STEAM_QUIRK_DECK ) {input_set_capability (input,EV_KEY ,BTN_BASE ); -input_set_capability (input,EV_KEY ,BTN_TRIGGER_HAPPY1 ); -input_set_capability (input,EV_KEY ,BTN_TRIGGER_HAPPY2 ); -input_set_capability (input,EV_KEY ,BTN_TRIGGER_HAPPY3 ); -input_set_capability (input,EV_KEY ,BTN_TRIGGER_HAPPY4 ); - }else { -input_set_capability (input,EV_KEY ,BTN_GEAR_DOWN ); -input_set_capability (input,EV_KEY ,BTN_GEAR_UP ); +input_set_capability (input,EV_KEY ,BTN_GRIPL2 ); +input_set_capability (input,EV_KEY ,BTN_GRIPR2 ); }input_set_abs_params (input,ABS_X ,-32767 ,32767 ,0 ,0 );
@@ -1419,8 +1416,8 @@ static inline s16 steam_le16(u8 *data)* 9.4 | BTN_SELECT | menu left * 9.5 | BTN_MODE | steam logo * 9.6 | BTN_START | menu right -* 9.7 | BTN_GEAR_DOWN | left back lever -* 10.0 | BTN_GEAR_UP | right back lever +* 9.7 | BTN_GRIPL | left back lever +* 10.0 | BTN_GRIPR | right back lever * 10.1 | -- | left-pad clicked * 10.2 | BTN_THUMBR | right-pad clicked * 10.3 | BTN_THUMB | left-pad touched (but see explanation below)
@@ -1485,8 +1482,8 @@ static void steam_do_input_event(struct steam_device *steam,input_event (input,EV_KEY ,BTN_SELECT , !!(b9 &BIT (4 )));input_event (input,EV_KEY ,BTN_MODE , !!(b9 &BIT (5 )));input_event (input,EV_KEY ,BTN_START , !!(b9 &BIT (6 ))); -input_event (input,EV_KEY ,BTN_GEAR_DOWN , !!(b9 &BIT (7 ))); -input_event (input,EV_KEY ,BTN_GEAR_UP , !!(b10 &BIT (0 ))); +input_event (input,EV_KEY ,BTN_GRIPL , !!(b9 &BIT (7 ))); +input_event (input,EV_KEY ,BTN_GRIPR , !!(b10 &BIT (0 )));input_event (input,EV_KEY ,BTN_THUMBR , !!(b10 &BIT (2 )));input_event (input,EV_KEY ,BTN_THUMBL , !!(b10 &BIT (6 )));input_event (input,EV_KEY ,BTN_THUMB , lpad_touched || lpad_and_joy);
@@ -1547,8 +1544,8 @@ static void steam_do_input_event(struct steam_device *steam,* 9.4 | BTN_SELECT | menu left * 9.5 | BTN_MODE | steam logo * 9.6 | BTN_START | menu right -* 9.7 | BTN_TRIGGER_HAPPY3 | left bottom grip button -* 10.0 | BTN_TRIGGER_HAPPY4 | right bottom grip button +* 9.7 | BTN_GRIPL2 | left bottom grip button +* 10.0 | BTN_GRIPR2 | right bottom grip button * 10.1 | BTN_THUMB | left pad pressed * 10.2 | BTN_THUMB2 | right pad pressed * 10.3 | -- | left pad touched
@@ -1573,8 +1570,8 @@ static void steam_do_input_event(struct steam_device *steam,* 12.6 | -- | unknown * 12.7 | -- | unknown * 13.0 | -- | unknown -* 13.1 | BTN_TRIGGER_HAPPY1 | left top grip button -* 13.2 | BTN_TRIGGER_HAPPY2 | right top grip button +* 13.1 | BTN_GRIPL | left top grip button +* 13.2 | BTN_GRIPR | right top grip button * 13.3 | -- | unknown * 13.4 | -- | unknown * 13.5 | -- | unknown
@@ -1659,8 +1656,8 @@ static void steam_do_deck_input_event(struct steam_device *steam,input_event (input,EV_KEY ,BTN_SELECT , !!(b9 &BIT (4 )));input_event (input,EV_KEY ,BTN_MODE , !!(b9 &BIT (5 )));input_event (input,EV_KEY ,BTN_START , !!(b9 &BIT (6 ))); -input_event (input,EV_KEY ,BTN_TRIGGER_HAPPY3 , !!(b9 &BIT (7 ))); -input_event (input,EV_KEY ,BTN_TRIGGER_HAPPY4 , !!(b10 &BIT (0 ))); +input_event (input,EV_KEY ,BTN_GRIPL2 , !!(b9 &BIT (7 ))); +input_event (input,EV_KEY ,BTN_GRIPR2 , !!(b10 &BIT (0 )));input_event (input,EV_KEY ,BTN_THUMBL , !!(b10 &BIT (6 )));input_event (input,EV_KEY ,BTN_THUMBR , !!(b11 &BIT (2 )));input_event (input,EV_KEY ,BTN_DPAD_UP , !!(b9 &BIT (0 )));
@@ -1669,8 +1666,8 @@ static void steam_do_deck_input_event(struct steam_device *steam,input_event (input,EV_KEY ,BTN_DPAD_DOWN , !!(b9 &BIT (3 )));input_event (input,EV_KEY ,BTN_THUMB , !!(b10 &BIT (1 )));input_event (input,EV_KEY ,BTN_THUMB2 , !!(b10 &BIT (2 ))); -input_event (input,EV_KEY ,BTN_TRIGGER_HAPPY1 , !!(b13 &BIT (1 ))); -input_event (input,EV_KEY ,BTN_TRIGGER_HAPPY2 , !!(b13 &BIT (2 ))); +input_event (input,EV_KEY ,BTN_GRIPL , !!(b13 &BIT (1 ))); +input_event (input,EV_KEY ,BTN_GRIPR , !!(b13 &BIT (2 )));input_event (input,EV_KEY ,BTN_BASE , !!(b14 &BIT (2 )));input_sync (input);
Signature · 1 line
2.49.0
Re: [PATCH v2 3/3] HID: hid-steam: Use new BTN_GRIP* buttons
Quoted 1 line · Vicki Pfau
Signed-off-by Vicki Pfau <[email protected]>
Dmitry,
with
can you please take it with the generic and xpad patch through your tree, to avoid cross-tree dependency?
Thanks!
Signature · 2 lines
Jiri Kosina SUSE Labs