[PD] hid objects on linux/mac/win? hidraw on linux? hidraw parsing?

Peter P. peterparker at fastmail.com
Wed Mar 13 12:02:33 CET 2024


I am forwarding another helpful reply from Lucas below, which seems to have bypassed
this list. Thank you Lucas for the information, this is much
appreciated! P

----- Forwarded message from Lucas Cordiviola -----

Subject: Re: [PD] hid objects on linux/mac/win? hidraw on linux? hidraw parsing?
Date: Wed, 13 Mar 2024 01:37:42 -0300

I don't wanna go to deep into HIDs as I know little about it.

I came to [hidraw] because i needed something easy for Windows (iirc hids
external were not working for me on Windows at that time) so I was writing my
first externals as a training and decided to wrap
https://github.com/libusb/hidapi.

> I am a bit puzzled that I don't get any error message from [hidraw] when
> trying 'listdevices'.

Me too. I had tested on Windows and Debian and it worked. On macOS I tested it
on a VM but i could not get "listed" devices. Someone at the time of the
release reported it worked just fine on a real mac with a real joystick.

> Understood. How can I tell which element of the list belongs to which
> switch/dimension/etc? Are these floats somehow (binary) encoded?

Yes they are encoded. There's a good side and a bad one. The good one is that
no "symbols" are used and that's better at Pd's internal message side. The bad
side is that each device has it's own implementation of this list of floats.
https://github.com/libusb/hidapi just grabs them and spits them. In [hidio]
and other better externals there's and OS layer involved that can tell
canonically what "switch/dimension/etc" it has received. So these externals
make your life easier and more realistic.

But if you get the chance to open a device with [hidraw] you won't be much
scared of the list of bytes. if you press one button you'll get say "0 11 0 0"
and on release you'll get "0 0 0 0". if you press another one you'll get say
"0 12 0 0".  Each float on the list represent a byte (0 - 255) and each device
has a different number of (fixed) items in the list.





More information about the Pd-list mailing list