Author Topic: libusb with hid feature requests?  (Read 10077 times)

ulao

  • Frequent Contributor
  • ****
  • Posts: 172
libusb with hid feature requests?
« on: November 30, 2017, 10:49:47 pm »
Jan, I know HIDAPI is preferred over libUSB but wondered if you could comment on why a common HID gampead does not allow feature request? It seems both C and JAVA have issues using feature requests. 

libusb_control_transfer returns -2 (invalid param)(edited) on windows but the same code works fine on linux



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: libusb with hid feature requests?
« Reply #1 on: December 01, 2017, 09:49:15 am »
If the device supports the request, one reason could be that the parameter is invalid on Windows. If you post the code, someone might see something.


ulao

  • Frequent Contributor
  • ****
  • Posts: 172
Re: libusb with hid feature requests?
« Reply #2 on: December 01, 2017, 10:04:03 am »
Code is copyritghted but relevant section is this
Code: [Select]

   ret = libusb_set_configuration(autoconfig_libusb_handle, 1);

   if (ret < 0)
   {
      RARCH_ERR("[Autoconf]: Error during libusb_set_configuration.\n");
      goto error;
   }

   ret = libusb_claim_interface(autoconfig_libusb_handle, 0);

   if (ret < 0)
   {
      RARCH_ERR("[Autoconf]: Error during libusb_claim_interface.\n");
      goto error;
   }

   ret = libusb_control_transfer(autoconfig_libusb_handle, USB_CTRL_IN, USB_HID_GET_REPORT, BLISSBOX_USB_FEATURE_REPORT_ID, 0, answer, USB_PACKET_CTRL_LEN, USB_TIMEOUT);

   if (ret < 0)
      RARCH_ERR("[Autoconf]: Error during libusb_control_transfer.\n");

   libusb_release_interface(autoconfig_libusb_handle, 0);

It more then likely will not tell much as the error is in the libusb but if it helps I can get the defined data.
« Last Edit: December 01, 2017, 10:57:48 am by ulao »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: libusb with hid feature requests?
« Reply #3 on: December 03, 2017, 12:27:27 pm »
That looks like code for IN Feature requests (device-host Data stage), if that makes a difference. Of course it also depends on what parameters are actually passed and if they are the correct type, size, etc.

ulao

  • Frequent Contributor
  • ****
  • Posts: 172
Re: libusb with hid feature requests?
« Reply #4 on: December 03, 2017, 02:20:08 pm »
yes correct and when sent 'in' it fails.  I did more reading and I here libusb requires drivers. It apparently is a mess. HIDAPI fix things up so libusb is out.