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

Input: xpad - query wireless controller state at init

When we initialize the driver/device, we really don't know how many
controllers are connected. So send a "query presence" command to the
base-station. (Command discovered by Zachary Lund)

Presence packet taken from:

https://github.com/computerquip/xpad5

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Pavel Rojtberg and committed by
Dmitry Torokhov
aba54876 b8154002

+40
+40
drivers/input/joystick/xpad.c
··· 768 768 } 769 769 } 770 770 771 + static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) 772 + { 773 + int retval; 774 + 775 + mutex_lock(&xpad->odata_mutex); 776 + 777 + xpad->odata[0] = 0x08; 778 + xpad->odata[1] = 0x00; 779 + xpad->odata[2] = 0x0F; 780 + xpad->odata[3] = 0xC0; 781 + xpad->odata[4] = 0x00; 782 + xpad->odata[5] = 0x00; 783 + xpad->odata[6] = 0x00; 784 + xpad->odata[7] = 0x00; 785 + xpad->odata[8] = 0x00; 786 + xpad->odata[9] = 0x00; 787 + xpad->odata[10] = 0x00; 788 + xpad->odata[11] = 0x00; 789 + xpad->irq_out->transfer_buffer_length = 12; 790 + 791 + retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL); 792 + 793 + mutex_unlock(&xpad->odata_mutex); 794 + 795 + return retval; 796 + } 797 + 771 798 #ifdef CONFIG_JOYSTICK_XPAD_FF 772 799 static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) 773 800 { ··· 1286 1259 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); 1287 1260 if (error) 1288 1261 goto err_deinit_input; 1262 + 1263 + /* 1264 + * Send presence packet. 1265 + * This will force the controller to resend connection packets. 1266 + * This is useful in the case we activate the module after the 1267 + * adapter has been plugged in, as it won't automatically 1268 + * send us info about the controllers. 1269 + */ 1270 + error = xpad_inquiry_pad_presence(xpad); 1271 + if (error) 1272 + goto err_kill_in_urb; 1289 1273 } 1290 1274 return 0; 1291 1275 1276 + err_kill_in_urb: 1277 + usb_kill_urb(xpad->irq_in); 1292 1278 err_deinit_input: 1293 1279 xpad_deinit_input(xpad); 1294 1280 err_deinit_output: