What's the difference between hid_hw_output_report and hid_hw_raw_request?

2 messages, 2 authors, 2016-04-23 · open the first message on its own page

What's the difference between hid_hw_output_report and hid_hw_raw_request?

From: Manuel Reimer <hidden>
Date: 2016-04-23 14:05:49

Hello,

I want to enable the rumble motors on a PS4 controller using libusb.

The kernel code calls different functions depending on whether USB or Bluetooth is used:
https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c#L1901
This difference does not exist in the code for the PS3 controller.

So why is this difference in the kernel driver? What do I have to do to emulate "hid_hw_output_report" using libusb?

Thanks in advance.

Manuel


My current code, which does *not* work, follows. I also tried to not send the report ID as first byte in the command sequence, but this doesn't work either. The data seems to get sent without any problems, but the controller doesn't react in any way.

 uint8_t cmd[] = {
    0x05,
    0xFF, 0x00, 0x00, right, left,  // rumble values
    0xFF, 0xFF, 0xFF, 0x00, 0x00,  // Red, Green, Blue, TimeBright, TimeDark
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00
  };

  return libusb_control_transfer(usbdev,
                        LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
                        HID_REQ_SET_REPORT,
                        (HID_OUTPUT_REPORT<<8)|0x05,
                        0,
                        cmd,
                        sizeof(cmd),
                        USB_CTRL_GET_TIMEOUT);

Re: What's the difference between hid_hw_output_report and hid_hw_raw_request?

From: Clément VUCHENER <hidden>
Date: 2016-04-23 14:56:17

2016-04-23 16:05 GMT+02:00 Manuel Reimer [off-list ref]:
Hello,

I want to enable the rumble motors on a PS4 controller using libusb.

The kernel code calls different functions depending on whether USB or
Bluetooth is used:
https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c#L1901
This difference does not exist in the code for the PS3 controller.

So why is this difference in the kernel driver? What do I have to do to
emulate "hid_hw_output_report" using libusb?
If I understand the code from hid-core.c correctly,
usbhid_output_report sends the report using the interrupt out pipe
instead of a control transfer. Check if the USB descriptor for your
device declares an interrupt out endpoint and use it if it exists.
Thanks in advance.

Manuel


My current code, which does *not* work, follows. I also tried to not send
the report ID as first byte in the command sequence, but this doesn't work
either. The data seems to get sent without any problems, but the controller
doesn't react in any way.

 uint8_t cmd[] = {
    0x05,
    0xFF, 0x00, 0x00, right, left,  // rumble values
    0xFF, 0xFF, 0xFF, 0x00, 0x00,  // Red, Green, Blue, TimeBright, TimeDark
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x00
  };

  return libusb_control_transfer(usbdev,
                        LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS |
LIBUSB_RECIPIENT_INTERFACE,
                        HID_REQ_SET_REPORT,
                        (HID_OUTPUT_REPORT<<8)|0x05,
                        0,
                        cmd,
                        sizeof(cmd),
                        USB_CTRL_GET_TIMEOUT);
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help