Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: xpad - Poweroff XBOX360W on mode button long press

Newer gamepads turn themselves off when the mode button is held down.
For XBOX360W gamepads we must do this in the driver.

Do not use BIT() macro for consistency within the file.

Signed-off-by: Santosh De Massari <s.demassari@gmail.com>
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Link: https://lore.kernel.org/r/20220818154411.510308-4-rojtberg@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Santosh De Massari and committed by
Dmitry Torokhov
da7e2128 a17b9841

+24
+24
drivers/input/joystick/xpad.c
··· 89 89 #define XTYPE_XBOXONE 3 90 90 #define XTYPE_UNKNOWN 4 91 91 92 + /* Send power-off packet to xpad360w after holding the mode button for this many 93 + * seconds 94 + */ 95 + #define XPAD360W_POWEROFF_TIMEOUT 5 96 + 92 97 static bool dpad_to_buttons; 93 98 module_param(dpad_to_buttons, bool, S_IRUGO); 94 99 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); ··· 635 630 int pad_nr; /* the order x360 pads were attached */ 636 631 const char *name; /* name of the device */ 637 632 struct work_struct work; /* init/remove device from callback */ 633 + time64_t mode_btn_down_ts; 638 634 }; 639 635 640 636 static int xpad_init_input(struct usb_xpad *xpad); 641 637 static void xpad_deinit_input(struct usb_xpad *xpad); 642 638 static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); 639 + static void xpad360w_poweroff_controller(struct usb_xpad *xpad); 643 640 644 641 /* 645 642 * xpad_process_packet ··· 793 786 } 794 787 795 788 input_sync(dev); 789 + 790 + /* XBOX360W controllers can't be turned off without driver assistance */ 791 + if (xpad->xtype == XTYPE_XBOX360W) { 792 + if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && 793 + ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= 794 + XPAD360W_POWEROFF_TIMEOUT)) { 795 + xpad360w_poweroff_controller(xpad); 796 + xpad->mode_btn_down_ts = 0; 797 + return; 798 + } 799 + 800 + /* mode button down/up */ 801 + if (data[3] & 0x04) 802 + xpad->mode_btn_down_ts = ktime_get_seconds(); 803 + else 804 + xpad->mode_btn_down_ts = 0; 805 + } 796 806 } 797 807 798 808 static void xpad_presence_work(struct work_struct *work)