[fpc-pascal] HIDAPI Bindings for FPC (on Linux)
prof7bit at gmail.com
Sun Nov 20 14:17:30 CET 2016
I found and fixed a few minor problems while writing the demo and
added a simple demo program that will enumerate and print all devices
and then tries to open a certain device by vid/pid, I have just hard
coded the vid/pid of a popular cheap Logitech joystick because that
was the only HID device that would make sense trying to demonstrate it
with, my other HID device is just a self built USB device implemented
on a Freescale evaluation board and I don't just want to open the
first device on the list and maybe pull the keyboard driver away from
under their hands.
The user using this will most likely be interested in testing this
with his own hardware and use different vid/pid anyways.
The demo program will produce output like this:
--($)-- sudo ./demo
[sudo] Passwort für bernd:
will now enumerate all USB HID devices.
Note that it will list more info if you run with sudo,
you might want to add an udev rule for your device.
Found: Logitech Extreme 3D (046D:C215) at: 0006:0003:00
Found: Demo Device (DEAD:BEEF) at: 0005:0002:00
Found: USB Keyboard (1A2C:0C21) at: 0003:0002:00
Found: USB Keyboard (1A2C:0C21) at: 0003:0002:01
Will now try to open device 046D:C215
device is open, now going to read data from it
Product: Logitech Extreme 3D
08 A2 87 80 00 88 00
2016-11-19 23:46 GMT+01:00 Michael Van Canneyt <michael at freepascal.org>:
> On Sat, 19 Nov 2016, Bernd wrote:
>> Hello list,
>> I have made a binding for libhidapi because i needed one and I could
>> not find any.
>> (LGPL + static linking)
>> It is not just an automated header translation, instead I have made it
>> using the good old Pascal objects (and pointers to them) to cast the
>> device handles into, attached Methods with Pascal-ish names to the
>> objects which not only wrap the original c functions but also do some
>> conversion of ugly wchar_t* stuff on the fly if needed and make it
>> much more fun to use this C API.
>> I hope someone might find it useful, its license compatible with other
>> FPC units.
> Nice work.
> I will add it to the FPC packages if that is OK with you. Would it be
> possible to provide a sample program which e.g. lists the available devices
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
More information about the fpc-pascal