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...



Any help would be greatly appreciated :)





Versions of OS's, if it matters:

Linux Ubuntu 18.04
Windows 8.1










share|improve this question




























    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...



    Any help would be greatly appreciated :)





    Versions of OS's, if it matters:

    Linux Ubuntu 18.04
    Windows 8.1










    share|improve this question


























      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...



      Any help would be greatly appreciated :)





      Versions of OS's, if it matters:

      Linux Ubuntu 18.04
      Windows 8.1










      share|improve this question















      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...



      Any help would be greatly appreciated :)





      Versions of OS's, if it matters:

      Linux Ubuntu 18.04
      Windows 8.1







      java linux windows hid hidapi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 7 hours ago

























      asked 10 hours ago









      Michael

      254




      254





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

          ts Property 'filter' does not exist on type '{}'

          mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window