atcurtis / saitekx52pro Goto Github PK
View Code? Open in Web Editor NEWJava Saitek X52 Pro
Java Saitek X52 Pro
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();
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.