mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
Input: xpad - re-send LED command on present event
The controller only receives commands when its present. So for the correct LED to be lit the LED command has to be sent on the present event. Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
75b7f05d27
commit
cae705baa4
@ -344,6 +344,7 @@ struct usb_xpad {
|
|||||||
|
|
||||||
int mapping; /* map d-pad to buttons or to axes */
|
int mapping; /* map d-pad to buttons or to axes */
|
||||||
int xtype; /* type of xbox device */
|
int xtype; /* type of xbox device */
|
||||||
|
unsigned long led_no; /* led to lit on xbox360 controllers */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -488,6 +489,8 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
|
|||||||
input_sync(dev);
|
input_sync(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xpad_identify_controller(struct usb_xpad *xpad);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xpad360w_process_packet
|
* xpad360w_process_packet
|
||||||
*
|
*
|
||||||
@ -510,6 +513,11 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
|
|||||||
if (data[1] & 0x80) {
|
if (data[1] & 0x80) {
|
||||||
xpad->pad_present = 1;
|
xpad->pad_present = 1;
|
||||||
usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
|
usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
|
||||||
|
/*
|
||||||
|
* Light up the segment corresponding to
|
||||||
|
* controller number.
|
||||||
|
*/
|
||||||
|
xpad_identify_controller(xpad);
|
||||||
} else
|
} else
|
||||||
xpad->pad_present = 0;
|
xpad->pad_present = 0;
|
||||||
}
|
}
|
||||||
@ -934,6 +942,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
|
|||||||
mutex_unlock(&xpad->odata_mutex);
|
mutex_unlock(&xpad->odata_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xpad_identify_controller(struct usb_xpad *xpad)
|
||||||
|
{
|
||||||
|
/* Light up the segment corresponding to controller number */
|
||||||
|
xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
|
||||||
|
}
|
||||||
|
|
||||||
static void xpad_led_set(struct led_classdev *led_cdev,
|
static void xpad_led_set(struct led_classdev *led_cdev,
|
||||||
enum led_brightness value)
|
enum led_brightness value)
|
||||||
{
|
{
|
||||||
@ -945,8 +959,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
|
|||||||
|
|
||||||
static int xpad_led_probe(struct usb_xpad *xpad)
|
static int xpad_led_probe(struct usb_xpad *xpad)
|
||||||
{
|
{
|
||||||
static atomic_t led_seq = ATOMIC_INIT(-1);
|
static atomic_t led_seq = ATOMIC_INIT(-1);
|
||||||
unsigned long led_no;
|
|
||||||
struct xpad_led *led;
|
struct xpad_led *led;
|
||||||
struct led_classdev *led_cdev;
|
struct led_classdev *led_cdev;
|
||||||
int error;
|
int error;
|
||||||
@ -958,9 +971,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
|
|||||||
if (!led)
|
if (!led)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
led_no = atomic_inc_return(&led_seq);
|
xpad->led_no = atomic_inc_return(&led_seq);
|
||||||
|
|
||||||
snprintf(led->name, sizeof(led->name), "xpad%lu", led_no);
|
snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
|
||||||
led->xpad = xpad;
|
led->xpad = xpad;
|
||||||
|
|
||||||
led_cdev = &led->led_cdev;
|
led_cdev = &led->led_cdev;
|
||||||
@ -974,10 +987,8 @@ static int xpad_led_probe(struct usb_xpad *xpad)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Light up the segment corresponding to controller number */
|
||||||
* Light up the segment corresponding to controller number
|
xpad_identify_controller(xpad);
|
||||||
*/
|
|
||||||
xpad_send_led_command(xpad, (led_no % 4) + 2);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -994,6 +1005,7 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
|
|||||||
#else
|
#else
|
||||||
static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
|
static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
|
||||||
static void xpad_led_disconnect(struct usb_xpad *xpad) { }
|
static void xpad_led_disconnect(struct usb_xpad *xpad) { }
|
||||||
|
static void xpad_identify_controller(struct usb_xpad *xpad) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user