-
-
Save lawl/cd21cd92ae05483456be83522f92ad30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/xpad.c b/xpad.c | |
index ed90ca4..0ba7303 100644 | |
--- a/xpad.c | |
+++ b/xpad.c | |
@@ -613,11 +613,13 @@ struct usb_xpad { | |
int pad_nr; /* the order x360 pads were attached */ | |
const char *name; /* name of the device */ | |
struct work_struct work; /* init/remove device from callback */ | |
+ time64_t mode_btn_down_ts; | |
}; | |
static int xpad_init_input(struct usb_xpad *xpad); | |
static void xpad_deinit_input(struct usb_xpad *xpad); | |
static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); | |
+static void xpad360w_poweroff_controller(struct usb_xpad *xpad); | |
/* | |
* xpad_process_packet | |
@@ -769,6 +771,23 @@ static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev, | |
} | |
input_sync(dev); | |
+ | |
+ /* XBOX360W controllers can't be turned off without driver assistance */ | |
+ if (xpad->xtype == XTYPE_XBOX360W) { | |
+ if (xpad->mode_btn_down_ts > 0 && | |
+ xpad->pad_present && | |
+ (ktime_get_seconds() - xpad->mode_btn_down_ts) >= 5) { | |
+ xpad360w_poweroff_controller(xpad); | |
+ xpad->mode_btn_down_ts = 0; | |
+ return; | |
+ } | |
+ | |
+ /* mode button down/up */ | |
+ if (data[3] & 0x04) | |
+ xpad->mode_btn_down_ts = ktime_get_seconds(); | |
+ else | |
+ xpad->mode_btn_down_ts = 0; | |
+ } | |
} | |
static void xpad_presence_work(struct work_struct *work) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment