Writing to HID keyboard works on Linux but not on Windows
up vote
1
down vote
favorite
I am attempting to set the LED's of my RGB keyboard by sending HID packets to it via my Java program, with the Java HIDAPI wrapper found here.
I've been successful so far, but only on my Linux laptop. When I try run the code on Windows, I get an error, 'Invalid function', which I'm assuming is equivalent to the system Error 0x1, ERROR_INVALID_FUNCTION.
This sample example piece of code will not run on Windows, but will run on Linux. (When it is run from the terminal with 'sudo' prepended to the command.)
// Device is found prior to this...
if (device != null) {
device.disableBlocking();
// Initialise the buffer, and send it. PACKET_SIZE is 264
byte buffer = new byte[PACKET_SIZE];
for (int i = 0; i < PACKET_SIZE; i++) { buffer[i] = (byte)0x00; }
// These bytes are required for it to actually change the LED's.
buffer[0] = 0x07;
buffer[1] = 0x0E;
buffer[2] = 0x01;
buffer[3] = 0x01;
try {
// Actually send the data.
device.sendFeatureReport(buffer);
}
// Handle I/O exceptions
catch (IOException e) {
e.printStackTrace();
}
// Close the device.
device.close();
}
else {
System.err.println("DEVICE IS NULL");
}
I've tried running as administrator, no difference unfortunately...
If my question is not clear enough, let me know and I'll attempt to clarify it further.
Any help would be greatly appreciated! I'm getting desperate to find a solution to this! :)
Versions of OS's, if it matters:
Linux Ubuntu 18.04
Windows 8.1
java linux windows hid hidapi
add a comment |
up vote
1
down vote
favorite
I am attempting to set the LED's of my RGB keyboard by sending HID packets to it via my Java program, with the Java HIDAPI wrapper found here.
I've been successful so far, but only on my Linux laptop. When I try run the code on Windows, I get an error, 'Invalid function', which I'm assuming is equivalent to the system Error 0x1, ERROR_INVALID_FUNCTION.
This sample example piece of code will not run on Windows, but will run on Linux. (When it is run from the terminal with 'sudo' prepended to the command.)
// Device is found prior to this...
if (device != null) {
device.disableBlocking();
// Initialise the buffer, and send it. PACKET_SIZE is 264
byte buffer = new byte[PACKET_SIZE];
for (int i = 0; i < PACKET_SIZE; i++) { buffer[i] = (byte)0x00; }
// These bytes are required for it to actually change the LED's.
buffer[0] = 0x07;
buffer[1] = 0x0E;
buffer[2] = 0x01;
buffer[3] = 0x01;
try {
// Actually send the data.
device.sendFeatureReport(buffer);
}
// Handle I/O exceptions
catch (IOException e) {
e.printStackTrace();
}
// Close the device.
device.close();
}
else {
System.err.println("DEVICE IS NULL");
}
I've tried running as administrator, no difference unfortunately...
If my question is not clear enough, let me know and I'll attempt to clarify it further.
Any help would be greatly appreciated! I'm getting desperate to find a solution to this! :)
Versions of OS's, if it matters:
Linux Ubuntu 18.04
Windows 8.1
java linux windows hid hidapi
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am attempting to set the LED's of my RGB keyboard by sending HID packets to it via my Java program, with the Java HIDAPI wrapper found here.
I've been successful so far, but only on my Linux laptop. When I try run the code on Windows, I get an error, 'Invalid function', which I'm assuming is equivalent to the system Error 0x1, ERROR_INVALID_FUNCTION.
This sample example piece of code will not run on Windows, but will run on Linux. (When it is run from the terminal with 'sudo' prepended to the command.)
// Device is found prior to this...
if (device != null) {
device.disableBlocking();
// Initialise the buffer, and send it. PACKET_SIZE is 264
byte buffer = new byte[PACKET_SIZE];
for (int i = 0; i < PACKET_SIZE; i++) { buffer[i] = (byte)0x00; }
// These bytes are required for it to actually change the LED's.
buffer[0] = 0x07;
buffer[1] = 0x0E;
buffer[2] = 0x01;
buffer[3] = 0x01;
try {
// Actually send the data.
device.sendFeatureReport(buffer);
}
// Handle I/O exceptions
catch (IOException e) {
e.printStackTrace();
}
// Close the device.
device.close();
}
else {
System.err.println("DEVICE IS NULL");
}
I've tried running as administrator, no difference unfortunately...
If my question is not clear enough, let me know and I'll attempt to clarify it further.
Any help would be greatly appreciated! I'm getting desperate to find a solution to this! :)
Versions of OS's, if it matters:
Linux Ubuntu 18.04
Windows 8.1
java linux windows hid hidapi
I am attempting to set the LED's of my RGB keyboard by sending HID packets to it via my Java program, with the Java HIDAPI wrapper found here.
I've been successful so far, but only on my Linux laptop. When I try run the code on Windows, I get an error, 'Invalid function', which I'm assuming is equivalent to the system Error 0x1, ERROR_INVALID_FUNCTION.
This sample example piece of code will not run on Windows, but will run on Linux. (When it is run from the terminal with 'sudo' prepended to the command.)
// Device is found prior to this...
if (device != null) {
device.disableBlocking();
// Initialise the buffer, and send it. PACKET_SIZE is 264
byte buffer = new byte[PACKET_SIZE];
for (int i = 0; i < PACKET_SIZE; i++) { buffer[i] = (byte)0x00; }
// These bytes are required for it to actually change the LED's.
buffer[0] = 0x07;
buffer[1] = 0x0E;
buffer[2] = 0x01;
buffer[3] = 0x01;
try {
// Actually send the data.
device.sendFeatureReport(buffer);
}
// Handle I/O exceptions
catch (IOException e) {
e.printStackTrace();
}
// Close the device.
device.close();
}
else {
System.err.println("DEVICE IS NULL");
}
I've tried running as administrator, no difference unfortunately...
If my question is not clear enough, let me know and I'll attempt to clarify it further.
Any help would be greatly appreciated! I'm getting desperate to find a solution to this! :)
Versions of OS's, if it matters:
Linux Ubuntu 18.04
Windows 8.1
java linux windows hid hidapi
java linux windows hid hidapi
edited 8 hours ago
asked 21 hours ago
Michael
254
254
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369233%2fwriting-to-hid-keyboard-works-on-linux-but-not-on-windows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown