awvalenti / bauhinia

Cross-platform Wii Remote Java library and remote controller application
GNU General Public License v3.0
6 stars 0 forks source link

Make nitida work independently of graphical environment #17

Open awvalenti opened 7 years ago

awvalenti commented 7 years ago

nitida currently uses java.awt.Robot, which unfortunately depends on a graphical environment to run. If issue #16 is solved, we could find a substitute for java.awt.Robot to be used on scenarios like Raspberry Pi. It could be platform-dependent (working only on Linux ARM, for example), because java.awt.Robot takes care of the other environments.

awvalenti commented 7 years ago

@jabrena, I encourage you to try running the following native C code on your platform to try to simulate key events the same way that java.awt.Robot does. It seems to need an X environment, which might not be your case.

Lines 272 and 291 (shown below) were taken from java.awt.Robot underlying implementation (https://searchcode.com/codesearch/view/17994444/):

// This should cause keyPress XTestFakeKeyEvent(awt_display, XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), True, CurrentTime);

// This should cause keyRelease XTestFakeKeyEvent(awt_display, XKeysymToKeycode(awt_display, awt_getX11KeySym(keycode)), False, CurrentTime);

The following include should be necessary:

include <X11/extensions/XTest.h>

If that works, we can write a simple Java wrapper and make nitida work on Raspberry Pi.