diff --git a/.classpath b/.classpath
deleted file mode 100644
index d1ad488..0000000
--- a/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index 49a05d3..7a84f4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,15 @@
bin
*.so
*.dll
+.gradle
+build
+*.swp
+.idea
+*.ipr
+*.iws
+*.iml
+out/
+classes/
+.DS_STORE
+target
diff --git a/.project b/.project
deleted file mode 100644
index a2e4452..0000000
--- a/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- evdev-java
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..54e81cb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,19 @@
+language: java
+jdk:
+ - openjdk7
+install: "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dcobertura.skip=true -B -V"
+before_script: "git clone -b travis `git config --get remote.origin.url` target/travis"
+script: "mvn deploy --settings target/travis/settings.xml -B -V"
+after_success:
+ - "mvn site --settings target/travis/settings.xml -B -V"
+branches:
+ except:
+ - travis
+ - gh-pages
+cache:
+ directories:
+ - $HOME/.m2
+env:
+ global:
+ - secure: "dEQ45kADimiVlBcOUcfreTLL1IpLzkOvFE/J8LzK4BI0C6KS3XNKhEErvXmJ7sa5J4K0PhyHYAqrxS53J2kk0til0iPRGv4sZlBxIhA5jJScXxS2JmFqQLyaxttquC9TO6lazan2iK8nZlaOix5b29JSqOY/2SfIYx8v7uYRt2Q="
+ - secure: "JNNxKdcCihOT/zj8qH2D+5fHNSSYURpSnxvkioZuBhBDQyNXt3njljYqqET/WYf1ZsEa3/Pe9BxmO1DYy1bYB68mv1AD3NdSSnzSFylQg8uzBomht9qcpUaZk/izqhBIgxFyqex8NEZvrqd+oIjvJKEwSn+zZNcr2S54uuH96/o="
diff --git a/README b/README
index b5a1f66..9427581 100644
--- a/README
+++ b/README
@@ -4,8 +4,8 @@
WHAT IS IT
This is a java API for the Linux evdev system. Evdev (event device) is used
-by the kernel to provide "input events" from input devices to userspace. Input
-devices include anything from keyboard and mice to joysticks to hardware buttons
+by the kernel to provide "input events" from input com.dgis.input.evdev.devices to userspace. Input
+com.dgis.input.evdev.devices include anything from keyboard and mice to joysticks to hardware buttons
(power, hibernate, laptop buttons), even soundcards (some recent ones generate
events upon a jack being plugged).
@@ -13,8 +13,8 @@ RATIONALE
One of my free-time projects is creating a full-featured Car PC system. Among
other things, the system needed a solid method of getting input from many
-devices. Some were obvious (keyboard, touch-screen), while others not so much
-(custom panel buttons, sensors, etc). Since most devices already had an evdev
+com.dgis.input.evdev.devices. Some were obvious (keyboard, touch-screen), while others not so much
+(custom panel buttons, sensors, etc). Since most com.dgis.input.evdev.devices already had an evdev
interface in the kernel, it was obvious that my system better take advantage
of this fact. I could not find any Java interface to evdev, I decided to write
my own, and here is a result.
@@ -31,7 +31,7 @@ written to take care of those.
DRIVERS/FILTERS
Raw InputEvents are fine for accomplishing more advanced features or for
-supporting a wide range of devices, but oftentimes a simpler interface is
+supporting a wide range of com.dgis.input.evdev.devices, but oftentimes a simpler interface is
desired (along with a reduced risk of error, yay for compiler error messages!).
Thus, evdev-java provides a driver/filter system. These implementations sit on
top of EventDevice and forward (and generate) device-specific events. At the
@@ -68,4 +68,3 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-
\ No newline at end of file
diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html
deleted file mode 100644
index 7ffe14a..0000000
--- a/doc/allclasses-frame.html
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
Create an EventDevice by connecting to the provided device filename.
- If the device file is accessible, open it and begin listening for events.
-
-
-
Parameters:
device - The path to the device file. Usually one of /dev/input/event*
-
Throws:
-
java.io.IOException - If the device is not found, or is otherwise inaccessible.
-
-
-
-
-
-
-
-
-Method Detail
-
-
-
-
-close
-
-public void close()
-
-
Releases all resources held by this EventDevice. No more events will be generated.
- It is impossible to restart an EventDevice once this method is called.
-
Adds an event listener to this device.
- When an event is received from Evdev, all InputListeners registered
- will be notified by a call to event().
- If the listener is already on the listener list,
- this method has no effect.
-
EvdevJoystickFilter
-
-
- This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
- when dealing with an evdev EventDevice.
-This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
- when dealing with an evdev EventDevice.
- Consolidates multiple events between EV_SYN events, and can tell you how many buttons and axes exist, and which changed.
-
- Copyright (C) 2009 Giacomo Ferrari
-
-
-
-
-
Author:
-
Giacomo Ferrari
-
-
-
-
-
-
-
-
-
-
-
-Constructor Summary
-
-
-
EvdevJoystickFilter(com.dgis.input.evdev.EventDevice dev)
-
-
- Constructs an EvdevJoystickFilter using the provided EventDevice as input.
-
-
-
EvdevJoystickFilter(java.lang.String device)
-
-
- Constructs an EvdevJoystickFilter using the provided event device as input.
This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
- when dealing with an evdev EventDevice.
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-Overview
-
-
-
-The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
-
-Package
-
-
-
-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
-
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
-
-
-Class/Interface
-
-
-
-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
-
-
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
-
-
Field Detail
Constructor Detail
Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-
-
-Annotation Type
-
-
-
-Each annotation type has its own separate page with the following sections:
-
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
-
-
-
-Enum
-
-
-
-Each enum has its own separate page with the following sections:
-
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
-
-
-Use
-
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-
-Tree (Class Hierarchy)
-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
-
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-
-Deprecated API
-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-
-Index
-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-
-Prev/Next
-These links take you to the next or previous class, interface, package, or related page.
-Frames/No Frames
-These links show and hide the HTML frames. All pages are available with or without frames.
-
-
-Serialized Form
-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-
This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
- when dealing with an evdev EventDevice.
-
-
-
-
-
-
-
diff --git a/doc/package-list b/doc/package-list
deleted file mode 100644
index 864b4bc..0000000
--- a/doc/package-list
+++ /dev/null
@@ -1,2 +0,0 @@
-com.dgis.input.evdev
-com.dgis.input.evdev.devices
diff --git a/doc/resources/inherit.gif b/doc/resources/inherit.gif
deleted file mode 100644
index c814867..0000000
Binary files a/doc/resources/inherit.gif and /dev/null differ
diff --git a/doc/stylesheet.css b/doc/stylesheet.css
deleted file mode 100644
index 6ea9e51..0000000
--- a/doc/stylesheet.css
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Javadoc style sheet */
-
-/* Define colors, fonts and other style attributes here to override the defaults */
-
-/* Page background color */
-body { background-color: #FFFFFF; color:#000000 }
-
-/* Headings */
-h1 { font-size: 145% }
-
-/* Table colors */
-.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
-.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
-.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-
-/* Navigation bar fonts and colors */
-.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
-.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
-.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
-
-.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
-.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
-
diff --git a/evdev-native-interface/.gitignore b/evdev-native-interface/.gitignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/evdev-native-interface/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/evdev-native-interface/pom.xml b/evdev-native-interface/pom.xml
new file mode 100644
index 0000000..de20aeb
--- /dev/null
+++ b/evdev-native-interface/pom.xml
@@ -0,0 +1,69 @@
+
+
+
+ 4.0.0
+
+ ch.ledcom.evdev
+ evdev-java
+ 1.2-SNAPSHOT
+
+
+ evdev-native-interface
+ evdev-java - Java interface to native code
+
+
+
+
+
+ com.github.github
+ site-maven-plugin
+
+ true
+ ${project.artifactId}
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+ org.pitest
+ pitest-maven
+
+
+ pitest
+ none
+
+
+
+
+
+
+
diff --git a/evdev-native-interface/src/main/java/com/dgis/input/evdev/NativeEventDevice.java b/evdev-native-interface/src/main/java/com/dgis/input/evdev/NativeEventDevice.java
new file mode 100644
index 0000000..c490841
--- /dev/null
+++ b/evdev-native-interface/src/main/java/com/dgis/input/evdev/NativeEventDevice.java
@@ -0,0 +1,33 @@
+/**
+ * This file is part of evdev-java - Java interface to native code.
+ *
+ * evdev-java - Java interface to native code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java interface to native code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java interface to native code. If not, see .
+ */
+package com.dgis.input.evdev;
+
+public class NativeEventDevice {
+
+ native boolean ioctlGetID(String device, short[] resp);
+
+ native int ioctlGetEvdevVersion(String device);
+
+ native boolean ioctlGetDeviceName(String device, byte[] resp);
+
+ native boolean ioctlEVIOCGBIT(String device, long[] resp, int start, int stop);
+
+ native boolean ioctlEVIOCGABS(String device, int[] resp, int axis);
+
+ native int ioctlEVIOCGRAB(int fd, int flags);
+
+}
diff --git a/evdev-native-interface/src/main/java/com/dgis/input/evdev/package-info.java b/evdev-native-interface/src/main/java/com/dgis/input/evdev/package-info.java
new file mode 100644
index 0000000..7613009
--- /dev/null
+++ b/evdev-native-interface/src/main/java/com/dgis/input/evdev/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * This file is part of evdev-java - Java interface to native code.
+ *
+ * evdev-java - Java interface to native code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java interface to native code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java interface to native code. If not, see .
+ */
+package com.dgis.input.evdev;
diff --git a/evdev-native/.gitignore b/evdev-native/.gitignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/evdev-native/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/evdev-native/pom.xml b/evdev-native/pom.xml
new file mode 100644
index 0000000..bc9a3bb
--- /dev/null
+++ b/evdev-native/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 4.0.0
+
+ ch.ledcom.evdev
+ evdev-java
+ 1.2-SNAPSHOT
+
+
+ evdev-native
+
+ so
+ evdev-java - Native implementation
+
+
+
+ ch.ledcom.evdev
+ evdev-native-interface
+ 1.2-SNAPSHOT
+
+
+
+
+
+
+ com.github.github
+ site-maven-plugin
+
+ true
+ ${project.artifactId}
+
+
+
+ org.pitest
+ pitest-maven
+
+
+ pitest
+ none
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ native-maven-plugin
+ 1.0-alpha-8
+ true
+
+
+ linux
+
+ -fPIC -O
+
+
+ -shared -lc -ldl
+
+
+ com.dgis.input.evdev.NativeEventDevice
+
+
+
+ src/main/native
+
+ evdev-java.c
+
+
+
+
+
+
+
+
+
diff --git a/native/evdev-java.c b/evdev-native/src/main/native/evdev-java.c
similarity index 66%
rename from native/evdev-java.c
rename to evdev-native/src/main/native/evdev-java.c
index 2263b73..830fb1c 100644
--- a/native/evdev-java.c
+++ b/evdev-native/src/main/native/evdev-java.c
@@ -1,3 +1,19 @@
+/**
+ * This file is part of evdev-java - Native implementation.
+ *
+ * evdev-java - Native implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Native implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Native implementation. If not, see .
+ */
#include
#include
@@ -7,14 +23,14 @@
#include
#include
-#include "com_dgis_input_evdev_EventDevice.h"
+#include "com_dgis_input_evdev_NativeEventDevice.h"
/*
- * Class: com_dgis_input_evdev_EventDevice
+ * Class: com_dgis_input_evdev_NativeEventDevice
* Method: ioctlGetID
* Signature: (Ljava/lang/String;[S)V
*/
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetID
+JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlGetID
(JNIEnv *env, jobject obj, jstring device_name, jshortArray out) {
/* Get C references to Java objects */
@@ -39,11 +55,11 @@ JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetID
}
/*
- * Class: com_dgis_input_evdev_EventDevice
+ * Class: com_dgis_input_evdev_NativeEventDevice
* Method: ioctlGetEvdevVersion
* Signature: (Ljava/lang/String;)I
*/
-JNIEXPORT jint JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetEvdevVersion
+JNIEXPORT jint JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlGetEvdevVersion
(JNIEnv *env, jobject obj, jstring device_name) {
/* Get C references to Java objects */
@@ -67,11 +83,11 @@ JNIEXPORT jint JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetEvdevVersio
}
/*
- * Class: com_dgis_input_evdev_EventDevice
+ * Class: com_dgis_input_evdev_NativeEventDevice
* Method: ioctlGetDeviceName
* Signature: ([BI)V
*/
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetDeviceName
+JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlGetDeviceName
(JNIEnv *env, jobject obj, jstring device_name, jbyteArray name) {
/* Get C references to Java objects */
@@ -96,11 +112,11 @@ JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetDeviceN
}
/*
- * Class: com_dgis_input_evdev_EventDevice
+ * Class: com_dgis_input_evdev_NativeEventDevice
* Method: ioctrlEVIOCGBIT
* Signature: (Ljava/lang/String;[J)Z
*/
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGBIT
+JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlEVIOCGBIT
(JNIEnv *env, jobject obj, jstring device_name, jlongArray out, jint start, jint stop) {
/* Get C references to Java objects */
const char* device_name_str = (*env)->GetStringUTFChars (env, device_name, NULL);
@@ -124,11 +140,11 @@ JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGBIT
}
/*
- * Class: com_dgis_input_evdev_EventDevice
+ * Class: com_dgis_input_evdev_NativeEventDevice
* Method: ioctlEVIOCGABS
* Signature: (Ljava/lang/String;[II)Z
*/
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGABS
+JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlEVIOCGABS
(JNIEnv *env, jobject obj, jstring device_name, jintArray out, jint axis) {
if((*env)->GetArrayLength(env, out) < 5) return 0;
@@ -153,3 +169,15 @@ JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGABS
return retval;
}
+
+/*
+ * Class: com_dgis_input_evdev_NativeEventDevice
+ * Method: ioctlEVIOCGRAB
+ * Signature: (II)Z
+ */
+JNIEXPORT jint JNICALL Java_com_dgis_input_evdev_NativeEventDevice_ioctlEVIOCGRAB
+ (JNIEnv *env, jobject obj, jint fd, jint flags) {
+
+ return ioctl(fd, EVIOCGRAB, flags);
+
+}
diff --git a/evdev/.gitignore b/evdev/.gitignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/evdev/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/evdev/pom.xml b/evdev/pom.xml
new file mode 100644
index 0000000..59d733e
--- /dev/null
+++ b/evdev/pom.xml
@@ -0,0 +1,170 @@
+
+
+
+ 4.0.0
+
+ ch.ledcom.evdev
+ evdev-java
+ 1.2-SNAPSHOT
+
+
+ evdev
+ evdev-java - Java implementation
+
+
+ 62
+ 80
+ 8
+
+
+
+
+ ch.ledcom.evdev
+ evdev-native
+ 1.2-SNAPSHOT
+ so
+
+
+ ch.ledcom.evdev
+ evdev-native-interface
+ 1.2-SNAPSHOT
+
+
+ org.mockito
+ mockito-core
+ 2.1.0-beta.120
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.7
+
+
+ org.projectlombok
+ lombok
+ 1.16.10
+ provided
+
+
+
+
+
+
+
+ com.github.github
+ site-maven-plugin
+
+ true
+ ${project.artifactId}
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+
+
+ 0
+ 0
+ 4
+ 13
+ 0
+ 0
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+ Max
+ Low
+ true
+
+
+
+
+ check
+
+ none
+
+
+
+
+ org.pitest
+ pitest-maven
+
+
+ com.dgis.input.evdev*
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ unpack-shared-resources
+
+ copy
+
+ generate-resources
+
+ ${project.build.directory}/generated-resources
+ true
+
+
+ ch.ledcom.evdev
+ evdev-native
+ ${project.version}
+ so
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.9.1
+
+
+ add-resource
+
+ add-resource
+
+ generate-resources
+
+
+
+ ${project.build.directory}/generated-resources
+
+
+
+
+
+
+
+
+
+
diff --git a/evdev/src/main/java/com/dgis/input/evdev/EvdevTest.java b/evdev/src/main/java/com/dgis/input/evdev/EvdevTest.java
new file mode 100644
index 0000000..54ece33
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/EvdevTest.java
@@ -0,0 +1,76 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Map.Entry;
+
+/**
+ * Simple program that prints info and all events from a device to STDOUT.
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+
+public class EvdevTest {
+
+ public static void main(String[] args) throws IOException {
+
+ if (args.length == 0) {
+ System.out.println("Usage: EvdevTest /dev/input/event*");
+ System.exit(1);
+ }
+
+ File fn = new File(args[0]);
+ EventDevice dev = new EventDevice(fn);
+ int version = dev.getEvdevVersion();
+ System.out.printf("Input driver version is %d.%d.%d\n",
+ version >>> 16, (version >>> 8) & 0xff, version & 0xff);
+
+ System.out.printf("Input device ID: bus 0x%x vendor 0x%x product 0x%x version 0x%x\n",
+ dev.getBusID(), dev.getVendorID(), dev.getProductID(), dev.getVersionID());
+ System.out.println("Input device name: " + dev.getDeviceName());
+ System.out.println("Supported events:");
+
+ for (Entry> e : dev.getSupportedEvents().entrySet()) {
+ System.out.println("Event type " + e.getKey() + " :");
+ for (int ev : e.getValue()) {
+ System.out.println("\tEvent code " + ev);
+ if (e.getKey() == InputEvent.EV_ABS) {
+ System.out.println("\t\t" + dev.getAxisParameters(ev));
+ }
+ }
+ }
+
+ System.out.println("Hit enter to quit.");
+
+ dev.addListener(System.out::println);
+ dev.grab();
+
+ //Wait for newline.
+ new BufferedReader(new InputStreamReader(System.in)).readLine();
+
+ dev.unGrab();
+ dev.close();
+ }
+
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/EventDevice.java b/evdev/src/main/java/com/dgis/input/evdev/EventDevice.java
new file mode 100644
index 0000000..834b4fe
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/EventDevice.java
@@ -0,0 +1,342 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import static sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess;
+
+/**
+ * Represents a connection to a Linux Evdev device.
+ *
+ * For additional info, see input/input.txt and input/input-programming.txt in the Linux kernel Documentation.
+ * IMPORTANT: If you want higher-level access for your joystick/pad/whatever, check @see com.dgis.input.evdev.devices
+ * for useful drivers to make your life easier!
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+public class EventDevice {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private final NativeEventDevice nativeEventDevice;
+
+ /** system architecture, for arch-specific struct handling */
+ private String arch = "amd64";
+
+ /**
+ * Notify these guys about input events.
+ */
+ private final List listeners = new CopyOnWriteArrayList<>();
+
+ /**
+ * Device filename we're using.
+ */
+ private final String device;
+
+ /**
+ * Attached to device we're using.
+ */
+ private FileChannel deviceInput;
+ private final ByteBuffer inputBuffer;
+ private int fd;
+
+
+ /**
+ * When this is true, the reader thread should terminate ASAP.
+ */
+ private volatile boolean terminate = false;
+
+ /**
+ * This thread repeatedly calls readEvent().
+ */
+ private Thread readerThread;
+
+ private final short[] idResponse = new short[4];
+
+ private int evdevVersionResponse;
+
+ private String deviceNameResponse;
+
+ /**
+ * Maps supported event types (keys) to lists of supported event codes.
+ */
+ private final HashMap> supportedEvents = new HashMap<>();
+
+
+ /**
+ * Ensures only one instance of InputAxisParameters is created for each axis (more would be wasteful).
+ */
+ private final HashMap axisParams = new HashMap<>();
+
+ /**
+ * Create an EventDevice by connecting to the provided device filename.
+ * If the device file is accessible, open it and begin listening for events.
+ *
+ * @param device The path to the device file. Usually one of /dev/input/event*
+ * @throws IOException If the device is not found, or is otherwise inaccessible.
+ */
+ public EventDevice(File device) throws IOException {
+ // check for embedded library:
+ arch = System.getProperty("os.arch");
+ logger.info("EventDevice: System: {}", arch);
+ if (arch.equals("arm")) {
+ inputBuffer = ByteBuffer.allocate(InputEvent.STRUCT_SIZE_BYTES_ARM);
+ } else {
+ inputBuffer = ByteBuffer.allocate(InputEvent.STRUCT_SIZE_BYTES);
+ }
+ String libPath = "/evdev-native.so";
+ logger.info("EventDevice: libPath: {}", libPath);
+ InputStream in = EventDevice.class.getResourceAsStream(libPath);
+ logger.info("EventDevice: in: {}", in);
+ if (in != null) {
+ final File nativeLibFile = File.createTempFile("libevdev-java", ".so");
+ nativeLibFile.deleteOnExit();
+
+ final OutputStream out = new BufferedOutputStream(new FileOutputStream(nativeLibFile));
+
+ int len;
+ byte[] buffer = new byte[8192];
+ while ((len = in.read(buffer)) > -1) {
+ out.write(buffer, 0, len);
+ }
+ out.close();
+ in.close();
+
+ System.load(nativeLibFile.getAbsolutePath());
+ } else {
+ logger.warn("EventDevice: falling back to java.library.path.");
+ System.loadLibrary("evdev-java");
+ }
+ this.device = device.getAbsolutePath();
+ this.nativeEventDevice = new NativeEventDevice();
+ inputBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ initDevice();
+ }
+
+ /**
+ * Get various ID info. Then, open the file, get the channel, and start the reader thread.
+ *
+ * @throws IOException
+ */
+ private void initDevice() throws IOException {
+ if (!nativeEventDevice.ioctlGetID(device, idResponse)) {
+ logger.error("WARN: couldn't get device ID: {}", device);
+ Arrays.fill(idResponse, (short) 0);
+ }
+ evdevVersionResponse = nativeEventDevice.ioctlGetEvdevVersion(device);
+ byte[] devName = new byte[255];
+ if (nativeEventDevice.ioctlGetDeviceName(device, devName)) {
+ deviceNameResponse = new String(devName);
+ } else {
+ logger.error("WARN: couldn't get device name: {}", device);
+ deviceNameResponse = "Unknown Device";
+ }
+
+ readSupportedEvents();
+
+ FileInputStream fis = new FileInputStream(device);
+ deviceInput = fis.getChannel();
+ fd = getJavaIOFileDescriptorAccess().get(fis.getFD());
+
+ readerThread = new Thread() {
+ @Override
+ public void run() {
+ while (!terminate) {
+ InputEvent ev = readEvent();
+ distributeEvent(ev);
+ }
+ }
+ };
+ readerThread.setDaemon(true); /* We don't want this thread to prevent the JVM from terminating */
+
+ readerThread.start();
+ }
+
+ /**
+ * Get supported events from device, and place into supportedEvents.
+ * Adapted from evtest.c.
+ */
+ private void readSupportedEvents() {
+ //System.out.println("Detecting device capabilities...");
+ long[][] bit = new long[InputEvent.EV_MAX][NBITS(InputEvent.KEY_MAX)];
+ nativeEventDevice.ioctlEVIOCGBIT(device, bit[0], 0, bit[0].length);
+ /* Loop over event types */
+ for (int i = 0; i < InputEvent.EV_MAX; i++) {
+ if (testBit(bit[0], i)) { /* Is this event supported? */
+ //System.out.printf(" Event type %d\n", i);
+ if (i == 0) continue;
+ ArrayList supportedTypes = new ArrayList<>();
+ nativeEventDevice.ioctlEVIOCGBIT(device, bit[i], i, InputEvent.KEY_MAX);
+ /* Loop over event codes for type */
+ for (int j = 0; j < InputEvent.KEY_MAX; j++)
+ if (testBit(bit[i], j)) { /* Is this event code supported? */
+ //System.out.printf(" Event code %d\n", j);
+ supportedTypes.add(j);
+ }
+ supportedEvents.put(i, supportedTypes);
+ }
+ }
+ }
+
+ private boolean testBit(long[] array, int bit) {
+ return ((array[LONG(bit)] >>> OFF(bit)) & 1) != 0;
+ }
+
+ private int LONG(int x) {
+ return x / (64);
+ }
+
+ private int OFF(int x) {
+ return x % (64);
+ }
+
+ private int NBITS(int x) {
+ return ((((x) - 1) / (8 * 8)) + 1);
+ }
+
+ /**
+ * Distribute an event to all registered listeners.
+ *
+ * @param inputEvent The event to distribute.
+ */
+ private void distributeEvent(InputEvent inputEvent) {
+ for (InputListener listener : listeners) {
+ listener.event(inputEvent);
+ }
+ }
+
+ /**
+ * Obtain an InputEvent from the input channel. Delegate to InputEvent for parsing.
+ *
+ * @return
+ */
+ private InputEvent readEvent() {
+ try {
+ /* Read exactly the amount of bytes specified by InputEvent.STRUCT_SIZE_BYTES (intrinsic size of inputBuffer)*/
+ inputBuffer.clear();
+ while (inputBuffer.hasRemaining()) deviceInput.read(inputBuffer);
+
+ /* We want to read now */
+ inputBuffer.flip();
+
+ /* Delegate parsing to InputEvent.parse() */
+ return InputEvent.parse(inputBuffer.asShortBuffer(), device, arch);
+ } catch (IOException e) {
+ logger.error("Cannot read event", e);
+ return null;
+ }
+ }
+
+ public void close() {
+ terminate = true;
+ try {
+ readerThread.join();
+ } catch (InterruptedException e) {
+ logger.error("Interrupted in close", e);
+ }
+ try {
+ deviceInput.close();
+ } catch (IOException e) {
+ logger.error("Error in close", e);
+ }
+ }
+
+ public short getBusID() {
+ return idResponse[InputEvent.ID_BUS];
+ }
+
+ public String getDeviceName() {
+ return deviceNameResponse;
+ }
+
+ public short getProductID() {
+ return idResponse[InputEvent.ID_PRODUCT];
+ }
+
+ public Map> getSupportedEvents() {
+ return supportedEvents;
+ }
+
+ public short getVendorID() {
+ return idResponse[InputEvent.ID_VENDOR];
+ }
+
+ public int getEvdevVersion() {
+ return evdevVersionResponse;
+ }
+
+ public short getVersionID() {
+ return idResponse[InputEvent.ID_VERSION];
+ }
+
+ public InputAxisParameters getAxisParameters(int axis) {
+ InputAxisParameters params;
+ if ((params = axisParams.get(axis)) == null) {
+ params = new InputAxisParameters(this, axis);
+ axisParams.put(axis, params);
+ }
+ return params;
+ }
+
+ public void addListener(InputListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(InputListener listener) {
+ listeners.remove(listener);
+ }
+
+ public String getDevicePath() {
+ return device;
+ }
+
+ public boolean ioctlEVIOCGABS(String device, int[] resp, int axis) {
+ return nativeEventDevice.ioctlEVIOCGABS(device, resp, axis);
+ }
+
+ public void grab() {
+ if (nativeEventDevice.ioctlEVIOCGRAB(fd, 1) == 0) return;
+ throw new RuntimeException("Could not grab device");
+ }
+
+ public void unGrab() {
+ if (nativeEventDevice.ioctlEVIOCGRAB(fd, 0) == 0) return;
+ throw new RuntimeException("Could not ungrab device");
+ }
+
+}
+
diff --git a/evdev/src/main/java/com/dgis/input/evdev/EventType.java b/evdev/src/main/java/com/dgis/input/evdev/EventType.java
new file mode 100644
index 0000000..33c25b1
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/EventType.java
@@ -0,0 +1,63 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import lombok.Getter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.lang.String.format;
+
+public enum EventType {
+
+ EV_SYN((short) 0x00),
+ EV_KEY((short) 0x01),
+ EV_REL((short) 0x02),
+ EV_ABS((short) 0x03),
+ EV_MSC((short) 0x04),
+ EV_SW((short) 0x05),
+ EV_LED((short) 0x11),
+ EV_SND((short) 0x12),
+ EV_REP((short) 0x14),
+ EV_FF((short) 0x15),
+ EV_PWR((short) 0x16),
+ EV_FF_STATUS((short) 0x17),
+ EV_MAX((short) 0x1f),
+ EV_CNT((short) (0x1f + 1));
+
+ private static final Map VALUE_LOOKUP = new HashMap<>();
+
+ static {
+ for (EventType eventType : EventType.values()) {
+ VALUE_LOOKUP.put(eventType.value, eventType);
+ }
+ }
+
+ @Getter
+ private final short value;
+
+ EventType(short value) {
+ this.value = value;
+ }
+
+ public static EventType valueOf(short value) {
+ if (VALUE_LOOKUP.containsKey(value)) return VALUE_LOOKUP.get(value);
+ throw new IllegalArgumentException(format("Unknown event type: %s", value));
+ }
+
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/EventValue.java b/evdev/src/main/java/com/dgis/input/evdev/EventValue.java
new file mode 100644
index 0000000..c802485
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/EventValue.java
@@ -0,0 +1,52 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import lombok.Getter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.lang.String.format;
+
+public enum EventValue {
+
+ TT(1);
+
+ private static final Map VALUE_LOOKUP = new HashMap<>();
+
+ static {
+ for (EventValue eventValue : EventValue.values()) {
+ VALUE_LOOKUP.put(eventValue.value, eventValue);
+ }
+ }
+
+ @Getter
+ private final int value;
+
+ EventValue(int value) {
+ this.value = value;
+ }
+
+ public static EventValue valueOf(int value) {
+ if (VALUE_LOOKUP.containsKey(value)) return VALUE_LOOKUP.get(value);
+ throw new IllegalArgumentException(format("Unknown event value: %s", value));
+ }
+
+
+
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/InputAxisParameters.java b/evdev/src/main/java/com/dgis/input/evdev/InputAxisParameters.java
new file mode 100644
index 0000000..a9442f5
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/InputAxisParameters.java
@@ -0,0 +1,81 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import javax.annotation.concurrent.ThreadSafe;
+
+/**
+ * Represents configurable parameters of an input axis. set*() should affect the value in the device.
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+@ThreadSafe
+class InputAxisParameters {
+
+ private final EventDevice device;
+ private final int axis;
+
+ private static final int VALUE_INDEX = 0;
+ private static final int MIN_INDEX = 1;
+ private static final int MAX_INDEX = 2;
+ private static final int FUZZ_INDEX = 3;
+ private static final int FLAT_INDEX = 4;
+
+ public InputAxisParameters(EventDevice device, int axis) {
+ this.device = device;
+ this.axis = axis;
+ }
+
+ private int readStatus(int i) {
+ if (i < 0 || i > 4) {
+ throw new IllegalArgumentException("Field index has to be between 0 and 4");
+ }
+ int[] resp = new int[5];
+ synchronized (this) {
+ device.ioctlEVIOCGABS(device.getDevicePath(), resp, axis);
+ }
+ return resp[i];
+ }
+
+ public int getValue() {
+ return readStatus(VALUE_INDEX);
+ }
+
+ public int getMin() {
+ return readStatus(MIN_INDEX);
+ }
+
+ public int getMax() {
+ return readStatus(MAX_INDEX);
+ }
+
+ public int getFuzz() {
+ return readStatus(FUZZ_INDEX);
+ }
+
+ public int getFlat() {
+ return readStatus(FLAT_INDEX);
+ }
+
+ @Override
+ public String toString() {
+ return "Value: " + getValue() + " Min: " + getMin() + " Max: "
+ + getMax() + " Fuzz: " + getFuzz() + " Flat: " + getFlat();
+ }
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/InputEvent.java b/evdev/src/main/java/com/dgis/input/evdev/InputEvent.java
new file mode 100644
index 0000000..f6a5df8
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/InputEvent.java
@@ -0,0 +1,877 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import javax.annotation.concurrent.Immutable;
+import java.io.IOException;
+import java.nio.ShortBuffer;
+
+import static com.dgis.input.evdev.EventType.valueOf;
+
+/**
+ * Analog to the input_event struct in linux/input.h.
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+@ToString
+@EqualsAndHashCode
+@Immutable
+public class InputEvent {
+ /**
+ * size of the input_event struct in bytes.
+ */
+ public static final int STRUCT_SIZE_BYTES = 24;
+ public static final int STRUCT_SIZE_BYTES_ARM = 16;
+
+ /* Event types */
+
+ public static final short EV_SYN = 0x00;
+ public static final short EV_KEY = 0x01;
+ public static final short EV_REL = 0x02;
+ public static final short EV_ABS = 0x03;
+ public static final short EV_MSC = 0x04;
+ public static final short EV_SW = 0x05;
+ public static final short EV_LED = 0x11;
+ public static final short EV_SND = 0x12;
+ public static final short EV_REP = 0x14;
+ public static final short EV_FF = 0x15;
+ public static final short EV_PWR = 0x16;
+ public static final short EV_FF_STATUS = 0x17;
+ public static final short EV_MAX = 0x1f;
+ public static final short EV_CNT = (EV_MAX + 1);
+
+ /* Synchronization events. */
+
+ public static final short SYN_REPORT = 0;
+ public static final short SYN_CONFIG = 1;
+ public static final short SYN_MT_REPORT = 2;
+
+ /*
+ * Keys and buttons
+ *
+ * Most of the keys/buttons are modeled after USB HUT 1.12 (see
+ * http://www.usb.org/developers/hidpage). Abbreviations in the comments: AC
+ * - Application Control AL - Application Launch Button SC - System Control
+ */
+
+ public static final short KEY_RESERVED = 0;
+ public static final short KEY_ESC = 1;
+ public static final short KEY_1 = 2;
+ public static final short KEY_2 = 3;
+ public static final short KEY_3 = 4;
+ public static final short KEY_4 = 5;
+ public static final short KEY_5 = 6;
+ public static final short KEY_6 = 7;
+ public static final short KEY_7 = 8;
+ public static final short KEY_8 = 9;
+ public static final short KEY_9 = 10;
+ public static final short KEY_0 = 11;
+ public static final short KEY_MINUS = 12;
+ public static final short KEY_EQUAL = 13;
+ public static final short KEY_BACKSPACE = 14;
+ public static final short KEY_TAB = 15;
+ public static final short KEY_Q = 16;
+ public static final short KEY_W = 17;
+ public static final short KEY_E = 18;
+ public static final short KEY_R = 19;
+ public static final short KEY_T = 20;
+ public static final short KEY_Y = 21;
+ public static final short KEY_U = 22;
+ public static final short KEY_I = 23;
+ public static final short KEY_O = 24;
+ public static final short KEY_P = 25;
+ public static final short KEY_LEFTBRACE = 26;
+ public static final short KEY_RIGHTBRACE = 27;
+ public static final short KEY_ENTER = 28;
+ public static final short KEY_LEFTCTRL = 29;
+ public static final short KEY_A = 30;
+ public static final short KEY_S = 31;
+ public static final short KEY_D = 32;
+ public static final short KEY_F = 33;
+ public static final short KEY_G = 34;
+ public static final short KEY_H = 35;
+ public static final short KEY_J = 36;
+ public static final short KEY_K = 37;
+ public static final short KEY_L = 38;
+ public static final short KEY_SEMICOLON = 39;
+ public static final short KEY_APOSTROPHE = 40;
+ public static final short KEY_GRAVE = 41;
+ public static final short KEY_LEFTSHIFT = 42;
+ public static final short KEY_BACKSLASH = 43;
+ public static final short KEY_Z = 44;
+ public static final short KEY_X = 45;
+ public static final short KEY_C = 46;
+ public static final short KEY_V = 47;
+ public static final short KEY_B = 48;
+ public static final short KEY_N = 49;
+ public static final short KEY_M = 50;
+ public static final short KEY_COMMA = 51;
+ public static final short KEY_DOT = 52;
+ public static final short KEY_SLASH = 53;
+ public static final short KEY_RIGHTSHIFT = 54;
+ public static final short KEY_KPASTERISK = 55;
+ public static final short KEY_LEFTALT = 56;
+ public static final short KEY_SPACE = 57;
+ public static final short KEY_CAPSLOCK = 58;
+ public static final short KEY_F1 = 59;
+ public static final short KEY_F2 = 60;
+ public static final short KEY_F3 = 61;
+ public static final short KEY_F4 = 62;
+ public static final short KEY_F5 = 63;
+ public static final short KEY_F6 = 64;
+ public static final short KEY_F7 = 65;
+ public static final short KEY_F8 = 66;
+ public static final short KEY_F9 = 67;
+ public static final short KEY_F10 = 68;
+ public static final short KEY_NUMLOCK = 69;
+ public static final short KEY_SCROLLLOCK = 70;
+ public static final short KEY_KP7 = 71;
+ public static final short KEY_KP8 = 72;
+ public static final short KEY_KP9 = 73;
+ public static final short KEY_KPMINUS = 74;
+ public static final short KEY_KP4 = 75;
+ public static final short KEY_KP5 = 76;
+ public static final short KEY_KP6 = 77;
+ public static final short KEY_KPPLUS = 78;
+ public static final short KEY_KP1 = 79;
+ public static final short KEY_KP2 = 80;
+ public static final short KEY_KP3 = 81;
+ public static final short KEY_KP0 = 82;
+ public static final short KEY_KPDOT = 83;
+
+ public static final short KEY_ZENKAKUHANKAKU = 85;
+ public static final short KEY_102ND = 86;
+ public static final short KEY_F11 = 87;
+ public static final short KEY_F12 = 88;
+ public static final short KEY_RO = 89;
+ public static final short KEY_KATAKANA = 90;
+ public static final short KEY_HIRAGANA = 91;
+ public static final short KEY_HENKAN = 92;
+ public static final short KEY_KATAKANAHIRAGANA = 93;
+ public static final short KEY_MUHENKAN = 94;
+ public static final short KEY_KPJPCOMMA = 95;
+ public static final short KEY_KPENTER = 96;
+ public static final short KEY_RIGHTCTRL = 97;
+ public static final short KEY_KPSLASH = 98;
+ public static final short KEY_SYSRQ = 99;
+ public static final short KEY_RIGHTALT = 100;
+ public static final short KEY_LINEFEED = 101;
+ public static final short KEY_HOME = 102;
+ public static final short KEY_UP = 103;
+ public static final short KEY_PAGEUP = 104;
+ public static final short KEY_LEFT = 105;
+ public static final short KEY_RIGHT = 106;
+ public static final short KEY_END = 107;
+ public static final short KEY_DOWN = 108;
+ public static final short KEY_PAGEDOWN = 109;
+ public static final short KEY_INSERT = 110;
+ public static final short KEY_DELETE = 111;
+ public static final short KEY_MACRO = 112;
+ public static final short KEY_MUTE = 113;
+ public static final short KEY_VOLUMEDOWN = 114;
+ public static final short KEY_VOLUMEUP = 115;
+ /** SC System Power Down */
+ public static final short KEY_POWER = 116;
+ public static final short KEY_KPEQUAL = 117;
+ public static final short KEY_KPPLUSMINUS = 118;
+ public static final short KEY_PAUSE = 119;
+ /** AL Compiz Scale (Expose) */
+ public static final short KEY_SCALE = 120;
+
+ public static final short KEY_KPCOMMA = 121;
+ public static final short KEY_HANGEUL = 122;
+ public static final short KEY_HANGUEL = KEY_HANGEUL;
+ public static final short KEY_HANJA = 123;
+ public static final short KEY_YEN = 124;
+ public static final short KEY_LEFTMETA = 125;
+ public static final short KEY_RIGHTMETA = 126;
+ public static final short KEY_COMPOSE = 127;
+
+ /** AC Stop */
+ public static final short KEY_STOP = 128;
+ public static final short KEY_AGAIN = 129;
+ /** AC Properties */
+ public static final short KEY_PROPS = 130;
+ /** AC Undo */
+ public static final short KEY_UNDO = 131;
+ public static final short KEY_FRONT = 132;
+ /** AC Copy */
+ public static final short KEY_COPY = 133;
+ /** AC Open */
+ public static final short KEY_OPEN = 134;
+ /** AC Paste */
+ public static final short KEY_PASTE = 135;
+ /** AC Search */
+ public static final short KEY_FIND = 136;
+ /** AC Cut */
+ public static final short KEY_CUT = 137;
+ /** AL Integrated Help Center */
+ public static final short KEY_HELP = 138;
+ /** Menu (show menu) */
+ public static final short KEY_MENU = 139;
+ /** AL Calculator */
+ public static final short KEY_CALC = 140;
+ public static final short KEY_SETUP = 141;
+ /** SC System Sleep */
+ public static final short KEY_SLEEP = 142;
+ /** System Wake Up */
+ public static final short KEY_WAKEUP = 143;
+ /** AL Local Machine Browser */
+ public static final short KEY_FILE = 144;
+ public static final short KEY_SENDFILE = 145;
+ public static final short KEY_DELETEFILE = 146;
+ public static final short KEY_XFER = 147;
+ public static final short KEY_PROG1 = 148;
+ public static final short KEY_PROG2 = 149;
+ /** AL Internet Browser */
+ public static final short KEY_WWW = 150;
+ public static final short KEY_MSDOS = 151;
+ /** AL Terminal Lock/Screensaver */
+ public static final short KEY_COFFEE = 152;
+ public static final short KEY_SCREENLOCK = KEY_COFFEE;
+ public static final short KEY_DIRECTION = 153;
+ public static final short KEY_CYCLEWINDOWS = 154;
+ public static final short KEY_MAIL = 155;
+ /** AC Bookmarks */
+ public static final short KEY_BOOKMARKS = 156;
+ public static final short KEY_COMPUTER = 157;
+ /** AC Back */
+ public static final short KEY_BACK = 158;
+ /** AC Forward */
+ public static final short KEY_FORWARD = 159;
+ public static final short KEY_CLOSECD = 160;
+ public static final short KEY_EJECTCD = 161;
+ public static final short KEY_EJECTCLOSECD = 162;
+ public static final short KEY_NEXTSONG = 163;
+ public static final short KEY_PLAYPAUSE = 164;
+ public static final short KEY_PREVIOUSSONG = 165;
+ public static final short KEY_STOPCD = 166;
+ public static final short KEY_RECORD = 167;
+ public static final short KEY_REWIND = 168;
+ /** Media Select Telephone */
+ public static final short KEY_PHONE = 169;
+ public static final short KEY_ISO = 170;
+ /** AL Consumer Control Configuration */
+ public static final short KEY_CONFIG = 171;
+ /** AC Home */
+ public static final short KEY_HOMEPAGE = 172;
+ /** AC Refresh */
+ public static final short KEY_REFRESH = 173;
+ /** AC Exit */
+ public static final short KEY_EXIT = 174;
+ public static final short KEY_MOVE = 175;
+ public static final short KEY_EDIT = 176;
+ public static final short KEY_SCROLLUP = 177;
+ public static final short KEY_SCROLLDOWN = 178;
+ public static final short KEY_KPLEFTPAREN = 179;
+ public static final short KEY_KPRIGHTPAREN = 180;
+ /** AC New */
+ public static final short KEY_NEW = 181;
+ /** AC Redo/Repeat */
+ public static final short KEY_REDO = 182;
+
+ public static final short KEY_F13 = 183;
+ public static final short KEY_F14 = 184;
+ public static final short KEY_F15 = 185;
+ public static final short KEY_F16 = 186;
+ public static final short KEY_F17 = 187;
+ public static final short KEY_F18 = 188;
+ public static final short KEY_F19 = 189;
+ public static final short KEY_F20 = 190;
+ public static final short KEY_F21 = 191;
+ public static final short KEY_F22 = 192;
+ public static final short KEY_F23 = 193;
+ public static final short KEY_F24 = 194;
+
+ public static final short KEY_PLAYCD = 200;
+ public static final short KEY_PAUSECD = 201;
+ public static final short KEY_PROG3 = 202;
+ public static final short KEY_PROG4 = 203;
+ /** AL Dashboard */
+ public static final short KEY_DASHBOARD = 204;
+ public static final short KEY_SUSPEND = 205;
+ /** AC Close */
+ public static final short KEY_CLOSE = 206;
+ public static final short KEY_PLAY = 207;
+ public static final short KEY_FASTFORWARD = 208;
+ public static final short KEY_BASSBOOST = 209;
+ /** AC Print */
+ public static final short KEY_PRINT = 210;
+ public static final short KEY_HP = 211;
+ public static final short KEY_CAMERA = 212;
+ public static final short KEY_SOUND = 213;
+ public static final short KEY_QUESTION = 214;
+ public static final short KEY_EMAIL = 215;
+ public static final short KEY_CHAT = 216;
+ public static final short KEY_SEARCH = 217;
+ public static final short KEY_CONNECT = 218;
+ /** AL Checkbook/Finance */
+ public static final short KEY_FINANCE = 219;
+ public static final short KEY_SPORT = 220;
+ public static final short KEY_SHOP = 221;
+ public static final short KEY_ALTERASE = 222;
+ /** AC Cancel */
+ public static final short KEY_CANCEL = 223;
+ public static final short KEY_BRIGHTNESSDOWN = 224;
+ public static final short KEY_BRIGHTNESSUP = 225;
+ public static final short KEY_MEDIA = 226;
+
+ /** Cycle between available video outputs (Monitor/LCD/TV-out/etc) */
+ public static final short KEY_SWITCHVIDEOMODE = 227;
+ public static final short KEY_KBDILLUMTOGGLE = 228;
+ public static final short KEY_KBDILLUMDOWN = 229;
+ public static final short KEY_KBDILLUMUP = 230;
+
+ /** AC Send */
+ public static final short KEY_SEND = 231;
+ /** AC Reply */
+ public static final short KEY_REPLY = 232;
+ /** AC Forward Msg */
+ public static final short KEY_FORWARDMAIL = 233;
+ /** AC Save */
+ public static final short KEY_SAVE = 234;
+ public static final short KEY_DOCUMENTS = 235;
+
+ public static final short KEY_BATTERY = 236;
+
+ public static final short KEY_BLUETOOTH = 237;
+ public static final short KEY_WLAN = 238;
+ public static final short KEY_UWB = 239;
+
+ public static final short KEY_UNKNOWN = 240;
+
+ /** drive next video source */
+ public static final short KEY_VIDEO_NEXT = 241;
+ /** drive previous video source */
+ public static final short KEY_VIDEO_PREV = 242;
+ /** brightness up, after max is min */
+ public static final short KEY_BRIGHTNESS_CYCLE = 243;
+ /** brightness off, use ambient */
+ public static final short KEY_BRIGHTNESS_ZERO = 244;
+ /** display device to off state */
+ public static final short KEY_DISPLAY_OFF = 245;
+
+ public static final short KEY_WIMAX = 246;
+
+ /* Range 248 - 255 is reserved for special needs of AT keyboard driver */
+
+ public static final short BTN_MISC = 0x100;
+ public static final short BTN_0 = 0x100;
+ public static final short BTN_1 = 0x101;
+ public static final short BTN_2 = 0x102;
+ public static final short BTN_3 = 0x103;
+ public static final short BTN_4 = 0x104;
+ public static final short BTN_5 = 0x105;
+ public static final short BTN_6 = 0x106;
+ public static final short BTN_7 = 0x107;
+ public static final short BTN_8 = 0x108;
+ public static final short BTN_9 = 0x109;
+
+ public static final short BTN_MOUSE = 0x110;
+ public static final short BTN_LEFT = 0x110;
+ public static final short BTN_RIGHT = 0x111;
+ public static final short BTN_MIDDLE = 0x112;
+ public static final short BTN_SIDE = 0x113;
+ public static final short BTN_EXTRA = 0x114;
+ public static final short BTN_FORWARD = 0x115;
+ public static final short BTN_BACK = 0x116;
+ public static final short BTN_TASK = 0x117;
+
+ public static final short BTN_JOYSTICK = 0x120;
+ public static final short BTN_TRIGGER = 0x120;
+ public static final short BTN_THUMB = 0x121;
+ public static final short BTN_THUMB2 = 0x122;
+ public static final short BTN_TOP = 0x123;
+ public static final short BTN_TOP2 = 0x124;
+ public static final short BTN_PINKIE = 0x125;
+ public static final short BTN_BASE = 0x126;
+ public static final short BTN_BASE2 = 0x127;
+ public static final short BTN_BASE3 = 0x128;
+ public static final short BTN_BASE4 = 0x129;
+ public static final short BTN_BASE5 = 0x12a;
+ public static final short BTN_BASE6 = 0x12b;
+ public static final short BTN_DEAD = 0x12f;
+
+ public static final short BTN_GAMEPAD = 0x130;
+ public static final short BTN_A = 0x130;
+ public static final short BTN_B = 0x131;
+ public static final short BTN_C = 0x132;
+ public static final short BTN_X = 0x133;
+ public static final short BTN_Y = 0x134;
+ public static final short BTN_Z = 0x135;
+ public static final short BTN_TL = 0x136;
+ public static final short BTN_TR = 0x137;
+ public static final short BTN_TL2 = 0x138;
+ public static final short BTN_TR2 = 0x139;
+ public static final short BTN_SELECT = 0x13a;
+ public static final short BTN_START = 0x13b;
+ public static final short BTN_MODE = 0x13c;
+ public static final short BTN_THUMBL = 0x13d;
+ public static final short BTN_THUMBR = 0x13e;
+
+ public static final short BTN_DIGI = 0x140;
+ public static final short BTN_TOOL_PEN = 0x140;
+ public static final short BTN_TOOL_RUBBER = 0x141;
+ public static final short BTN_TOOL_BRUSH = 0x142;
+ public static final short BTN_TOOL_PENCIL = 0x143;
+ public static final short BTN_TOOL_AIRBRUSH = 0x144;
+ public static final short BTN_TOOL_FINGER = 0x145;
+ public static final short BTN_TOOL_MOUSE = 0x146;
+ public static final short BTN_TOOL_LENS = 0x147;
+ public static final short BTN_TOUCH = 0x14a;
+ public static final short BTN_STYLUS = 0x14b;
+ public static final short BTN_STYLUS2 = 0x14c;
+ public static final short BTN_TOOL_DOUBLETAP = 0x14d;
+ public static final short BTN_TOOL_TRIPLETAP = 0x14e;
+ /** Four fingers on trackpad */
+ public static final short BTN_TOOL_QUADTAP = 0x14f;
+
+ public static final short BTN_WHEEL = 0x150;
+ public static final short BTN_GEAR_DOWN = 0x150;
+ public static final short BTN_GEAR_UP = 0x151;
+
+ public static final short KEY_OK = 0x160;
+ public static final short KEY_SELECT = 0x161;
+ public static final short KEY_GOTO = 0x162;
+ public static final short KEY_CLEAR = 0x163;
+ public static final short KEY_POWER2 = 0x164;
+ public static final short KEY_OPTION = 0x165;
+ /** AL OEM Features/Tips/Tutorial */
+ public static final short KEY_INFO = 0x166;
+ public static final short KEY_TIME = 0x167;
+ public static final short KEY_VENDOR = 0x168;
+ public static final short KEY_ARCHIVE = 0x169;
+ /** Media Select Program Guide */
+ public static final short KEY_PROGRAM = 0x16a;
+ public static final short KEY_CHANNEL = 0x16b;
+ public static final short KEY_FAVORITES = 0x16c;
+ public static final short KEY_EPG = 0x16d;
+ /** Media Select Home */
+ public static final short KEY_PVR = 0x16e;
+ public static final short KEY_MHP = 0x16f;
+ public static final short KEY_LANGUAGE = 0x170;
+ public static final short KEY_TITLE = 0x171;
+ public static final short KEY_SUBTITLE = 0x172;
+ public static final short KEY_ANGLE = 0x173;
+ public static final short KEY_ZOOM = 0x174;
+ public static final short KEY_MODE = 0x175;
+ public static final short KEY_KEYBOARD = 0x176;
+ public static final short KEY_SCREEN = 0x177;
+ /** Media Select Computer */
+ public static final short KEY_PC = 0x178;
+ /** Media Select TV */
+ public static final short KEY_TV = 0x179;
+ /** Media Select Cable */
+ public static final short KEY_TV2 = 0x17a;
+ /** Media Select VCR */
+ public static final short KEY_VCR = 0x17b;
+ /** VCR Plus */
+ public static final short KEY_VCR2 = 0x17c;
+ /** Media Select Satellite */
+ public static final short KEY_SAT = 0x17d;
+ public static final short KEY_SAT2 = 0x17e;
+ /** Media Select CD */
+ public static final short KEY_CD = 0x17f;
+ /** Media Select Tape */
+ public static final short KEY_TAPE = 0x180;
+ public static final short KEY_RADIO = 0x181;
+ /** Media Select Tuner */
+ public static final short KEY_TUNER = 0x182;
+ public static final short KEY_PLAYER = 0x183;
+ public static final short KEY_TEXT = 0x184;
+ /** Media Select DVD */
+ public static final short KEY_DVD = 0x185;
+ public static final short KEY_AUX = 0x186;
+ public static final short KEY_MP3 = 0x187;
+ public static final short KEY_AUDIO = 0x188;
+ public static final short KEY_VIDEO = 0x189;
+ public static final short KEY_DIRECTORY = 0x18a;
+ public static final short KEY_LIST = 0x18b;
+ /** Media Select Messages */
+ public static final short KEY_MEMO = 0x18c;
+ public static final short KEY_CALENDAR = 0x18d;
+ public static final short KEY_RED = 0x18e;
+ public static final short KEY_GREEN = 0x18f;
+ public static final short KEY_YELLOW = 0x190;
+ public static final short KEY_BLUE = 0x191;
+ /** Channel Increment */
+ public static final short KEY_CHANNELUP = 0x192;
+ /** Channel Decrement */
+ public static final short KEY_CHANNELDOWN = 0x193;
+ public static final short KEY_FIRST = 0x194;
+ /** Recall Last */
+ public static final short KEY_LAST = 0x195;
+ public static final short KEY_AB = 0x196;
+ public static final short KEY_NEXT = 0x197;
+ public static final short KEY_RESTART = 0x198;
+ public static final short KEY_SLOW = 0x199;
+ public static final short KEY_SHUFFLE = 0x19a;
+ public static final short KEY_BREAK = 0x19b;
+ public static final short KEY_PREVIOUS = 0x19c;
+ public static final short KEY_DIGITS = 0x19d;
+ public static final short KEY_TEEN = 0x19e;
+ public static final short KEY_TWEN = 0x19f;
+ /** Media Select Video Phone */
+ public static final short KEY_VIDEOPHONE = 0x1a0;
+ /** Media Select Games */
+ public static final short KEY_GAMES = 0x1a1;
+ /** AC Zoom In */
+ public static final short KEY_ZOOMIN = 0x1a2;
+ /** AC Zoom Out */
+ public static final short KEY_ZOOMOUT = 0x1a3;
+ /** AC Zoom */
+ public static final short KEY_ZOOMRESET = 0x1a4;
+ /** AL Word Processor */
+ public static final short KEY_WORDPROCESSOR = 0x1a5;
+ /** AL Text Editor */
+ public static final short KEY_EDITOR = 0x1a6;
+ /** AL Spreadsheet */
+ public static final short KEY_SPREADSHEET = 0x1a7;
+ /** AL Graphics Editor */
+ public static final short KEY_GRAPHICSEDITOR = 0x1a8;
+ /** AL Presentation App */
+ public static final short KEY_PRESENTATION = 0x1a9;
+ /** AL Database App */
+ public static final short KEY_DATABASE = 0x1aa;
+ /** AL Newsreader */
+ public static final short KEY_NEWS = 0x1ab;
+ /** AL Voicemail */
+ public static final short KEY_VOICEMAIL = 0x1ac;
+ /** AL Contacts/Address Book */
+ public static final short KEY_ADDRESSBOOK = 0x1ad;
+ /** AL Instant Messaging */
+ public static final short KEY_MESSENGER = 0x1ae;
+ /** Turn display (LCD) on and off */
+ public static final short KEY_DISPLAYTOGGLE = 0x1af;
+ /** AL Spell Check */
+ public static final short KEY_SPELLCHECK = 0x1b0;
+ /** AL Logoff */
+ public static final short KEY_LOGOFF = 0x1b1;
+
+ public static final short KEY_DOLLAR = 0x1b2;
+ public static final short KEY_EURO = 0x1b3;
+
+ /** Consumer - transport controls */
+ public static final short KEY_FRAMEBACK = 0x1b4;
+ public static final short KEY_FRAMEFORWARD = 0x1b5;
+ /** GenDesc - system context menu */
+ public static final short KEY_CONTEXT_MENU = 0x1b6;
+ /** Consumer - transport control */
+ public static final short KEY_MEDIA_REPEAT = 0x1b7;
+
+ public static final short KEY_DEL_EOL = 0x1c0;
+ public static final short KEY_DEL_EOS = 0x1c1;
+ public static final short KEY_INS_LINE = 0x1c2;
+ public static final short KEY_DEL_LINE = 0x1c3;
+
+ public static final short KEY_FN = 0x1d0;
+ public static final short KEY_FN_ESC = 0x1d1;
+ public static final short KEY_FN_F1 = 0x1d2;
+ public static final short KEY_FN_F2 = 0x1d3;
+ public static final short KEY_FN_F3 = 0x1d4;
+ public static final short KEY_FN_F4 = 0x1d5;
+ public static final short KEY_FN_F5 = 0x1d6;
+ public static final short KEY_FN_F6 = 0x1d7;
+ public static final short KEY_FN_F7 = 0x1d8;
+ public static final short KEY_FN_F8 = 0x1d9;
+ public static final short KEY_FN_F9 = 0x1da;
+ public static final short KEY_FN_F10 = 0x1db;
+ public static final short KEY_FN_F11 = 0x1dc;
+ public static final short KEY_FN_F12 = 0x1dd;
+ public static final short KEY_FN_1 = 0x1de;
+ public static final short KEY_FN_2 = 0x1df;
+ public static final short KEY_FN_D = 0x1e0;
+ public static final short KEY_FN_E = 0x1e1;
+ public static final short KEY_FN_F = 0x1e2;
+ public static final short KEY_FN_S = 0x1e3;
+ public static final short KEY_FN_B = 0x1e4;
+
+ public static final short KEY_BRL_DOT1 = 0x1f1;
+ public static final short KEY_BRL_DOT2 = 0x1f2;
+ public static final short KEY_BRL_DOT3 = 0x1f3;
+ public static final short KEY_BRL_DOT4 = 0x1f4;
+ public static final short KEY_BRL_DOT5 = 0x1f5;
+ public static final short KEY_BRL_DOT6 = 0x1f6;
+ public static final short KEY_BRL_DOT7 = 0x1f7;
+ public static final short KEY_BRL_DOT8 = 0x1f8;
+ public static final short KEY_BRL_DOT9 = 0x1f9;
+ public static final short KEY_BRL_DOT10 = 0x1fa;
+
+ /* used by phones, remote controls */
+ public static final short KEY_NUMERIC_0 = 0x200;
+ public static final short KEY_NUMERIC_1 = 0x201;
+ public static final short KEY_NUMERIC_2 = 0x202;
+ public static final short KEY_NUMERIC_3 = 0x203;
+ public static final short KEY_NUMERIC_4 = 0x204;
+ public static final short KEY_NUMERIC_5 = 0x205;
+ public static final short KEY_NUMERIC_6 = 0x206;
+ public static final short KEY_NUMERIC_7 = 0x207;
+ public static final short KEY_NUMERIC_8 = 0x208;
+ public static final short KEY_NUMERIC_9 = 0x209;
+ public static final short KEY_NUMERIC_STAR = 0x20a;
+ public static final short KEY_NUMERIC_POUND = 0x20b;
+
+ /* We avoid low common keys in module aliases so they don't get huge. */
+ public static final short KEY_MIN_INTERESTING = KEY_MUTE;
+ public static final short KEY_MAX = 0x2ff;
+ public static final short KEY_CNT = (KEY_MAX + 1);
+
+ /* Relative axes */
+
+ public static final short REL_X = 0x00;
+ public static final short REL_Y = 0x01;
+ public static final short REL_Z = 0x02;
+ public static final short REL_RX = 0x03;
+ public static final short REL_RY = 0x04;
+ public static final short REL_RZ = 0x05;
+ public static final short REL_HWHEEL = 0x06;
+ public static final short REL_DIAL = 0x07;
+ public static final short REL_WHEEL = 0x08;
+ public static final short REL_MISC = 0x09;
+ public static final short REL_MAX = 0x0f;
+ public static final short REL_CNT = (REL_MAX + 1);
+
+ /* Absolute axes */
+
+ public static final short ABS_X = 0x00;
+ public static final short ABS_Y = 0x01;
+ public static final short ABS_Z = 0x02;
+ public static final short ABS_RX = 0x03;
+ public static final short ABS_RY = 0x04;
+ public static final short ABS_RZ = 0x05;
+ public static final short ABS_THROTTLE = 0x06;
+ public static final short ABS_RUDDER = 0x07;
+ public static final short ABS_WHEEL = 0x08;
+ public static final short ABS_GAS = 0x09;
+ public static final short ABS_BRAKE = 0x0a;
+ public static final short ABS_HAT0X = 0x10;
+ public static final short ABS_HAT0Y = 0x11;
+ public static final short ABS_HAT1X = 0x12;
+ public static final short ABS_HAT1Y = 0x13;
+ public static final short ABS_HAT2X = 0x14;
+ public static final short ABS_HAT2Y = 0x15;
+ public static final short ABS_HAT3X = 0x16;
+ public static final short ABS_HAT3Y = 0x17;
+ public static final short ABS_PRESSURE = 0x18;
+ public static final short ABS_DISTANCE = 0x19;
+ public static final short ABS_TILT_X = 0x1a;
+ public static final short ABS_TILT_Y = 0x1b;
+ public static final short ABS_TOOL_WIDTH = 0x1c;
+ public static final short ABS_VOLUME = 0x20;
+ public static final short ABS_MISC = 0x28;
+
+ /** Major axis of touching ellipse */
+ public static final short ABS_MT_TOUCH_MAJOR = 0x30;
+ /** Minor axis (omit if circular) */
+ public static final short ABS_MT_TOUCH_MINOR = 0x31;
+ /** Major axis of approaching ellipse */
+ public static final short ABS_MT_WIDTH_MAJOR = 0x32;
+ /** Minor axis (omit if circular) */
+ public static final short ABS_MT_WIDTH_MINOR = 0x33;
+ /** Ellipse orientation */
+ public static final short ABS_MT_ORIENTATION = 0x34;
+ /** Center X ellipse position */
+ public static final short ABS_MT_POSITION_X = 0x35;
+ /** Center Y ellipse position */
+ public static final short ABS_MT_POSITION_Y = 0x36;
+ /** Type of touching device */
+ public static final short ABS_MT_TOOL_TYPE = 0x37;
+ /** Group a set of packets as a blob */
+ public static final short ABS_MT_BLOB_ID = 0x38;
+ /** Unique ID of initiated contact */
+ public static final short ABS_MT_TRACKING_ID = 0x39;
+
+ public static final short ABS_MAX = 0x3f;
+ public static final short ABS_CNT = (ABS_MAX + 1);
+
+ /* Switch events */
+ /** set = lid shut */
+ public static final short SW_LID = 0x00;
+ /** set = tablet mode */
+ public static final short SW_TABLET_MODE = 0x01;
+ /** set = inserted */
+ public static final short SW_HEADPHONE_INSERT = 0x02;
+ /** rfkill master switch, type "any" set = radio enabled */
+ public static final short SW_RFKILL_ALL = 0x03;
+ /** @deprecated */
+ public static final short SW_RADIO = SW_RFKILL_ALL;
+ /** set = inserted */
+ public static final short SW_MICROPHONE_INSERT = 0x04;
+ /** set = plugged into dock */
+ public static final short SW_DOCK = 0x05;
+ /** set = inserted */
+ public static final short SW_LINEOUT_INSERT = 0x06;
+ /** set = mechanical switch set */
+ public static final short SW_JACK_PHYSICAL_INSERT = 0x07;
+ /** set = inserted */
+ public static final short SW_VIDEOOUT_INSERT = 0x08;
+ public static final short SW_MAX = 0x0f;
+ public static final short SW_CNT = (SW_MAX + 1);
+
+ /* Misc events */
+
+ public static final short MSC_SERIAL = 0x00;
+ public static final short MSC_PULSELED = 0x01;
+ public static final short MSC_GESTURE = 0x02;
+ public static final short MSC_RAW = 0x03;
+ public static final short MSC_SCAN = 0x04;
+ public static final short MSC_MAX = 0x07;
+ public static final short MSC_CNT = (MSC_MAX + 1);
+
+ /* LEDs */
+
+ public static final short LED_NUML = 0x00;
+ public static final short LED_CAPSL = 0x01;
+ public static final short LED_SCROLLL = 0x02;
+ public static final short LED_COMPOSE = 0x03;
+ public static final short LED_KANA = 0x04;
+ public static final short LED_SLEEP = 0x05;
+ public static final short LED_SUSPEND = 0x06;
+ public static final short LED_MUTE = 0x07;
+ public static final short LED_MISC = 0x08;
+ public static final short LED_MAIL = 0x09;
+ public static final short LED_CHARGING = 0x0a;
+ public static final short LED_MAX = 0x0f;
+ public static final short LED_CNT = (LED_MAX + 1);
+
+ /* Autorepeat values */
+
+ public static final short REP_DELAY = 0x00;
+ public static final short REP_PERIOD = 0x01;
+ public static final short REP_MAX = 0x01;
+
+ /* Sounds */
+
+ public static final short SND_CLICK = 0x00;
+ public static final short SND_BELL = 0x01;
+ public static final short SND_TONE = 0x02;
+ public static final short SND_MAX = 0x07;
+ public static final short SND_CNT = (SND_MAX + 1);
+
+ /* IDs. */
+
+ public static final short ID_BUS = 0;
+ public static final short ID_VENDOR = 1;
+ public static final short ID_PRODUCT = 2;
+ public static final short ID_VERSION = 3;
+
+ public static final short BUS_PCI = 0x01;
+ public static final short BUS_ISAPNP = 0x02;
+ public static final short BUS_USB = 0x03;
+ public static final short BUS_HIL = 0x04;
+ public static final short BUS_BLUETOOTH = 0x05;
+ public static final short BUS_VIRTUAL = 0x06;
+
+ public static final short BUS_ISA = 0x10;
+ public static final short BUS_I8042 = 0x11;
+ public static final short BUS_XTKBD = 0x12;
+ public static final short BUS_RS232 = 0x13;
+ public static final short BUS_GAMEPORT = 0x14;
+ public static final short BUS_PARPORT = 0x15;
+ public static final short BUS_AMIGA = 0x16;
+ public static final short BUS_ADB = 0x17;
+ public static final short BUS_I2C = 0x18;
+ public static final short BUS_HOST = 0x19;
+ public static final short BUS_GSC = 0x1A;
+ public static final short BUS_ATARI = 0x1B;
+
+ /* MT_TOOL types */
+ public static final short MT_TOOL_FINGER = 0;
+ public static final short MT_TOOL_PEN = 1;
+
+ /* Values describing the status of a force-feedback effect */
+ public static final short FF_STATUS_STOPPED = 0x00;
+ public static final short FF_STATUS_PLAYING = 0x01;
+ public static final short FF_STATUS_MAX = 0x01;
+
+
+ @Getter public final long timeSec;
+ @Getter public final long timeMicroSec;
+ @Getter public final EventType type;
+ @Getter public final /*__u16*/ short code;
+ @Getter public final /*__s32*/ int value;
+ @Getter public final String source;
+
+ private InputEvent(long timeSec, long timeMicroSec, EventType type, short code, int value, String source) {
+ this.timeSec = timeSec;
+ this.timeMicroSec = timeMicroSec;
+ this.type = type;
+ this.code = code;
+ this.value = value;
+ this.source = source;
+ }
+
+ /**
+ * Parse an InputEvent out of a ShortBuffer.
+ *
+ * @param shortBuffer
+ * @param source
+ * @return the parsed InputEvent
+ * @throws IOException
+ */
+ public static InputEvent parse(ShortBuffer shortBuffer, String source) throws IOException {
+ return parse(shortBuffer, source, null);
+ }
+
+ /**
+ * Parse an InputEvent out of a ShortBuffer.
+ *
+ * @param shortBuffer
+ * @param source
+ * @param arch
+ * @return the parsed InputEvent
+ * @throws IOException
+ */
+ public static InputEvent parse(ShortBuffer shortBuffer, String source, String arch) {
+ short a, b, c, d;
+ a = shortBuffer.get();
+ b = shortBuffer.get();
+ long timeSec;
+ if (arch.equals("arm")) {
+ timeSec = (b << 16) | a;
+ } else {
+ c = shortBuffer.get();
+ d = shortBuffer.get();
+ timeSec = ((long)d << 48) | ((long)c << 32) | ((long)b << 16) | a;
+ }
+ a = shortBuffer.get();
+ b = shortBuffer.get();
+ long timeMicroSec;
+ if (arch.equals("arm")) {
+ timeMicroSec = (b << 16) | a;
+ } else {
+ c = shortBuffer.get();
+ d = shortBuffer.get();
+ // fixme : longs are signed, so this is probably not doing what we expect it to do
+ timeMicroSec = (d << 48) | (c << 32) | (b << 16) | a;
+ }
+ short type = shortBuffer.get();
+ short code = shortBuffer.get();
+ c = shortBuffer.get();
+ d = shortBuffer.get();
+ int value = (d << 16) | c;
+
+ return new InputEvent(timeSec, timeMicroSec, valueOf(type), code, value, source);
+ }
+
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/InputListener.java b/evdev/src/main/java/com/dgis/input/evdev/InputListener.java
new file mode 100644
index 0000000..e367471
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/InputListener.java
@@ -0,0 +1,35 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+/**
+ * Listener for Evdev events.
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ * @see com.dgis.input.evdev.EventDevice
+ */
+
+public interface InputListener {
+ /**
+ * This method is called by a EventDevice when an event is reported by
+ * the event device under its watch.
+ *
+ * @param e The event details.
+ */
+ void event(InputEvent e);
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickFilter.java b/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickFilter.java
new file mode 100644
index 0000000..33efb96
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickFilter.java
@@ -0,0 +1,182 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev.devices;
+
+import com.dgis.input.evdev.EventDevice;
+import com.dgis.input.evdev.InputEvent;
+import com.dgis.input.evdev.InputListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
+ * when dealing with an evdev EventDevice.
+ * Consolidates multiple events between EV_SYN events, and can tell you how many buttons and axes exist, and which changed.
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+
+public class EvdevJoystickFilter implements InputListener {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private final EventDevice device;
+ private JoystickState state;
+
+ private final ArrayList listeners = new ArrayList<>();
+
+ /**
+ * Holds the event codes for each joystick button, in order. That is, if
+ * event code 288 is button one, it is the first entry here.
+ */
+ private final ArrayList buttonEventCodes = new ArrayList<>();
+
+ /**
+ * Holds the event codes for each joystick axis, in order. That is, if
+ * event code 0 is axis one, it is the first entry here.
+ */
+ private final ArrayList axisEventCodes = new ArrayList<>();
+
+ private boolean[] buttonChanged, axisChanged;
+
+ /**
+ * Constructs an EvdevJoystickFilter using the provided EventDevice as input.
+ */
+ public EvdevJoystickFilter(EventDevice dev) {
+ this.device = dev;
+ setupDevice();
+ }
+
+ /**
+ * Constructs an EvdevJoystickFilter using the provided event device as input.
+ */
+ public EvdevJoystickFilter(File device) throws IOException {
+ this(new EventDevice(device));
+ }
+
+ private void setupDevice() {
+ Map> supportedEvents = device.getSupportedEvents();
+ List supportedAxes = supportedEvents.get((int) InputEvent.EV_ABS);
+ List supportedKeys = supportedEvents.get((int) InputEvent.EV_KEY);
+
+ int numAxes = supportedAxes == null ? 0 : supportedAxes.size();
+ int numButtons = supportedKeys == null ? 0 : supportedKeys.size();
+
+ if (supportedKeys != null) buttonEventCodes.addAll(supportedKeys);
+ if (supportedAxes != null) axisEventCodes.addAll(supportedAxes);
+
+ System.out.println("Detected " + buttonEventCodes.size() + " buttons and " + axisEventCodes.size() + " axes.");
+
+ buttonChanged = new boolean[numButtons];
+ axisChanged = new boolean[numAxes];
+
+ state = new JoystickState(numButtons, numAxes);
+ device.addListener(this);
+ }
+
+ @Override
+ public void event(InputEvent e) {
+ switch (e.type) {
+ case EV_KEY:
+ handleButton(e.code, e.value > 0);
+ break;
+ case EV_ABS:
+ handleAxis(e.code, e.value);
+ break;
+ case EV_SYN:
+ dispatchEvents();
+ default:
+ logger.warn("Unknown event {}", e);
+ }
+ }
+
+ /**
+ * Broadcast events for what changed since the last dispatchEvents().
+ */
+ private void dispatchEvents() {
+ boolean anyAxisChanged = false;
+ boolean anyButtonChanged = false;
+ for (boolean x : buttonChanged) anyButtonChanged |= x;
+ for (boolean x : axisChanged) anyAxisChanged |= x;
+
+ for (JoystickListener l : listeners) {
+ if (anyButtonChanged)
+ l.buttonChanged(buttonChanged, state, device.getDevicePath());
+ if (anyAxisChanged)
+ l.joystickMoved(axisChanged, state, device.getDevicePath());
+ }
+
+ Arrays.fill(axisChanged, false);
+ Arrays.fill(buttonChanged, false);
+ }
+
+ private void handleAxis(short axisNumber, int value) {
+ int axisNumber2 = axisEventCodes.indexOf((int) axisNumber);
+ if (axisNumber2 < 0) {
+ System.err.println("WARN: Couldn't find axis " + axisNumber + " in mapping! Perhaps device reported capabilities improperly!");
+ return;
+ }
+ axisChanged[axisNumber2] = (value != state.getAxisState(axisNumber2)); //only flag as changed if _actually_ changed.
+ state.setAxisState(axisNumber2, value);
+
+ }
+
+ private void handleButton(short buttonNumber, boolean buttonState) {
+ int buttonNumber2 = buttonEventCodes.indexOf((int) buttonNumber);
+ if (buttonNumber2 < 0) {
+ System.err.println("WARN: Couldn't find button " + buttonNumber + " in mapping! Perhaps device reported capabilities improperly!");
+ return;
+ }
+ buttonChanged[buttonNumber2] = (buttonState != state.getButtonState(buttonNumber2)); //only flag as changed if _actually_ changed.
+ state.setButtonState(buttonNumber2, buttonState);
+ }
+
+ /**
+ * Adds an event listener to this device.
+ * If the listener is already on the listener list,
+ * this method has no effect.
+ *
+ * @param list The listener to add. Must not be null.
+ */
+ public void addListener(JoystickListener list) {
+ listeners.add(list);
+ }
+
+ /**
+ * Removes an event listener to this device.
+ * If the listener is not on the listener list,
+ * this method has no effect.
+ *
+ * @param list The listener to remove. Must not be null.
+ */
+ public void removeListener(JoystickListener list) {
+ listeners.remove(list);
+ }
+
+ public void close() {
+ device.close();
+ }
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickTest.java b/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickTest.java
new file mode 100644
index 0000000..ac2b9f2
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/devices/EvdevJoystickTest.java
@@ -0,0 +1,69 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev.devices;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * Simple program that prints info and all events from a device to STDOUT.
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+
+public class EvdevJoystickTest {
+
+ public static void main(String[] args) throws IOException {
+
+ if (args.length == 0) {
+ System.out.println("Usage: EvdevJoystickTest /dev/input/event*");
+ System.exit(1);
+ }
+
+ File fn = new File(args[0]);
+ EvdevJoystickFilter dev = new EvdevJoystickFilter(fn);
+ System.out.println("Hit enter to quit.");
+
+ dev.addListener(new JoystickListener() {
+ @Override
+ public void buttonChanged(boolean[] buttonsChanged,
+ JoystickState state, String source) {
+ System.out.print("Button change: [ ");
+ for (boolean b : buttonsChanged) System.out.print((b ? 1 : 0) + " ");
+ System.out.println(" ]");
+ System.out.println(state);
+ }
+
+ @Override
+ public void joystickMoved(boolean[] axesChanged, JoystickState state, String source) {
+ System.out.print("Axis change: [ ");
+ for (boolean b : axesChanged) System.out.print((b ? 1 : 0) + " ");
+ System.out.println(" ]");
+ System.out.println(state);
+ }
+ });
+
+ //Wait for newline.
+ new BufferedReader(new InputStreamReader(System.in)).readLine();
+
+ dev.close();
+ }
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickListener.java b/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickListener.java
new file mode 100644
index 0000000..293f4fb
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickListener.java
@@ -0,0 +1,43 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev.devices;
+
+/**
+ * Listener for Joystick events.
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ * @see com.dgis.input.evdev.EventDevice
+ */
+
+public interface JoystickListener {
+ /**
+ * Called whenever a joystick's axis changes state.
+ *
+ * @param axesChanged Bitmap of axis status. If the nth value in this array is true, then the nth axis changed state.
+ * @param state The updated joystick state.
+ */
+ void joystickMoved(boolean[] axesChanged, JoystickState state, String source);
+
+ /**
+ * Called whenever a joystick's button changes state.
+ *
+ * @param buttonsChanged Bitmap of button status. If the nth value in this array is true, then the nth button changed state.
+ * @param state The updated joystick state.
+ */
+ void buttonChanged(boolean[] buttonsChanged, JoystickState state, String source);
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickState.java b/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickState.java
new file mode 100644
index 0000000..7219b57
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/devices/JoystickState.java
@@ -0,0 +1,129 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev.devices;
+
+/**
+ * Represents the state of a joystick (buttons and axes)
+ *
+ * Copyright (C) 2009 Giacomo Ferrari
+ *
+ * @author Giacomo Ferrari
+ */
+
+public class JoystickState {
+ private final int numButtons;
+ private final int numAxes;
+ private final boolean buttonStates[];
+ private final int axisStates[];
+ private final int axisMinValue[];
+ private final int axisMaxValue[];
+
+ JoystickState(int numButtons, int numAxes) {
+ this.numButtons = numButtons;
+ this.numAxes = numAxes;
+ buttonStates = new boolean[numButtons];
+ axisStates = new int[numAxes];
+ axisMinValue = new int[numAxes];
+ axisMaxValue = new int[numAxes];
+ }
+
+ /**
+ * Gets the number of buttons reported by this joystick.
+ *
+ * @return The number of buttons reported.
+ */
+ public int getNumButtons() {
+ return numButtons;
+ }
+
+ /**
+ * Gets the number of axes reported by this joystick.
+ *
+ * @return The number of axes reported.
+ */
+ public int getNumAxes() {
+ return numAxes;
+ }
+
+ /**
+ * Queries the state of a joystick button.
+ *
+ * @param button The button number to check. Valid ranges are 0 to getNumButtons()-1.
+ * @return The state of the button.
+ */
+ public boolean getButtonState(int button) {
+ return buttonStates[button];
+ }
+
+ /**
+ * Queries the state of a joystick axis.
+ *
+ * @param axis The axis number to check. Valid ranges are 0 to getNumAxes()-1.
+ * @return The state of the axis, typically in the range +-32768.
+ * @see JoystickState#getAxisMaxValue(int)
+ * @see JoystickState#getAxisMinValue(int)
+ */
+ public int getAxisState(int axis) {
+ return axisStates[axis];
+ }
+
+ /**
+ * Queries the smallest value ever seen on a given axis for calibration purposes.
+ *
+ * @param axis The axis to check. Valid ranges are 0 to getNumButtons()-1.
+ * @return The smallest value ever seen on this axis.
+ */
+ public int getAxisMinValue(int axis) {
+ return axisMinValue[axis];
+ }
+
+ /**
+ * Queries the largest value ever seen on a given axis for calibration purposes.
+ *
+ * @param axis The axis to check. Valid ranges are 0 to getNumButtons()-1.
+ * @return The largest value ever seen on this axis.
+ */
+ public int getAxisMaxValue(int axis) {
+ return axisMaxValue[axis];
+ }
+
+ void setButtonState(int button, boolean state) {
+ buttonStates[button] = state;
+ }
+
+ void setAxisState(int axis, int state) {
+ axisStates[axis] = state;
+ }
+
+ void setAxisMinValue(int axis, int min) {
+ axisMinValue[axis] = min;
+ }
+
+ void setAxisMaxValue(int axis, int max) {
+ axisMaxValue[axis] = max;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buf = new StringBuilder("Buttons: [ ");
+ for (boolean b : buttonStates) buf.append(b ? 1 : 0).append(" ");
+ buf.append("] Axes: [ ");
+ for (int a : axisStates) buf.append(a).append(" ");
+ buf.append("]");
+ return buf.toString();
+ }
+}
diff --git a/evdev/src/main/java/com/dgis/input/evdev/devices/package-info.java b/evdev/src/main/java/com/dgis/input/evdev/devices/package-info.java
new file mode 100644
index 0000000..bd7bc10
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/devices/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev.devices;
diff --git a/evdev/src/main/java/com/dgis/input/evdev/package-info.java b/evdev/src/main/java/com/dgis/input/evdev/package-info.java
new file mode 100644
index 0000000..6820188
--- /dev/null
+++ b/evdev/src/main/java/com/dgis/input/evdev/package-info.java
@@ -0,0 +1,17 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
diff --git a/evdev/src/test/java/com/dgis/input/evdev/InputAxisParametersTest.java b/evdev/src/test/java/com/dgis/input/evdev/InputAxisParametersTest.java
new file mode 100644
index 0000000..91412e1
--- /dev/null
+++ b/evdev/src/test/java/com/dgis/input/evdev/InputAxisParametersTest.java
@@ -0,0 +1,76 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class InputAxisParametersTest {
+
+ @Test
+ public void readValue() {
+ EventDevice eventDevice = mockEventDevice(0, 4);
+ InputAxisParameters axisParameters = new InputAxisParameters(eventDevice, 0);
+ assertThat(axisParameters.getValue()).isEqualTo(4);
+ }
+
+ @Test
+ public void readMin() {
+ EventDevice eventDevice = mockEventDevice(1, 5);
+ InputAxisParameters axisParameters = new InputAxisParameters(eventDevice, 0);
+ assertThat(axisParameters.getMin()).isEqualTo(5);
+ }
+
+ @Test
+ public void readMax() {
+ EventDevice eventDevice = mockEventDevice(2, 6);
+ InputAxisParameters axisParameters = new InputAxisParameters(eventDevice, 0);
+ assertThat(axisParameters.getMax()).isEqualTo(6);
+ }
+
+ @Test
+ public void readFuzz() {
+ EventDevice eventDevice = mockEventDevice(3, 7);
+ InputAxisParameters axisParameters = new InputAxisParameters(eventDevice, 0);
+ assertThat(axisParameters.getFuzz()).isEqualTo(7);
+ }
+
+ @Test
+ public void readFlat() {
+ EventDevice eventDevice = mockEventDevice(4, 8);
+ InputAxisParameters axisParameters = new InputAxisParameters(eventDevice, 0);
+ assertThat(axisParameters.getFlat()).isEqualTo(8);
+ }
+
+ private EventDevice mockEventDevice(final int position, final int value) {
+ EventDevice eventDevice = mock(EventDevice.class);
+ when(eventDevice.ioctlEVIOCGABS(any(), any(int[].class), anyInt()))
+ .thenAnswer(invocation -> {
+ int[] response = invocation.getArgument(1);
+ response[position] = value;
+ return true;
+ });
+
+ return eventDevice;
+ }
+
+}
diff --git a/evdev/src/test/java/com/dgis/input/evdev/InputEventTest.java b/evdev/src/test/java/com/dgis/input/evdev/InputEventTest.java
new file mode 100644
index 0000000..1d13a65
--- /dev/null
+++ b/evdev/src/test/java/com/dgis/input/evdev/InputEventTest.java
@@ -0,0 +1,65 @@
+/**
+ * This file is part of evdev-java - Java implementation.
+ *
+ * evdev-java - Java implementation is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * evdev-java - Java implementation is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with evdev-java - Java implementation. If not, see .
+ */
+package com.dgis.input.evdev;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.ShortBuffer;
+
+import static com.dgis.input.evdev.EventType.EV_KEY;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class InputEventTest {
+
+ @Test
+ public void testParsingSimpleValue() throws IOException {
+ ShortBuffer buffer = ShortBuffer.allocate(12);
+ // time seconds
+ write(buffer, 1, 2, 0, 0);
+ // time micro seconds
+ write(buffer, 4, 5, 0, 0);
+ // type
+ buffer.put(EV_KEY.getValue());
+ // code
+ buffer.put((short) 9);
+ // value
+ write(buffer, 10, 11);
+
+ buffer.rewind();
+
+ InputEvent event = InputEvent.parse(buffer, "source", "arch");
+ assertThat(event.source).isEqualTo("source");
+ assertThat(event.timeSec).isEqualTo((2L << 16) + 1);
+ assertThat(event.timeMicroSec).isEqualTo((5L << 16) + 4);
+ assertThat(event.type).isEqualTo(EV_KEY);
+ assertThat(event.code).isEqualTo((short)9);
+ assertThat(event.value).isEqualTo(10 + (11 << 16));
+ }
+
+ private void write(ShortBuffer buffer, int s0, int s1, int s2, int s3) {
+ buffer.put((short) s0);
+ buffer.put((short) s1);
+ buffer.put((short) s2);
+ buffer.put((short) s3);
+ }
+ private void write(ShortBuffer buffer, int s0, int s1) {
+ buffer.put((short) s0);
+ buffer.put((short) s1);
+ }
+
+}
diff --git a/native/com_dgis_input_evdev_EventDevice.h b/native/com_dgis_input_evdev_EventDevice.h
deleted file mode 100644
index cbc8cde..0000000
--- a/native/com_dgis_input_evdev_EventDevice.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include
-/* Header for class com_dgis_input_evdev_EventDevice */
-
-#ifndef _Included_com_dgis_input_evdev_EventDevice
-#define _Included_com_dgis_input_evdev_EventDevice
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: com_dgis_input_evdev_EventDevice
- * Method: ioctlGetID
- * Signature: (Ljava/lang/String;[S)Z
- */
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetID
- (JNIEnv *, jobject, jstring, jshortArray);
-
-/*
- * Class: com_dgis_input_evdev_EventDevice
- * Method: ioctlGetEvdevVersion
- * Signature: (Ljava/lang/String;)I
- */
-JNIEXPORT jint JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetEvdevVersion
- (JNIEnv *, jobject, jstring);
-
-/*
- * Class: com_dgis_input_evdev_EventDevice
- * Method: ioctlGetDeviceName
- * Signature: (Ljava/lang/String;[B)Z
- */
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlGetDeviceName
- (JNIEnv *, jobject, jstring, jbyteArray);
-
-/*
- * Class: com_dgis_input_evdev_EventDevice
- * Method: ioctlEVIOCGBIT
- * Signature: (Ljava/lang/String;[JII)Z
- */
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGBIT
- (JNIEnv *, jobject, jstring, jlongArray, jint, jint);
-
-/*
- * Class: com_dgis_input_evdev_EventDevice
- * Method: ioctlEVIOCGABS
- * Signature: (Ljava/lang/String;[II)Z
- */
-JNIEXPORT jboolean JNICALL Java_com_dgis_input_evdev_EventDevice_ioctlEVIOCGABS
- (JNIEnv *, jobject, jstring, jintArray, jint);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/native/compile.sh b/native/compile.sh
deleted file mode 100755
index b3ccb5a..0000000
--- a/native/compile.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-gcc -Wall -shared -fPIC -o libevdev-java.so evdev-java.c
-
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..942c3b9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,103 @@
+
+
+
+ 4.0.0
+
+
+ ch.ledcom
+ ledcom-parent-pom
+ 1.55
+
+
+ ch.ledcom.evdev
+ evdev-java
+ 1.2-SNAPSHOT
+ pom
+
+ http://gehel.github.com/evdev-java/
+ 2009
+
+
+ evdev-native
+ evdev-native-interface
+ evdev
+
+
+
+ scm:git:git://github.com/gehel/evdev-java.git
+ scm:git:ssh://git@github.com/gehel/evdev-java.git
+ HEAD
+ https://github.com/gehel/evdev-java
+
+
+
+ GitHub
+ https://github.com/gehel/evdev-java/issues
+
+
+
+ travis
+ https://travis-ci.org/gehel/evdev-java
+
+
+
+
+
+
+ com.mycila
+ license-maven-plugin
+
+ com/mycila/maven/plugin/license/templates/GPL-3.txt
+
+ ${project.inceptionYear}
+ Giacomo Ferrari
+ http://giferrari.net/blog/
+
+
+
+
+ com.mycila
+ license-maven-plugin
+
+
+ **/pom.xml
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ src/etc/checkstyle-suppressions.xml
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
diff --git a/src-test/com/dgis/input/evdev/EvdevJoystickTest.java b/src-test/com/dgis/input/evdev/EvdevJoystickTest.java
deleted file mode 100644
index 60790ea..0000000
--- a/src-test/com/dgis/input/evdev/EvdevJoystickTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.dgis.input.evdev;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import com.dgis.input.evdev.devices.EvdevJoystickFilter;
-import com.dgis.input.evdev.devices.JoystickListener;
-import com.dgis.input.evdev.devices.JoystickState;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Simple program that prints info and all events from a device to STDOUT.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class EvdevJoystickTest {
-
- public static void main(String[] args) throws IOException {
-
- if(args.length == 0) {
- System.out.println("Usage: EvdevJoystickTest /dev/input/event*");
- System.exit(1);
- }
-
- String fn = args[0];
- EvdevJoystickFilter dev = new EvdevJoystickFilter(fn);
- System.out.println("Hit enter to quit.");
-
- dev.addListener(new JoystickListener() {
- @Override
- public void buttonChanged(boolean[] buttonsChanged,
- JoystickState state, String source) {
- System.out.print("Button change: [ ");
- for(boolean b : buttonsChanged) System.out.print((b?1:0) + " ");
- System.out.println(" ]");
- System.out.println(state);
- }
- @Override
- public void joystickMoved(boolean[] axesChanged, JoystickState state, String source) {
- System.out.print("Axis change: [ ");
- for(boolean b : axesChanged) System.out.print((b?1:0) + " ");
- System.out.println(" ]");
- System.out.println(state);
- }
- });
-
- //Wait for newline.
- new BufferedReader(new InputStreamReader(System.in)).readLine();
-
- dev.close();
- }
-}
diff --git a/src-test/com/dgis/input/evdev/EvdevTest.java b/src-test/com/dgis/input/evdev/EvdevTest.java
deleted file mode 100644
index 64e6886..0000000
--- a/src-test/com/dgis/input/evdev/EvdevTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.dgis.input.evdev;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.List;
-import java.util.Map.Entry;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Simple program that prints info and all events from a device to STDOUT.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class EvdevTest {
-
- public static void main(String[] args) throws IOException {
-
- if(args.length == 0) {
- System.out.println("Usage: EvdevTest /dev/input/event*");
- System.exit(1);
- }
-
- String fn = args[0];
- EventDevice dev = new EventDevice(fn);
- int version = dev.getEvdevVersion();
- System.out.printf("Input driver version is %d.%d.%d\n",
- version >>> 16, (version >>> 8) & 0xff, version & 0xff);
-
- System.out.printf("Input device ID: bus 0x%x vendor 0x%x product 0x%x version 0x%x\n",
- dev.getBusID(), dev.getVendorID(), dev.getProductID(), dev.getVersionID());
- System.out.println("Input device name: "+dev.getDeviceName());
- System.out.println("Supported events:");
-
- for(Entry> e : dev.getSupportedEvents().entrySet()) {
- System.out.println("Event type "+e.getKey()+" :");
- for(int ev : e.getValue()) {
- System.out.println("\tEvent code "+ev);
- if(e.getKey() == InputEvent.EV_ABS) {
- System.out.println("\t\t"+dev.getAxisParameters(ev));
- }
- }
- }
-
- System.out.println("Hit enter to quit.");
-
- dev.addListener(new InputListener() {
- @Override
- public void event(InputEvent e) {
- System.out.println(e);
- }
- });
-
- //Wait for newline.
- new BufferedReader(new InputStreamReader(System.in)).readLine();
-
- dev.close();
- }
-}
diff --git a/src/com/dgis/input/evdev/EventDevice.java b/src/com/dgis/input/evdev/EventDevice.java
deleted file mode 100644
index 93e3e34..0000000
--- a/src/com/dgis/input/evdev/EventDevice.java
+++ /dev/null
@@ -1,507 +0,0 @@
-package com.dgis.input.evdev;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Represents a connection to a Linux Evdev device.
- * For additional info, see input/input.txt and input/input-programming.txt in the Linux kernel Documentation.
- * IMPORTANT: If you want higher-level access for your joystick/pad/whatever, check com.dgis.input.evdev.devices
- * for useful drivers to make your life easier!
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-interface IEventDevice {
-
- public static final int MAJOR_VER = 0;
- public static final int MINOR_VER = 5;
-
- /**
- * @return The version of Evdev reported by the kernel.
- */
- public int getEvdevVersion();
-
- /**
- * @return the bus ID of the attached device.
- */
- public short getBusID();
- /**
- * @return the vendor ID of the attached device.
- */
- public short getVendorID();
- /**
- * @return the product ID of the attached device.
- */
- public short getProductID();
- /**
- * @return the version ID of the attached device.
- */
- public short getVersionID();
- /**
- * @return the name of the attached device.
- */
- public String getDeviceName();
- /**
- * @return A mapping from device supported event types to list of supported event codes.
- */
- public Map> getSupportedEvents();
-
- /**
- * Obtains the configurable parameters of an absolute axis (value, min, max, fuzz, flatspot) from the device.
- * @param axis The axis number (an event code under event type 3 (abs)).
- * @return The parameters, or null if there was an error. Modifications to this object will be reflected in the device.
- */
- public InputAxisParameters getAxisParameters(int axis);
-
- /**
- * Adds an event listener to this device.
- * When an event is received from Evdev, all InputListeners registered
- * will be notified by a call to event().
- * If the listener is already on the listener list,
- * this method has no effect.
- * @param list The listener to add. Must not be null.
- */
- public void addListener(InputListener list);
- /**
- * Removes an event listener to this device.
- * If the listener is not on the listener list,
- * this method has no effect.
- * @param list The listener to remove. Must not be null.
- */
- public void removeListener(InputListener list);
-
- /**
- * Releases all resources held by this EventDevice. No more events will be generated.
- * It is impossible to restart an EventDevice once this method is called.
- */
- public void close();
-}
-
-/**
- * Driver for a Linux Evdev character device.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class EventDevice implements IEventDevice{
-
- /**
- * Notify these guys about input events.
- */
- private List listeners = new ArrayList();
-
- /**
- * Device filename we're using.
- */
- String device;
-
- /**
- * Attached to device we're using.
- */
- private FileChannel deviceInput;
- private ByteBuffer inputBuffer = ByteBuffer.allocate(InputEvent.STRUCT_SIZE_BYTES);
-
-
- /**
- * When this is true, the reader thread should terminate ASAP.
- */
- private volatile boolean terminate = false;
-
- /**
- * This thread repeatedly calls readEvent().
- */
- private Thread readerThread;
-
- private short[] idResponse = new short[4];
-
- private int evdevVersionResponse;
-
- private String deviceNameResponse;
-
- /**
- * Maps supported event types (keys) to lists of supported event codes.
- */
- private HashMap> supportedEvents = new HashMap>();
-
-
- /**
- * Ensures only one instance of InputAxisParameters is created for each axis (more would be wasteful).
- */
- private HashMap axisParams = new HashMap();
-
- /**
- * Create an EventDevice by connecting to the provided device filename.
- * If the device file is accessible, open it and begin listening for events.
- * @param device The path to the device file. Usually one of /dev/input/event*
- * @throws IOException If the device is not found, or is otherwise inaccessible.
- */
- public EventDevice(String device) throws IOException {
- System.loadLibrary("evdev-java");
- this.device = device;
- inputBuffer.order(ByteOrder.LITTLE_ENDIAN);
- initDevice();
- }
-
- /**
- * Get various ID info. Then, open the file, get the channel, and start the reader thread.
- * @throws IOException
- */
- private void initDevice() throws IOException {
-
- if(!ioctlGetID(device, idResponse)) {
- System.err.println("WARN: couldn't get device ID: "+device);
- Arrays.fill(idResponse, (short)0);
- }
- evdevVersionResponse = ioctlGetEvdevVersion(device);
- byte[] devName = new byte[255];
- if(ioctlGetDeviceName(device, devName)) {
- deviceNameResponse = new String(devName);
- } else {
- System.err.println("WARN: couldn't get device name: "+device);
- deviceNameResponse = "Unknown Device";
- }
-
- readSupportedEvents();
-
- FileInputStream fis = new FileInputStream(device);
- deviceInput = fis.getChannel();
-
- readerThread = new Thread() {
- @Override
- public void run() {
- while(!terminate) {
- InputEvent ev = readEvent();
- distributeEvent(ev);
- }
- }
- };
- readerThread.setDaemon(true); /* We don't want this thread to prevent the JVM from terminating */
-
- readerThread.start();
- }
-
- /**
- * Get supported events from device, and place into supportedEvents.
- * Adapted from evtest.c.
- */
- private void readSupportedEvents() {
- //System.out.println("Detecting device capabilities...");
- long[][] bit = new long[InputEvent.EV_MAX][NBITS(InputEvent.KEY_MAX)];
- ioctlEVIOCGBIT(device, bit[0], 0, bit[0].length);
- /* Loop over event types */
- for (int i = 0; i < InputEvent.EV_MAX; i++) {
- if (testBit(bit[0], i)) { /* Is this event supported? */
- //System.out.printf(" Event type %d\n", i);
- if (i==0) continue;
- ArrayList supportedTypes = new ArrayList();
- ioctlEVIOCGBIT(device, bit[i], i, InputEvent.KEY_MAX);
- /* Loop over event codes for type */
- for (int j = 0; j < InputEvent.KEY_MAX; j++)
- if (testBit(bit[i], j)) { /* Is this event code supported? */
- //System.out.printf(" Event code %d\n", j);
- supportedTypes.add(j);
- }
- supportedEvents.put(i, supportedTypes);
- }
- }
- }
-
- private boolean testBit(long[] array, int bit) {
- return ((array[LONG(bit)] >>> OFF(bit)) & 1)!=0;
- }
- private int LONG(int x) {
- return x/(64);
- }
- private int OFF(int x) {
- return x%(64);
- }
- private int NBITS(int x) {
- return ((((x)-1)/(8*8))+1);
- }
-
- /**
- * Distribute an event to all registered listeners.
- * @param ev The event to distribute.
- */
- private void distributeEvent(InputEvent ev) {
- synchronized (listeners) {
- for(InputListener il : listeners) {
- il.event(ev);
- }
- }
- }
-
- /**
- * Obtain an InputEvent from the input channel. Delegate to InputEvent for parsing.
- * @return
- */
- private InputEvent readEvent() {
- try {
- /* Read exactly the amount of bytes specified by InputEvent.STRUCT_SIZE_BYTES (intrinsic size of inputBuffer)*/
- inputBuffer.clear();
- while(inputBuffer.hasRemaining()) deviceInput.read(inputBuffer);
-
- /* We want to read now */
- inputBuffer.flip();
-
- /* Delegate parsing to InputEvent.parse() */
- return InputEvent.parse(inputBuffer.asShortBuffer(), device);
- } catch (IOException e ) {
- return null;
- }
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#close()
- */
- @Override
- public void close() {
- terminate=true;
- try {
- readerThread.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- try {
- deviceInput.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getBusID()
- */
- @Override
- public short getBusID() {
- return idResponse[InputEvent.ID_BUS];
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getDeviceName()
- */
- @Override
- public String getDeviceName() {
- return deviceNameResponse;
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getProductID()
- */
- @Override
- public short getProductID() {
- // TODO Auto-generated method stub
- return idResponse[InputEvent.ID_PRODUCT];
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getSupportedEvents()
- */
- @Override
- public Map> getSupportedEvents() {
- return supportedEvents;
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getVendorID()
- */
- @Override
- public short getVendorID() {
- return idResponse[InputEvent.ID_VENDOR];
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getEvdevVersion()
- */
- @Override
- public int getEvdevVersion() {
- return evdevVersionResponse;
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#getVersionID()
- */
- @Override
- public short getVersionID() {
- return idResponse[InputEvent.ID_VERSION];
- }
-
- @Override
- public InputAxisParameters getAxisParameters(int axis) {
- InputAxisParameters params;
- if((params = axisParams.get(axis)) == null) {
- params = new InputAxisParametersImpl(this, axis);
- axisParams.put(axis, params);
- }
- return params;
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#addListener(com.dgis.input.evdev.InputListener)
- */
- @Override
- public void addListener(InputListener list) {
- synchronized (listeners) {
- listeners.add(list);
- }
- }
-
- /**
- * @see com.dgis.input.evdev.IEventDevice#removeListener(com.dgis.input.evdev.InputListener)
- */
- @Override
- public void removeListener(InputListener list) {
- synchronized (listeners) {
- listeners.remove(list);
- }
- }
-
-
- public String getDevicePath() {
- return device;
- }
-
- ////BEGIN JNI METHODS////
- native boolean ioctlGetID(String device, short[] resp);
- native int ioctlGetEvdevVersion(String device);
- native boolean ioctlGetDeviceName(String device, byte[] resp);
- native boolean ioctlEVIOCGBIT(String device, long[] resp, int start, int stop);
- native boolean ioctlEVIOCGABS(String device, int[] resp, int axis);
-}
-
-class InputAxisParametersImpl implements InputAxisParameters {
-
- private EventDevice device;
- private int axis;
-
- private int value, min, max, fuzz, flat;
-
- public InputAxisParametersImpl(EventDevice device, int axis) {
- this.device = device;
- this.axis = axis;
- readStatus();
- }
-
- /**
- * Repopulate values stored in this class with values read from the device.
- */
- private void readStatus() {
- int[] resp = new int[5];
- device.ioctlEVIOCGABS(device.device, resp, axis);
- value = resp[0];
- min = resp[1];
- max = resp[2];
- fuzz = resp[3];
- flat = resp[4];
- }
-
- /**
- * Repopulate values stored in the device with values read from this class.
- */
- private void writeStatus() {
- throw new Error("Not implemented yet!");
- }
-
- public int getValue() {
- synchronized (this) {
- readStatus();
- return value;
- }
- }
-
- public void setValue(int value) {
- synchronized (this) {
- this.value = value;
- writeStatus();
- }
- }
-
- public int getMin() {
- synchronized (this) {
- readStatus();
- return min;
- }
- }
-
- public void setMin(int min) {
- synchronized (this) {
- this.min = min;
- writeStatus();
- }
- }
-
- public int getMax() {
- synchronized (this) {
- readStatus();
- return max;
- }
- }
-
- public void setMax(int max) {
- synchronized (this) {
- this.max = max;
- writeStatus();
- }
- }
-
- public int getFuzz() {
- synchronized (this) {
- readStatus();
- return fuzz;
- }
- }
-
- public void setFuzz(int fuzz) {
- synchronized (this) {
- this.fuzz = fuzz;
- writeStatus();
- }
- }
-
- public int getFlat() {
- synchronized (this) {
- readStatus();
- return flat;
- }
- }
-
- public void setFlat(int flat) {
- synchronized (this) {
- this.flat = flat;
- writeStatus();
- }
- }
-
- @Override
- public String toString() {
- return "Value: " + getValue() + " Min: " + getMin() + " Max: "
- + getMax() + " Fuzz: " + getFuzz() + " Flat: " + getFlat();
- }
-}
\ No newline at end of file
diff --git a/src/com/dgis/input/evdev/InputAxisParameters.java b/src/com/dgis/input/evdev/InputAxisParameters.java
deleted file mode 100644
index cf5bdf6..0000000
--- a/src/com/dgis/input/evdev/InputAxisParameters.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.dgis.input.evdev;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Represents configurable parameters of an input axis. set*() should affect the value in the device.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-interface InputAxisParameters {
-
- public int getValue();
-
- public void setValue(int value);
-
- public int getMin();
-
- public void setMin(int min);
-
- public int getMax();
-
- public void setMax(int max);
-
- public int getFuzz();
-
- public void setFuzz(int fuzz);
-
- public int getFlat();
-
- public void setFlat(int flat);
-
-}
\ No newline at end of file
diff --git a/src/com/dgis/input/evdev/InputEvent.java b/src/com/dgis/input/evdev/InputEvent.java
deleted file mode 100644
index 80081c8..0000000
--- a/src/com/dgis/input/evdev/InputEvent.java
+++ /dev/null
@@ -1,834 +0,0 @@
-package com.dgis.input.evdev;
-
-import java.io.IOException;
-import java.nio.ShortBuffer;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Analog to the input_event struct in linux/input.h.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class InputEvent {
- /**
- * size of the input_event struct in bytes.
- */
- public static final int STRUCT_SIZE_BYTES = 24;
-
- /*
- * Event types
- */
-
- public static final short EV_SYN = 0x00;
- public static final short EV_KEY = 0x01;
- public static final short EV_REL = 0x02;
- public static final short EV_ABS = 0x03;
- public static final short EV_MSC = 0x04;
- public static final short EV_SW = 0x05;
- public static final short EV_LED = 0x11;
- public static final short EV_SND = 0x12;
- public static final short EV_REP = 0x14;
- public static final short EV_FF = 0x15;
- public static final short EV_PWR = 0x16;
- public static final short EV_FF_STATUS = 0x17;
- public static final short EV_MAX = 0x1f;
- public static final short EV_CNT = (EV_MAX + 1);
-
- /*
- * Synchronization events.
- */
-
- public static final short SYN_REPORT = 0;
- public static final short SYN_CONFIG = 1;
- public static final short SYN_MT_REPORT = 2;
-
- /*
- * Keys and buttons
- *
- * Most of the keys/buttons are modeled after USB HUT 1.12 (see
- * http://www.usb.org/developers/hidpage). Abbreviations in the comments: AC
- * - Application Control AL - Application Launch Button SC - System Control
- */
-
- public static final short KEY_RESERVED = 0;
- public static final short KEY_ESC = 1;
- public static final short KEY_1 = 2;
- public static final short KEY_2 = 3;
- public static final short KEY_3 = 4;
- public static final short KEY_4 = 5;
- public static final short KEY_5 = 6;
- public static final short KEY_6 = 7;
- public static final short KEY_7 = 8;
- public static final short KEY_8 = 9;
- public static final short KEY_9 = 10;
- public static final short KEY_0 = 11;
- public static final short KEY_MINUS = 12;
- public static final short KEY_EQUAL = 13;
- public static final short KEY_BACKSPACE = 14;
- public static final short KEY_TAB = 15;
- public static final short KEY_Q = 16;
- public static final short KEY_W = 17;
- public static final short KEY_E = 18;
- public static final short KEY_R = 19;
- public static final short KEY_T = 20;
- public static final short KEY_Y = 21;
- public static final short KEY_U = 22;
- public static final short KEY_I = 23;
- public static final short KEY_O = 24;
- public static final short KEY_P = 25;
- public static final short KEY_LEFTBRACE = 26;
- public static final short KEY_RIGHTBRACE = 27;
- public static final short KEY_ENTER = 28;
- public static final short KEY_LEFTCTRL = 29;
- public static final short KEY_A = 30;
- public static final short KEY_S = 31;
- public static final short KEY_D = 32;
- public static final short KEY_F = 33;
- public static final short KEY_G = 34;
- public static final short KEY_H = 35;
- public static final short KEY_J = 36;
- public static final short KEY_K = 37;
- public static final short KEY_L = 38;
- public static final short KEY_SEMICOLON = 39;
- public static final short KEY_APOSTROPHE = 40;
- public static final short KEY_GRAVE = 41;
- public static final short KEY_LEFTSHIFT = 42;
- public static final short KEY_BACKSLASH = 43;
- public static final short KEY_Z = 44;
- public static final short KEY_X = 45;
- public static final short KEY_C = 46;
- public static final short KEY_V = 47;
- public static final short KEY_B = 48;
- public static final short KEY_N = 49;
- public static final short KEY_M = 50;
- public static final short KEY_COMMA = 51;
- public static final short KEY_DOT = 52;
- public static final short KEY_SLASH = 53;
- public static final short KEY_RIGHTSHIFT = 54;
- public static final short KEY_KPASTERISK = 55;
- public static final short KEY_LEFTALT = 56;
- public static final short KEY_SPACE = 57;
- public static final short KEY_CAPSLOCK = 58;
- public static final short KEY_F1 = 59;
- public static final short KEY_F2 = 60;
- public static final short KEY_F3 = 61;
- public static final short KEY_F4 = 62;
- public static final short KEY_F5 = 63;
- public static final short KEY_F6 = 64;
- public static final short KEY_F7 = 65;
- public static final short KEY_F8 = 66;
- public static final short KEY_F9 = 67;
- public static final short KEY_F10 = 68;
- public static final short KEY_NUMLOCK = 69;
- public static final short KEY_SCROLLLOCK = 70;
- public static final short KEY_KP7 = 71;
- public static final short KEY_KP8 = 72;
- public static final short KEY_KP9 = 73;
- public static final short KEY_KPMINUS = 74;
- public static final short KEY_KP4 = 75;
- public static final short KEY_KP5 = 76;
- public static final short KEY_KP6 = 77;
- public static final short KEY_KPPLUS = 78;
- public static final short KEY_KP1 = 79;
- public static final short KEY_KP2 = 80;
- public static final short KEY_KP3 = 81;
- public static final short KEY_KP0 = 82;
- public static final short KEY_KPDOT = 83;
-
- public static final short KEY_ZENKAKUHANKAKU = 85;
- public static final short KEY_102ND = 86;
- public static final short KEY_F11 = 87;
- public static final short KEY_F12 = 88;
- public static final short KEY_RO = 89;
- public static final short KEY_KATAKANA = 90;
- public static final short KEY_HIRAGANA = 91;
- public static final short KEY_HENKAN = 92;
- public static final short KEY_KATAKANAHIRAGANA = 93;
- public static final short KEY_MUHENKAN = 94;
- public static final short KEY_KPJPCOMMA = 95;
- public static final short KEY_KPENTER = 96;
- public static final short KEY_RIGHTCTRL = 97;
- public static final short KEY_KPSLASH = 98;
- public static final short KEY_SYSRQ = 99;
- public static final short KEY_RIGHTALT = 100;
- public static final short KEY_LINEFEED = 101;
- public static final short KEY_HOME = 102;
- public static final short KEY_UP = 103;
- public static final short KEY_PAGEUP = 104;
- public static final short KEY_LEFT = 105;
- public static final short KEY_RIGHT = 106;
- public static final short KEY_END = 107;
- public static final short KEY_DOWN = 108;
- public static final short KEY_PAGEDOWN = 109;
- public static final short KEY_INSERT = 110;
- public static final short KEY_DELETE = 111;
- public static final short KEY_MACRO = 112;
- public static final short KEY_MUTE = 113;
- public static final short KEY_VOLUMEDOWN = 114;
- public static final short KEY_VOLUMEUP = 115;
- public static final short KEY_POWER = 116; /* SC System Power Down */
- public static final short KEY_KPEQUAL = 117;
- public static final short KEY_KPPLUSMINUS = 118;
- public static final short KEY_PAUSE = 119;
- public static final short KEY_SCALE = 120; /* AL Compiz Scale (Expose) */
-
- public static final short KEY_KPCOMMA = 121;
- public static final short KEY_HANGEUL = 122;
- public static final short KEY_HANGUEL = KEY_HANGEUL;
- public static final short KEY_HANJA = 123;
- public static final short KEY_YEN = 124;
- public static final short KEY_LEFTMETA = 125;
- public static final short KEY_RIGHTMETA = 126;
- public static final short KEY_COMPOSE = 127;
-
- public static final short KEY_STOP = 128;/* AC Stop */
- public static final short KEY_AGAIN = 129;
- public static final short KEY_PROPS = 130;/* AC Properties */
- public static final short KEY_UNDO = 131;/* AC Undo */
- public static final short KEY_FRONT = 132;
- public static final short KEY_COPY = 133;/* AC Copy */
- public static final short KEY_OPEN = 134;/* AC Open */
- public static final short KEY_PASTE = 135;/* AC Paste */
- public static final short KEY_FIND = 136;/* AC Search */
- public static final short KEY_CUT = 137;/* AC Cut */
- public static final short KEY_HELP = 138;/* AL Integrated Help Center */
- public static final short KEY_MENU = 139;/* Menu (show menu) */
- public static final short KEY_CALC = 140;/* AL Calculator */
- public static final short KEY_SETUP = 141;
- public static final short KEY_SLEEP = 142;/* SC System Sleep */
- public static final short KEY_WAKEUP = 143;/* System Wake Up */
- public static final short KEY_FILE = 144;/* AL Local Machine Browser */
- public static final short KEY_SENDFILE = 145;
- public static final short KEY_DELETEFILE = 146;
- public static final short KEY_XFER = 147;
- public static final short KEY_PROG1 = 148;
- public static final short KEY_PROG2 = 149;
- public static final short KEY_WWW = 150;/* AL Internet Browser */
- public static final short KEY_MSDOS = 151;
- public static final short KEY_COFFEE = 152;/* AL Terminal Lock/Screensaver */
- public static final short KEY_SCREENLOCK = KEY_COFFEE;
- public static final short KEY_DIRECTION = 153;
- public static final short KEY_CYCLEWINDOWS = 154;
- public static final short KEY_MAIL = 155;
- public static final short KEY_BOOKMARKS = 156;/* AC Bookmarks */
- public static final short KEY_COMPUTER = 157;
- public static final short KEY_BACK = 158;/* AC Back */
- public static final short KEY_FORWARD = 159;/* AC Forward */
- public static final short KEY_CLOSECD = 160;
- public static final short KEY_EJECTCD = 161;
- public static final short KEY_EJECTCLOSECD = 162;
- public static final short KEY_NEXTSONG = 163;
- public static final short KEY_PLAYPAUSE = 164;
- public static final short KEY_PREVIOUSSONG = 165;
- public static final short KEY_STOPCD = 166;
- public static final short KEY_RECORD = 167;
- public static final short KEY_REWIND = 168;
- public static final short KEY_PHONE = 169;/* Media Select Telephone */
- public static final short KEY_ISO = 170;
- public static final short KEY_CONFIG = 171;/*
- * AL Consumer Control
- * Configuration
- */
- public static final short KEY_HOMEPAGE = 172;/* AC Home */
- public static final short KEY_REFRESH = 173;/* AC Refresh */
- public static final short KEY_EXIT = 174;/* AC Exit */
- public static final short KEY_MOVE = 175;
- public static final short KEY_EDIT = 176;
- public static final short KEY_SCROLLUP = 177;
- public static final short KEY_SCROLLDOWN = 178;
- public static final short KEY_KPLEFTPAREN = 179;
- public static final short KEY_KPRIGHTPAREN = 180;
- public static final short KEY_NEW = 181;/* AC New */
- public static final short KEY_REDO = 182;/* AC Redo/Repeat */
-
- public static final short KEY_F13 = 183;
- public static final short KEY_F14 = 184;
- public static final short KEY_F15 = 185;
- public static final short KEY_F16 = 186;
- public static final short KEY_F17 = 187;
- public static final short KEY_F18 = 188;
- public static final short KEY_F19 = 189;
- public static final short KEY_F20 = 190;
- public static final short KEY_F21 = 191;
- public static final short KEY_F22 = 192;
- public static final short KEY_F23 = 193;
- public static final short KEY_F24 = 194;
-
- public static final short KEY_PLAYCD = 200;
- public static final short KEY_PAUSECD = 201;
- public static final short KEY_PROG3 = 202;
- public static final short KEY_PROG4 = 203;
- public static final short KEY_DASHBOARD = 204;/* AL Dashboard */
- public static final short KEY_SUSPEND = 205;
- public static final short KEY_CLOSE = 206;/* AC Close */
- public static final short KEY_PLAY = 207;
- public static final short KEY_FASTFORWARD = 208;
- public static final short KEY_BASSBOOST = 209;
- public static final short KEY_PRINT = 210;/* AC Print */
- public static final short KEY_HP = 211;
- public static final short KEY_CAMERA = 212;
- public static final short KEY_SOUND = 213;
- public static final short KEY_QUESTION = 214;
- public static final short KEY_EMAIL = 215;
- public static final short KEY_CHAT = 216;
- public static final short KEY_SEARCH = 217;
- public static final short KEY_CONNECT = 218;
- public static final short KEY_FINANCE = 219;/* AL Checkbook/Finance */
- public static final short KEY_SPORT = 220;
- public static final short KEY_SHOP = 221;
- public static final short KEY_ALTERASE = 222;
- public static final short KEY_CANCEL = 223;/* AC Cancel */
- public static final short KEY_BRIGHTNESSDOWN = 224;
- public static final short KEY_BRIGHTNESSUP = 225;
- public static final short KEY_MEDIA = 226;
-
- public static final short KEY_SWITCHVIDEOMODE = 227;/*
- * Cycle between
- * available video
- * outputs
- * (Monitor/LCD/TV
- * -out/etc)
- */
- public static final short KEY_KBDILLUMTOGGLE = 228;
- public static final short KEY_KBDILLUMDOWN = 229;
- public static final short KEY_KBDILLUMUP = 230;
-
- public static final short KEY_SEND = 231;/* AC Send */
- public static final short KEY_REPLY = 232;/* AC Reply */
- public static final short KEY_FORWARDMAIL = 233;/* AC Forward Msg */
- public static final short KEY_SAVE = 234;/* AC Save */
- public static final short KEY_DOCUMENTS = 235;
-
- public static final short KEY_BATTERY = 236;
-
- public static final short KEY_BLUETOOTH = 237;
- public static final short KEY_WLAN = 238;
- public static final short KEY_UWB = 239;
-
- public static final short KEY_UNKNOWN = 240;
-
- public static final short KEY_VIDEO_NEXT = 241;/* drive next video source */
- public static final short KEY_VIDEO_PREV = 242;/*
- * drive previous video
- * source
- */
- public static final short KEY_BRIGHTNESS_CYCLE = 243;/*
- * brightness up, after
- * max is min
- */
- public static final short KEY_BRIGHTNESS_ZERO = 244;/*
- * brightness off, use
- * ambient
- */
- public static final short KEY_DISPLAY_OFF = 245;/*
- * display device to off
- * state
- */
-
- public static final short KEY_WIMAX = 246;
-
- /* Range 248 - 255 is reserved for special needs of AT keyboard driver */
-
- public static final short BTN_MISC = 0x100;
- public static final short BTN_0 = 0x100;
- public static final short BTN_1 = 0x101;
- public static final short BTN_2 = 0x102;
- public static final short BTN_3 = 0x103;
- public static final short BTN_4 = 0x104;
- public static final short BTN_5 = 0x105;
- public static final short BTN_6 = 0x106;
- public static final short BTN_7 = 0x107;
- public static final short BTN_8 = 0x108;
- public static final short BTN_9 = 0x109;
-
- public static final short BTN_MOUSE = 0x110;
- public static final short BTN_LEFT = 0x110;
- public static final short BTN_RIGHT = 0x111;
- public static final short BTN_MIDDLE = 0x112;
- public static final short BTN_SIDE = 0x113;
- public static final short BTN_EXTRA = 0x114;
- public static final short BTN_FORWARD = 0x115;
- public static final short BTN_BACK = 0x116;
- public static final short BTN_TASK = 0x117;
-
- public static final short BTN_JOYSTICK = 0x120;
- public static final short BTN_TRIGGER = 0x120;
- public static final short BTN_THUMB = 0x121;
- public static final short BTN_THUMB2 = 0x122;
- public static final short BTN_TOP = 0x123;
- public static final short BTN_TOP2 = 0x124;
- public static final short BTN_PINKIE = 0x125;
- public static final short BTN_BASE = 0x126;
- public static final short BTN_BASE2 = 0x127;
- public static final short BTN_BASE3 = 0x128;
- public static final short BTN_BASE4 = 0x129;
- public static final short BTN_BASE5 = 0x12a;
- public static final short BTN_BASE6 = 0x12b;
- public static final short BTN_DEAD = 0x12f;
-
- public static final short BTN_GAMEPAD = 0x130;
- public static final short BTN_A = 0x130;
- public static final short BTN_B = 0x131;
- public static final short BTN_C = 0x132;
- public static final short BTN_X = 0x133;
- public static final short BTN_Y = 0x134;
- public static final short BTN_Z = 0x135;
- public static final short BTN_TL = 0x136;
- public static final short BTN_TR = 0x137;
- public static final short BTN_TL2 = 0x138;
- public static final short BTN_TR2 = 0x139;
- public static final short BTN_SELECT = 0x13a;
- public static final short BTN_START = 0x13b;
- public static final short BTN_MODE = 0x13c;
- public static final short BTN_THUMBL = 0x13d;
- public static final short BTN_THUMBR = 0x13e;
-
- public static final short BTN_DIGI = 0x140;
- public static final short BTN_TOOL_PEN = 0x140;
- public static final short BTN_TOOL_RUBBER = 0x141;
- public static final short BTN_TOOL_BRUSH = 0x142;
- public static final short BTN_TOOL_PENCIL = 0x143;
- public static final short BTN_TOOL_AIRBRUSH = 0x144;
- public static final short BTN_TOOL_FINGER = 0x145;
- public static final short BTN_TOOL_MOUSE = 0x146;
- public static final short BTN_TOOL_LENS = 0x147;
- public static final short BTN_TOUCH = 0x14a;
- public static final short BTN_STYLUS = 0x14b;
- public static final short BTN_STYLUS2 = 0x14c;
- public static final short BTN_TOOL_DOUBLETAP = 0x14d;
- public static final short BTN_TOOL_TRIPLETAP = 0x14e;
- public static final short BTN_TOOL_QUADTAP = 0x14f;/*
- * Four fingers on
- * trackpad
- */
-
- public static final short BTN_WHEEL = 0x150;
- public static final short BTN_GEAR_DOWN = 0x150;
- public static final short BTN_GEAR_UP = 0x151;
-
- public static final short KEY_OK = 0x160;
- public static final short KEY_SELECT = 0x161;
- public static final short KEY_GOTO = 0x162;
- public static final short KEY_CLEAR = 0x163;
- public static final short KEY_POWER2 = 0x164;
- public static final short KEY_OPTION = 0x165;
- public static final short KEY_INFO = 0x166;/* AL OEM Features/Tips/Tutorial */
- public static final short KEY_TIME = 0x167;
- public static final short KEY_VENDOR = 0x168;
- public static final short KEY_ARCHIVE = 0x169;
- public static final short KEY_PROGRAM = 0x16a;/* Media Select Program Guide */
- public static final short KEY_CHANNEL = 0x16b;
- public static final short KEY_FAVORITES = 0x16c;
- public static final short KEY_EPG = 0x16d;
- public static final short KEY_PVR = 0x16e;/* Media Select Home */
- public static final short KEY_MHP = 0x16f;
- public static final short KEY_LANGUAGE = 0x170;
- public static final short KEY_TITLE = 0x171;
- public static final short KEY_SUBTITLE = 0x172;
- public static final short KEY_ANGLE = 0x173;
- public static final short KEY_ZOOM = 0x174;
- public static final short KEY_MODE = 0x175;
- public static final short KEY_KEYBOARD = 0x176;
- public static final short KEY_SCREEN = 0x177;
- public static final short KEY_PC = 0x178;/* Media Select Computer */
- public static final short KEY_TV = 0x179;/* Media Select TV */
- public static final short KEY_TV2 = 0x17a;/* Media Select Cable */
- public static final short KEY_VCR = 0x17b;/* Media Select VCR */
- public static final short KEY_VCR2 = 0x17c;/* VCR Plus */
- public static final short KEY_SAT = 0x17d;/* Media Select Satellite */
- public static final short KEY_SAT2 = 0x17e;
- public static final short KEY_CD = 0x17f;/* Media Select CD */
- public static final short KEY_TAPE = 0x180;/* Media Select Tape */
- public static final short KEY_RADIO = 0x181;
- public static final short KEY_TUNER = 0x182;/* Media Select Tuner */
- public static final short KEY_PLAYER = 0x183;
- public static final short KEY_TEXT = 0x184;
- public static final short KEY_DVD = 0x185;/* Media Select DVD */
- public static final short KEY_AUX = 0x186;
- public static final short KEY_MP3 = 0x187;
- public static final short KEY_AUDIO = 0x188;
- public static final short KEY_VIDEO = 0x189;
- public static final short KEY_DIRECTORY = 0x18a;
- public static final short KEY_LIST = 0x18b;
- public static final short KEY_MEMO = 0x18c;/* Media Select Messages */
- public static final short KEY_CALENDAR = 0x18d;
- public static final short KEY_RED = 0x18e;
- public static final short KEY_GREEN = 0x18f;
- public static final short KEY_YELLOW = 0x190;
- public static final short KEY_BLUE = 0x191;
- public static final short KEY_CHANNELUP = 0x192;/* Channel Increment */
- public static final short KEY_CHANNELDOWN = 0x193;/* Channel Decrement */
- public static final short KEY_FIRST = 0x194;
- public static final short KEY_LAST = 0x195;/* Recall Last */
- public static final short KEY_AB = 0x196;
- public static final short KEY_NEXT = 0x197;
- public static final short KEY_RESTART = 0x198;
- public static final short KEY_SLOW = 0x199;
- public static final short KEY_SHUFFLE = 0x19a;
- public static final short KEY_BREAK = 0x19b;
- public static final short KEY_PREVIOUS = 0x19c;
- public static final short KEY_DIGITS = 0x19d;
- public static final short KEY_TEEN = 0x19e;
- public static final short KEY_TWEN = 0x19f;
- public static final short KEY_VIDEOPHONE = 0x1a0;/* Media Select Video Phone */
- public static final short KEY_GAMES = 0x1a1;/* Media Select Games */
- public static final short KEY_ZOOMIN = 0x1a2;/* AC Zoom In */
- public static final short KEY_ZOOMOUT = 0x1a3;/* AC Zoom Out */
- public static final short KEY_ZOOMRESET = 0x1a4;/* AC Zoom */
- public static final short KEY_WORDPROCESSOR = 0x1a5;/* AL Word Processor */
- public static final short KEY_EDITOR = 0x1a6;/* AL Text Editor */
- public static final short KEY_SPREADSHEET = 0x1a7;/* AL Spreadsheet */
- public static final short KEY_GRAPHICSEDITOR = 0x1a8;/* AL Graphics Editor */
- public static final short KEY_PRESENTATION = 0x1a9;/* AL Presentation App */
- public static final short KEY_DATABASE = 0x1aa;/* AL Database App */
- public static final short KEY_NEWS = 0x1ab;/* AL Newsreader */
- public static final short KEY_VOICEMAIL = 0x1ac;/* AL Voicemail */
- public static final short KEY_ADDRESSBOOK = 0x1ad;/* AL Contacts/Address Book */
- public static final short KEY_MESSENGER = 0x1ae;/* AL Instant Messaging */
- public static final short KEY_DISPLAYTOGGLE = 0x1af;/*
- * Turn display (LCD) on
- * and off
- */
- public static final short KEY_SPELLCHECK = 0x1b0;/* AL Spell Check */
- public static final short KEY_LOGOFF = 0x1b1;/* AL Logoff */
-
- public static final short KEY_DOLLAR = 0x1b2;
- public static final short KEY_EURO = 0x1b3;
-
- public static final short KEY_FRAMEBACK = 0x1b4;/*
- * Consumer - transport
- * controls
- */
- public static final short KEY_FRAMEFORWARD = 0x1b5;
- public static final short KEY_CONTEXT_MENU = 0x1b6;/*
- * GenDesc - system
- * context menu
- */
- public static final short KEY_MEDIA_REPEAT = 0x1b7;/*
- * Consumer - transport
- * control
- */
-
- public static final short KEY_DEL_EOL = 0x1c0;
- public static final short KEY_DEL_EOS = 0x1c1;
- public static final short KEY_INS_LINE = 0x1c2;
- public static final short KEY_DEL_LINE = 0x1c3;
-
- public static final short KEY_FN = 0x1d0;
- public static final short KEY_FN_ESC = 0x1d1;
- public static final short KEY_FN_F1 = 0x1d2;
- public static final short KEY_FN_F2 = 0x1d3;
- public static final short KEY_FN_F3 = 0x1d4;
- public static final short KEY_FN_F4 = 0x1d5;
- public static final short KEY_FN_F5 = 0x1d6;
- public static final short KEY_FN_F6 = 0x1d7;
- public static final short KEY_FN_F7 = 0x1d8;
- public static final short KEY_FN_F8 = 0x1d9;
- public static final short KEY_FN_F9 = 0x1da;
- public static final short KEY_FN_F10 = 0x1db;
- public static final short KEY_FN_F11 = 0x1dc;
- public static final short KEY_FN_F12 = 0x1dd;
- public static final short KEY_FN_1 = 0x1de;
- public static final short KEY_FN_2 = 0x1df;
- public static final short KEY_FN_D = 0x1e0;
- public static final short KEY_FN_E = 0x1e1;
- public static final short KEY_FN_F = 0x1e2;
- public static final short KEY_FN_S = 0x1e3;
- public static final short KEY_FN_B = 0x1e4;
-
- public static final short KEY_BRL_DOT1 = 0x1f1;
- public static final short KEY_BRL_DOT2 = 0x1f2;
- public static final short KEY_BRL_DOT3 = 0x1f3;
- public static final short KEY_BRL_DOT4 = 0x1f4;
- public static final short KEY_BRL_DOT5 = 0x1f5;
- public static final short KEY_BRL_DOT6 = 0x1f6;
- public static final short KEY_BRL_DOT7 = 0x1f7;
- public static final short KEY_BRL_DOT8 = 0x1f8;
- public static final short KEY_BRL_DOT9 = 0x1f9;
- public static final short KEY_BRL_DOT10 = 0x1fa;
-
- public static final short KEY_NUMERIC_0 = 0x200;/*
- * used by phones, remote
- * controls,
- */
- public static final short KEY_NUMERIC_1 = 0x201;/* and other keypads */
- public static final short KEY_NUMERIC_2 = 0x202;
- public static final short KEY_NUMERIC_3 = 0x203;
- public static final short KEY_NUMERIC_4 = 0x204;
- public static final short KEY_NUMERIC_5 = 0x205;
- public static final short KEY_NUMERIC_6 = 0x206;
- public static final short KEY_NUMERIC_7 = 0x207;
- public static final short KEY_NUMERIC_8 = 0x208;
- public static final short KEY_NUMERIC_9 = 0x209;
- public static final short KEY_NUMERIC_STAR = 0x20a;
- public static final short KEY_NUMERIC_POUND = 0x20b;
-
- /* We avoid low common keys in module aliases so they don't get huge. */
- public static final short KEY_MIN_INTERESTING = KEY_MUTE;
- public static final short KEY_MAX = 0x2ff;
- public static final short KEY_CNT = (KEY_MAX + 1);
-
- /*
- * Relative axes
- */
-
- public static final short REL_X = 0x00;
- public static final short REL_Y = 0x01;
- public static final short REL_Z = 0x02;
- public static final short REL_RX = 0x03;
- public static final short REL_RY = 0x04;
- public static final short REL_RZ = 0x05;
- public static final short REL_HWHEEL = 0x06;
- public static final short REL_DIAL = 0x07;
- public static final short REL_WHEEL = 0x08;
- public static final short REL_MISC = 0x09;
- public static final short REL_MAX = 0x0f;
- public static final short REL_CNT = (REL_MAX + 1);
-
- /*
- * Absolute axes
- */
-
- public static final short ABS_X = 0x00;
- public static final short ABS_Y = 0x01;
- public static final short ABS_Z = 0x02;
- public static final short ABS_RX = 0x03;
- public static final short ABS_RY = 0x04;
- public static final short ABS_RZ = 0x05;
- public static final short ABS_THROTTLE = 0x06;
- public static final short ABS_RUDDER = 0x07;
- public static final short ABS_WHEEL = 0x08;
- public static final short ABS_GAS = 0x09;
- public static final short ABS_BRAKE = 0x0a;
- public static final short ABS_HAT0X = 0x10;
- public static final short ABS_HAT0Y = 0x11;
- public static final short ABS_HAT1X = 0x12;
- public static final short ABS_HAT1Y = 0x13;
- public static final short ABS_HAT2X = 0x14;
- public static final short ABS_HAT2Y = 0x15;
- public static final short ABS_HAT3X = 0x16;
- public static final short ABS_HAT3Y = 0x17;
- public static final short ABS_PRESSURE = 0x18;
- public static final short ABS_DISTANCE = 0x19;
- public static final short ABS_TILT_X = 0x1a;
- public static final short ABS_TILT_Y = 0x1b;
- public static final short ABS_TOOL_WIDTH = 0x1c;
- public static final short ABS_VOLUME = 0x20;
- public static final short ABS_MISC = 0x28;
-
- public static final short ABS_MT_TOUCH_MAJOR = 0x30;/*
- * Major axis of
- * touching ellipse
- */
- public static final short ABS_MT_TOUCH_MINOR = 0x31;/*
- * Minor axis (omit if
- * circular)
- */
- public static final short ABS_MT_WIDTH_MAJOR = 0x32;/*
- * Major axis of
- * approaching ellipse
- */
- public static final short ABS_MT_WIDTH_MINOR = 0x33;/*
- * Minor axis (omit if
- * circular)
- */
- public static final short ABS_MT_ORIENTATION = 0x34;/* Ellipse orientation */
- public static final short ABS_MT_POSITION_X = 0x35;/*
- * Center X ellipse
- * position
- */
- public static final short ABS_MT_POSITION_Y = 0x36;/*
- * Center Y ellipse
- * position
- */
- public static final short ABS_MT_TOOL_TYPE = 0x37;/* Type of touching device */
- public static final short ABS_MT_BLOB_ID = 0x38;/*
- * Group a set of packets as
- * a blob
- */
- public static final short ABS_MT_TRACKING_ID = 0x39;/*
- * Unique ID of
- * initiated contact
- */
-
- public static final short ABS_MAX = 0x3f;
- public static final short ABS_CNT = (ABS_MAX + 1);
-
- /*
- * Switch events
- */
-
- public static final short SW_LID = 0x00;/* set = lid shut */
- public static final short SW_TABLET_MODE = 0x01;/* set = tablet mode */
- public static final short SW_HEADPHONE_INSERT = 0x02;/* set = inserted */
- public static final short SW_RFKILL_ALL = 0x03;/*
- * rfkill master switch,
- * type "any" set = radio
- * enabled
- */
- public static final short SW_RADIO = SW_RFKILL_ALL;/* deprecated */
- public static final short SW_MICROPHONE_INSERT = 0x04;/* set = inserted */
- public static final short SW_DOCK = 0x05;/* set = plugged into dock */
- public static final short SW_LINEOUT_INSERT = 0x06;/* set = inserted */
- public static final short SW_JACK_PHYSICAL_INSERT = 0x07;/*
- * set = mechanical
- * switch set
- */
- public static final short SW_VIDEOOUT_INSERT = 0x08;/* set = inserted */
- public static final short SW_MAX = 0x0f;
- public static final short SW_CNT = (SW_MAX + 1);
-
- /*
- * Misc events
- */
-
- public static final short MSC_SERIAL = 0x00;
- public static final short MSC_PULSELED = 0x01;
- public static final short MSC_GESTURE = 0x02;
- public static final short MSC_RAW = 0x03;
- public static final short MSC_SCAN = 0x04;
- public static final short MSC_MAX = 0x07;
- public static final short MSC_CNT = (MSC_MAX + 1);
-
- /*
- * LEDs
- */
-
- public static final short LED_NUML = 0x00;
- public static final short LED_CAPSL = 0x01;
- public static final short LED_SCROLLL = 0x02;
- public static final short LED_COMPOSE = 0x03;
- public static final short LED_KANA = 0x04;
- public static final short LED_SLEEP = 0x05;
- public static final short LED_SUSPEND = 0x06;
- public static final short LED_MUTE = 0x07;
- public static final short LED_MISC = 0x08;
- public static final short LED_MAIL = 0x09;
- public static final short LED_CHARGING = 0x0a;
- public static final short LED_MAX = 0x0f;
- public static final short LED_CNT = (LED_MAX + 1);
-
- /*
- * Autorepeat values
- */
-
- public static final short REP_DELAY = 0x00;
- public static final short REP_PERIOD = 0x01;
- public static final short REP_MAX = 0x01;
-
- /*
- * Sounds
- */
-
- public static final short SND_CLICK = 0x00;
- public static final short SND_BELL = 0x01;
- public static final short SND_TONE = 0x02;
- public static final short SND_MAX = 0x07;
- public static final short SND_CNT = (SND_MAX + 1);
-
- /*
- * IDs.
- */
-
- public static final short ID_BUS = 0;
- public static final short ID_VENDOR = 1;
- public static final short ID_PRODUCT = 2;
- public static final short ID_VERSION = 3;
-
- public static final short BUS_PCI = 0x01;
- public static final short BUS_ISAPNP = 0x02;
- public static final short BUS_USB = 0x03;
- public static final short BUS_HIL = 0x04;
- public static final short BUS_BLUETOOTH = 0x05;
- public static final short BUS_VIRTUAL = 0x06;
-
- public static final short BUS_ISA = 0x10;
- public static final short BUS_I8042 = 0x11;
- public static final short BUS_XTKBD = 0x12;
- public static final short BUS_RS232 = 0x13;
- public static final short BUS_GAMEPORT = 0x14;
- public static final short BUS_PARPORT = 0x15;
- public static final short BUS_AMIGA = 0x16;
- public static final short BUS_ADB = 0x17;
- public static final short BUS_I2C = 0x18;
- public static final short BUS_HOST = 0x19;
- public static final short BUS_GSC = 0x1A;
- public static final short BUS_ATARI = 0x1B;
-
- /*
- * MT_TOOL types
- */
- public static final short MT_TOOL_FINGER = 0;
- public static final short MT_TOOL_PEN = 1;
-
- /*
- * Values describing the status of a force-feedback effect
- */
- public static final short FF_STATUS_STOPPED = 0x00;
- public static final short FF_STATUS_PLAYING = 0x01;
- public static final short FF_STATUS_MAX = 0x01;
-
-
- public long time_sec;
- public long time_usec;
- public /*__u16*/ short type;
- public /*__u16*/ short code;
- public /*__s32*/ int value;
- public String source;
-
- /**
- * Parse an InputEvent out of a ShortBuffer.
- * @param shortBuffer
- * @return the parsed InputEvent
- * @throws IOException
- */
- public static InputEvent parse(ShortBuffer shortBuffer, String source) throws IOException {
- InputEvent e = new InputEvent();
- short a,b,c,d;
- a=shortBuffer.get();
- b=shortBuffer.get();
- c=shortBuffer.get();
- d=shortBuffer.get();
- e.time_sec = (d<<48) | (c<<32) | (b<<16) | a;
- a=shortBuffer.get();
- b=shortBuffer.get();
- c=shortBuffer.get();
- d=shortBuffer.get();
- e.time_usec = (d<<48) | (c<<32) | (b<<16) | a;
- e.type = shortBuffer.get();
- e.code = shortBuffer.get();
- c=shortBuffer.get();
- d=shortBuffer.get();
- e.value = (d<<16) | c;
- e.source = source;
- return e;
- }
-
- private InputEvent() {}
-
- @Override
- public String toString() {
- //TODO Java sucks at printing unsigned longs. Dur...
- return String.format("Event: time %d.%06d, type %d, code %d, value %02x",
- time_sec, time_usec, type, code, value);
- }
-
-}
diff --git a/src/com/dgis/input/evdev/InputListener.java b/src/com/dgis/input/evdev/InputListener.java
deleted file mode 100644
index 6d23ca5..0000000
--- a/src/com/dgis/input/evdev/InputListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.dgis.input.evdev;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Listener for Evdev events.
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- * @see com.dgis.input.evdev.EventDevice
- */
-
-public interface InputListener {
- /**
- * This method is called by a EventDevice when an event is reported by
- * the event device under its watch.
- * @param e The event details.
- */
- public void event(InputEvent e);
-}
diff --git a/src/com/dgis/input/evdev/devices/EvdevJoystickFilter.java b/src/com/dgis/input/evdev/devices/EvdevJoystickFilter.java
deleted file mode 100644
index d392a32..0000000
--- a/src/com/dgis/input/evdev/devices/EvdevJoystickFilter.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package com.dgis.input.evdev.devices;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import com.dgis.input.evdev.EventDevice;
-import com.dgis.input.evdev.InputEvent;
-import com.dgis.input.evdev.InputListener;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * This class simplifies using "joystick" type input device (read: anything generating absolute axis and button events)
- * when dealing with an evdev EventDevice.
- * Consolidates multiple events between EV_SYN events, and can tell you how many buttons and axes exist, and which changed.
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class EvdevJoystickFilter implements InputListener {
-
- private EventDevice device;
- private JoystickState state;
-
- private ArrayList listeners = new ArrayList();
-
- /**
- * Holds the event codes for each joystick button, in order. That is, if
- * event code 288 is button one, it is the first entry here.
- */
- private ArrayList buttonEventCodes = new ArrayList();
-
- /**
- * Holds the event codes for each joystick axis, in order. That is, if
- * event code 0 is axis one, it is the first entry here.
- */
- private ArrayList axisEventCodes = new ArrayList();
-
- private boolean[] buttonChanged, axisChanged;
-
- /**
- * Constructs an EvdevJoystickFilter using the provided EventDevice as input.
- */
- public EvdevJoystickFilter(EventDevice dev) {
- this.device = dev;
- setupDevice();
- }
- /**
- * Constructs an EvdevJoystickFilter using the provided event device as input.
- */
- public EvdevJoystickFilter(String device) throws IOException {
- this(new EventDevice(device));
- }
-
- private void setupDevice() {
- Map> supportedEvents = device.getSupportedEvents();
- List supportedAxes = supportedEvents.get((int)InputEvent.EV_ABS);
- List supportedKeys = supportedEvents.get((int)InputEvent.EV_KEY);
-
- int numAxes = supportedAxes == null ? 0 : supportedAxes.size();
- int numButtons = supportedKeys == null ? 0 : supportedKeys.size();
-
- buttonEventCodes.addAll(supportedKeys);
- axisEventCodes.addAll(supportedAxes);
-
- System.out.println("Detected "+buttonEventCodes.size()+" buttons and "+axisEventCodes.size()+" axes.");
-
- buttonChanged = new boolean[numButtons];
- axisChanged = new boolean[numAxes];
-
- state = new JoystickState(numButtons, numAxes);
- device.addListener(this);
- }
-
- @Override
- public void event(InputEvent e) {
- switch(e.type) {
- case InputEvent.EV_KEY:
- handleButton(e.code, e.value>0);
- break;
- case InputEvent.EV_ABS:
- handleAxis(e.code, e.value);
- break;
- case InputEvent.EV_SYN:
- dispatchEvents();
- default: /* Unknown to us, ignore */
- }
- }
- /**
- * Broadcast events for what changed since the last dispatchEvents().
- */
- private void dispatchEvents() {
- boolean anyAxisChanged = false;
- boolean anyButtonChanged = false;
- for(boolean x:buttonChanged) anyButtonChanged |=x;
- for(boolean x:axisChanged) anyAxisChanged |=x;
-
- for(JoystickListener l : listeners) {
- if(anyButtonChanged)
- l.buttonChanged(buttonChanged, state, device.getDevicePath());
- if(anyAxisChanged)
- l.joystickMoved(axisChanged, state, device.getDevicePath());
- }
-
- Arrays.fill(axisChanged, false);
- Arrays.fill(buttonChanged, false);
- }
- private void handleAxis(short axisNumber, int value) {
- int axisNumber2 = axisEventCodes.indexOf((int)axisNumber);
- if(axisNumber2 <0) {
- System.err.println("WARN: Couldn't find axis "+axisNumber+" in mapping! Perhaps device reported capabilities improperly!");
- return;
- }
- axisChanged[axisNumber2] = (value != state.getAxisState(axisNumber2)); //only flag as changed if _actually_ changed.
- state.setAxisState(axisNumber2, value);
-
- }
-
- private void handleButton(short buttonNumber, boolean buttonState) {
- int buttonNumber2 = buttonEventCodes.indexOf((int)buttonNumber);
- if(buttonNumber2 <0) {
- System.err.println("WARN: Couldn't find button "+buttonNumber+" in mapping! Perhaps device reported capabilities improperly!");
- return;
- }
- buttonChanged[buttonNumber2] = (buttonState != state.getButtonState(buttonNumber2)); //only flag as changed if _actually_ changed.
- state.setButtonState(buttonNumber2, buttonState);
- }
-
- /**
- * Adds an event listener to this device.
- * If the listener is already on the listener list,
- * this method has no effect.
- * @param list The listener to add. Must not be null.
- */
- public void addListener(JoystickListener list) {
- listeners.add(list);
- }
-
- /**
- * Removes an event listener to this device.
- * If the listener is not on the listener list,
- * this method has no effect.
- * @param list The listener to remove. Must not be null.
- */
- public void removeListener(JoystickListener list) {
- listeners.remove(list);
- }
-
- public void close() {
- device.close();
- }
-}
diff --git a/src/com/dgis/input/evdev/devices/JoystickListener.java b/src/com/dgis/input/evdev/devices/JoystickListener.java
deleted file mode 100644
index 6f1512a..0000000
--- a/src/com/dgis/input/evdev/devices/JoystickListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.dgis.input.evdev.devices;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Listener for Joystick events.
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- * @see com.dgis.input.evdev.EventDevice
- */
-
-public interface JoystickListener {
- /**
- * Called whenever a joystick's axis changes state.
- * @param axesChanged Bitmap of axis status. If the nth value in this array is true, then the nth axis changed state.
- * @param state The updated joystick state.
- */
- public void joystickMoved(boolean[] axesChanged, JoystickState state, String source);
- /**
- * Called whenever a joystick's button changes state.
- * @param buttonsChanged Bitmap of button status. If the nth value in this array is true, then the nth button changed state.
- * @param state The updated joystick state.
- */
- public void buttonChanged(boolean[] buttonsChanged, JoystickState state, String source);
-}
diff --git a/src/com/dgis/input/evdev/devices/JoystickState.java b/src/com/dgis/input/evdev/devices/JoystickState.java
deleted file mode 100644
index c49960d..0000000
--- a/src/com/dgis/input/evdev/devices/JoystickState.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.dgis.input.evdev.devices;
-
-/*
- * Copyright (C) 2009 Giacomo Ferrari
- * This file is part of evdev-java.
- * evdev-java is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * evdev-java is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with evdev-java. If not, see .
- */
-
-/**
- * Represents the state of a joystick (buttons and axes)
- *
- * Copyright (C) 2009 Giacomo Ferrari
- * @author Giacomo Ferrari
- */
-
-public class JoystickState {
- private int numButtons;
- private int numAxes;
- private boolean buttonStates[];
- private int axisStates[];
- private int axisMinValue[];
- private int axisMaxValue[];
-
- JoystickState(int numButtons, int numAxes) {
- buttonStates = new boolean[numButtons];
- axisStates = new int[numAxes];
- axisMinValue = new int[numAxes];
- axisMaxValue = new int[numAxes];
- }
-
- /**
- * Gets the number of buttons reported by this joystick.
- * @return The number of buttons reported.
- */
- public int getNumButtons() {
- return numButtons;
- }
-
- /**
- * Gets the number of axes reported by this joystick.
- * @return The number of axes reported.
- */
- public int getNumAxes() {
- return numAxes;
- }
-
- /**
- * Queries the state of a joystick button.
- * @param button The button number to check. Valid ranges are 0 to getNumButtons()-1.
- * @return The state of the button.
- */
- public boolean getButtonState(int button) {
- return buttonStates[button];
- }
-
- /**
- * Queries the state of a joystick axis.
- * @param axis The axis number to check. Valid ranges are 0 to getNumAxes()-1.
- * @return The state of the axis, typically in the range +-32768.
- * @see JoystickState#getAxisMaxValue(int)
- * @see JoystickState#getAxisMinValue(int)
- */
- public int getAxisState(int axis) {
- return axisStates[axis];
- }
-
- /**
- * Queries the smallest value ever seen on a given axis for calibration purposes.
- * @param axis The axis to check. Valid ranges are 0 to getNumButtons()-1.
- * @return The smallest value ever seen on this axis.
- */
- public int getAxisMinValue(int axis) {
- return axisMinValue[axis];
- }
-
- /**
- * Queries the largest value ever seen on a given axis for calibration purposes.
- * @param axis The axis to check. Valid ranges are 0 to getNumButtons()-1.
- * @return The largest value ever seen on this axis.
- */
- public int getAxisMaxValue(int axis) {
- return axisMaxValue[axis];
- }
-
- void setButtonState(int button, boolean state) {
- buttonStates[button] = state;;
- }
-
- void setAxisState(int axis, int state) {
- axisStates[axis] = state;
- }
-
- void setAxisMinValue(int axis, int min) {
- axisMinValue[axis] = min;
- }
-
- void setAxisMaxValue(int axis, int max) {
- axisMaxValue[axis] = max;
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer("Buttons: [ ");
- for(boolean b : buttonStates) buf.append((b?1:0) + " ");
- buf.append("] Axes: [ ");
- for(int a : axisStates) buf.append(a + " ");
- buf.append("]");
- return buf.toString();
- }
-}
diff --git a/src/etc/checkstyle-suppressions.xml b/src/etc/checkstyle-suppressions.xml
new file mode 100644
index 0000000..46acf8c
--- /dev/null
+++ b/src/etc/checkstyle-suppressions.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+