PB 6.30 b1 - HIDInfo()

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

PB 6.30 b1 - HIDInfo()

Post 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.
Fred
Administrator
Administrator
Posts: 18252
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.30 b1 - HIDInfo()

Post 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
User avatar
Piero
Addict
Addict
Posts: 953
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: PB 6.30 b1 - HIDInfo()

Post 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
User_Russian
Addict
Addict
Posts: 1554
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.30 b1 - HIDInfo()

Post by User_Russian »

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

Re: PB 6.30 b1 - HIDInfo()

Post by Piero »

User_Russian wrote: Mon Sep 08, 2025 4:55 pm Constants here viewtopic.php?p=644808#p644808
Thanks! :oops:
 

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
User_Russian
Addict
Addict
Posts: 1554
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.30 b1 - HIDInfo()

Post 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.
Image

On Windows and Linux, this problem does not exist.
User avatar
Piero
Addict
Addict
Posts: 953
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: PB 6.30 b1 - HIDInfo()

Post 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)
Post Reply