Page 1 of 1
PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Fri Sep 05, 2025 10:30 pm
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
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 10:10 am
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 ?
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 1:31 pm
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.
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 2:52 pm
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.
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 2:53 pm
by Fred
OK. Does it means than you can't do some stuff on MacOS or is it only informative data ?
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 2:54 pm
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
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 3:18 pm
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.
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 3:39 pm
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
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 3:46 pm
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.
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 7:00 pm
by Piero
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 7:26 pm
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
Re: PB 6.30 b1 - GetHIDIndexedString() does not work
Posted: Mon Sep 08, 2025 11:11 pm
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
HID Bonanza!
Posted: Tue Sep 09, 2025 6:05 am
by Piero