Page 1 of 1
PB 6.30 b1 - HIDInfo()
Posted: Fri Sep 05, 2025 10:24 pm
by User_Russian
In MacOS function HIDInfo() with parameters #PB_HID_Product and #PB_HID_Manufacturer reads string in incorrect encoding. The USB descriptor contains unicode strings. But function HIDInfo() reads strings as ascii or utf8.
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 10:12 am
by Fred
HIDAPI returns UTF-32 string which are converted in UTF-16 so it should work properly. Which characters are not converted as expected ? Can anybody else confirm with another device ?
Code: Select all
ExamineHIDs()
While NextHID()
Debug HIDInfo(#PB_HID_Product)
Debug HIDInfo(#PB_HID_Manufacturer)
Debug "****************"
Wend
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 4:22 pm
by Piero
Mac ARM
Code: Select all
; Debug HIDInfo(#PB_HID_Product)
; [COMPILER] Line 1: Constant not found: #PB_HID_Product.
ExamineHIDs()
While NextHID()
if HIDInfo(6)="Logitech"
Debug HIDInfo(7) ; Logitech Dual Action
Debug HIDInfo(8) ; 1
Debug HIDInfo(9) ; 4
EndIf
Wend
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 4:55 pm
by User_Russian
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 5:30 pm
by Piero
Thanks!
Code: Select all
; Also SEEMS to list disconnected devices (audio only?)
ExamineHIDs()
While NextHID()
Debug HIDInfo(6)
Debug HIDInfo(7)
Debug "---"
Wend
; Apple
; Headset
; ---
; Apple
;
; other Bluetooth devices SEEM to get listed only when connected (debug is longer):
; ---
;
; Pro Controller
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 8:33 pm
by User_Russian
It's probably a bug hidapi library for macos.
I compared the result of this code
Code: Select all
ExamineHIDs(4660,2)
If NextHID()
s.s = HIDInfo(#PB_HID_Product)
ShowMemoryViewer(@s, StringByteLength(s))
EndIf
with result from hidapi
Code: Select all
ImportC #PB_Compiler_Home+"/purelibraries/macos/libraries/libpbhidapi.a"
hid_open(v,p,s)
hid_get_product_string(handle, *wstr, len)
EndImport
ExamineHIDs()
h = hid_open(4660,2,0)
*point = AllocateMemory(4096)
hid_get_product_string(h, *point, MemorySize(*point))
ShowMemoryViewer(*point, MemorySize(*point))
And it is clear that there is a bug in hidapi.
On Windows and Linux, this problem does not exist.
Re: PB 6.30 b1 - HIDInfo()
Posted: Mon Sep 08, 2025 9:51 pm
by Piero
I think it may be because the Mac (Sequoia) needs you to grant access to devices
Also, when you turn Bluetooth on, you see a list of "known devices" (even if disconnected)
Anyway, as you can read
here, you can quickly select the right devices by Usage Page and Usage Value/ID (page 32 of
this)