Write something to linux hid device?
USB HID devices are mostly input devices, so they don't usually provide an OUT endpoint (they are allowed by the HID specification but I've never seen one). If an OUT endpoint is not provided, then output reports are sent through the control endpoint (EP0). The URB should be something like this:
bmRequestType = 0x21 (To class interface)
bRequest = 0x09 (SET_REPORT)
wValue = 0x02 <report_code>
wIndex = <interface> (Usually 0x0001)
wLength = <Data length>
Data = <report_code> <data>...
Naturally, there are functions that do just that. From kernel, you may look at hiddev_lookup_report/usbhid_submit_report. From userland, if you use /dev/usb/hiddev? you may try the HIDIOCSREPORT ioctl, and if you use /dev/hidraw? you simply write() into it.
HID also defines "Features", that are an output control mechanism, but I've never used them.
How can I capture raw HID input on Linux?
You'll want uinput
. You'll listen on your /dev/usb/hiddev0 and then create new events that you'll send out on /dev/input/uinput
.
This explains it and gives a little tutorial:
Using uinput driver in Linux- 2.6.x to send user input {This is the EInfochips' "Dashboard" publication issue January 2007 "Tip of the Month" article mentioned on this archived page}.
Writing to HID keyboard works on Linux but not on Windows
Alright, so I managed to finally get it working!
Basically, I switched from the Java HIDAPI to hid4java, modified the code to do the same thing, and it worked like a charm ! (On Windows)
I also removed the first byte in the buffer, and used it as the reportId parameter in hid4java's HidDevice.sendFeatureReport function. This shifted all the bytes over by 1, but this was easily fixed by subtracting 1 at the index when a value in the buffer was to be set. (Not shown in the example of my question.)
I haven't yet tested this on Linux though, but I'd assume it would still work.
Related Topics
Problem of Understanding Clock_Gettime
Dreaming of Making My Own Os- What Should I Use? (Suggestions)
Where The Structure "Struct Page" Is Stored on The Linux Kernel
How to Prevent Remote Branch Deletion in Git Without Using Gitolite
Avoid Daemon Running in Dedicated CPU Cores
Using Winscp to Grab a File Through a Tunnel
How to Make Linux Ignore a Keyboard While Keeping It Available for My Program to Read
How to Get The Output of at Command in Current or Another Terminal Window
How to Distinguish Between Different Operating System Distros in Node.Js
Monitor/Audit File Delete on Linux
I Need a Tcp Option (Ioctl) to Send Data Immediately
How to Use 'History-C' Command in a Bash Script
Transliteration Script for Linux Shell
Gnutls_Handshake() Failed: Handshake Failed Git