Skip to content

Commit 5710fab

Browse files
Antonio OspiteJiri Kosina
authored andcommitted
HID: hid-sony.c: Fix sending Output reports to the Sixaxis
The Sixaxis does not want the report_id as part of the data packet in Output reports, so we have to discard buf[0] when sending the actual control message. Add also some documentation about that and about why hdev->hid_output_raw_report needs to be overridden. Signed-off-by: Antonio Ospite <ospite@studenti.unina.it> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 177900e commit 5710fab

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/hid/hid-sony.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
4646
return rdesc;
4747
}
4848

49+
/*
50+
* The Sony Sixaxis does not handle HID Output Reports on the Interrupt EP
51+
* like it should according to usbhid/hid-core.c::usbhid_output_raw_report()
52+
* so we need to override that forcing HID Output Reports on the Control EP.
53+
*
54+
* There is also another issue about HID Output Reports via USB, the Sixaxis
55+
* does not want the report_id as part of the data packet, so we have to
56+
* discard buf[0] when sending the actual control message, even for numbered
57+
* reports, humpf!
58+
*/
4959
static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf,
5060
size_t count, unsigned char report_type)
5161
{
@@ -55,13 +65,23 @@ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf,
5565
int report_id = buf[0];
5666
int ret;
5767

68+
if (report_type == HID_OUTPUT_REPORT) {
69+
/* Don't send the Report ID */
70+
buf++;
71+
count--;
72+
}
73+
5874
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
5975
HID_REQ_SET_REPORT,
6076
USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
6177
((report_type + 1) << 8) | report_id,
6278
interface->desc.bInterfaceNumber, buf, count,
6379
USB_CTRL_SET_TIMEOUT);
6480

81+
/* Count also the Report ID, in case of an Output report. */
82+
if (ret > 0 && report_type == HID_OUTPUT_REPORT)
83+
ret++;
84+
6585
return ret;
6686
}
6787

0 commit comments

Comments
 (0)