PB 6.30 b1 - GetHIDIndexedString() does not work

Post bugreports for the Mac OSX version here
User_Russian
Addict
Addict
Posts: 1550
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

PB 6.30 b1 - GetHIDIndexedString() does not work

Post by User_Russian »

The function GetHIDIndexedString() returns an empty string.

Code: Select all

ExamineHIDs()
While NextHID()
  
  Debug HIDInfo(#PB_HID_Product)
  Debug HIDInfo(#PB_HID_Manufacturer)
  Debug HIDInfo(#PB_HID_VendorId)
  Debug HIDInfo(#PB_HID_ProductId)
  Debug HIDInfo(#PB_HID_Path)
  Debug HIDInfo(#PB_HID_SerialNumber)
  Debug "****************"
  If OpenHIDPath(0, HIDInfo(#PB_HID_Path))
    For i=0 To 3
      Debug GetHIDIndexedString(0, i)
    Next
    CloseHID(0)
  EndIf
  Debug "----------------"
Wend
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by Fred »

You're right, because it's not supported by the OSX backend:

Code: Select all

ExamineHIDs()
While NextHID()
  
  Debug HIDInfo(#PB_HID_Product)
  Debug HIDInfo(#PB_HID_Manufacturer)
  Debug HIDInfo(#PB_HID_VendorId)
  Debug HIDInfo(#PB_HID_ProductId)
  Debug HIDInfo(#PB_HID_Path)
  Debug HIDInfo(#PB_HID_SerialNumber)
  Debug "****************"
  If OpenHIDPath(0, HIDInfo(#PB_HID_Path))
    For i=0 To 3
      Debug "Index string: " + i + GetHIDIndexedString(0, i)
      debug HIDError()
    Next
    CloseHID(0)
  EndIf
  Debug "----------------"
Wend
https://fossies.org/linux/Ardour/libs/hidapi/mac/hid.c

So does it worth to keep this function around for Linux/Windows and mention it doesn't work on MacOS or remove it ?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by spikey »

Fred wrote: Mon Sep 08, 2025 10:10 am So does it worth to keep this function around for Linux/Windows and mention it doesn't work on MacOS or remove it ?
Seems a shame to me to write the work off before it has even seen the light of day fully! You never know the MacOS version might catch up in a future release.
User_Russian
Addict
Addict
Posts: 1550
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by User_Russian »

Fred wrote: Mon Sep 08, 2025 10:10 amSo does it worth to keep this function around for Linux/Windows and mention it doesn't work on MacOS
Yes, sure. The function is useful.
In PB has functions for one platform - SetWindowCallback() for windows only and CocoaMessage() for macos only etc.
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by Fred »

OK. Does it means than you can't do some stuff on MacOS or is it only informative data ?
PeDe
Enthusiast
Enthusiast
Posts: 287
Joined: Sun Nov 26, 2017 3:13 pm

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by PeDe »

I don't think this function is necessary. It can't be used properly. Where do you get an index? Normally, you read in a descriptor for an interface, for example, and use the index contained therein to determine the corresponding string, e.g., for the manufacturer, serial number, etc. But HID has its own functions for this. And I have never seen an index for a string in a report descriptor. At the moment, I don't know what this function could be used for.

Peter
User_Russian
Addict
Addict
Posts: 1550
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by User_Russian »

Fred wrote: Mon Sep 08, 2025 2:53 pmDoes it means than you can't do some stuff on MacOS or is it only informative data ?
This is a helper function and it reads data from USB descriptor by index. It is for information only (not for transmitting/receiving data).
Here USB Device Descriptor

Code: Select all

/* USB Standard Device Descriptor */
const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
  {
    0x12,                       /*bLength */
    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
    0x00,                       /*bcdUSB */
    0x02,
    0x00,                       /*bDeviceClass*/
    0x00,                       /*bDeviceSubClass*/
    0x00,                       /*bDeviceProtocol*/
    0x40,                       /*bMaxPacketSize40*/
    0x83,                       /*idVendor (0x0483)*/
    0x04,
    0x50,                       /*idProduct = 0x5750*/
    0x57,
    0x00,                       /*bcdDevice rel. 2.00*/
    0x02,
    1,                          /*Index of string descriptor describing manufacturer */
    2,                          /*Index of string descriptor describing product*/
    3,                          /*Index of string descriptor describing the device serial number */
    0x01                        /*bNumConfigurations*/
  }
  ; /* CustomHID_DeviceDescriptor */
The numbers 1, 2, 3 in the descriptor are the index of the unicode strings that the reads function GetHIDIndexedString().
Similar information can be read using the function HIDInfo() with parameters #PB_HID_Manufacturer, #PB_HID_Product and #PB_HID_SerialNumber.
PeDe
Enthusiast
Enthusiast
Posts: 287
Joined: Sun Nov 26, 2017 3:13 pm

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by PeDe »

And how do you get the correct index without reading the device descriptor? How do you know that, for example, zero (0) is not in the field for the serial number if there is none? The index does not always have to be 1, 2, or 3.

Peter
User_Russian
Addict
Addict
Posts: 1550
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by User_Russian »

If this is an unknown device, then the first thing you should be interested in is how to find out the data exchange protocol. Without knowing this, you will not be able to interact with the device.
If you have documentation for the device (or you are its developer), then you know at what index the data is located.
User avatar
Piero
Addict
Addict
Posts: 950
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by Piero »

User avatar
Piero
Addict
Addict
Posts: 950
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by Piero »

Here's 2 controllers plus "Headset" (the rest is "Built-In = 1" here) from hidutil list in Terminal:

Code: Select all

Devices:
VendorID ProductID LocationID UsagePage Usage RegistryID  Transport Class                      Product                            UserClass                 Built-In 
0x46d    0xc216    0x1100000  1         4     0x101d4e25c USB       AppleUserHIDDevice         Logitech Dual Action               AppleUserUSBHostHIDDevice 0        
0x57e    0x2009    0x2378d900 1         5     0x101d4e283 Bluetooth IOHIDResource              Pro Controller                     (null)                    0        
0x0      0x0       0x0        12        1     0x1000006e9 Audio     AppleCS42L83Audio          Headset                            (null)                    0        
User avatar
Piero
Addict
Addict
Posts: 950
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: PB 6.30 b1 - GetHIDIndexedString() does not work

Post by Piero »

Fred wrote: Mon Sep 08, 2025 10:10 amSo does it worth to keep this function around for Linux/Windows and mention it doesn't work on MacOS or remove it ?
Isn't kIOHIDReportDescriptorKey (hid_get_report_descriptor) the Mac """equivalent"""?

In case please forgive me
User avatar
Piero
Addict
Addict
Posts: 950
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

HID Bonanza!

Post by Piero »

Post Reply