
hi roel, On 09.12.09 16:50, Roel van Dijk wrote:
On Wed, Dec 9, 2009 at 4:20 PM, stefan kersten
wrote: looks great, thanks! do you happen to have some example code for working with HID devices (mice, keyboards, etc.)?
The usb package does not support the various device classes directly. You won't find a function like "isKeyPressed ∷ Device → KeyCode → IO Bool". But you could write it based solely on functions from the usb package. Enumerate the devices connected to your system, find your HID device, open a handle (or enter a safe region), choose an interface and an alternative and finally send some sort of control request encoded in a ByteString. The actual bytes you need to send in order to discover if some key on your USB keyboard is pressed is defined somewhere in the USB HID device class specification.
ok, thanks. i just thought you might have something ready to use ;)
If you really need that kind of functionality then you could create a package "usb-hid" that offers an abstraction over the HID device class. But if you just want to know if some key is pressed then a much simpler solution would be to use a library like SDL or GLUT.
i'm interested in "headless" appliances, where no window system is actually running. on linux i could use the input device layer, but it would be nice to have something more portable ... <sk>