Input: xpad - reduce amount of magic numbers
Subsystems (2)
cover Input: xpad - reduce amount of magic numbers
From: Pavel Rojtberg <[email protected]>
This patchset slightly refactors the code of the xpad driver. These are only renames and no functional changes were made yet.
The first patch introduces the BIT() macro as promised in my last patchset. The second patch introduces GIP_* defines to make the xboxone packets readable.
Pavel Rojtberg (2):
Input: xpad - refactor using BIT() macro
Input: xpad - decipher xpadone packages with GIP defines
drivers/input/joystick/xpad.c | 211 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 86 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 Input: xpad - refactor using BIT() macro
From: Pavel Rojtberg <[email protected]>
reduces the amount of magic numbers and makes the code more readable
--- drivers/input/joystick/xpad.c | 112 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 56 deletions(-)
drivers/input/joystick/xpad.c +56 -56
@@ -709,10 +709,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 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY2 , data[2 ] &0x08 ); -input_report_key (dev,BTN_TRIGGER_HAPPY3 , data[2 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY4 , data[2 ] &0x02 ); +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 )); }else {input_report_abs (dev,ABS_HAT0X , !!(data[2 ] &0x08 ) - !!(data[2 ] &0x04 ));
@@ -721,10 +721,10 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d }/* start/back buttons and stick press left/right */ -input_report_key (dev,BTN_START , data[2 ] &0x10 ); -input_report_key (dev,BTN_SELECT , data[2 ] &0x20 ); -input_report_key (dev,BTN_THUMBL , data[2 ] &0x40 ); -input_report_key (dev,BTN_THUMBR , data[2 ] &0x80 ); +input_report_key (dev,BTN_START , data[2 ] &BIT (4 )); +input_report_key (dev,BTN_SELECT , data[2 ] &BIT (5 )); +input_report_key (dev,BTN_THUMBL , data[2 ] &BIT (6 )); +input_report_key (dev,BTN_THUMBR , data[2 ] &BIT (7 ));/* "analog" buttons A, B, X, Y */ input_report_key (dev,BTN_A , data[4 ]);
@@ -759,10 +759,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 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY2 , data[2 ] &0x08 ); -input_report_key (dev,BTN_TRIGGER_HAPPY3 , data[2 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY4 , data[2 ] &0x02 ); +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 )); }/*
@@ -780,21 +780,21 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev, }/* start/back buttons */ -input_report_key (dev,BTN_START , data[2 ] &0x10 ); -input_report_key (dev,BTN_SELECT , data[2 ] &0x20 ); +input_report_key (dev,BTN_START , data[2 ] &BIT (4 )); +input_report_key (dev,BTN_SELECT , data[2 ] &BIT (5 ));/* stick press left/right */ -input_report_key (dev,BTN_THUMBL , data[2 ] &0x40 ); -input_report_key (dev,BTN_THUMBR , data[2 ] &0x80 ); +input_report_key (dev,BTN_THUMBL , data[2 ] &BIT (6 )); +input_report_key (dev,BTN_THUMBR , data[2 ] &BIT (7 ));/* buttons A,B,X,Y,TL,TR and MODE */ -input_report_key (dev,BTN_A , data[3 ] &0x10 ); -input_report_key (dev,BTN_B , data[3 ] &0x20 ); -input_report_key (dev,BTN_X , data[3 ] &0x40 ); -input_report_key (dev,BTN_Y , data[3 ] &0x80 ); -input_report_key (dev,BTN_TL , data[3 ] &0x01 ); -input_report_key (dev,BTN_TR , data[3 ] &0x02 ); -input_report_key (dev,BTN_MODE , data[3 ] &0x04 ); +input_report_key (dev,BTN_A , data[3 ] &BIT (4 )); +input_report_key (dev,BTN_B , data[3 ] &BIT (5 )); +input_report_key (dev,BTN_X , data[3 ] &BIT (6 )); +input_report_key (dev,BTN_Y , data[3 ] &BIT (7 )); +input_report_key (dev,BTN_TL , data[3 ] &BIT (0 )); +input_report_key (dev,BTN_TR , data[3 ] &BIT (1 )); +input_report_key (dev,BTN_MODE , data[3 ] &BIT (2 ));if (!(xpad->mapping &MAP_STICKS_TO_NULL )) {/* left stick */
@@ -832,7 +832,7 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev, }/* mode button down/up */ -if (data[3 ] &0x04 ) +if (data[3 ] &BIT (2 )) xpad->mode_btn_down_ts =ktime_get_seconds ();else xpad->mode_btn_down_ts =0 ;
@@ -928,7 +928,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned charif (data[1 ] ==0x30 )xpadone_ack_mode_report (xpad, data[2 ]); -input_report_key (dev,BTN_MODE , data[4 ] &0x01 ); +input_report_key (dev,BTN_MODE , data[4 ] &BIT (0 )); do_sync = true; }else if (data[0 ] ==0X0C ) {
@@ -942,33 +942,33 @@ 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 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[18 ] &0x02 ); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[18 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[18 ] &0x08 ); +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 )); do_sync = true; } }else if (data[0 ] ==0X20 ) {/* The main valid packet type for inputs */ /* menu/view buttons */ -input_report_key (dev,BTN_START , data[4 ] &0x04 ); -input_report_key (dev,BTN_SELECT , data[4 ] &0x08 ); +input_report_key (dev,BTN_START , data[4 ] &BIT (2 )); +input_report_key (dev,BTN_SELECT , data[4 ] &BIT (3 ));if (xpad->mapping &MAP_SELECT_BUTTON ) -input_report_key (dev,KEY_RECORD , data[22 ] &0x01 ); +input_report_key (dev,KEY_RECORD , data[22 ] &BIT (0 ));/* buttons A,B,X,Y */ -input_report_key (dev,BTN_A , data[4 ] &0x10 ); -input_report_key (dev,BTN_B , data[4 ] &0x20 ); -input_report_key (dev,BTN_X , data[4 ] &0x40 ); -input_report_key (dev,BTN_Y , data[4 ] &0x80 ); +input_report_key (dev,BTN_A , data[4 ] &BIT (4 )); +input_report_key (dev,BTN_B , data[4 ] &BIT (5 )); +input_report_key (dev,BTN_X , data[4 ] &BIT (6 )); +input_report_key (dev,BTN_Y , data[4 ] &BIT (7 ));/* 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 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY2 , data[5 ] &0x08 ); -input_report_key (dev,BTN_TRIGGER_HAPPY3 , data[5 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY4 , data[5 ] &0x02 ); +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 )); }else {input_report_abs (dev,ABS_HAT0X , !!(data[5 ] &0x08 ) - !!(data[5 ] &0x04 ));
@@ -977,12 +977,12 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char }/* TL/TR */ -input_report_key (dev,BTN_TL , data[5 ] &0x10 ); -input_report_key (dev,BTN_TR , data[5 ] &0x20 ); +input_report_key (dev,BTN_TL , data[5 ] &BIT (4 )); +input_report_key (dev,BTN_TR , data[5 ] &BIT (5 ));/* stick press left/right */ -input_report_key (dev,BTN_THUMBL , data[5 ] &0x40 ); -input_report_key (dev,BTN_THUMBR , data[5 ] &0x80 ); +input_report_key (dev,BTN_THUMBL , data[5 ] &BIT (6 )); +input_report_key (dev,BTN_THUMBR , data[5 ] &BIT (7 ));if (!(xpad->mapping &MAP_STICKS_TO_NULL )) {/* left stick */
@@ -1023,10 +1023,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 ] &0x02 ); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[32 ] &0x08 ); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[32 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[32 ] &0x04 ); +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 )); }else if (xpad->packet_type ==PKT_XBE2_FW_OLD ) {/* Mute paddles if controller has a custom mapping applied. * Checked by comparing the current mapping
@@ -1036,10 +1036,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 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[18 ] &0x02 ); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[18 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[18 ] &0x08 ); +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 )); }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
@@ -1051,10 +1051,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 ] &0x01 ); -input_report_key (dev,BTN_TRIGGER_HAPPY6 , data[22 ] &0x02 ); -input_report_key (dev,BTN_TRIGGER_HAPPY7 , data[22 ] &0x04 ); -input_report_key (dev,BTN_TRIGGER_HAPPY8 , data[22 ] &0x08 ); +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 )); } }
Signature · 1 line
2.34.1
Dmitry Torokhov
maintainerRe: [PATCH 1/2] Input: xpad - refactor using BIT() macro
Quoted 4 lines · Pavel Rojtberg
From: Pavel Rojtberg <[email protected]>
reduces the amount of magic numbers and makes the code more readable
It is nice to include headers defining used APIs directly, so I added "#include <linux/bits.h>" and applied, thank you.
Signature · 1 line
Dmitry
PATCH 2/2 Input: xpad - decipher xpadone packages with GIP defines
In reply to Pavel RojtbergFrom: Pavel Rojtberg <[email protected]>
only renames, no functional changes. Some of the packets we send seem superfluous now. Unfortunately I dont have the hardware to verify whether they are.
--- drivers/input/joystick/xpad.c | 99 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 30 deletions(-)
drivers/input/joystick/xpad.c +69 -30
@@ -513,13 +513,52 @@ struct xboxone_init_packet { .len = ARRAY_SIZE(_data), \ } +/* +* starting with xbox one, the game input protocol is used +* magic numbers are taken from +* - https://github.com/xpadneo/gip-dissector/blob/main/src/gip-dissector.lua +* - https://github.com/medusalix/xone/blob/master/bus/protocol.c +*/ +#define GIP_CMD_ACK 0x01 +#define GIP_CMD_IDENTIFY 0x04 +#define GIP_CMD_POWER 0x05 +#define GIP_CMD_AUTHENTICATE 0x06 +#define GIP_CMD_VIRTUAL_KEY 0x07 +#define GIP_CMD_RUMBLE 0x09 +#define GIP_CMD_LED 0x0a +#define GIP_CMD_FIRMWARE 0x0c +#define GIP_CMD_INPUT 0x20 + +#define GIP_SEQ0 0x00 + +#define GIP_OPT_ACK 0x10 +#define GIP_OPT_INTERNAL 0x20 + +/* +* length of the command payload encoded with +* https://en.wikipedia.org/wiki/LEB128 +* which is a no-op for N < 128 +*/ +#define GIP_PL_LEN (N ) (N) + +/* +* payload specific defines +*/ +#define GIP_PWR_ON 0x00 +#define GIP_LED_ON 0x01 + +#define GIP_MOTOR_R BIT(0) +#define GIP_MOTOR_L BIT(1) +#define GIP_MOTOR_RT BIT(2) +#define GIP_MOTOR_LT BIT(3) +#define GIP_MOTOR_ALL (GIP_MOTOR_R | GIP_MOTOR_L | GIP_MOTOR_RT | GIP_MOTOR_LT)/* * This packet is required for all Xbox One pads with 2015 * or later firmware installed (or present from the factory). */ -static const u8 xboxone_fw2015_init[] = { -0x05 ,0x20 ,0x00 ,0x01 ,0x00 +static const u8 xboxone_power_on[] = { +GIP_CMD_POWER ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,GIP_PL_LEN (1 ),GIP_PWR_ON };/*
@@ -529,7 +568,7 @@ static const u8 xboxone_fw2015_init[] = {* Bluetooth mode. */ static const u8 xboxone_s_init[] = { -0x05 ,0x20 ,0x00 ,0x0f ,0x06 +GIP_CMD_POWER ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,0x0f ,0x06 };/*
@@ -546,9 +585,9 @@ static const u8 extra_input_packet_init[] = {* (0x0e6f:0x0165) to finish initialization and for Hori pads * (0x0f0d:0x0067) to make the analog sticks work. */ -static const u8 xboxone_hori_init[] = { -0x01 ,0x20 ,0x00 ,0x09 ,0x00 ,0x04 ,0x20 ,0x3a , -0x00 ,0x00 ,0x00 ,0x80 ,0x00 +static const u8 xboxone_hori_ack_id[] = { +GIP_CMD_ACK ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,GIP_PL_LEN (9 ), +0x00 ,GIP_CMD_IDENTIFY ,GIP_OPT_INTERNAL ,0x3a ,0x00 ,0x00 ,0x00 ,0x80 ,0x00 };/*
@@ -556,8 +595,8 @@ static const u8 xboxone_hori_init[] = {* sending input reports. These pads include: (0x0e6f:0x02ab), * (0x0e6f:0x02a4), (0x0e6f:0x02a6). */ -static const u8 xboxone_pdp_init1[] = { -0x0a ,0x20 ,0x00 ,0x03 ,0x00 ,0x01 ,0x14 +static const u8 xboxone_pdp_led_on[] = { +GIP_CMD_LED ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,GIP_PL_LEN (3 ),0x00 ,GIP_LED_ON ,0x14 };/*
@@ -565,8 +604,8 @@ static const u8 xboxone_pdp_init1[] = {* sending input reports. These pads include: (0x0e6f:0x02ab), * (0x0e6f:0x02a4), (0x0e6f:0x02a6). */ -static const u8 xboxone_pdp_init2[] = { -0x06 ,0x20 ,0x00 ,0x02 ,0x01 ,0x00 +static const u8 xboxone_pdp_auth[] = { +GIP_CMD_AUTHENTICATE ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,GIP_PL_LEN (2 ),0x01 ,0x00 };/*
@@ -574,8 +613,8 @@ static const u8 xboxone_pdp_init2[] = {* sending input reports. One of those pads is (0x24c6:0x543a). */ static const u8 xboxone_rumblebegin_init[] = { -0x09 ,0x00 ,0x00 ,0x09 ,0x00 ,0x0F ,0x00 ,0x00 , -0x1D ,0x1D ,0xFF ,0x00 ,0x00 +GIP_CMD_RUMBLE ,0x00 ,GIP_SEQ0 ,GIP_PL_LEN (9 ), +0x00 ,GIP_MOTOR_ALL ,0x00 ,0x00 ,0x1D ,0x1D ,0xFF ,0x00 ,0x00 };/*
@@ -585,8 +624,8 @@ static const u8 xboxone_rumblebegin_init[] = {* spin up to enough speed to actually vibrate the gamepad. */ static const u8 xboxone_rumbleend_init[] = { -0x09 ,0x00 ,0x00 ,0x09 ,0x00 ,0x0F ,0x00 ,0x00 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 +GIP_CMD_RUMBLE ,0x00 ,GIP_SEQ0 ,GIP_PL_LEN (9 ), +0x00 ,GIP_MOTOR_ALL ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };/*
@@ -596,14 +635,14 @@ static const u8 xboxone_rumbleend_init[] = {* packet is going to be sent. */ static const struct xboxone_init_packet xboxone_init_packets[] = { -XBOXONE_INIT_PKT (0x0e6f ,0x0165 , xboxone_hori_init), -XBOXONE_INIT_PKT (0x0f0d ,0x0067 , xboxone_hori_init), -XBOXONE_INIT_PKT (0x0000 ,0x0000 , xboxone_fw2015_init), +XBOXONE_INIT_PKT (0x0e6f ,0x0165 , xboxone_hori_ack_id), +XBOXONE_INIT_PKT (0x0f0d ,0x0067 , xboxone_hori_ack_id), +XBOXONE_INIT_PKT (0x0000 ,0x0000 , xboxone_power_on),XBOXONE_INIT_PKT (0x045e ,0x02ea , xboxone_s_init),XBOXONE_INIT_PKT (0x045e ,0x0b00 , xboxone_s_init),XBOXONE_INIT_PKT (0x045e ,0x0b00 , extra_input_packet_init), -XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_init1), -XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_init2), +XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_led_on), +XBOXONE_INIT_PKT (0x0e6f ,0x0000 , xboxone_pdp_auth),XBOXONE_INIT_PKT (0x24c6 ,0x541a , xboxone_rumblebegin_init),XBOXONE_INIT_PKT (0x24c6 ,0x542a , xboxone_rumblebegin_init),XBOXONE_INIT_PKT (0x24c6 ,0x543a , xboxone_rumblebegin_init),
@@ -919,19 +958,19 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned charbool do_sync = false;/* the xbox button has its own special report */ -if (data[0 ] ==0X07 ) { +if (data[0 ] ==GIP_CMD_VIRTUAL_KEY ) {/* * The Xbox One S controller requires these reports to be * acked otherwise it continues sending them forever and * won't report further mode button events. */ -if (data[1 ] ==0x30 ) +if (data[1 ] == (GIP_OPT_ACK |GIP_OPT_INTERNAL ))xpadone_ack_mode_report (xpad, data[2 ]);input_report_key (dev,BTN_MODE , data[4 ] &BIT (0 )); do_sync = true; - }else if (data[0 ] ==0X0C ) { + }else if (data[0 ] ==GIP_CMD_FIRMWARE ) {/* Some packet formats force us to use this separate to poll paddle inputs */ if (xpad->packet_type ==PKT_XBE2_FW_5_11 ) {/* Mute paddles if controller is in a custom profile slot
@@ -949,7 +988,7 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char do_sync = true; } - }else if (data[0 ] ==0X20 ) {/* The main valid packet type for inputs */ + }else if (data[0 ] ==GIP_CMD_INPUT ) {/* The main valid packet type for inputs */ /* menu/view buttons */ input_report_key (dev,BTN_START , data[4 ] &BIT (2 ));input_report_key (dev,BTN_SELECT , data[4 ] &BIT (3 ));
@@ -1362,8 +1401,8 @@ static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num)struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_CMD_IDX ];static const u8 mode_report_ack[] = { -0x01 ,0x20 ,0x00 ,0x09 ,0x00 ,0x07 ,0x20 ,0x02 , -0x00 ,0x00 ,0x00 ,0x00 ,0x00 +GIP_CMD_ACK ,GIP_OPT_INTERNAL ,GIP_SEQ0 ,GIP_PL_LEN (9 ), +0x00 ,GIP_CMD_VIRTUAL_KEY ,GIP_OPT_INTERNAL ,0x02 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };spin_lock_irqsave (&xpad->odata_lock, flags);
@@ -1441,14 +1480,14 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effectbreak ;case XTYPE_XBOXONE : - packet->data[0 ] =0x09 ;/* activate rumble */ + packet->data[0 ] =GIP_CMD_RUMBLE ;/* activate rumble */ packet->data[1 ] =0x00 ; packet->data[2 ] = xpad->odata_serial++; - packet->data[3 ] =0x09 ; + packet->data[3 ] =GIP_PL_LEN (9 ); packet->data[4 ] =0x00 ; - packet->data[5 ] =0x0F ; - packet->data[6 ] =0x00 ; - packet->data[7 ] =0x00 ; + packet->data[5 ] =GIP_MOTOR_ALL ; + packet->data[6 ] =0x00 ;/* left trigger */ + packet->data[7 ] =0x00 ;/* right trigger */ packet->data[8 ] = strong /512 ;/* left actuator */ packet->data[9 ] = weak /512 ;/* right actuator */ packet->data[10 ] =0xFF ;/* on period */
Signature · 1 line
2.34.1
Re: [PATCH 2/2] Input: xpad - decipher xpadone packages with GIP defines
Quoted 7 lines · Pavel Rojtberg
From: Pavel Rojtberg <[email protected]>
only renames, no functional changes. Some of the packets we send seem superfluous now. Unfortunately I dont have the hardware to verify whether they are.
Signed-off-by Pavel Rojtberg <[email protected]>
Applied, thank you.
Signature · 1 line
Dmitry
Am 13.09.22 um 23:31 schrieb Pavel Rojtberg:
Quoted 8 lines
From: Pavel Rojtberg <[email protected]>
This patchset slightly refactors the code of the xpad driver. These are only renames and no functional changes were made yet.
The first patch introduces the
BIT()macro as promised in my last patchset. The second patch introduces GIP_* defines to make the xboxone packets readable.
Quoted 7 lines
Pavel Rojtberg (2):
Input: xpad - refactor usingBIT()macro
Input: xpad - decipher xpadone packages with GIP definesdrivers/input/joystick/xpad.c | 211 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 86 deletions(-)
merge/ rework/ never submit again?
Greetings, Pavel