[fpc-pascal] USB Human Interface Devices

James Richters james at productionautomation.net
Sat Aug 10 23:50:51 CEST 2019


I'm making an attempt to copy TUSBPseudoHIDInterface into libusboop.pas.  I've made the recomended name changes and then tried to compile it.  Some things I found like the names changing from things like

PUSBInterfaceDescriptop to Plibusb_interface_descriptor 

are pretty obvious, but just taking a guess on other things like:

 changing:
      if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK = USB_ENDPOINT_TYPE_INTERRUPT) and
         (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then

To:
      if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK = LIBUSB_TRANSFER_TYPE_INTERRUPT) and
         (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0) then

Based on looking at something similar in libusbutil... but I'm not sure it's right at all.... I'm not sure if USB_ENDPOINT_TYPE_MASK was really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else happened.  But at least it compiles... 
but now I've hit a few items that I just don't know what to do with.    I can't find anything similar to get a reference from:

libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"
libusboop.pas(1199,5) Error: Identifier not found "USB_REQ_HID_SET_REPORT"
libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
libusboop.pas(1217,5) Error: Identifier not found "USB_REQ_HID_GET_REPORT"
libusboop.pas(1227,23) Error: Identifier not found "HID_REPORT_TYPE_OUTPUT"

I've tried things that seem to be in line with other changes, like changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out REQUEST instead of REQ which also seems to be done in other places, but still the identifiers are not found... the problem is I have no idea where these identifiers were/are defined.

I made a fork in github and a branch called "test"  here:
https://github.com/Zaaphod/pas-libusb/tree/Test

Any advice is greatly appreciated

James



> Actually you could copy the class TUSBPseudoHIDInterface (plus the types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas and change everything necessary.

> At least one difference is that all names change from TUSB* to TLibUsb*. I'm sure there are more, but I don't know by heart.



More information about the fpc-pascal mailing list