Writing one byte size always writes 0. This seems to be because of the following conditional that checks for above one byte.
File org.hid4java.jna.HidApi.java
Function write:
public static int write(HidDeviceStructure device, byte[] data, int len, byte reportId)
Section:
} else {
// Put report ID into position 0 and fill out buffer
report = new WideStringBuffer(len + 1);
report.buffer[0] = reportId;
if (len > 1) {
System.arraycopy(data, 0, report.buffer, 1, len);
}
I did the following:
} else {
// Put report ID into position 0 and fill out buffer
report = new WideStringBuffer(len + 1);
report.buffer[0] = reportId;
if (len > 0) {
System.arraycopy(data, 0, report.buffer, 1, len);
}
Writing one byte size always writes 0. This seems to be because of the following conditional that checks for above one byte. File org.hid4java.jna.HidApi.java
Function write: public static int write(HidDeviceStructure device, byte[] data, int len, byte reportId)
Section: } else { // Put report ID into position 0 and fill out buffer
report = new WideStringBuffer(len + 1); report.buffer[0] = reportId; if (len > 1) { System.arraycopy(data, 0, report.buffer, 1, len); } I did the following: } else { // Put report ID into position 0 and fill out buffer
report = new WideStringBuffer(len + 1); report.buffer[0] = reportId; if (len > 0) { System.arraycopy(data, 0, report.buffer, 1, len); }