Coder Social home page Coder Social logo

saitekx52pro's People

Contributors

atcurtis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dcerisano feffi

saitekx52pro's Issues

Garbled MFD and hung joystick

Hi
Thanks for a very nice library, works fine.

I have discovered an inconvenient issue which I have solved (sort of), and I just wanted to inform you of this.
Sometimes I get a garbled MFD on my X52 Pro joystick when writing text using:
setText(int line, CharSequence text)
It also sometimes completely hung the joystick requiring a disconnect/connect of the USB plug.

I solved this by adding sleep for 1 ms. Perhaps not the most elegant solution, but it decreased the number of garbled writes by ca 90% and the hanging by 100%:

   public void setText(int line, CharSequence text) {
    if (!feat_mfd)
      throw new UnsupportedOperationException("setText not supported");
    if (line < 1 || line > 3)
      throw new IndexOutOfBoundsException("line number out of bounds");
    int r = controlMsg(clear_idx[line], (short) 0x0000);
    if (r < 0)
      throw new LibUsbException("setText failed to clear", r);
    if (r < 0)
      throw new LibUsbException("failed at clear command: " + LibUsb.strError(r), r);
    for (int index = 0, length = text.length(); length > 0; index+=2, length-=2) {
      short chars;
      if (length == 1) {
        chars = (short) ( (' ' << 8) | text.charAt(index) );
      }
      else {
        chars = (short) ( (text.charAt(index + 1) << 8) | text.charAt(index) );
      }
      r = controlMsg(write_idx[line], chars);
      if (r < 0)
        throw new LibUsbException("setText failed", r);
      // Added short sleep to avoid garbled MFD and hung joystick
      try {
        Thread.sleep(1);
      } catch(InterruptedException ex) {
        Thread.currentThread().interrupt();
      }
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.