//by Christophe ILLY 2017
//under MIT license
public class InputProxy {
static {
System.loadLibrary("inputNative");
}
public static InputProxy in = new InputProxy();
//event types
public static int KEY_PRESSED = 0;
public static int KEY_RELEASED = 1;
//keys (windows values)
public static int SCAN_CODE_ECHAP = 1;
public static int SCAN_CODE_SPACE = 57;
public static int SCAN_CODE_ARROW_LEFT = 75;
public static int SCAN_CODE_ARROW_RIGHT = 77;
public static int SCAN_CODE_ARROW_UP = 72;
public static int SCAN_CODE_ARROW_DOWN = 80;
public static int SCAN_CODE_A = 16;
public static int SCAN_CODE_Q = 30;
//... add whatever you need
public InputProxy() {
if(!init()){
System.out.println(getErrorMsg());
exit();
}
}
private native boolean init();
public native void exit();
public native String getErrorMsg();
public native String eventToString();
public native boolean checkEvents();
public native int getEvent();
public native int getEventType();
public static void main(String[] args) {
System.out.println("(Quit : Q)");
boolean run = true;
while(run){
if(InputProxy.in.checkEvents()){
int event = InputProxy.in.getEvent();
System.out.println(event);
System.out.println(InputProxy.in.eventToString());
if(event == SCAN_CODE_Q){
run = false;
}
}
try{ Thread.sleep(1); } catch(InterruptedException e) {}
}
InputProxy.in.exit();
System.out.println("Goodbye.");
}
}