mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-02-02 05:44:44 +01:00
Compare commits
238 commits
post-issue
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47fda71672 | ||
|
|
447ec94f22 | ||
|
|
d861b32778 | ||
|
|
8662748d00 | ||
|
|
b98ee86b13 | ||
|
|
8eafaaa61e | ||
|
|
796c4780fd | ||
|
|
b6150acbce | ||
|
|
d0487df592 | ||
|
|
33640ec47d | ||
|
|
f37172befd | ||
|
|
c826412056 | ||
|
|
847c20d89c | ||
|
|
b70a38d9f1 | ||
|
|
3b79a57e9f | ||
|
|
d8fd89c5f2 | ||
|
|
196fab2d6f | ||
|
|
be5f3a6307 | ||
|
|
341db62139 | ||
|
|
ba876c7e34 | ||
|
|
abceb81d56 | ||
|
|
351e8e1201 | ||
|
|
f7155114ce | ||
|
|
f12daf06da | ||
|
|
b15ffc59b4 | ||
|
|
d5451041a7 | ||
|
|
fc1f43c5cf | ||
|
|
6c5b3cf39d | ||
|
|
78ca4c4d18 | ||
|
|
f7742fbd95 | ||
|
|
d166d82729 | ||
|
|
62c5953307 | ||
|
|
5a83f72422 | ||
|
|
43ba12c160 | ||
|
|
06d9d5ca66 | ||
|
|
4f6269fdd2 | ||
|
|
92f17913ca | ||
|
|
7ea0ebcc1f | ||
|
|
16202823b5 | ||
|
|
466e4a6bdb | ||
|
|
67902800ab | ||
|
|
af914ca5e4 | ||
|
|
d057119f79 | ||
|
|
a623d0c271 | ||
|
|
c77ad3226c | ||
|
|
ad452077d4 | ||
|
|
83dd362c65 | ||
|
|
7d3e5f31ae | ||
|
|
88395eef77 | ||
|
|
a775a55c46 | ||
|
|
981587abbc | ||
|
|
b87aa830e8 | ||
|
|
30304ba8f4 | ||
|
|
a19b3c9fa3 | ||
|
|
59c21d42c5 | ||
|
|
4ef9e03623 | ||
|
|
d80d2ad2b2 | ||
|
|
91428ceee0 | ||
|
|
0cfd2ae7cd | ||
|
|
db8c6804b4 | ||
|
|
c9152a679d | ||
|
|
4b8183ead9 | ||
|
|
5ba05aff65 | ||
|
|
b853018676 | ||
|
|
f5f30e17ab | ||
|
|
516aed2c93 | ||
|
|
72d4ca05a8 | ||
|
|
f0d7f6db03 | ||
|
|
9c639cdfbc | ||
|
|
4b00766888 | ||
|
|
2bc8a793c8 | ||
|
|
81c9c872cd | ||
|
|
98a19dbb1a | ||
|
|
974302e420 | ||
|
|
3bc6b827e0 | ||
|
|
c63b09a047 | ||
|
|
6150206edb | ||
|
|
a4c7d312d2 | ||
|
|
99debb71a0 | ||
|
|
9509787f01 | ||
|
|
b6ca29e9f1 | ||
|
|
a095351e4a | ||
|
|
bd571ad746 | ||
|
|
c72d1fcb01 | ||
|
|
b997ef8545 | ||
|
|
97416d3813 | ||
|
|
d4ce65b28b | ||
|
|
8ba4395c2d | ||
|
|
544e00cd5c | ||
|
|
12496a9fbb | ||
|
|
76613c2c6f | ||
|
|
f1b1b5a74f | ||
|
|
ded17f0897 | ||
|
|
b6253e440e | ||
|
|
165a4d74e6 | ||
|
|
b440e211e1 | ||
|
|
5eb89d4e12 | ||
|
|
771499a7ca | ||
|
|
5b799195e3 | ||
|
|
bd61698f16 | ||
|
|
79a3fc9291 | ||
|
|
aa699f5ffb | ||
|
|
f228dbcf59 | ||
|
|
b82395833a | ||
|
|
8a569fdc63 | ||
|
|
d9586e25bb | ||
|
|
98cf806325 | ||
|
|
0d466440d9 | ||
|
|
b93ddcc46e | ||
|
|
70c9291774 | ||
|
|
99df8dc84c | ||
|
|
5d19200671 | ||
|
|
6b177835ff | ||
|
|
4731a08964 | ||
|
|
5b0cafeb36 | ||
|
|
f541fdb219 | ||
|
|
dc75289f96 | ||
|
|
5b7c6314ed | ||
|
|
04b2dce53a | ||
|
|
676f94ed4c | ||
|
|
b1d6589b73 | ||
|
|
55e0f46eec | ||
|
|
9f650f8a5d | ||
|
|
0f52875091 | ||
|
|
e0676a02df | ||
|
|
5119891aa7 | ||
|
|
9d11cb04da | ||
|
|
517357401e | ||
|
|
69d6b1b8a6 | ||
|
|
cc2c663916 | ||
|
|
4c7eff906e | ||
|
|
62451c9cb7 | ||
|
|
49946e27e0 | ||
|
|
c6a6d2e8f8 | ||
|
|
2acfe0edaa | ||
|
|
8a213d061c | ||
|
|
a5112ed015 | ||
|
|
f4876067c1 | ||
|
|
4b66611142 | ||
|
|
0e321e77a2 | ||
|
|
4a7f075d23 | ||
|
|
92391498cf | ||
|
|
4cb3cc08fc | ||
|
|
ee9aa09577 | ||
|
|
76669f6b51 | ||
|
|
9a6fd1cf66 | ||
|
|
c875ade848 | ||
|
|
40f2e7fd25 | ||
|
|
809334336c | ||
|
|
c82ba65e2b | ||
|
|
96eea217e3 | ||
|
|
ba840b81f4 | ||
|
|
b08843d82b | ||
|
|
64ec6fe8e4 | ||
|
|
c8996c0581 | ||
|
|
4e98105deb | ||
|
|
e0a512be48 | ||
|
|
5a80ec7321 | ||
|
|
557be525a2 | ||
|
|
f2b022b197 | ||
|
|
22b9ee15a4 | ||
|
|
3b886a200e | ||
|
|
3faf26532e | ||
|
|
1eea3061f1 | ||
|
|
682ebbaf69 | ||
|
|
c71f96a708 | ||
|
|
252ca8876f | ||
|
|
2b7d10e435 | ||
|
|
289a6db298 | ||
|
|
4517180482 | ||
|
|
b2fd759065 | ||
|
|
294629a312 | ||
|
|
2c9654b300 | ||
|
|
e730077f78 | ||
|
|
822e0b4827 | ||
|
|
2f7d29dd39 | ||
|
|
e866ea5dc9 | ||
|
|
c1014ab8a6 | ||
|
|
57586046d8 | ||
|
|
e7ed731ceb | ||
|
|
b813d5594e | ||
|
|
bbf4c985f0 | ||
|
|
61edc6b2cd | ||
|
|
643e6380ed | ||
|
|
0943752c25 | ||
|
|
3c24e13a83 | ||
|
|
335552cf71 | ||
|
|
2837517753 | ||
|
|
350d8fec21 | ||
|
|
790b666865 | ||
|
|
a5c79be8d0 | ||
|
|
29d8717a75 | ||
|
|
229d2c9dda | ||
|
|
9452bb5f80 | ||
|
|
eee0db5b4f | ||
|
|
900a46506a | ||
|
|
87e7d8df2f | ||
|
|
9646122032 | ||
|
|
c07fe191ea | ||
|
|
62ed7dc473 | ||
|
|
3c352dc3cc | ||
|
|
84be9b9b36 | ||
|
|
b1384277ad | ||
|
|
73fe22bc94 | ||
|
|
b7302c451f | ||
|
|
45e8a00390 | ||
|
|
823c47bc2b | ||
|
|
0ad4010e80 | ||
|
|
40af67538f | ||
|
|
2789d50724 | ||
|
|
32829e5df6 | ||
|
|
530a7eaf94 | ||
|
|
967fde8a93 | ||
|
|
86fb3d5499 | ||
|
|
d4a1fd4ae6 | ||
|
|
bfce766c46 | ||
|
|
3cc17edd10 | ||
|
|
2644b47f44 | ||
|
|
d60c807a24 | ||
|
|
c95cf4bddd | ||
|
|
b789b8cd52 | ||
|
|
571769019e | ||
|
|
8a606b3e3f | ||
|
|
c5ff2100e2 | ||
|
|
ca1963aadc | ||
|
|
db9ebeccef | ||
|
|
2ed5250bf4 | ||
|
|
8ed1ae2586 | ||
|
|
971b9e3e39 | ||
|
|
eaa55d4860 | ||
|
|
f2a679ae06 | ||
|
|
7d527dda1c | ||
|
|
b210efd1d0 | ||
|
|
3694ba5514 | ||
|
|
0015c724b3 | ||
|
|
69a2984615 | ||
|
|
13e1269023 | ||
|
|
a2f62499b9 |
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
build/
|
||||||
|
target/
|
||||||
|
apidocs/
|
||||||
|
bin/
|
||||||
|
classes/
|
||||||
|
dist/
|
||||||
|
eclipse_bin/
|
||||||
|
*.iml
|
||||||
|
.idea/
|
||||||
|
dependency-reduced-pom.xml
|
||||||
31
CHANGES
31
CHANGES
|
|
@ -1,31 +0,0 @@
|
||||||
Major:
|
|
||||||
- Flattened Mouse so it isn't separated into child controllers (ball, buttons).
|
|
||||||
- Removed useless component members from Mouse and Keyboard. For example, Mouse.getX() is now simply getComponent(Component.Identifier.Axis.X).
|
|
||||||
- Removed StandardKeyboard.
|
|
||||||
- Removed Mouse.Button and Keyboard.Key since they only complicated plugins
|
|
||||||
- Added Keyboard.isKeyDown(Component.Identifier.Key) (with default false for non-existent keys).
|
|
||||||
- Removed Component.isPolling() and Component.setPolling().
|
|
||||||
- Removed Component.isNormalized() since all plugins return normalized data for absolute axes anyway.
|
|
||||||
- Windows XP: Added RawInputEnvironmentPlugin to enable multiple mice and keyboards. DirectInput will only report one system mouse and one system keyboard where all mice and keyboard input are combined (in fact, Windows was the OS with the most complicated and confusing APIs, apart from the fact that I had to code two separate plugins for it). The RawInputEnvironment is not enabled per default, since it seems to exclude mouse and keybaord input to DirectInput which will probably confuse unsuspecting applications. But at least there is now a method to access multiple keyboards and mice on windows xp.
|
|
||||||
- DirectInput: Got rid of the nasty DataFormat special case handling. The DirectInput data format is now one large (java int) array which is a better match for the jinput abstraction than the builtin DirectInput data formats for mice, keyboards and joysticks.
|
|
||||||
- Added event queue support. An Event contains a Component, a value and a relative timestamp in nanoseconds.
|
|
||||||
- Basically rewrote all plugins from scratch, with focus on minimizing the amount of native code in general, and in particular for moving decisions from native to java, making the native code more general purpose and less likely to need changes. Additionally, all plugins support the new event queue interface. All plugins now have much better error handling (exceptions) and much tighter native code (no more global variables, helper functions declared static etc.). Additionally, all plugin internal java classes are package protected and final for added security.
|
|
||||||
- Mac OS X: Added missing features and fixed broken Mouse.
|
|
||||||
- Cleaned up build system and added option for a combined jinput.jar with all plugins as opposed to just the OS specific packages
|
|
||||||
- JInput should now be thread safe.
|
|
||||||
- Mac OS X intel mac support. The jinput-osx.jnilib library is for 10.4 or better (both ppc and i386), while libjinput-osx-legacy.jnilib is for 10.3 or earlier.
|
|
||||||
|
|
||||||
Minor:
|
|
||||||
- Removed keyId from Component.Identifier.Key
|
|
||||||
- Made components, children and rumblers final in AbstractController
|
|
||||||
- Added Identifier->Component Map to AbstractController to avoid Keyboard special code and to speed up the Component.getComponent() method in general.
|
|
||||||
- Added exceptions to native code for accurate error messages (instead of the standard printf). I use the checked IOException exclusively, but since exceptions are not exposed to user code, that can easily be changed.
|
|
||||||
- Added printfJava(env, format, ...) to native code to avoid printfs altogether
|
|
||||||
|
|
||||||
Issues not fixed:
|
|
||||||
- Linux plugin report buttons ids with semantic value (trigger button, thumb button etc.) while all other plugins use simple button indices (0, 1, 2, 3 etc.). This is a property of the underlying linux input API and will probably confuse some jinput programs.
|
|
||||||
- The Plugin architecture seems somewhat complex and IMHO unnecessary. It involves custom Classloaders to separate the each Plugin's namespaces, but since you can't use custom Classloaders in restricted environments (web start, applets) the plugins have to have manually separate namespaces anyway. I'm inclined to remove it, but since it was there originally, there is probably some use case it covers I don't know about.
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
- A utility for collecting events from multiple controller at once. An application then just needs to register all its devices to the utility and only call poll() and getEventQueue() in one place. Event will probably need to be extended with a getController() method.
|
|
||||||
|
|
||||||
144
Jenkinsfile
vendored
Normal file
144
Jenkinsfile
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
pipeline {
|
||||||
|
agent none
|
||||||
|
triggers { pollSCM('H/15 * * * *') }
|
||||||
|
tools {
|
||||||
|
maven 'Maven 3.5.3'
|
||||||
|
jdk 'OpenJDK 9'
|
||||||
|
}
|
||||||
|
options { buildDiscarder(logRotator(numToKeepStr: '5')) }
|
||||||
|
parameters {
|
||||||
|
booleanParam(defaultValue: false, description: 'Perform Release', name: 'release')
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Build core') {
|
||||||
|
agent {
|
||||||
|
label "osx"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'mvn -B -Dmaven.antrun.skip -Dmaven.source.skip -Dmaven.test.skip -DskipTests -DskipITs -pl coreAPI/ package'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
archiveArtifacts artifacts: 'coreAPI/target/apidocs/**/*', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build natives') {
|
||||||
|
parallel {
|
||||||
|
stage('Build Windows natives') {
|
||||||
|
agent {
|
||||||
|
label "windows"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
bat 'mvn -B -am -pl plugins/windows/,plugins/wintab/ clean compile'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
stash includes: 'plugins/**/target/natives/*.dll', name: 'windows-natives'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build Linux natives') {
|
||||||
|
agent {
|
||||||
|
label "linux"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'mvn -B -am -pl plugins/linux/ clean compile'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
stash includes: 'plugins/**/target/natives/*.so*', name: 'linux-natives'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build OSX natives') {
|
||||||
|
agent {
|
||||||
|
label "osx"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'mvn -B -am -pl plugins/OSX/ clean compile'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
stash includes: '**/target/natives/*.jnilib', name: 'osx-natives'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
|
agent {
|
||||||
|
label "linux"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
unstash 'windows-natives'
|
||||||
|
unstash 'osx-natives'
|
||||||
|
unstash 'linux-natives'
|
||||||
|
sh 'mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.javadoc.skip -Dmaven.source.skip -Dmaven.test.skip -DskipTests -DskipITs package'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
stash includes: '**/target/*.jar', name: 'all-java-jars'
|
||||||
|
archiveArtifacts artifacts: '**/target/*.jar*', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy') {
|
||||||
|
agent {
|
||||||
|
label "linux"
|
||||||
|
}
|
||||||
|
when { branch 'master' }
|
||||||
|
steps {
|
||||||
|
milestone(1)
|
||||||
|
unstash 'windows-natives'
|
||||||
|
unstash 'osx-natives'
|
||||||
|
unstash 'linux-natives'
|
||||||
|
sh 'echo $GPG_SECRET_KEYS | base64 --decode | gpg --batch --import'
|
||||||
|
sh 'echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust'
|
||||||
|
withMaven(
|
||||||
|
maven: 'Maven 3.5.3',
|
||||||
|
jdk: 'OpenJDK 9',
|
||||||
|
globalMavenSettingsConfig: 'global-maven-settings-ossrh',
|
||||||
|
mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts
|
||||||
|
) {
|
||||||
|
sh "mvn -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Release') {
|
||||||
|
agent {
|
||||||
|
label "linux"
|
||||||
|
}
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
return params.release
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
milestone(3)
|
||||||
|
unstash 'windows-natives'
|
||||||
|
unstash 'osx-natives'
|
||||||
|
unstash 'linux-natives'
|
||||||
|
sh 'echo $GPG_SECRET_KEYS | base64 --decode | gpg --batch --import'
|
||||||
|
sh 'echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust'
|
||||||
|
withMaven(
|
||||||
|
maven: 'Maven 3.5.3',
|
||||||
|
jdk: 'OpenJDK 9',
|
||||||
|
globalMavenSettingsConfig: 'global-maven-settings-ossrh',
|
||||||
|
mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts
|
||||||
|
) {
|
||||||
|
sh "mvn -P windows,linux,osx,wintab versions:set -DremoveSnapshot"
|
||||||
|
script {
|
||||||
|
VERSION_TAG = sh(script: "mvn -Dexpression=project.version help:evaluate | grep -e '^[[:digit:]]'", returnStdout: true).trim()
|
||||||
|
}
|
||||||
|
sh "git tag -a ${VERSION_TAG} -m 'Release tag ${VERSION_TAG}'"
|
||||||
|
sh "mvn -P windows,linux,osx,wintab,release -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy"
|
||||||
|
sh "mvn -P windows,linux,osx,wintab versions:revert"
|
||||||
|
sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot"
|
||||||
|
sh "git commit -m 'Next development release' ."
|
||||||
|
sh "git push origin HEAD:master --follow-tags"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
README.md
Normal file
9
README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# JInput
|
||||||
|
|
||||||
|
[](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi)
|
||||||
|
[](http://www.javadoc.io/doc/net.java.jinput/coreapi)
|
||||||
|
|
||||||
|
Library for access to input devices.
|
||||||
|
|
||||||
|
## License
|
||||||
|
Licensed under [BSD License](https://opensource.org/licenses/BSD-3-Clause), copyright is attributed in each source file committed.
|
||||||
92
README.txt
92
README.txt
|
|
@ -1,92 +0,0 @@
|
||||||
Project: net.java.games.*
|
|
||||||
Purpose: Open source game libraries
|
|
||||||
Authors:
|
|
||||||
-- input API design:
|
|
||||||
Michael Martak, Sun Microsystems
|
|
||||||
Thomas Daniel, Sony Computer Entertainment
|
|
||||||
-- input API original author:
|
|
||||||
Michael Martak,Sun Microsystems
|
|
||||||
-- input API original release author:
|
|
||||||
Jeff Kesselman, Game Technology Architect,
|
|
||||||
Advanced Software Technologies Group,
|
|
||||||
Sun Microsystems.
|
|
||||||
-- this file updated on 06/06/2003 by Jeff Kesselman
|
|
||||||
|
|
||||||
|
|
||||||
Introduction:
|
|
||||||
|
|
||||||
This is the source tree for the Java Game Initiative (JGI) Open Source
|
|
||||||
client game programming APIs.
|
|
||||||
|
|
||||||
Build Requirements:
|
|
||||||
|
|
||||||
Note: This build depends on there being a jutils.jar in the lib directories
|
|
||||||
of both the coreAPI and the plug-ins. If you install the JGI Jutils project
|
|
||||||
at the same root as this project and build it first it will put jars in the
|
|
||||||
right places.
|
|
||||||
|
|
||||||
This project has been built in the following environment.
|
|
||||||
-- Win32 (Win 2000 in the case of our machine)
|
|
||||||
-- Sun J2SDK 1.4 (available at java.sun.com)
|
|
||||||
-- MinGW 2.0.0 plus the following updates: (all available at www.mingw.org)
|
|
||||||
-- binutils 2.13.90
|
|
||||||
-- w32api-2.2
|
|
||||||
-- mingw-runtime-2.4
|
|
||||||
-- "Peter Puck's" directx8 binding
|
|
||||||
(http://www.urebelscum.speedhost.com/download.html, file: dx8libs.zip
|
|
||||||
(Copy all of his *.a library files into the MingW "lib" directory)
|
|
||||||
-- The DirectX 9 SDK available at the Microsoft DirectX site.
|
|
||||||
(http://www.microsoft.com/directx)
|
|
||||||
The Win32 plug-in build.xml file expects this to be installed in
|
|
||||||
c:\dx9. You can install it elsewhere but then you will have to modify
|
|
||||||
the reference in that build.xml ant script.
|
|
||||||
-- ANT 1.4.1 (available at apache.org)
|
|
||||||
|
|
||||||
|
|
||||||
Directory Organization:
|
|
||||||
|
|
||||||
The root contains a master ANT build.xml and the following sub directories:
|
|
||||||
-- coreAPI: The actual API
|
|
||||||
-- plugins: Directories for building controller plugins.
|
|
||||||
(Currently the only plug in is the Win32 DX8 plugin.)
|
|
||||||
|
|
||||||
Build instructions:
|
|
||||||
|
|
||||||
To clean: ant clean
|
|
||||||
To build: ant all (or just ant)
|
|
||||||
To build docs: ant javadoc
|
|
||||||
To test:
|
|
||||||
First cd to coreAPI. There are currently 2 tests there.
|
|
||||||
Textest: A simple discovery test that dumps
|
|
||||||
the data about the discovered controllers to stdout
|
|
||||||
To run: ant textest
|
|
||||||
Readtest: A test that creates a window for each discovered
|
|
||||||
controller (or sub-controller) which displays the
|
|
||||||
current state of all the controller's axes.
|
|
||||||
(Note: The windows currently all open at the same
|
|
||||||
place on the screen so you will have to move them to
|
|
||||||
see them all.)
|
|
||||||
To run: ant readtest
|
|
||||||
|
|
||||||
Release Info:
|
|
||||||
Initial Release: This release contains an implementation of the input
|
|
||||||
API designed by Mike Martak of Sun and Thomas (?) of Sony CEA for
|
|
||||||
the WIn32 platform. All the code in src/input is cross platform. The
|
|
||||||
Win32 code is segregated to the DirectX plugin (src/DXplugin) which
|
|
||||||
depends on DirectInput from DX7 (or later).
|
|
||||||
|
|
||||||
05/09/2003: A number of bugs and problems with the DXPlugin are fixed in this
|
|
||||||
release. This release also brings the code up to date using the DI8
|
|
||||||
interface. This thus is the first release that requires Peter Puck's
|
|
||||||
DX8 bindings to compile with MinGW.
|
|
||||||
|
|
||||||
05/09/2003 (second update):
|
|
||||||
This version adds a new standard value type to the API.
|
|
||||||
Axis.POV holds standard definitions for values for POV (hat) switches
|
|
||||||
-- Axis.POV.CENTER and Axis.POV.OFF are synonymous and are
|
|
||||||
the center position.
|
|
||||||
-- Axis.POV.UP, Axis.POV.DOWN, Axis.POV.LEFT and Axis.POV.RIGHT
|
|
||||||
should be self explanatory.
|
|
||||||
Any hat that claims to be "normalized" will return these values. (It is
|
|
||||||
recommended that all hats be normalized by the system specific plugins.)
|
|
||||||
|
|
||||||
18
applet/jinput-event.html
Normal file
18
applet/jinput-event.html
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
|
<meta http-equiv="content-language" content="en">
|
||||||
|
<title>JInput Applet Test</title>
|
||||||
|
<script src="http://java.com/js/deployJava.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
deployJava.setInstallerType('kernel');
|
||||||
|
// include any required packages as shown below
|
||||||
|
deployJava.setAdditionalPackages('javax.swing, javax.xml');
|
||||||
|
deployJava.runApplet({codebase:".",
|
||||||
|
archive:"jinput.jar,jinput-test.jar,jinput-applet-test.jar", code:"net.java.games.input.applet.test.ControllerEventTestApplet",
|
||||||
|
width:"320", Height:"400"}, null, "1.4.2");
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
18
applet/jinput.html
Normal file
18
applet/jinput.html
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
|
<meta http-equiv="content-language" content="en">
|
||||||
|
<title>JInput Applet Test</title>
|
||||||
|
<script src="http://java.com/js/deployJava.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
deployJava.setInstallerType('kernel');
|
||||||
|
// include any required packages as shown below
|
||||||
|
deployJava.setAdditionalPackages('javax.swing, javax.xml');
|
||||||
|
deployJava.runApplet({codebase:".",
|
||||||
|
archive:"jinput.jar,jinput-test.jar,jinput-applet-test.jar", code:"net.java.games.input.applet.test.ControllerReadTestApplet",
|
||||||
|
width:"320", Height:"400"}, null, "1.4.2");
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
applet/pom.xml
Normal file
27
applet/pom.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>applet</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - applet</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput-parent</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer. Redistributions in binary
|
||||||
|
* form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* The name of the author may not be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||||
|
*/
|
||||||
|
package net.java.games.input.applet;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class JInputAppletResourceLoader {
|
||||||
|
|
||||||
|
private static final Logger diagnosticLog = Logger.getLogger(JInputAppletResourceLoader.class.getName());
|
||||||
|
private int percentageDone = 0;
|
||||||
|
|
||||||
|
private String getPrivilegedProperty(final String property) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setPrivilegedProperty(final String property, final String value) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.setProperty(property, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadResources(URL codeBase) throws IOException {
|
||||||
|
downloadNativesJar(codeBase);
|
||||||
|
extractNativesJar(codeBase);
|
||||||
|
setJInputClasspath(codeBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPercentageDone() {
|
||||||
|
return percentageDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setJInputClasspath(URL codeBase) {
|
||||||
|
setPrivilegedProperty("net.java.games.input.librarypath", getTempDir(codeBase) + File.separator + "natives" + File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extractNativesJar(URL codeBase) throws IOException {
|
||||||
|
File tempDir = new File(getTempDir(codeBase));
|
||||||
|
String osName = getPrivilegedProperty("os.name");
|
||||||
|
String nativeJar = null;
|
||||||
|
if (osName.startsWith("Win")) {
|
||||||
|
nativeJar = "jinput-windows-native.jar";
|
||||||
|
} else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) {
|
||||||
|
nativeJar = "jinput-linux-native.jar";
|
||||||
|
} else if (osName.startsWith("Mac")) {
|
||||||
|
nativeJar = "jinput-osx-native.jar";
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
JarFile localJarFile = new JarFile(new File(tempDir, nativeJar), true);
|
||||||
|
|
||||||
|
Enumeration<JarEntry> jarEntries = localJarFile.entries();
|
||||||
|
int totalUncompressedBytes = 0;
|
||||||
|
int totalUncompressedBytesWritten = 0;
|
||||||
|
List<JarEntry> entriesToUse = new ArrayList<>();
|
||||||
|
|
||||||
|
while(jarEntries.hasMoreElements()) {
|
||||||
|
JarEntry jarEntry = jarEntries.nextElement();
|
||||||
|
String entryName = jarEntry.getName();
|
||||||
|
if(!entryName.startsWith("META-INF")) {
|
||||||
|
totalUncompressedBytes+=jarEntry.getSize();
|
||||||
|
entriesToUse.add(jarEntry);
|
||||||
|
diagnosticLog.log(Level.INFO, "Got entry " + entryName + " " + jarEntry.getSize() + " big, total of " + totalUncompressedBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File tempNativesDir = new File(tempDir, "natives");
|
||||||
|
if(!tempNativesDir.exists()) {
|
||||||
|
tempNativesDir.mkdirs();
|
||||||
|
tempNativesDir.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<entriesToUse.size();i++) {
|
||||||
|
JarEntry jarEntry = entriesToUse.get(i);
|
||||||
|
InputStream inStream = localJarFile.getInputStream(localJarFile.getEntry(jarEntry.getName()));
|
||||||
|
File nativeFile = new File(tempNativesDir, jarEntry.getName());
|
||||||
|
FileOutputStream fos = new FileOutputStream(nativeFile);
|
||||||
|
|
||||||
|
byte[] dataBuffer = new byte[65535];
|
||||||
|
int bytesRead = 0;
|
||||||
|
|
||||||
|
// Read the first block
|
||||||
|
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
|
||||||
|
while(bytesRead!=-1) {
|
||||||
|
|
||||||
|
fos.write(dataBuffer, 0, bytesRead);
|
||||||
|
|
||||||
|
totalUncompressedBytesWritten+=bytesRead;
|
||||||
|
|
||||||
|
int unpackingPercentageDone = (int)((((float)totalUncompressedBytesWritten)/totalUncompressedBytes)*100);
|
||||||
|
percentageDone = 50 + (unpackingPercentageDone/2); //Reading the file is only 1/2 the job
|
||||||
|
diagnosticLog.log(Level.INFO, "Written " + totalUncompressedBytesWritten + " out of " + totalUncompressedBytes + " " + unpackingPercentageDone + "%, (" + percentageDone + "% total)");
|
||||||
|
|
||||||
|
// Read the next block
|
||||||
|
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
|
||||||
|
}
|
||||||
|
long entryModifiedTime = jarEntry.getTime();
|
||||||
|
nativeFile.setLastModified(entryModifiedTime);
|
||||||
|
diagnosticLog.log(Level.INFO, "Setting native modified time to " + new Date(entryModifiedTime));
|
||||||
|
fos.close();
|
||||||
|
inStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadNativesJar(URL codeBase) throws IOException {
|
||||||
|
diagnosticLog.log(Level.INFO, "codebase: " + codeBase);
|
||||||
|
File tempDir = new File(getTempDir(codeBase));
|
||||||
|
if(!tempDir.exists()) {
|
||||||
|
tempDir.mkdirs();
|
||||||
|
tempDir.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
String osName = getPrivilegedProperty("os.name");
|
||||||
|
String nativeJar = null;
|
||||||
|
if (osName.startsWith("Win")) {
|
||||||
|
nativeJar = "jinput-windows-native.jar";
|
||||||
|
} else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) {
|
||||||
|
nativeJar = "jinput-linux-native.jar";
|
||||||
|
} else if (osName.startsWith("Mac")) {
|
||||||
|
nativeJar = "jinput-osx-native.jar";
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
File localJarFile = new File(tempDir, nativeJar);
|
||||||
|
localJarFile.deleteOnExit();
|
||||||
|
|
||||||
|
diagnosticLog.log(Level.INFO, "Using local file " + localJarFile.getCanonicalPath());
|
||||||
|
|
||||||
|
OutputStream outStream = new FileOutputStream(localJarFile);
|
||||||
|
outStream = new BufferedOutputStream(outStream);
|
||||||
|
|
||||||
|
URL remoteJarURL = new URL(codeBase, nativeJar);
|
||||||
|
|
||||||
|
diagnosticLog.log(Level.INFO, "Using remote file " + remoteJarURL);
|
||||||
|
|
||||||
|
URLConnection connection = remoteJarURL.openConnection();
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setConnectTimeout(2000);
|
||||||
|
|
||||||
|
int contentLength = connection.getContentLength();
|
||||||
|
|
||||||
|
diagnosticLog.log(Level.INFO, "remote jar is " + contentLength + " bytes");
|
||||||
|
|
||||||
|
InputStream inStream = connection.getInputStream();
|
||||||
|
byte[] dataBuffer = new byte[65535];
|
||||||
|
int bytesRead = 0;
|
||||||
|
int totalRead = 0;
|
||||||
|
int totalWritten = 0;
|
||||||
|
|
||||||
|
// Read the first block
|
||||||
|
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
|
||||||
|
while(bytesRead!=-1) {
|
||||||
|
//Update total read
|
||||||
|
totalRead+=bytesRead;
|
||||||
|
|
||||||
|
outStream.write(dataBuffer, 0, bytesRead);
|
||||||
|
|
||||||
|
totalWritten+=bytesRead;
|
||||||
|
|
||||||
|
int thisFilePercent = (int)((((float)totalRead)/contentLength)*100);
|
||||||
|
percentageDone = thisFilePercent/2; //Reading the file is only 1/2 the job
|
||||||
|
diagnosticLog.log(Level.INFO, "Written " + totalRead + " out of " + contentLength + " " + thisFilePercent + "%, (" + percentageDone + "% total)");
|
||||||
|
|
||||||
|
// Read the next block
|
||||||
|
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
inStream.close();
|
||||||
|
outStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTempDir(URL codeBase) {
|
||||||
|
return getPrivilegedProperty("java.io.tmpdir") + File.separator + codeBase.getHost() + File.separator + "jinput";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
234
build.xml
234
build.xml
|
|
@ -1,234 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<project name="Sun Games Initiative Client Technologies" basedir="." default="all">
|
|
||||||
<target name="init">
|
|
||||||
<!-- If we are running in windows, set dx8 property to true -->
|
|
||||||
<condition property="windows" >
|
|
||||||
<os family="windows" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- If we are running in linux, set linux property to true -->
|
|
||||||
<condition property="linux" >
|
|
||||||
<!--<os family="unix" />-->
|
|
||||||
<os name="linux" />
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- If we are running in Mac OS X, set osx property to true -->
|
|
||||||
<condition property="osx" >
|
|
||||||
<and>
|
|
||||||
<os family="mac" />
|
|
||||||
<os family="unix" />
|
|
||||||
</and>
|
|
||||||
</condition>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="runtest" depends="dist">
|
|
||||||
<java classname="${mainclass}"
|
|
||||||
fork="true" failonerror="true" dir=".">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="dist/jinput.jar"/>
|
|
||||||
<pathelement location="dist/jinput-test.jar"/>
|
|
||||||
</classpath>
|
|
||||||
<jvmarg value="-Djava.library.path=dist"/>
|
|
||||||
</java>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="texttest">
|
|
||||||
<antcall target="runtest">
|
|
||||||
<param name="mainclass" value="net.java.games.input.test.ControllerTextTest"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="readtest" depends="init,all" description="Try running it.">
|
|
||||||
<antcall target="runtest">
|
|
||||||
<param name="mainclass" value="net.java.games.input.test.ControllerReadTest"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="eventtest" depends="init,all" description="Try running it.">
|
|
||||||
<antcall target="runtest">
|
|
||||||
<param name="mainclass" value="net.java.games.input.test.ControllerEventTest"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="rumbletest" depends="init,all" description="Try running it.">
|
|
||||||
<antcall target="runtest">
|
|
||||||
<param name="mainclass" value="net.java.games.input.test.RumbleTest"/>
|
|
||||||
</antcall>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<macrodef name="iterate">
|
|
||||||
<attribute name="target"/>
|
|
||||||
<sequential>
|
|
||||||
<subant target="@{target}">
|
|
||||||
<fileset file="coreAPI/build.xml"/>
|
|
||||||
<fileset file="plugins/linux/build.xml"/>
|
|
||||||
<fileset file="plugins/windows/build.xml"/>
|
|
||||||
<fileset file="plugins/wintab/build.xml"/>
|
|
||||||
<fileset file="plugins/OSX/build.xml"/>
|
|
||||||
<fileset file="plugins/awt/build.xml"/>
|
|
||||||
</subant>
|
|
||||||
</sequential>
|
|
||||||
</macrodef>
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<iterate target="clean"/>
|
|
||||||
<delete dir="dist" failonerror="no"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="all" depends="dist">
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="javadoc" depends="init">
|
|
||||||
<iterate target="javadoc"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="pluginTest" depends="dist" description="Build plugin version">
|
|
||||||
<mkdir dir="dist"/>
|
|
||||||
<mkdir dir="dist/controller"/>
|
|
||||||
<copy todir="dist">
|
|
||||||
<fileset file="coreAPI/bin/jinput-core.jar"/>
|
|
||||||
<fileset file="coreAPI/bin/jinput-test.jar"/>
|
|
||||||
<fileset file="plugins/DX8/lib/jutils.jar"/>
|
|
||||||
</copy>
|
|
||||||
<copy todir="dist/controller">
|
|
||||||
<fileset dir="plugins/awt/bin"/>
|
|
||||||
<fileset dir="plugins/linux/bin"/>
|
|
||||||
<fileset dir="plugins/OSX/bin"/>
|
|
||||||
<fileset dir="plugins/windows/bin"/>
|
|
||||||
<fileset dir="plugins/wintab/bin"/>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dist" depends="init" description="Build the distribution file for this system">
|
|
||||||
<iterate target="all"/>
|
|
||||||
<mkdir dir="dist"/>
|
|
||||||
<jar jarfile="dist/jinput.jar" compress="true" duplicate="preserve">
|
|
||||||
<fileset dir="coreAPI/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
<exclude name="**/test/*.class"/>
|
|
||||||
<exclude name="**/example/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/linux/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/OSX/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/awt/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/windows/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/wintab/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<zipfileset src="lib/jutils.jar" includes="**/*.class"/>
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Sealed" value="true"/>
|
|
||||||
</manifest>
|
|
||||||
</jar>
|
|
||||||
<copy todir="dist">
|
|
||||||
<fileset file="coreAPI/bin/jinput-test.jar"/>
|
|
||||||
<fileset dir="plugins/linux/bin" includes="*so"/>
|
|
||||||
<fileset dir="plugins/OSX/bin" includes="*jnilib"/>
|
|
||||||
<fileset dir="plugins/windows/bin" includes="*dll"/>
|
|
||||||
<fileset dir="plugins/wintab/bin" includes="*dll"/>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="simple_dist" depends="dist,simple_windows,simple_wintab,simple_linux,simple_osx" description="Build the simple jars for each platform"/>
|
|
||||||
|
|
||||||
<target name="simple_linux" depends="dist" description="Build the simple linux jar" if="linux">
|
|
||||||
<jar jarfile="dist/jinput-linux.jar" compress="true">
|
|
||||||
<fileset dir="coreAPI/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/linux/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<zipfileset src="lib/jutils.jar" includes="**/*.class"/>
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Sealed" value="true"/>
|
|
||||||
</manifest>
|
|
||||||
</jar>
|
|
||||||
<tar destfile="dist/jinput_linux.tgz" compression="gzip">
|
|
||||||
<tarfileset dir=".">
|
|
||||||
<include name="dist/jinput-linux.jar"/>
|
|
||||||
</tarfileset>
|
|
||||||
<tarfileset dir="plugins/linux/bin">
|
|
||||||
<include name="*.so"/>
|
|
||||||
</tarfileset>
|
|
||||||
</tar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="simple_windows" depends="dist" description="Build the simple windows jar" if="windows">
|
|
||||||
<jar jarfile="dist/jinput-windows.jar" compress="true">
|
|
||||||
<fileset dir="coreAPI/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/windows/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<zipfileset src="lib/jutils.jar" includes="**/*.class"/>
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Sealed" value="true"/>
|
|
||||||
</manifest>
|
|
||||||
</jar>
|
|
||||||
<zip destfile="dist/jinput_windows.zip">
|
|
||||||
<zipfileset dir=".">
|
|
||||||
<include name="dist/jinput-windows.jar"/>
|
|
||||||
</zipfileset>
|
|
||||||
<zipfileset dir="plugins/windows/bin">
|
|
||||||
<include name="*.dll"/>
|
|
||||||
</zipfileset>
|
|
||||||
</zip>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="simple_wintab" depends="dist" description="Build the simple windows jar" if="windows">
|
|
||||||
<jar jarfile="dist/jinput-wintab.jar" compress="true">
|
|
||||||
<fileset dir="coreAPI/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/wintab/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<zipfileset src="lib/jutils.jar" includes="**/*.class"/>
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Sealed" value="true"/>
|
|
||||||
</manifest>
|
|
||||||
</jar>
|
|
||||||
<zip destfile="dist/jinput_wintab.zip">
|
|
||||||
<zipfileset dir=".">
|
|
||||||
<include name="dist/jinput-wintab.jar"/>
|
|
||||||
</zipfileset>
|
|
||||||
<zipfileset dir="plugins/wintab/bin">
|
|
||||||
<include name="*.dll"/>
|
|
||||||
</zipfileset>
|
|
||||||
</zip>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="simple_osx" depends="dist" description="Build the simple osx jar" if="osx">
|
|
||||||
<jar jarfile="dist/jinput-osx.jar" compress="true">
|
|
||||||
<fileset dir="coreAPI/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="plugins/OSX/classes">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</fileset>
|
|
||||||
<zipfileset src="lib/jutils.jar" includes="**/*.class"/>
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Sealed" value="true"/>
|
|
||||||
</manifest>
|
|
||||||
</jar>
|
|
||||||
<tar destfile="dist/jinput_osx.tgz" compression="gzip">
|
|
||||||
<tarfileset dir=".">
|
|
||||||
<include name="dist/jinput-osx.jar"/>
|
|
||||||
</tarfileset>
|
|
||||||
<tarfileset dir="plugins/OSX/bin">
|
|
||||||
<include name="*.jnilib"/>
|
|
||||||
</tarfileset>
|
|
||||||
</tar>
|
|
||||||
</target>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
This file modified last on 06/06/2003 by Jeff Kesselman
|
|
||||||
|
|
||||||
This is the source tree for the core input API.
|
|
||||||
|
|
||||||
Directory Organization:
|
|
||||||
|
|
||||||
The root contains a master ANT build.xml.
|
|
||||||
After a successful build of the project you will have the following sub directories:
|
|
||||||
-- apidocs Where the javadocs get built to
|
|
||||||
-- lib Where dependant libraries are kept.
|
|
||||||
-- bin Where the actual API is built to
|
|
||||||
-- src The source files.
|
|
||||||
-- src/test Execution directories and data for tests.
|
|
||||||
|
|
||||||
Build instructions:
|
|
||||||
|
|
||||||
To clean: ant clean
|
|
||||||
To build: ant all (or just ant)
|
|
||||||
To build docs: ant javadoc
|
|
||||||
To test:
|
|
||||||
Textest: A simple discovery test that dumps
|
|
||||||
the data about the discovered controllers to stdout
|
|
||||||
To run: ant textest
|
|
||||||
Readtest: A test that creates a window for each discovered
|
|
||||||
controller (or sub-controller) which displays the
|
|
||||||
current state of all the controller's axiis.
|
|
||||||
(Note: The windows currrently all open at the same
|
|
||||||
place on the screen so yo uwill have to move them to
|
|
||||||
see them all.)
|
|
||||||
To run: ant readtest
|
|
||||||
|
|
||||||
|
|
||||||
Release Info:
|
|
||||||
Initial Release: This release contains an implementation of the input
|
|
||||||
API designed by Mike Martak of Sun and Thomas (?) of Sony CEA for
|
|
||||||
the WIn32 platform. All the code in src/input is cross platform. The
|
|
||||||
Win32 code is segregated to the DirectX plugin (src/DXplugin) which
|
|
||||||
depends on DirectInput from DX7 (or later).
|
|
||||||
|
|
||||||
05/09/2003: A number of bugs and problems with the DXPlugin are fixed in this
|
|
||||||
release. This release also brings the code up to date using the DI8
|
|
||||||
interface. This thus is the first release that requries Peter Puck's
|
|
||||||
DX8 bindings to compile with MinGW.
|
|
||||||
|
|
||||||
05/09/2003 (second update):
|
|
||||||
This version adds a new standard value type to the API.
|
|
||||||
Axis.POV holds standard definitions for values for POV (hat) switches
|
|
||||||
-- Axis.POV.CENTER and Axis.POV.OFF are synonmous and are
|
|
||||||
the center position.
|
|
||||||
-- Axis.POV.UP, Axis.POV.DOWN, Axis.POV.LEFT and Axis.POV.RIGHT
|
|
||||||
should be self explainatory.
|
|
||||||
Any hat that claims to be "normalized" will return these values. (It is
|
|
||||||
recommended that all hats be normalized by the systemn specific plugins.)
|
|
||||||
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<project name="Game Input API" basedir="." default="all">
|
|
||||||
<target name="init">
|
|
||||||
<property name="utils" location="../lib/jutils.jar"/>
|
|
||||||
<mkdir dir="apidocs"/>
|
|
||||||
<mkdir dir="classes"/>
|
|
||||||
<mkdir dir="bin"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile" depends="init">
|
|
||||||
<javac srcdir="src/java" destdir="classes" debug="true" deprecation="true" source="1.4" target="1.4">
|
|
||||||
<include name="net/**"/>
|
|
||||||
<!-- To add something to the classpath: -->
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="${utils}"/>
|
|
||||||
</classpath>
|
|
||||||
</javac>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="jar" depends="init,compile">
|
|
||||||
<jar jarfile="bin/jinput-core.jar" compress="true" basedir="classes">
|
|
||||||
<include name="net/java/games/input/*class"/>
|
|
||||||
</jar>
|
|
||||||
<jar jarfile="bin/jinput-test.jar" compress="true" basedir="classes">
|
|
||||||
<include name="net/java/games/input/test/*class"/>
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="javadoc" depends="init" description="Javadoc for my API.">
|
|
||||||
<javadoc packagenames="net.java.games.input.*"
|
|
||||||
destdir="apidocs"
|
|
||||||
additionalparam="-source 1.4"
|
|
||||||
excludepackagenames="net.java.games.input.example.*,net.java.games.input.test.*">
|
|
||||||
<sourcepath>
|
|
||||||
<pathelement location="src/java"/>
|
|
||||||
</sourcepath>
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="${utils}"/>
|
|
||||||
</classpath>
|
|
||||||
</javadoc>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean" depends="init" description="Clean all build products.">
|
|
||||||
<delete dir="classes"/>
|
|
||||||
<delete dir="bin"/>
|
|
||||||
<delete dir="apidocs"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="all" depends="init,jar" description="Build everything.">
|
|
||||||
<echo message="JInput has been built and jinput.jar is located in the bin directory."/>
|
|
||||||
</target>
|
|
||||||
</project>
|
|
||||||
31
coreAPI/pom.xml
Normal file
31
coreAPI/pom.xml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>coreapi</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - core API</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput-parent</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jutils</groupId>
|
||||||
|
<artifactId>jutils</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<!-- <plugin> -->
|
||||||
|
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
|
||||||
|
<!-- </plugin> -->
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -94,9 +94,9 @@ public abstract class AbstractComponent implements Component {
|
||||||
/**
|
/**
|
||||||
* Returns the data from the last time the control has been polled.
|
* Returns the data from the last time the control has been polled.
|
||||||
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
|
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
|
||||||
* If this axis is normalized, the value returned will be between -1.0f and
|
* If this axis is normalised, the value returned will be between -1.0f and
|
||||||
* 1.0f.
|
* 1.0f.
|
||||||
* @return 0.0f by default, can be overridden
|
* @return The data from the last time the control has been polled.
|
||||||
*/
|
*/
|
||||||
public final float getPollData() {
|
public final float getPollData() {
|
||||||
if (!has_polled && !isRelative()) {
|
if (!has_polled && !isRelative()) {
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
|
||||||
*
|
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
|
@ -35,13 +29,11 @@
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
@ -77,7 +69,7 @@ public abstract class AbstractController implements Controller {
|
||||||
/**
|
/**
|
||||||
* Map from Component.Identifiers to Components
|
* Map from Component.Identifiers to Components
|
||||||
*/
|
*/
|
||||||
private final Map id_to_components = new HashMap();
|
private final Map<Component.Identifier, Component> id_to_components = new HashMap<>();
|
||||||
|
|
||||||
private EventQueue event_queue = new EventQueue(EVENT_QUEUE_DEPTH);
|
private EventQueue event_queue = new EventQueue(EVENT_QUEUE_DEPTH);
|
||||||
|
|
||||||
|
|
@ -128,7 +120,7 @@ public abstract class AbstractController implements Controller {
|
||||||
* if no component with the specified type could be found.
|
* if no component with the specified type could be found.
|
||||||
*/
|
*/
|
||||||
public final Component getComponent(Component.Identifier id) {
|
public final Component getComponent(Component.Identifier id) {
|
||||||
return (Component)id_to_components.get(id);
|
return id_to_components.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -183,7 +175,7 @@ public abstract class AbstractController implements Controller {
|
||||||
setDeviceEventQueueSize(size);
|
setDeviceEventQueueSize(size);
|
||||||
event_queue = new EventQueue(size);
|
event_queue = new EventQueue(size);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ControllerEnvironment.logln("Failed to create new event queue of size " + size + ": " + e);
|
ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +225,7 @@ public abstract class AbstractController implements Controller {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ControllerEnvironment.logln("Failed to poll device: " + e.getMessage());
|
ControllerEnvironment.log("Failed to poll device: " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -444,7 +444,11 @@ public interface Component {
|
||||||
/** 'Select' button on a gamepad
|
/** 'Select' button on a gamepad
|
||||||
*/
|
*/
|
||||||
public static final Button SELECT = new Button("Select");
|
public static final Button SELECT = new Button("Select");
|
||||||
|
|
||||||
|
/** 'Start' button on a gamepad
|
||||||
|
*/
|
||||||
|
public static final Button START = new Button("Start");
|
||||||
|
|
||||||
/** 'Mode' button on a gamepad
|
/** 'Mode' button on a gamepad
|
||||||
*/
|
*/
|
||||||
public static final Button MODE = new Button("Mode");
|
public static final Button MODE = new Button("Mode");
|
||||||
|
|
@ -540,6 +544,50 @@ public interface Component {
|
||||||
* Returns the side mouse button.
|
* Returns the side mouse button.
|
||||||
*/
|
*/
|
||||||
public static final Button SIDE = new Button("Side");
|
public static final Button SIDE = new Button("Side");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra, unnamed, buttons
|
||||||
|
*/
|
||||||
|
public static final Button EXTRA_1 = new Button("Extra 1");
|
||||||
|
public static final Button EXTRA_2 = new Button("Extra 2");
|
||||||
|
public static final Button EXTRA_3 = new Button("Extra 3");
|
||||||
|
public static final Button EXTRA_4 = new Button("Extra 4");
|
||||||
|
public static final Button EXTRA_5 = new Button("Extra 5");
|
||||||
|
public static final Button EXTRA_6 = new Button("Extra 6");
|
||||||
|
public static final Button EXTRA_7 = new Button("Extra 7");
|
||||||
|
public static final Button EXTRA_8 = new Button("Extra 8");
|
||||||
|
public static final Button EXTRA_9 = new Button("Extra 9");
|
||||||
|
public static final Button EXTRA_10 = new Button("Extra 10");
|
||||||
|
public static final Button EXTRA_11 = new Button("Extra 11");
|
||||||
|
public static final Button EXTRA_12 = new Button("Extra 12");
|
||||||
|
public static final Button EXTRA_13 = new Button("Extra 13");
|
||||||
|
public static final Button EXTRA_14 = new Button("Extra 14");
|
||||||
|
public static final Button EXTRA_15 = new Button("Extra 15");
|
||||||
|
public static final Button EXTRA_16 = new Button("Extra 16");
|
||||||
|
public static final Button EXTRA_17 = new Button("Extra 17");
|
||||||
|
public static final Button EXTRA_18 = new Button("Extra 18");
|
||||||
|
public static final Button EXTRA_19 = new Button("Extra 19");
|
||||||
|
public static final Button EXTRA_20 = new Button("Extra 20");
|
||||||
|
public static final Button EXTRA_21 = new Button("Extra 21");
|
||||||
|
public static final Button EXTRA_22 = new Button("Extra 22");
|
||||||
|
public static final Button EXTRA_23 = new Button("Extra 23");
|
||||||
|
public static final Button EXTRA_24 = new Button("Extra 24");
|
||||||
|
public static final Button EXTRA_25 = new Button("Extra 25");
|
||||||
|
public static final Button EXTRA_26 = new Button("Extra 26");
|
||||||
|
public static final Button EXTRA_27 = new Button("Extra 27");
|
||||||
|
public static final Button EXTRA_28 = new Button("Extra 28");
|
||||||
|
public static final Button EXTRA_29 = new Button("Extra 29");
|
||||||
|
public static final Button EXTRA_30 = new Button("Extra 30");
|
||||||
|
public static final Button EXTRA_31 = new Button("Extra 31");
|
||||||
|
public static final Button EXTRA_32 = new Button("Extra 32");
|
||||||
|
public static final Button EXTRA_33 = new Button("Extra 33");
|
||||||
|
public static final Button EXTRA_34 = new Button("Extra 34");
|
||||||
|
public static final Button EXTRA_35 = new Button("Extra 35");
|
||||||
|
public static final Button EXTRA_36 = new Button("Extra 36");
|
||||||
|
public static final Button EXTRA_37 = new Button("Extra 37");
|
||||||
|
public static final Button EXTRA_38 = new Button("Extra 38");
|
||||||
|
public static final Button EXTRA_39 = new Button("Extra 39");
|
||||||
|
public static final Button EXTRA_40 = new Button("Extra 40");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,10 +39,11 @@
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ControllerEnvironment represents a collection of controllers that are
|
* A ControllerEnvironment represents a collection of controllers that are
|
||||||
|
|
@ -69,12 +70,9 @@ import java.util.Iterator;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class ControllerEnvironment {
|
public abstract class ControllerEnvironment {
|
||||||
static void logln(String msg) {
|
|
||||||
log(msg + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void log(String msg) {
|
static void log(String msg) {
|
||||||
System.out.print(msg);
|
Logger.getLogger(ControllerEnvironment.class.getName()).info(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -86,12 +84,17 @@ public abstract class ControllerEnvironment {
|
||||||
/**
|
/**
|
||||||
* List of controller listeners
|
* List of controller listeners
|
||||||
*/
|
*/
|
||||||
protected final ArrayList controllerListeners = new ArrayList();
|
protected final ArrayList<ControllerListener> controllerListeners = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected constructor for subclassing.
|
* Protected constructor for subclassing.
|
||||||
*/
|
*/
|
||||||
protected ControllerEnvironment() {
|
protected ControllerEnvironment() {
|
||||||
|
if(System.getProperty("jinput.loglevel") != null) {
|
||||||
|
String loggerName = ControllerEnvironment.class.getPackage().getName();
|
||||||
|
Level level = Level.parse(System.getProperty("jinput.loglevel"));
|
||||||
|
Logger.getLogger(loggerName).setLevel(level);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -129,9 +132,9 @@ public abstract class ControllerEnvironment {
|
||||||
*/
|
*/
|
||||||
protected void fireControllerAdded(Controller c) {
|
protected void fireControllerAdded(Controller c) {
|
||||||
ControllerEvent ev = new ControllerEvent(c);
|
ControllerEvent ev = new ControllerEvent(c);
|
||||||
Iterator it = controllerListeners.iterator();
|
Iterator<ControllerListener> it = controllerListeners.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
((ControllerListener)it.next()).controllerAdded(ev);
|
it.next().controllerAdded(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,9 +144,9 @@ public abstract class ControllerEnvironment {
|
||||||
*/
|
*/
|
||||||
protected void fireControllerRemoved(Controller c) {
|
protected void fireControllerRemoved(Controller c) {
|
||||||
ControllerEvent ev = new ControllerEvent(c);
|
ControllerEvent ev = new ControllerEvent(c);
|
||||||
Iterator it = controllerListeners.iterator();
|
Iterator<ControllerListener> it = controllerListeners.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
((ControllerListener)it.next()).controllerRemoved(ev);
|
it.next().controllerRemoved(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,4 +157,4 @@ public abstract class ControllerEnvironment {
|
||||||
public static ControllerEnvironment getDefaultEnvironment() {
|
public static ControllerEnvironment getDefaultEnvironment() {
|
||||||
return defaultEnvironment;
|
return defaultEnvironment;
|
||||||
}
|
}
|
||||||
} // ControllerEnvironment
|
}
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
|
||||||
*
|
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
|
@ -35,21 +29,19 @@
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
|
import net.java.games.util.plugins.Plugins;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import net.java.games.util.plugins.*;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default controller environment.
|
* The default controller environment.
|
||||||
|
|
@ -60,6 +52,8 @@ import net.java.games.util.plugins.*;
|
||||||
class DefaultControllerEnvironment extends ControllerEnvironment {
|
class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
static String libPath;
|
static String libPath;
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(DefaultControllerEnvironment.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static utility method for loading native libraries.
|
* Static utility method for loading native libraries.
|
||||||
* It will try to load from either the path given by
|
* It will try to load from either the path given by
|
||||||
|
|
@ -68,42 +62,31 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void loadLibrary(final String lib_name) {
|
static void loadLibrary(final String lib_name) {
|
||||||
AccessController.doPrivileged(
|
AccessController.doPrivileged((PrivilegedAction<String>) () -> {
|
||||||
new PrivilegedAction() {
|
|
||||||
public final Object run() {
|
|
||||||
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
||||||
if (lib_path != null)
|
if (lib_path != null)
|
||||||
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
||||||
else
|
else
|
||||||
System.loadLibrary(lib_name);
|
System.loadLibrary(lib_name);
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property) {
|
static String getPrivilegedProperty(final String property) {
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property));
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property, final String default_value) {
|
static String getPrivilegedProperty(final String property, final String default_value) {
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property, default_value));
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property, default_value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all controllers in this environment
|
* List of all controllers in this environment
|
||||||
*/
|
*/
|
||||||
private ArrayList controllers;
|
private ArrayList<Controller> controllers;
|
||||||
|
|
||||||
private Collection loadedPlugins = new ArrayList();
|
private Collection<String> loadedPluginNames = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public no-arg constructor.
|
* Public no-arg constructor.
|
||||||
|
|
@ -118,13 +101,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
public Controller[] getControllers() {
|
public Controller[] getControllers() {
|
||||||
if (controllers == null) {
|
if (controllers == null) {
|
||||||
// Controller list has not been scanned.
|
// Controller list has not been scanned.
|
||||||
controllers = new ArrayList();
|
controllers = new ArrayList<>();
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
AccessController.doPrivileged((PrivilegedAction<Void>) () -> scanControllers());
|
||||||
public Object run() {
|
|
||||||
scanControllers();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//Check the properties for specified controller classes
|
//Check the properties for specified controller classes
|
||||||
String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
|
String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
|
||||||
if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
|
if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
|
||||||
|
|
@ -133,17 +111,16 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
|
pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
|
||||||
} else if(osName.equals("Mac OS X")) {
|
} else if(osName.equals("Mac OS X")) {
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
|
pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
|
||||||
} else if(osName.equals("Windows XP")) {
|
} else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7") || osName.equals("Windows 8") || osName.equals("Windows 8.1") || osName.equals("Windows 10")) {
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
||||||
} else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
|
} else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
|
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
|
||||||
} else if (osName.startsWith("Windows")) {
|
} else if (osName.startsWith("Windows")) {
|
||||||
System.out.println("WARNING: Found unknown Windows version: " + osName);
|
log.warning("Found unknown Windows version: " + osName);
|
||||||
System.out.println("Attempting to use default windows plug-in.");
|
log.warning("Attempting to use default windows plug-in.");
|
||||||
System.out.flush();
|
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Trying to use default plugin, OS name " + osName +" not recognised");
|
log.warning("Trying to use default plugin, OS name " + osName +" not recognised");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,15 +128,15 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
while(pluginClassTok.hasMoreTokens()) {
|
while(pluginClassTok.hasMoreTokens()) {
|
||||||
String className = pluginClassTok.nextToken();
|
String className = pluginClassTok.nextToken();
|
||||||
try {
|
try {
|
||||||
if(!loadedPlugins.contains(className)) {
|
if(!loadedPluginNames.contains(className)) {
|
||||||
System.out.println("Loading: " + className);
|
log.fine("Loading: " + className);
|
||||||
Class ceClass = Class.forName(className);
|
Class<?> ceClass = Class.forName(className);
|
||||||
ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance();
|
ControllerEnvironment ce = (ControllerEnvironment) ceClass.getDeclaredConstructor().newInstance();
|
||||||
if(ce.isSupported()) {
|
if(ce.isSupported()) {
|
||||||
addControllers(ce.getControllers());
|
addControllers(ce.getControllers());
|
||||||
loadedPlugins.add(ce.getClass().getName());
|
loadedPluginNames.add(ce.getClass().getName());
|
||||||
} else {
|
} else {
|
||||||
logln(ceClass.getName() + " is not supported");
|
log(ceClass.getName() + " is not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
@ -168,17 +145,17 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controller[] ret = new Controller[controllers.size()];
|
Controller[] ret = new Controller[controllers.size()];
|
||||||
Iterator it = controllers.iterator();
|
Iterator<Controller> it = controllers.iterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
ret[i] = (Controller)it.next();
|
ret[i] = it.next();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is jeff's new plugin code using Jeff's Plugin manager */
|
/* This is jeff's new plugin code using Jeff's Plugin manager */
|
||||||
private void scanControllers() {
|
private Void scanControllers() {
|
||||||
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
|
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
|
||||||
if(pluginPathName == null) {
|
if(pluginPathName == null) {
|
||||||
pluginPathName = "controller";
|
pluginPathName = "controller";
|
||||||
|
|
@ -188,6 +165,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
File.separator + "lib"+File.separator + pluginPathName);
|
File.separator + "lib"+File.separator + pluginPathName);
|
||||||
scanControllersAt(getPrivilegedProperty("user.dir")+
|
scanControllersAt(getPrivilegedProperty("user.dir")+
|
||||||
File.separator + pluginPathName);
|
File.separator + pluginPathName);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanControllersAt(String path) {
|
private void scanControllersAt(String path) {
|
||||||
|
|
@ -197,19 +176,19 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Plugins plugins = new Plugins(file);
|
Plugins plugins = new Plugins(file);
|
||||||
Class[] envClasses = plugins.getExtends(ControllerEnvironment.class);
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<ControllerEnvironment>[] envClasses = plugins.getExtends(ControllerEnvironment.class);
|
||||||
for(int i=0;i<envClasses.length;i++){
|
for(int i=0;i<envClasses.length;i++){
|
||||||
try {
|
try {
|
||||||
ControllerEnvironment.logln("ControllerEnvironment "+
|
ControllerEnvironment.log("ControllerEnvironment "+
|
||||||
envClasses[i].getName()
|
envClasses[i].getName()
|
||||||
+" loaded by "+envClasses[i].getClassLoader());
|
+" loaded by "+envClasses[i].getClassLoader());
|
||||||
ControllerEnvironment ce = (ControllerEnvironment)
|
ControllerEnvironment ce = envClasses[i].getDeclaredConstructor().newInstance();
|
||||||
envClasses[i].newInstance();
|
|
||||||
if(ce.isSupported()) {
|
if(ce.isSupported()) {
|
||||||
addControllers(ce.getControllers());
|
addControllers(ce.getControllers());
|
||||||
loadedPlugins.add(ce.getClass().getName());
|
loadedPluginNames.add(ce.getClass().getName());
|
||||||
} else {
|
} else {
|
||||||
logln(envClasses[i].getName() + " is not supported");
|
log(envClasses[i].getName() + " is not supported");
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -38,31 +38,53 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A FIFO queue for input events.
|
||||||
|
*/
|
||||||
public final class EventQueue {
|
public final class EventQueue {
|
||||||
private final Event[] queue;
|
private final Event[] queue;
|
||||||
|
|
||||||
private int head;
|
private int head;
|
||||||
private int tail;
|
private int tail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an internal method and should not be called by applications using the API
|
||||||
|
*/
|
||||||
public EventQueue(int size) {
|
public EventQueue(int size) {
|
||||||
queue = new Event[size + 1];
|
queue = new Event[size + 1];
|
||||||
for (int i = 0; i < queue.length; i++)
|
for (int i = 0; i < queue.length; i++)
|
||||||
queue[i] = new Event();
|
queue[i] = new Event();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an internal method and should not be called by applications using the API
|
||||||
|
*/
|
||||||
final synchronized void add(Event event) {
|
final synchronized void add(Event event) {
|
||||||
queue[tail].set(event);
|
queue[tail].set(event);
|
||||||
tail = increase(tail);
|
tail = increase(tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the queue is full
|
||||||
|
* @return true if the queue is full
|
||||||
|
*/
|
||||||
final synchronized boolean isFull() {
|
final synchronized boolean isFull() {
|
||||||
return increase(tail) == head;
|
return increase(tail) == head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an internal method and should not be called by applications using the API
|
||||||
|
*/
|
||||||
private final int increase(int x) {
|
private final int increase(int x) {
|
||||||
return (x + 1)%queue.length;
|
return (x + 1)%queue.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the provided event with the details of the event on the head of the queue.
|
||||||
|
*
|
||||||
|
* @param event The event to populate
|
||||||
|
* @return false if there were no events left on the queue, otherwise true.
|
||||||
|
*/
|
||||||
public final synchronized boolean getNextEvent(Event event) {
|
public final synchronized boolean getNextEvent(Event event) {
|
||||||
if (head == tail)
|
if (head == tail)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
|
||||||
*
|
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
|
@ -35,7 +29,7 @@
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -77,7 +71,7 @@ class PluginClassLoader extends ClassLoader {
|
||||||
* Overrides findClass to first look in the parent class loader,
|
* Overrides findClass to first look in the parent class loader,
|
||||||
* then try loading the class from the plugin file system.
|
* then try loading the class from the plugin file system.
|
||||||
*/
|
*/
|
||||||
protected Class findClass(String name)
|
protected Class<?> findClass(String name)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
// Try loading the class from the file system.
|
// Try loading the class from the file system.
|
||||||
byte[] b = loadClassData(name);
|
byte[] b = loadClassData(name);
|
||||||
|
|
@ -123,13 +117,14 @@ class PluginClassLoader extends ClassLoader {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new ClassNotFoundException(name);
|
throw new ClassNotFoundException(name);
|
||||||
}
|
}
|
||||||
FileInputStream fileInputStream = new FileInputStream(file);
|
try(FileInputStream fileInputStream = new FileInputStream(file)) {
|
||||||
assert file.length() <= Integer.MAX_VALUE;
|
assert file.length() <= Integer.MAX_VALUE;
|
||||||
int length = (int)file.length();
|
int length = (int) file.length();
|
||||||
byte[] bytes = new byte[length];
|
byte[] bytes = new byte[length];
|
||||||
int length2 = fileInputStream.read(bytes);
|
int length2 = fileInputStream.read(bytes);
|
||||||
assert length == length2;
|
assert length == length2;
|
||||||
return bytes;
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,14 +142,15 @@ class PluginClassLoader extends ClassLoader {
|
||||||
JarFile jarfile = new JarFile(jarFiles[i]);
|
JarFile jarfile = new JarFile(jarFiles[i]);
|
||||||
JarEntry jarentry = jarfile.getJarEntry(name + ".class");
|
JarEntry jarentry = jarfile.getJarEntry(name + ".class");
|
||||||
if (jarentry != null) {
|
if (jarentry != null) {
|
||||||
InputStream jarInputStream = jarfile.getInputStream(jarentry);
|
try(InputStream jarInputStream = jarfile.getInputStream(jarentry)) {
|
||||||
assert jarentry.getSize() <= Integer.MAX_VALUE;
|
assert jarentry.getSize() <= Integer.MAX_VALUE;
|
||||||
int length = (int)jarentry.getSize();
|
int length = (int) jarentry.getSize();
|
||||||
assert length >= 0;
|
assert length >= 0;
|
||||||
byte[] bytes = new byte[length];
|
byte[] bytes = new byte[length];
|
||||||
int length2 = jarInputStream.read(bytes);
|
int length2 = jarInputStream.read(bytes);
|
||||||
assert length == length2;
|
assert length == length2;
|
||||||
return bytes;
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException(name);
|
throw new FileNotFoundException(name);
|
||||||
|
|
@ -33,9 +33,14 @@
|
||||||
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version and build number of this implementation.
|
* The version and build number of this implementation.
|
||||||
* Version numbers for a release are of the form: w.x.y[-a]-z, where:
|
* Version numbers for a release are of the form: w.x.y, where:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>
|
* <li>
|
||||||
* w - the major version number of the release. This number should
|
* w - the major version number of the release. This number should
|
||||||
|
|
@ -53,27 +58,13 @@ package net.java.games.input;
|
||||||
* bump in the minor-minor version number signifies that new bug
|
* bump in the minor-minor version number signifies that new bug
|
||||||
* fixes have been added to the build.
|
* fixes have been added to the build.
|
||||||
* </li>
|
* </li>
|
||||||
* <li>
|
|
||||||
* a - an optional build designator followed by a digit. Valid build
|
|
||||||
* designators are:
|
|
||||||
* <ul>
|
|
||||||
* <li>alpha</li>
|
|
||||||
* <li>beta</li>
|
|
||||||
* </ul>
|
|
||||||
* </li>
|
|
||||||
* <li>
|
|
||||||
* z - build number. This is used to specify the build number of the
|
|
||||||
* release. This is usually only important to people that use
|
|
||||||
* the daily build of a project. The format is the lower-case
|
|
||||||
* letter 'b' followed by a two digit number.
|
|
||||||
* </li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* For example, the following are all valid version strings:
|
* For example, the following are all valid version strings:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>1.1.2-b02</li>
|
* <li>1.1.2</li>
|
||||||
* <li>1.3.5-alpha1-b19</li>
|
* <li>1.3.5-SNAPSHOT</li>
|
||||||
* <li>4.7.1-beta3-b20</li>
|
* <li>4.7.1-M2</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -86,19 +77,26 @@ public final class Version {
|
||||||
private Version() {
|
private Version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Version string of this build.
|
|
||||||
*/
|
|
||||||
private static final String version = "2.0.0-b01";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the verison string and build number of
|
* Returns the verison string and build number of
|
||||||
* this implementation. See the class descritpion
|
* this implementation. See the class descritpion
|
||||||
* for the version string format.
|
* for the version string format.
|
||||||
*
|
*
|
||||||
* @return The version string of this implementation.
|
* @return The version string of this implementation.
|
||||||
*/
|
*/
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
return version;
|
String version = "Unversioned";
|
||||||
|
try {
|
||||||
|
Properties p = new Properties();
|
||||||
|
InputStream is = Version.class.getResourceAsStream("/META-INF/maven/net.java.jinput/coreapi/pom.properties");
|
||||||
|
if(is != null) {
|
||||||
|
p.load(is);
|
||||||
|
version = p.getProperty("version", "");
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,5 +9,6 @@ Top level package for JInput.
|
||||||
Use -Djinput.useDefaultPlugin=false (or net.java.games.input.useDefaultPlugin=false) to disable automatic loading of the default plugin for the platform.<BR/>
|
Use -Djinput.useDefaultPlugin=false (or net.java.games.input.useDefaultPlugin=false) to disable automatic loading of the default plugin for the platform.<BR/>
|
||||||
Use -Djinput.plugins (or net.java.games.input.plugins) and specifiy a list of class name to over ride the plugins system. This will force the classes passed to be loaded first, then plugins will be searched for in the default manner (./controller/*.jar)<BR/>
|
Use -Djinput.plugins (or net.java.games.input.plugins) and specifiy a list of class name to over ride the plugins system. This will force the classes passed to be loaded first, then plugins will be searched for in the default manner (./controller/*.jar)<BR/>
|
||||||
Use -Djinput.controllerPluginPath to change the path the plugins mechanism will use to search for plugin Jars.
|
Use -Djinput.controllerPluginPath to change the path the plugins mechanism will use to search for plugin Jars.
|
||||||
|
Use -Djinput.loglevel to change the logging level using Java util logging level strings.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
6
docs/_config.yml
Normal file
6
docs/_config.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
title: JInput
|
||||||
|
description: Java library for access to input devices.
|
||||||
|
show_downloads: true
|
||||||
|
google_analytics:
|
||||||
|
theme: jekyll-theme-architect
|
||||||
|
jinput_version: 2.0.9
|
||||||
93
docs/index.md
Normal file
93
docs/index.md
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
---
|
||||||
|
[](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi)
|
||||||
|
[](http://www.javadoc.io/doc/net.java.jinput/coreapi)
|
||||||
|
|
||||||
|
# Welcome to the Java Input API Project!
|
||||||
|
|
||||||
|
<p>The JInput Project hosts an implementation of an API for game controller
|
||||||
|
discovery and polled input. It is part of a suite of open-source technologies
|
||||||
|
initiated by the Game Technology Group at Sun Microsystems with intention of
|
||||||
|
making the development of high performance games in Java a reality.</p>
|
||||||
|
<p>The API itself is pure Java and presents a platform-neutral
|
||||||
|
completely portable model of controller discovery and polling.
|
||||||
|
It can handle arbitrary controllers and returns both human and
|
||||||
|
machine understandable descriptions of the inputs available.</p>
|
||||||
|
<p>The implementation hosted here also includes plug-ins to allow
|
||||||
|
the API to adapt to various specific platforms. These plug-ins
|
||||||
|
often contain a native code portion to interface to the host system.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### Maven
|
||||||
|
|
||||||
|
Include the dependency in your project:
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput</artifactId>
|
||||||
|
<version>{{site.jinput_version}}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput</artifactId>
|
||||||
|
<version>{{site.jinput_version}}</version>
|
||||||
|
<classifier>natives-all</classifier>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
You'll also need to add the build plugin in your `build/plugins` section of your pom
|
||||||
|
```xml
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.googlecode.mavennatives</groupId>
|
||||||
|
<artifactId>maven-nativedependencies-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
```
|
||||||
|
|
||||||
|
A full pom might look like [this one](https://github.com/jinput/jinput/blob/master/examples/example.pom.xml)
|
||||||
|
|
||||||
|
### Without maven
|
||||||
|
The jar file with the java code in should be in maven central, you'll need the [jinput.jar](http://repo1.maven.org/maven2/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}.jar) and [jinput-natives-all.jar](http://repo1.maven.org/maven2/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}-natives-all.jar) that contains the native binaries.
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
Add the jinput jar to your classpath, if you are using maven and have the native dependencies plugin working, it will have unpacked the native binaries to `target/natives`, you must specify the `java.library.path` property to point to this directy.
|
||||||
|
|
||||||
|
Example
|
||||||
|
```
|
||||||
|
java -cp ~/.m2/repository/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}.jar:target/examples-pom-{{site.jinput_version}}.jar -Djava.library.path=target/natives net.java.games.input.example.ReadFirstMouse
|
||||||
|
```
|
||||||
|
|
||||||
|
More generally
|
||||||
|
```
|
||||||
|
java -cp <path to jinput.jar>:<your own jars> -Djava.library.path=<path to natives> <main class>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```java
|
||||||
|
/* Create an event object for the underlying plugin to populate */
|
||||||
|
Event event = new Event();
|
||||||
|
|
||||||
|
/* Get the available controllers */
|
||||||
|
Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
||||||
|
for (int i = 0; i < controllers.length; i++) {
|
||||||
|
/* Remember to poll each one */
|
||||||
|
controllers[i].poll();
|
||||||
|
|
||||||
|
/* Get the controllers event queue */
|
||||||
|
EventQueue queue = controllers[i].getEventQueue();
|
||||||
|
|
||||||
|
/* For each object in the queue */
|
||||||
|
while (queue.getNextEvent(event)) {
|
||||||
|
/* Get event component */
|
||||||
|
Component comp = event.getComponent();
|
||||||
|
|
||||||
|
/* Process event (your awesome code) */
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[More examples here](https://github.com/jinput/jinput/tree/master/examples/src/main/java/net/java/games/input/example).
|
||||||
77
examples/example.pom.xml
Normal file
77
examples/example.pom.xml
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>examples-pom</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - example pom</name>
|
||||||
|
<version>2.0.9</version>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<releases><enabled>false</enabled></releases>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<classifier>natives-all</classifier>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.googlecode.mavennatives</groupId>
|
||||||
|
<artifactId>maven-nativedependencies-plugin</artifactId>
|
||||||
|
<version>0.0.7</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>unpacknatives</id>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<executable>java</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>-classpath</argument>
|
||||||
|
<classpath/>
|
||||||
|
<argument>-Djava.library.path=${project.build.directory}/natives</argument>
|
||||||
|
<argument>-Djinput.loglevel=OFF</argument>
|
||||||
|
<argument>net.java.games.input.example.ReadAllEvents</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
78
examples/pom.xml
Normal file
78
examples/pom.xml
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>examples</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - examples</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>jinput-parent</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<releases><enabled>false</enabled></releases>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jinput</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.googlecode.mavennatives</groupId>
|
||||||
|
<artifactId>maven-nativedependencies-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>ReadAllEvents</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<executable>java</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>-classpath</argument>
|
||||||
|
<classpath/>
|
||||||
|
<argument>-Djava.library.path=${project.build.directory}/natives</argument>
|
||||||
|
<argument>-Djinput.loglevel=OFF</argument>
|
||||||
|
<argument>net.java.games.input.example.ReadAllEvents</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</project>
|
||||||
|
|
@ -39,7 +39,7 @@ public class ReadAllEvents {
|
||||||
while (queue.getNextEvent(event)) {
|
while (queue.getNextEvent(event)) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a strug buffer and put in it, the controller name,
|
* Create a string buffer and put in it, the controller name,
|
||||||
* the time stamp of the event, the name of the component
|
* the time stamp of the event, the name of the component
|
||||||
* that changed and the new value.
|
* that changed and the new value.
|
||||||
*
|
*
|
||||||
|
|
@ -3,7 +3,6 @@ package net.java.games.input.example;
|
||||||
import net.java.games.input.Component;
|
import net.java.games.input.Component;
|
||||||
import net.java.games.input.Controller;
|
import net.java.games.input.Controller;
|
||||||
import net.java.games.input.ControllerEnvironment;
|
import net.java.games.input.ControllerEnvironment;
|
||||||
import net.java.games.input.test.ControllerTextTest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class shows how to read the values in a polling loop for the first mouse
|
* This class shows how to read the values in a polling loop for the first mouse
|
||||||
|
|
@ -1,80 +1,52 @@
|
||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
<project basedir="." default="all" name="OSX Plugin">
|
<project name="OS X Plugin, Native code" basedir="." default="compileNativeJinputLib">
|
||||||
<description>OSX JInput Plugin</description>
|
<description>OSX JInput Native Plugin</description>
|
||||||
<property name="src" location="src" />
|
|
||||||
<property name="build" location="classes"/>
|
|
||||||
<property name="bin" location="bin" />
|
|
||||||
<property name="plugins" location="plugins" />
|
|
||||||
|
|
||||||
<target name="init">
|
|
||||||
<mkdir dir="${build}"/>
|
|
||||||
<mkdir dir="${bin}"/>
|
|
||||||
<condition property="macosx">
|
|
||||||
<and>
|
|
||||||
<os family="mac" />
|
|
||||||
<os family="unix" />
|
|
||||||
</and>
|
|
||||||
</condition>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="init" name="compile">
|
<target name="init">
|
||||||
<javac debug="true" deprecation="true" destdir="${build}" source="1.4" srcdir="src/java">
|
<mkdir dir="target/natives/arm64"/>
|
||||||
<classpath>
|
</target>
|
||||||
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
|
|
||||||
<pathelement location="../../lib/jutils.jar"/>
|
|
||||||
</classpath>
|
|
||||||
</javac>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="init,compile" name="jar">
|
|
||||||
<jar jarfile="${bin}/HIDWrapper.jar" compress="true" basedir="${build}">
|
|
||||||
<include name="**/*.class"/>
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="compileNativeJinputLib,jar" description="Build everything." name="all">
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="javadoc" depends="init" description="Javadoc for OS X plugin for JInput.">
|
|
||||||
<mkdir dir="apidocs"/>
|
|
||||||
<javadoc packagenames="net.java.games.input.*"
|
|
||||||
destdir="apidocs"
|
|
||||||
additionalparam="-source 1.4"
|
|
||||||
link="../../../coreAPI/apidocs">
|
|
||||||
<sourcepath>
|
|
||||||
<pathelement location="src/java"/>
|
|
||||||
</sourcepath>
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
|
|
||||||
<pathelement location="../../lib/jutils.jar"/>
|
|
||||||
</classpath>
|
|
||||||
</javadoc>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target description="Clean all build products." name="clean">
|
|
||||||
<delete dir="classes" failonerror="no"/>
|
|
||||||
<delete dir="bin" failonerror="no"/>
|
|
||||||
<delete dir="apidocs" failonerror="no"/>
|
|
||||||
<ant inheritAll="false" antfile="src/native/build.xml" target="clean"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="init,compile" name="createJNIHeaders">
|
|
||||||
<javah destdir="src/native">
|
|
||||||
<classpath>
|
|
||||||
<pathelement path="${build}"/>
|
|
||||||
<pathelement location="../../coreAPI/classes"/>
|
|
||||||
</classpath>
|
|
||||||
<class name="net.java.games.input.OSXHIDDeviceIterator"/>
|
|
||||||
<class name="net.java.games.input.OSXHIDDevice"/>
|
|
||||||
<class name="net.java.games.input.OSXHIDQueue"/>
|
|
||||||
</javah>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
|
<target name="compile">
|
||||||
|
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
|
||||||
|
<arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I../../../../common/src/native -I../../generated-sources/natives/"/>
|
||||||
|
<mapper type="glob" from="*.c" to="*.o"/>
|
||||||
|
<fileset dir="src/main/native" includes="*.c"/>
|
||||||
|
<fileset dir="../common/src/native" includes="*.c"/>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="compileNativeJinputLib" depends="init,createJNIHeaders" if="macosx">
|
<target name="link">
|
||||||
<ant dir="src/native" target="compileNativeJinputLib"/>
|
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||||
<copy todir="${bin}">
|
<arg line="${linkerflags} -dynamiclib -o ${libname} -framework CoreFoundation -framework IOKit -framework CoreServices -L/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib"/>
|
||||||
<fileset dir="src/native" includes="*.jnilib"/>
|
<fileset dir="${objdir}" includes="*.o"/>
|
||||||
</copy>
|
</apply>
|
||||||
</target>
|
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
|
||||||
|
<arg line="-S -X"/>
|
||||||
|
<fileset dir="." includes="${libname}"/>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="compileNativeJinputLib" depends="init">
|
||||||
|
<property name="arm64_sdkroot" location="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"/>
|
||||||
|
<property name="arm64_flags" value="-isysroot ${arm64_sdkroot} -arch arm64 -mmacosx-version-min=10.5 -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/ -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/darwin/"/>
|
||||||
|
<antcall target="compile">
|
||||||
|
<param name="dstdir" location="target/natives/arm64"/>
|
||||||
|
<param name="compiler" value="gcc"/>
|
||||||
|
<param name="sdkroot" location="${arm64_sdkroot}"/>
|
||||||
|
<param name="cflags" value="${arm64_flags}"/>
|
||||||
|
</antcall>
|
||||||
|
<antcall target="link">
|
||||||
|
<param name="objdir" location="target/natives/arm64"/>
|
||||||
|
<param name="libname" value="libjinput-osx-arm64.jnilib"/>
|
||||||
|
<param name="linker" value="gcc"/>
|
||||||
|
<param name="linkerflags" value="${arm64_flags}"/>
|
||||||
|
</antcall>
|
||||||
|
<apply dir="target/natives" parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
|
||||||
|
<arg value="-create"/>
|
||||||
|
<srcfile/>
|
||||||
|
<arg value="-output"/>
|
||||||
|
<arg path="target/natives/libjinput-osx.jnilib"/>
|
||||||
|
<fileset file="target/natives/arm64/libjinput-osx-arm64.jnilib"/>
|
||||||
|
</apply>
|
||||||
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
69
plugins/OSX/pom.xml
Normal file
69
plugins/OSX/pom.xml
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>osx-plugin</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - OSX Plugin</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>plugins</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>coreapi</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<!-- <plugin> -->
|
||||||
|
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
|
||||||
|
<!-- </plugin> -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<ant dir="." target="compileNativeJinputLib"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<classesDirectory>${project.build.directory}/natives</classesDirectory>
|
||||||
|
<classifier>natives-osx</classifier>
|
||||||
|
<includes>
|
||||||
|
<include>*.jnilib</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* %W% %E%
|
|
||||||
*
|
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
|
||||||
|
|
||||||
/** Generic Desktop Usages
|
|
||||||
* @author elias
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public interface Usage {
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -46,13 +40,13 @@ import java.util.HashMap;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
final class ButtonUsage implements Usage {
|
final class ButtonUsage implements Usage {
|
||||||
private final static Map map = new HashMap();
|
private final static Map<Integer, ButtonUsage> map = new HashMap<>();
|
||||||
|
|
||||||
private final int button_id;
|
private final int button_id;
|
||||||
|
|
||||||
public final static ButtonUsage map(int button_id) {
|
public final static ButtonUsage map(int button_id) {
|
||||||
Integer button_id_obj = new Integer(button_id);
|
Integer button_id_obj = button_id;
|
||||||
ButtonUsage existing = (ButtonUsage)map.get(button_id_obj);
|
ButtonUsage existing = map.get(button_id_obj);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
return existing;
|
return existing;
|
||||||
ButtonUsage new_button = new ButtonUsage(button_id);
|
ButtonUsage new_button = new ButtonUsage(button_id);
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
/** Generic Desktop Usages
|
/** Generic Desktop Usages
|
||||||
|
|
@ -1,46 +1,37 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/** Mapping from Keyboard HID usages to Component.Identifier.Key
|
/** Mapping from Keyboard HID usages to Component.Identifier.Key
|
||||||
* @author elias
|
* @author elias
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -67,34 +61,28 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void loadLibrary(final String lib_name) {
|
static void loadLibrary(final String lib_name) {
|
||||||
AccessController.doPrivileged(
|
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||||
new PrivilegedAction() {
|
try {
|
||||||
public final Object run() {
|
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
||||||
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
if (lib_path != null)
|
||||||
if (lib_path != null)
|
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
||||||
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
else
|
||||||
else
|
System.loadLibrary(lib_name);
|
||||||
System.loadLibrary(lib_name);
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
supported = false;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property) {
|
static String getPrivilegedProperty(final String property) {
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property));
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property, final String default_value) {
|
static String getPrivilegedProperty(final String property, final String default_value) {
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property, default_value));
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property, default_value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
@ -117,7 +105,7 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
major = Integer.parseInt(major_str);
|
major = Integer.parseInt(major_str);
|
||||||
minor = Integer.parseInt(minor_str);
|
minor = Integer.parseInt(minor_str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logln("Exception occurred while trying to determine OS version: " + e);
|
log("Exception occurred while trying to determine OS version: " + e);
|
||||||
// Best guess, no
|
// Best guess, no
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -142,10 +130,10 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static void addElements(OSXHIDQueue queue, List elements, List components, boolean map_mouse_buttons) throws IOException {
|
private final static void addElements(OSXHIDQueue queue, List<OSXHIDElement> elements, List<OSXComponent> components, boolean map_mouse_buttons) throws IOException {
|
||||||
Iterator it = elements.iterator();
|
Iterator<OSXHIDElement> it = elements.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
OSXHIDElement element = (OSXHIDElement)it.next();
|
OSXHIDElement element = it.next();
|
||||||
Component.Identifier id = element.getIdentifier();
|
Component.Identifier id = element.getIdentifier();
|
||||||
if (id == null)
|
if (id == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -164,8 +152,8 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List elements) throws IOException {
|
private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements) throws IOException {
|
||||||
List components = new ArrayList();
|
List<OSXComponent> components = new ArrayList<>();
|
||||||
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
||||||
try {
|
try {
|
||||||
addElements(queue, elements, components, false);
|
addElements(queue, elements, components, false);
|
||||||
|
|
@ -175,12 +163,11 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
}
|
}
|
||||||
Component[] components_array = new Component[components.size()];
|
Component[] components_array = new Component[components.size()];
|
||||||
components.toArray(components_array);
|
components.toArray(components_array);
|
||||||
Keyboard keyboard = new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{});
|
return new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{});
|
||||||
return keyboard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Mouse createMouseFromDevice(OSXHIDDevice device, List elements) throws IOException {
|
private final static Mouse createMouseFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements) throws IOException {
|
||||||
List components = new ArrayList();
|
List<OSXComponent> components = new ArrayList<>();
|
||||||
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
||||||
try {
|
try {
|
||||||
addElements(queue, elements, components, true);
|
addElements(queue, elements, components, true);
|
||||||
|
|
@ -199,8 +186,8 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List elements, Controller.Type type) throws IOException {
|
private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements, Controller.Type type) throws IOException {
|
||||||
List components = new ArrayList();
|
List<OSXComponent> components = new ArrayList<>();
|
||||||
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
|
||||||
try {
|
try {
|
||||||
addElements(queue, elements, components, false);
|
addElements(queue, elements, components, false);
|
||||||
|
|
@ -210,15 +197,14 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
}
|
}
|
||||||
Component[] components_array = new Component[components.size()];
|
Component[] components_array = new Component[components.size()];
|
||||||
components.toArray(components_array);
|
components.toArray(components_array);
|
||||||
AbstractController controller = new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type);
|
return new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type);
|
||||||
return controller;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static void createControllersFromDevice(OSXHIDDevice device, List controllers) throws IOException {
|
private final static void createControllersFromDevice(OSXHIDDevice device, List<Controller> controllers) throws IOException {
|
||||||
UsagePair usage_pair = device.getUsagePair();
|
UsagePair usage_pair = device.getUsagePair();
|
||||||
if (usage_pair == null)
|
if (usage_pair == null)
|
||||||
return;
|
return;
|
||||||
List elements = device.getElements();
|
List<OSXHIDElement> elements = device.getElements();
|
||||||
if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.MOUSE ||
|
if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.MOUSE ||
|
||||||
usage_pair.getUsage() == GenericDesktopUsage.POINTER)) {
|
usage_pair.getUsage() == GenericDesktopUsage.POINTER)) {
|
||||||
Controller mouse = createMouseFromDevice(device, elements);
|
Controller mouse = createMouseFromDevice(device, elements);
|
||||||
|
|
@ -226,22 +212,18 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
controllers.add(mouse);
|
controllers.add(mouse);
|
||||||
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.KEYBOARD ||
|
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.KEYBOARD ||
|
||||||
usage_pair.getUsage() == GenericDesktopUsage.KEYPAD)) {
|
usage_pair.getUsage() == GenericDesktopUsage.KEYPAD)) {
|
||||||
Controller keyboard = createKeyboardFromDevice(device, elements);
|
controllers.add(createKeyboardFromDevice(device, elements));
|
||||||
if (keyboard != null)
|
|
||||||
controllers.add(keyboard);
|
|
||||||
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.JOYSTICK) {
|
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.JOYSTICK) {
|
||||||
Controller joystick = createControllerFromDevice(device, elements, Controller.Type.STICK);
|
controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK));
|
||||||
if (joystick != null)
|
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.MULTI_AXIS_CONTROLLER) {
|
||||||
controllers.add(joystick);
|
controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK));
|
||||||
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.GAME_PAD) {
|
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.GAME_PAD) {
|
||||||
Controller game_pad = createControllerFromDevice(device, elements, Controller.Type.GAMEPAD);
|
controllers.add(createControllerFromDevice(device, elements, Controller.Type.GAMEPAD));
|
||||||
if (game_pad != null)
|
|
||||||
controllers.add(game_pad);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Controller[] enumerateControllers() {
|
private final static Controller[] enumerateControllers() {
|
||||||
List controllers = new ArrayList();
|
List<Controller> controllers = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
OSXHIDDeviceIterator it = new OSXHIDDeviceIterator();
|
OSXHIDDeviceIterator it = new OSXHIDDeviceIterator();
|
||||||
try {
|
try {
|
||||||
|
|
@ -257,12 +239,12 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
|
||||||
createControllersFromDevice(device, controllers);
|
createControllersFromDevice(device, controllers);
|
||||||
device_used = old_size != controllers.size();
|
device_used = old_size != controllers.size();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logln("Failed to create controllers from device: " + device.getProductName());
|
log("Failed to create controllers from device: " + device.getProductName());
|
||||||
}
|
}
|
||||||
if (!device_used)
|
if (!device_used)
|
||||||
device.release();
|
device.release();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logln("Failed to enumerate device: " + e.getMessage());
|
log("Failed to enumerate device: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -43,6 +37,7 @@ import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/** OSX HIDManager implementation
|
/** OSX HIDManager implementation
|
||||||
* @author elias
|
* @author elias
|
||||||
|
|
@ -50,6 +45,7 @@ import java.util.Iterator;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
final class OSXHIDDevice {
|
final class OSXHIDDevice {
|
||||||
|
private final static Logger log = Logger.getLogger(OSXHIDDevice.class.getName());
|
||||||
private final static int AXIS_DEFAULT_MIN_VALUE = 0;
|
private final static int AXIS_DEFAULT_MIN_VALUE = 0;
|
||||||
private final static int AXIS_DEFAULT_MAX_VALUE = 64*1024;
|
private final static int AXIS_DEFAULT_MAX_VALUE = 64*1024;
|
||||||
|
|
||||||
|
|
@ -102,7 +98,7 @@ final class OSXHIDDevice {
|
||||||
|
|
||||||
private final long device_address;
|
private final long device_address;
|
||||||
private final long device_interface_address;
|
private final long device_interface_address;
|
||||||
private final Map properties;
|
private final Map<String,?> properties;
|
||||||
|
|
||||||
private boolean released;
|
private boolean released;
|
||||||
|
|
||||||
|
|
@ -128,7 +124,7 @@ final class OSXHIDDevice {
|
||||||
return (String)properties.get(kIOHIDProductKey);
|
return (String)properties.get(kIOHIDProductKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final OSXHIDElement createElementFromElementProperties(Map element_properties) {
|
private final OSXHIDElement createElementFromElementProperties(Map<String,?> element_properties) {
|
||||||
/* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey);
|
/* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey);
|
||||||
// ignore elements that can't fit into the 32 bit value field of a hid event
|
// ignore elements that can't fit into the 32 bit value field of a hid event
|
||||||
if (size > 32)
|
if (size > 32)
|
||||||
|
|
@ -152,19 +148,20 @@ final class OSXHIDDevice {
|
||||||
int usage_page = getIntFromProperties(element_properties, kIOHIDElementUsagePageKey);
|
int usage_page = getIntFromProperties(element_properties, kIOHIDElementUsagePageKey);
|
||||||
UsagePair usage_pair = createUsagePair(usage_page, usage);
|
UsagePair usage_pair = createUsagePair(usage_page, usage);
|
||||||
if (usage_pair == null || (element_type != ElementType.INPUT_MISC && element_type != ElementType.INPUT_BUTTON && element_type != ElementType.INPUT_AXIS)) {
|
if (usage_pair == null || (element_type != ElementType.INPUT_MISC && element_type != ElementType.INPUT_BUTTON && element_type != ElementType.INPUT_AXIS)) {
|
||||||
//System.out.println("element_type = 0x" + element_type + " | usage = " + usage + " | usage_page = " + usage_page);
|
//log.info("element_type = 0x" + element_type + " | usage = " + usage + " | usage_page = " + usage_page);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new OSXHIDElement(this, usage_pair, element_cookie, element_type, min, max, is_relative);
|
return new OSXHIDElement(this, usage_pair, element_cookie, element_type, min, max, is_relative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void addElements(List elements, Map properties) {
|
@SuppressWarnings("unchecked")
|
||||||
|
private final void addElements(List<OSXHIDElement> elements, Map<String,?> properties) {
|
||||||
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
|
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
|
||||||
if (elements_properties == null)
|
if (elements_properties == null)
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < elements_properties.length; i++) {
|
for (int i = 0; i < elements_properties.length; i++) {
|
||||||
Map element_properties = (Map)elements_properties[i];
|
Map<String,?> element_properties = (Map<String,?>)elements_properties[i];
|
||||||
OSXHIDElement element = createElementFromElementProperties(element_properties);
|
OSXHIDElement element = createElementFromElementProperties(element_properties);
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
elements.add(element);
|
elements.add(element);
|
||||||
|
|
@ -173,28 +170,28 @@ final class OSXHIDDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List getElements() {
|
public final List<OSXHIDElement> getElements() {
|
||||||
List elements = new ArrayList();
|
List<OSXHIDElement> elements = new ArrayList<>();
|
||||||
addElements(elements, properties);
|
addElements(elements, properties);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static long getLongFromProperties(Map properties, String key, long default_value) {
|
private final static long getLongFromProperties(Map<String,?> properties, String key, long default_value) {
|
||||||
Long long_obj = (Long)properties.get(key);
|
Long long_obj = (Long)properties.get(key);
|
||||||
if (long_obj == null)
|
if (long_obj == null)
|
||||||
return default_value;
|
return default_value;
|
||||||
return long_obj.longValue();
|
return long_obj.longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static boolean getBooleanFromProperties(Map properties, String key, boolean default_value) {
|
private final static boolean getBooleanFromProperties(Map<String,?> properties, String key, boolean default_value) {
|
||||||
return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0;
|
return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int getIntFromProperties(Map properties, String key) {
|
private final static int getIntFromProperties(Map<String,?> properties, String key) {
|
||||||
return (int)getLongFromProperties(properties, key);
|
return (int)getLongFromProperties(properties, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static long getLongFromProperties(Map properties, String key) {
|
private final static long getLongFromProperties(Map<String,?> properties, String key) {
|
||||||
Long long_obj = (Long)properties.get(key);
|
Long long_obj = (Long)properties.get(key);
|
||||||
return long_obj.longValue();
|
return long_obj.longValue();
|
||||||
}
|
}
|
||||||
|
|
@ -215,44 +212,22 @@ final class OSXHIDDevice {
|
||||||
return createUsagePair(usage_page_id, usage_id);
|
return createUsagePair(usage_page_id, usage_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public final List getUsagePairs() {
|
|
||||||
List usage_pairs_list = new ArrayList();
|
|
||||||
Object[] usage_pairs = (Object[])properties.get(kIOHIDDeviceUsagePairsKey);
|
|
||||||
if (usage_pairs == null) {
|
|
||||||
int usage_page_id = getIntFromProperties(properties, kIOHIDPrimaryUsagePageKey);
|
|
||||||
int usage_id = getIntFromProperties(properties, kIOHIDPrimaryUsageKey);
|
|
||||||
UsagePair pair = createUsagePair(usage_page_id, usage_id);
|
|
||||||
if (pair != null)
|
|
||||||
usage_pairs_list.add(pair);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < usage_pairs.length; i++) {
|
|
||||||
Map usage_pair = (Map)usage_pairs[i];
|
|
||||||
int usage_page_id = getIntFromProperties(usage_pair, kIOHIDDeviceUsagePageKey);
|
|
||||||
int usage_id = getIntFromProperties(usage_pair, kIOHIDDeviceUsageKey);
|
|
||||||
UsagePair pair = createUsagePair(usage_page_id, usage_id);
|
|
||||||
if (pair != null)
|
|
||||||
usage_pairs_list.add(pair);
|
|
||||||
}
|
|
||||||
return usage_pairs_list;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private final void dumpProperties() {
|
private final void dumpProperties() {
|
||||||
System.out.println(toString());
|
log.info(toString());
|
||||||
dumpMap("", properties);
|
dumpMap("", properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static void dumpArray(String prefix, Object[] array) {
|
private final static void dumpArray(String prefix, Object[] array) {
|
||||||
System.out.println(prefix + "{");
|
log.info(prefix + "{");
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
dumpObject(prefix + "\t", array[i]);
|
dumpObject(prefix + "\t", array[i]);
|
||||||
System.out.println(prefix + ",");
|
log.info(prefix + ",");
|
||||||
}
|
}
|
||||||
System.out.println(prefix + "}");
|
log.info(prefix + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static void dumpMap(String prefix, Map map) {
|
private final static void dumpMap(String prefix, Map<String,?> map) {
|
||||||
Iterator keys = map.keySet().iterator();
|
Iterator<String> keys = map.keySet().iterator();
|
||||||
while (keys.hasNext()) {
|
while (keys.hasNext()) {
|
||||||
Object key = keys.next();
|
Object key = keys.next();
|
||||||
Object value = map.get(key);
|
Object value = map.get(key);
|
||||||
|
|
@ -260,23 +235,24 @@ final class OSXHIDDevice {
|
||||||
dumpObject(prefix + "\t", value);
|
dumpObject(prefix + "\t", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private final static void dumpObject(String prefix, Object obj) {
|
private final static void dumpObject(String prefix, Object obj) {
|
||||||
if (obj instanceof Long) {
|
if (obj instanceof Long) {
|
||||||
Long l = (Long)obj;
|
Long l = (Long)obj;
|
||||||
System.out.println(prefix + "0x" + Long.toHexString(l.longValue()));
|
log.info(prefix + "0x" + Long.toHexString(l.longValue()));
|
||||||
} else if (obj instanceof Map)
|
} else if (obj instanceof Map)
|
||||||
dumpMap(prefix, (Map)obj);
|
dumpMap(prefix, (Map<String,?>)obj);
|
||||||
else if (obj.getClass().isArray())
|
else if (obj.getClass().isArray())
|
||||||
dumpArray(prefix, (Object[])obj);
|
dumpArray(prefix, (Object[])obj);
|
||||||
else
|
else
|
||||||
System.out.println(prefix + obj);
|
log.info(prefix + obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map getDeviceProperties() throws IOException {
|
private final Map<String,?> getDeviceProperties() throws IOException {
|
||||||
return nGetDeviceProperties(device_address);
|
return nGetDeviceProperties(device_address);
|
||||||
}
|
}
|
||||||
private final static native Map nGetDeviceProperties(long device_address) throws IOException;
|
private final static native Map<String,?> nGetDeviceProperties(long device_address) throws IOException;
|
||||||
|
|
||||||
public final synchronized void release() throws IOException {
|
public final synchronized void release() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -47,7 +41,7 @@ import java.util.HashMap;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
final class OSXHIDQueue {
|
final class OSXHIDQueue {
|
||||||
private final Map map = new HashMap();
|
private final Map<Long,OSXComponent> map = new HashMap<>();
|
||||||
private final long queue_address;
|
private final long queue_address;
|
||||||
|
|
||||||
private boolean released;
|
private boolean released;
|
||||||
|
|
@ -80,7 +74,7 @@ final class OSXHIDQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final OSXComponent mapEvent(OSXEvent event) {
|
public final OSXComponent mapEvent(OSXEvent event) {
|
||||||
return (OSXComponent)map.get(new Long(event.getCookie()));
|
return map.get(event.getCookie());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void open(int queue_depth) throws IOException {
|
private final void open(int queue_depth) throws IOException {
|
||||||
|
|
@ -118,13 +112,13 @@ final class OSXHIDQueue {
|
||||||
|
|
||||||
public final void addElement(OSXHIDElement element, OSXComponent component) throws IOException {
|
public final void addElement(OSXHIDElement element, OSXComponent component) throws IOException {
|
||||||
nAddElement(queue_address, element.getCookie());
|
nAddElement(queue_address, element.getCookie());
|
||||||
map.put(new Long(element.getCookie()), component);
|
map.put(element.getCookie(), component);
|
||||||
}
|
}
|
||||||
private final static native void nAddElement(long queue_address, long cookie) throws IOException;
|
private final static native void nAddElement(long queue_address, long cookie) throws IOException;
|
||||||
|
|
||||||
public final void removeElement(OSXHIDElement element) throws IOException {
|
public final void removeElement(OSXHIDElement element) throws IOException {
|
||||||
nRemoveElement(queue_address, element.getCookie());
|
nRemoveElement(queue_address, element.getCookie());
|
||||||
map.remove(new Long(element.getCookie()));
|
map.remove(element.getCookie());
|
||||||
}
|
}
|
||||||
private final static native void nRemoveElement(long queue_address, long cookie) throws IOException;
|
private final static native void nRemoveElement(long queue_address, long cookie) throws IOException;
|
||||||
|
|
||||||
40
plugins/OSX/src/main/java/net/java/games/input/Usage.java
Normal file
40
plugins/OSX/src/main/java/net/java/games/input/Usage.java
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.java.games.input;
|
||||||
|
|
||||||
|
/** Generic Desktop Usages
|
||||||
|
* @author elias
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public interface Usage {
|
||||||
|
}
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* %W% %E%
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistribution of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Redistribution in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materails provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||||
|
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||||
|
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
||||||
|
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
||||||
|
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
||||||
|
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||||
|
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||||
|
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||||
|
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
|
||||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************
|
|
||||||
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* - Redistribution of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistribution in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materails provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name Sun Microsystems, Inc. or the names of the contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* This software is provided "AS IS," without a warranty of any kind.
|
|
||||||
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
|
||||||
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
|
||||||
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
|
|
||||||
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
|
|
||||||
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
|
|
||||||
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
|
||||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
|
||||||
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
|
||||||
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
|
|
||||||
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*
|
|
||||||
* You acknowledge that this software is not designed or intended for us in
|
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -77,7 +71,7 @@ final class UsagePage {
|
||||||
/* ReservedPointofSalepages 0x8E - 0X8F */
|
/* ReservedPointofSalepages 0x8E - 0X8F */
|
||||||
public final static UsagePage CAMERACONTROL= new UsagePage(0x90); /* USB Device Class Definition for Image Class Devices */
|
public final static UsagePage CAMERACONTROL= new UsagePage(0x90); /* USB Device Class Definition for Image Class Devices */
|
||||||
public final static UsagePage ARCADE = new UsagePage(0x91); /* OAAF Definitions for arcade and coinop related Devices */
|
public final static UsagePage ARCADE = new UsagePage(0x91); /* OAAF Definitions for arcade and coinop related Devices */
|
||||||
private final Class usage_class;
|
private final Class<? extends Usage> usage_class;
|
||||||
private final int usage_page_id;
|
private final int usage_page_id;
|
||||||
|
|
||||||
public final static UsagePage map(int page_id) {
|
public final static UsagePage map(int page_id) {
|
||||||
|
|
@ -86,7 +80,7 @@ final class UsagePage {
|
||||||
return map[page_id];
|
return map[page_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
private UsagePage(int page_id, Class usage_class) {
|
private UsagePage(int page_id, Class<? extends Usage> usage_class) {
|
||||||
map[page_id] = this;
|
map[page_id] = this;
|
||||||
this.usage_class = usage_class;
|
this.usage_class = usage_class;
|
||||||
this.usage_page_id = page_id;
|
this.usage_page_id = page_id;
|
||||||
|
|
@ -104,8 +98,8 @@ final class UsagePage {
|
||||||
if (usage_class == null)
|
if (usage_class == null)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
Method map_method = usage_class.getMethod("map", new Class[]{int.class});
|
Method map_method = usage_class.getMethod("map", int.class);
|
||||||
Object result = map_method.invoke(null, new Object[]{new Integer(usage_id)});
|
Object result = map_method.invoke(null, usage_id);
|
||||||
return (Usage)result;
|
return (Usage)result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Error(e);
|
throw new Error(e);
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
<?xml version="1.0" ?>
|
|
||||||
<project name="OS X Plugin, Native code" basedir="." default="compileNativeJinputLib">
|
|
||||||
<description>OSX JInput Native Plugin</description>
|
|
||||||
|
|
||||||
<target name="init">
|
|
||||||
<mkdir dir="ppc"/>
|
|
||||||
<mkdir dir="intel"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<delete failonerror="false">
|
|
||||||
<fileset dir="intel"/>
|
|
||||||
<fileset dir="ppc"/>
|
|
||||||
<fileset file="libjinput-osx.jnilib"/>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile">
|
|
||||||
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
|
|
||||||
<arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I../../../../common/src/native -I.."/>
|
|
||||||
<mapper type="glob" from="*.c" to="*.o"/>
|
|
||||||
<fileset dir="." includes="*.c"/>
|
|
||||||
<fileset dir="../../../common/src/native" includes="*.c"/>
|
|
||||||
</apply>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="link">
|
|
||||||
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
|
||||||
<arg line="${linkerflags} -dynamiclib -o ${libname} -framework JavaVM -framework CoreFoundation -framework IOKit -framework CoreServices"/>
|
|
||||||
<fileset dir="${objdir}" includes="*.o"/>
|
|
||||||
</apply>
|
|
||||||
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
|
|
||||||
<arg line="-S -X"/>
|
|
||||||
<fileset dir="." includes="${libname}"/>
|
|
||||||
</apply>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compileNativeJinputLib" depends="init">
|
|
||||||
<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
|
|
||||||
<property name="legacy_sdkroot" location="/Developer/SDKs/MacOSX10.3.9.sdk"/>
|
|
||||||
<property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386"/>
|
|
||||||
<antcall target="compile">
|
|
||||||
<param name="dstdir" location="intel"/>
|
|
||||||
<param name="compiler" value="gcc-4.0"/>
|
|
||||||
<param name="sdkroot" location="${universal_sdkroot}"/>
|
|
||||||
<param name="cflags" value="${universal_flags}"/>
|
|
||||||
</antcall>
|
|
||||||
<antcall target="link">
|
|
||||||
<param name="objdir" location="intel"/>
|
|
||||||
<param name="libname" value="libjinput-osx-intel.jnilib"/>
|
|
||||||
<param name="linker" value="gcc-4.0"/>
|
|
||||||
<param name="linkerflags" value="${universal_flags}"/>
|
|
||||||
</antcall>
|
|
||||||
<antcall target="compile">
|
|
||||||
<param name="dstdir" location="ppc"/>
|
|
||||||
<param name="compiler" value="gcc-3.3"/>
|
|
||||||
<param name="sdkroot" location="${legacy_sdkroot}"/>
|
|
||||||
<param name="cflags" value=""/>
|
|
||||||
</antcall>
|
|
||||||
<antcall target="link">
|
|
||||||
<param name="objdir" location="ppc"/>
|
|
||||||
<param name="libname" value="libjinput-osx-ppc.jnilib"/>
|
|
||||||
<param name="linker" value="gcc-3.3"/>
|
|
||||||
<param name="linkerflags" value=""/>
|
|
||||||
</antcall>
|
|
||||||
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
|
|
||||||
<arg value="-create"/>
|
|
||||||
<srcfile/>
|
|
||||||
<arg value="-output"/>
|
|
||||||
<arg path="libjinput-osx.jnilib"/>
|
|
||||||
<fileset file="ppc/libjinput-osx-ppc.jnilib"/>
|
|
||||||
<fileset file="intel/libjinput-osx-intel.jnilib"/>
|
|
||||||
</apply>
|
|
||||||
</target>
|
|
||||||
</project>
|
|
||||||
32
plugins/awt/pom.xml
Normal file
32
plugins/awt/pom.xml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>awt-plugin</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - AWT Plugin</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>plugins</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>coreapi</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<!-- <plugin> -->
|
||||||
|
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
|
||||||
|
<!-- </plugin> -->
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
|
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -43,7 +43,7 @@ import java.lang.reflect.Modifier;
|
||||||
* @author elias
|
* @author elias
|
||||||
*/
|
*/
|
||||||
final class AWTKeyboard extends Keyboard implements AWTEventListener {
|
final class AWTKeyboard extends Keyboard implements AWTEventListener {
|
||||||
private final List awt_events = new ArrayList();
|
private final List<KeyEvent> awt_events = new ArrayList<>();
|
||||||
private Event[] processed_events;
|
private Event[] processed_events;
|
||||||
private int processed_events_index;
|
private int processed_events_index;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ final class AWTKeyboard extends Keyboard implements AWTEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Component[] createComponents() {
|
private final static Component[] createComponents() {
|
||||||
List components = new ArrayList();
|
List<Component> components = new ArrayList<>();
|
||||||
Field[] vkey_fields = KeyEvent.class.getFields();
|
Field[] vkey_fields = KeyEvent.class.getFields();
|
||||||
for (int i = 0; i < vkey_fields.length; i++) {
|
for (int i = 0; i < vkey_fields.length; i++) {
|
||||||
Field vkey_field = vkey_fields[i];
|
Field vkey_field = vkey_fields[i];
|
||||||
|
|
@ -80,7 +80,7 @@ final class AWTKeyboard extends Keyboard implements AWTEventListener {
|
||||||
components.add(new Key(Component.Identifier.Key.RETURN));
|
components.add(new Key(Component.Identifier.Key.RETURN));
|
||||||
components.add(new Key(Component.Identifier.Key.NUMPADCOMMA));
|
components.add(new Key(Component.Identifier.Key.NUMPADCOMMA));
|
||||||
components.add(new Key(Component.Identifier.Key.COMMA));
|
components.add(new Key(Component.Identifier.Key.COMMA));
|
||||||
return (Component[])components.toArray(new Component[]{});
|
return components.toArray(new Component[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void resizeEventQueue(int size) {
|
private final void resizeEventQueue(int size) {
|
||||||
|
|
@ -96,13 +96,12 @@ final class AWTKeyboard extends Keyboard implements AWTEventListener {
|
||||||
|
|
||||||
public final synchronized void eventDispatched(AWTEvent event) {
|
public final synchronized void eventDispatched(AWTEvent event) {
|
||||||
if (event instanceof KeyEvent)
|
if (event instanceof KeyEvent)
|
||||||
awt_events.add(event);
|
awt_events.add((KeyEvent)event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final synchronized void pollDevice() throws IOException {
|
public final synchronized void pollDevice() throws IOException {
|
||||||
for (int i = 0; i < awt_events.size(); i++) {
|
for (int i = 0; i < awt_events.size(); i++) {
|
||||||
KeyEvent event = (KeyEvent)awt_events.get(i);
|
processEvent(awt_events.get(i));
|
||||||
processEvent(event);
|
|
||||||
}
|
}
|
||||||
awt_events.clear();
|
awt_events.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
|
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.awt.AWTEvent;
|
import java.awt.AWTEvent;
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.AWTEventListener;
|
import java.awt.event.AWTEventListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
@ -47,8 +46,8 @@ final class AWTMouse extends Mouse implements AWTEventListener {
|
||||||
private final static int EVENT_Y = 2;
|
private final static int EVENT_Y = 2;
|
||||||
private final static int EVENT_BUTTON = 4;
|
private final static int EVENT_BUTTON = 4;
|
||||||
|
|
||||||
private final List awt_events = new ArrayList();
|
private final List<AWTEvent> awt_events = new ArrayList<>();
|
||||||
private final List processed_awt_events = new ArrayList();
|
private final List<AWTEvent> processed_awt_events = new ArrayList<>();
|
||||||
|
|
||||||
private int event_state = EVENT_X;
|
private int event_state = EVENT_X;
|
||||||
|
|
||||||
|
|
@ -115,7 +114,7 @@ final class AWTMouse extends Mouse implements AWTEventListener {
|
||||||
Axis wheel = (Axis)getWheel();
|
Axis wheel = (Axis)getWheel();
|
||||||
wheel.setValue(0);
|
wheel.setValue(0);
|
||||||
for (int i = 0; i < awt_events.size(); i++) {
|
for (int i = 0; i < awt_events.size(); i++) {
|
||||||
AWTEvent event = (AWTEvent)awt_events.get(i);
|
AWTEvent event = awt_events.get(i);
|
||||||
processEvent(event);
|
processEvent(event);
|
||||||
processed_awt_events.add(event);
|
processed_awt_events.add(event);
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +125,7 @@ final class AWTMouse extends Mouse implements AWTEventListener {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (processed_awt_events.isEmpty())
|
if (processed_awt_events.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
AWTEvent awt_event = (AWTEvent)processed_awt_events.get(0);
|
AWTEvent awt_event = processed_awt_events.get(0);
|
||||||
if (awt_event instanceof MouseWheelEvent) {
|
if (awt_event instanceof MouseWheelEvent) {
|
||||||
MouseWheelEvent awt_wheel_event = (MouseWheelEvent)awt_event;
|
MouseWheelEvent awt_wheel_event = (MouseWheelEvent)awt_event;
|
||||||
long nanos = awt_wheel_event.getWhen()*1000000L;
|
long nanos = awt_wheel_event.getWhen()*1000000L;
|
||||||
|
|
@ -1,71 +1,45 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project basedir="." default="all" name="Linux Plugin">
|
<project basedir="." default="compileNativeJinputLib" name="Linux Plugin">
|
||||||
|
<property name="libname64" value="libjinput-linux64.so"/>
|
||||||
|
<property name="libname32" value="libjinput-linux.so"/>
|
||||||
|
|
||||||
<target name="init">
|
<target name="init">
|
||||||
<mkdir dir="classes"/>
|
<mkdir dir="target/natives"/>
|
||||||
<mkdir dir="bin"/>
|
</target>
|
||||||
<condition property="linux" >
|
|
||||||
<!--<os family="unix" />-->
|
<target name="createNativeDefinitions.java">
|
||||||
<os name="Linux" />
|
<exec dir="src/main/native" executable="gawk" os="Linux" output="../java/net/java/games/input/NativeDefinitions.java">
|
||||||
|
<arg line="-f"/>
|
||||||
|
<arg line="getDefinitions"/>
|
||||||
|
<arg line="/usr/include/linux/input.h"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target depends="init" name="compileNativeJinputLib">
|
||||||
|
<exec executable="uname" outputproperty="hwplatform">
|
||||||
|
<arg value="-m"/>
|
||||||
|
</exec>
|
||||||
|
<condition property="libname" value="${libname64}" else="${libname32}">
|
||||||
|
<equals arg1="${hwplatform}" arg2="x86_64"/>
|
||||||
</condition>
|
</condition>
|
||||||
|
<apply dir="target/natives" executable="cc" os="Linux" dest="target/natives" skipemptyfilesets="true" failonerror="true">
|
||||||
</target>
|
<arg line="-O2 -Wall -c -fPIC"/>
|
||||||
|
<arg value="-I${java.home}/include"/>
|
||||||
<target depends="init" name="compile">
|
<arg value="-I${java.home}/include/linux"/>
|
||||||
<!-- <ant dir="src/native" target="createNativeDefinitions.java"/>-->
|
<arg value="-I${java.home}/../include"/>
|
||||||
<javac debug="true" deprecation="true" destdir="classes" source="1.4" target="1.4" srcdir="src/java">
|
<arg value="-I${java.home}/../include/linux"/>
|
||||||
<classpath>
|
<arg value="-I../../../common/src/native"/>
|
||||||
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
|
<arg value="-I../generated-sources/natives"/>
|
||||||
<pathelement location="../../lib/jutils.jar"/>
|
<mapper type="glob" from="*.c" to="*.o"/>
|
||||||
</classpath>
|
<fileset dir="src/main/native" includes="*.c"/>
|
||||||
</javac>
|
<fileset dir="../common/src/native" includes="*.c"/>
|
||||||
</target>
|
</apply>
|
||||||
|
<apply dir="target/natives" parallel="true" executable="cc" os="Linux" failonerror="true">
|
||||||
<target depends="init,compile" name="jar">
|
<arg line="-shared -O2 -Wall -o ${libname}"/>
|
||||||
<jar jarfile="bin/linux.jar" compress="true" basedir="classes">
|
<fileset dir="target/natives" includes="*.o"/>
|
||||||
<include name="**/*.class"/>
|
</apply>
|
||||||
</jar>
|
<apply dir="target/natives" parallel="true" executable="strip" os="Linux" failonerror="true">
|
||||||
</target>
|
<fileset file="target/natives/${libname}"/>
|
||||||
|
</apply>
|
||||||
<target depends="jar,compileNativeJinputLib" description="Build everything." name="all">
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="javadoc" depends="init" description="Javadoc for Linux plugin for JInput.">
|
|
||||||
<mkdir dir="apidocs"/>
|
|
||||||
<javadoc packagenames="net.java.games.input.*"
|
|
||||||
destdir="apidocs"
|
|
||||||
additionalparam="-source 1.4"
|
|
||||||
link="../../../coreAPI/apidocs">
|
|
||||||
<sourcepath>
|
|
||||||
<pathelement location="src/java"/>
|
|
||||||
</sourcepath>
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
|
|
||||||
<pathelement location="../../coreAPI/lib/jutils.jar"/>
|
|
||||||
</classpath>
|
|
||||||
</javadoc>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target description="Clean all build products." name="clean">
|
|
||||||
<delete dir="classes" failonerror="no"/>
|
|
||||||
<delete dir="bin" failonerror="no"/>
|
|
||||||
<delete dir="apidocs" failonerror="no"/>
|
|
||||||
<ant inheritAll="false" antfile="src/native/build.xml" target="clean"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="init,compile" name="createJNIHeaders">
|
|
||||||
<javah destdir="src/native">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="classes"/>
|
|
||||||
</classpath>
|
|
||||||
<class name="net.java.games.input.LinuxEventDevice"/>
|
|
||||||
<class name="net.java.games.input.LinuxJoystickDevice"/>
|
|
||||||
</javah>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target depends="init,createJNIHeaders" name="compileNativeJinputLib" if="linux">
|
|
||||||
<ant dir="src/native" target="compileNativeJinputLib"/>
|
|
||||||
<copy todir="bin">
|
|
||||||
<fileset dir="src/native" includes="libjinput-linux*.so"/>
|
|
||||||
</copy>
|
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
69
plugins/linux/pom.xml
Normal file
69
plugins/linux/pom.xml
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>linux-plugin</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>JInput - Linux Plugin</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>plugins</artifactId>
|
||||||
|
<version>2.0.10-SNAPSHOT</version>
|
||||||
|
<relativePath>../</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.jinput</groupId>
|
||||||
|
<artifactId>coreapi</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<ant dir="." target="compileNativeJinputLib"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<classesDirectory>${project.build.directory}/natives</classesDirectory>
|
||||||
|
<classifier>natives-linux</classifier>
|
||||||
|
<includes>
|
||||||
|
<include>*.so</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -1,489 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer. Redistributions in binary
|
|
||||||
* form must reproduce the above copyright notice, this list of conditions and
|
|
||||||
* the following disclaimer in the documentation and/or other materials provided
|
|
||||||
* with the distribution.
|
|
||||||
* The name of the author may not be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
||||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
|
||||||
*/
|
|
||||||
package net.java.games.input;
|
|
||||||
|
|
||||||
import net.java.games.util.plugins.Plugin;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
/** Environment plugin for linux
|
|
||||||
* @author elias
|
|
||||||
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
|
|
||||||
*/
|
|
||||||
public final class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
|
|
||||||
private final static String LIBNAME = "jinput-linux";
|
|
||||||
private final static String POSTFIX64BIT = "64";
|
|
||||||
private static boolean supported = false;
|
|
||||||
|
|
||||||
private final Controller[] controllers;
|
|
||||||
private final List devices = new ArrayList();
|
|
||||||
private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static utility method for loading native libraries.
|
|
||||||
* It will try to load from either the path given by
|
|
||||||
* the net.java.games.input.librarypath property
|
|
||||||
* or through System.loadLibrary().
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void loadLibrary(final String lib_name) {
|
|
||||||
AccessController.doPrivileged(
|
|
||||||
new PrivilegedAction() {
|
|
||||||
public final Object run() {
|
|
||||||
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
|
||||||
if (lib_path != null)
|
|
||||||
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
|
||||||
else
|
|
||||||
System.loadLibrary(lib_name);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property) {
|
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property, final String default_value) {
|
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
|
||||||
public Object run() {
|
|
||||||
return System.getProperty(property, default_value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
String osName = getPrivilegedProperty("os.name", "").trim();
|
|
||||||
if(osName.equals("Linux")) {
|
|
||||||
supported = true;
|
|
||||||
try {
|
|
||||||
loadLibrary(LIBNAME);
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
try {
|
|
||||||
loadLibrary(LIBNAME + POSTFIX64BIT);
|
|
||||||
} catch (UnsatisfiedLinkError e2) {
|
|
||||||
logln("Failed to load 64 bit library: " + e2.getMessage());
|
|
||||||
// throw original error
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static Object execute(LinuxDeviceTask task) throws IOException {
|
|
||||||
return device_thread.execute(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinuxEnvironmentPlugin() {
|
|
||||||
if(isSupported()) {
|
|
||||||
this.controllers = enumerateControllers();
|
|
||||||
logln("Linux plugin claims to have found " + controllers.length + " controllers");
|
|
||||||
AccessController.doPrivileged(
|
|
||||||
new PrivilegedAction() {
|
|
||||||
public final Object run() {
|
|
||||||
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
controllers = new Controller[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a list of all controllers available to this environment,
|
|
||||||
* or an empty array if there are no controllers in this environment.
|
|
||||||
* @return Returns a list of all controllers available to this environment,
|
|
||||||
* or an empty array if there are no controllers in this environment.
|
|
||||||
*/
|
|
||||||
public final Controller[] getControllers() {
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Component[] createComponents(List event_components, LinuxEventDevice device) {
|
|
||||||
LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
|
|
||||||
List components = new ArrayList();
|
|
||||||
for (int i = 0; i < event_components.size(); i++) {
|
|
||||||
LinuxEventComponent event_component = (LinuxEventComponent)event_components.get(i);
|
|
||||||
Component.Identifier identifier = event_component.getIdentifier();
|
|
||||||
|
|
||||||
if (identifier == Component.Identifier.Axis.POV) {
|
|
||||||
int native_code = event_component.getDescriptor().getCode();
|
|
||||||
switch (native_code) {
|
|
||||||
case NativeDefinitions.ABS_HAT0X:
|
|
||||||
povs[0][0] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT0Y:
|
|
||||||
povs[0][1] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT1X:
|
|
||||||
povs[1][0] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT1Y:
|
|
||||||
povs[1][1] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT2X:
|
|
||||||
povs[2][0] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT2Y:
|
|
||||||
povs[2][1] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT3X:
|
|
||||||
povs[3][0] = event_component;
|
|
||||||
break;
|
|
||||||
case NativeDefinitions.ABS_HAT3Y:
|
|
||||||
povs[3][1] = event_component;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logln("Unknown POV instance: " + native_code);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (identifier != null) {
|
|
||||||
LinuxComponent component = new LinuxComponent(event_component);
|
|
||||||
components.add(component);
|
|
||||||
device.registerComponent(event_component.getDescriptor(), component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < povs.length; i++) {
|
|
||||||
LinuxEventComponent x = povs[i][0];
|
|
||||||
LinuxEventComponent y = povs[i][1];
|
|
||||||
if (x != null && y != null) {
|
|
||||||
LinuxComponent controller_component = new LinuxPOV(x, y);
|
|
||||||
components.add(controller_component);
|
|
||||||
device.registerComponent(x.getDescriptor(), controller_component);
|
|
||||||
device.registerComponent(y.getDescriptor(), controller_component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component[] components_array = new Component[components.size()];
|
|
||||||
components.toArray(components_array);
|
|
||||||
return components_array;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
|
|
||||||
Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers());
|
|
||||||
if (mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null)
|
|
||||||
return mouse;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Keyboard createKeyboardFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
|
|
||||||
Keyboard keyboard = new LinuxKeyboard(device, components, new Controller[]{}, device.getRumblers());
|
|
||||||
return keyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Controller createJoystickFromDevice(LinuxEventDevice device, Component[] components, Controller.Type type) throws IOException {
|
|
||||||
Controller joystick = new LinuxAbstractController(device, components, new Controller[]{}, device.getRumblers(), type);
|
|
||||||
return joystick;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException {
|
|
||||||
List event_components = device.getComponents();
|
|
||||||
Component[] components = createComponents(event_components, device);
|
|
||||||
Controller.Type type = device.getType();
|
|
||||||
|
|
||||||
if (type == Controller.Type.MOUSE) {
|
|
||||||
return createMouseFromDevice(device, components);
|
|
||||||
} else if (type == Controller.Type.KEYBOARD) {
|
|
||||||
return createKeyboardFromDevice(device, components);
|
|
||||||
} else if (type == Controller.Type.STICK || type == Controller.Type.GAMEPAD) {
|
|
||||||
return createJoystickFromDevice(device, components, type);
|
|
||||||
} else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Controller[] enumerateControllers() {
|
|
||||||
List controllers = new ArrayList();
|
|
||||||
List eventControllers = new ArrayList();
|
|
||||||
List jsControllers = new ArrayList();
|
|
||||||
enumerateEventControllers(eventControllers);
|
|
||||||
enumerateJoystickControllers(jsControllers);
|
|
||||||
|
|
||||||
for(int i=0;i<eventControllers.size();i++) {
|
|
||||||
for(int j=0;j<jsControllers.size();j++) {
|
|
||||||
Controller evController = (Controller) eventControllers.get(i);
|
|
||||||
Controller jsController = (Controller) jsControllers.get(j);
|
|
||||||
|
|
||||||
// compare
|
|
||||||
// Check if the nodes have the same name
|
|
||||||
if(evController.getName().equals(jsController.getName())) {
|
|
||||||
// Check they have the same component count
|
|
||||||
Component[] evComponents = evController.getComponents();
|
|
||||||
Component[] jsComponents = jsController.getComponents();
|
|
||||||
if(evComponents.length==jsComponents.length) {
|
|
||||||
boolean foundADifference = false;
|
|
||||||
// check the component pairs are of the same type
|
|
||||||
for(int k=0;k<evComponents.length;k++) {
|
|
||||||
// Check the type of the component is the same
|
|
||||||
if(!(evComponents[k].getIdentifier() == jsComponents[k].getIdentifier())) {
|
|
||||||
foundADifference = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!foundADifference) {
|
|
||||||
controllers.add(new LinuxCombinedController((LinuxAbstractController)eventControllers.remove(i), (LinuxJoystickAbstractController)jsControllers.remove(j)));
|
|
||||||
i--;
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controllers.addAll(eventControllers);
|
|
||||||
controllers.addAll(jsControllers);
|
|
||||||
|
|
||||||
Controller[] controllers_array = new Controller[controllers.size()];
|
|
||||||
controllers.toArray(controllers_array);
|
|
||||||
return controllers_array;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Component.Identifier.Button getButtonIdentifier(int index) {
|
|
||||||
switch (index) {
|
|
||||||
case 0:
|
|
||||||
return Component.Identifier.Button._0;
|
|
||||||
case 1:
|
|
||||||
return Component.Identifier.Button._1;
|
|
||||||
case 2:
|
|
||||||
return Component.Identifier.Button._2;
|
|
||||||
case 3:
|
|
||||||
return Component.Identifier.Button._3;
|
|
||||||
case 4:
|
|
||||||
return Component.Identifier.Button._4;
|
|
||||||
case 5:
|
|
||||||
return Component.Identifier.Button._5;
|
|
||||||
case 6:
|
|
||||||
return Component.Identifier.Button._6;
|
|
||||||
case 7:
|
|
||||||
return Component.Identifier.Button._7;
|
|
||||||
case 8:
|
|
||||||
return Component.Identifier.Button._8;
|
|
||||||
case 9:
|
|
||||||
return Component.Identifier.Button._9;
|
|
||||||
case 10:
|
|
||||||
return Component.Identifier.Button._10;
|
|
||||||
case 11:
|
|
||||||
return Component.Identifier.Button._11;
|
|
||||||
case 12:
|
|
||||||
return Component.Identifier.Button._12;
|
|
||||||
case 13:
|
|
||||||
return Component.Identifier.Button._13;
|
|
||||||
case 14:
|
|
||||||
return Component.Identifier.Button._14;
|
|
||||||
case 15:
|
|
||||||
return Component.Identifier.Button._15;
|
|
||||||
case 16:
|
|
||||||
return Component.Identifier.Button._16;
|
|
||||||
case 17:
|
|
||||||
return Component.Identifier.Button._17;
|
|
||||||
case 18:
|
|
||||||
return Component.Identifier.Button._18;
|
|
||||||
case 19:
|
|
||||||
return Component.Identifier.Button._19;
|
|
||||||
case 20:
|
|
||||||
return Component.Identifier.Button._20;
|
|
||||||
case 21:
|
|
||||||
return Component.Identifier.Button._21;
|
|
||||||
case 22:
|
|
||||||
return Component.Identifier.Button._22;
|
|
||||||
case 23:
|
|
||||||
return Component.Identifier.Button._23;
|
|
||||||
case 24:
|
|
||||||
return Component.Identifier.Button._24;
|
|
||||||
case 25:
|
|
||||||
return Component.Identifier.Button._25;
|
|
||||||
case 26:
|
|
||||||
return Component.Identifier.Button._26;
|
|
||||||
case 27:
|
|
||||||
return Component.Identifier.Button._27;
|
|
||||||
case 28:
|
|
||||||
return Component.Identifier.Button._28;
|
|
||||||
case 29:
|
|
||||||
return Component.Identifier.Button._29;
|
|
||||||
case 30:
|
|
||||||
return Component.Identifier.Button._30;
|
|
||||||
case 31:
|
|
||||||
return Component.Identifier.Button._31;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) {
|
|
||||||
List components = new ArrayList();
|
|
||||||
byte[] axisMap = device.getAxisMap();
|
|
||||||
char[] buttonMap = device.getButtonMap();
|
|
||||||
LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6];
|
|
||||||
|
|
||||||
for (int i = 0; i < device.getNumButtons(); i++) {
|
|
||||||
Component.Identifier button_id = (Component.Identifier)LinuxNativeTypesMap.getButtonID(buttonMap[i]);
|
|
||||||
if (button_id != null) {
|
|
||||||
LinuxJoystickButton button = new LinuxJoystickButton(button_id);
|
|
||||||
device.registerButton(i, button);
|
|
||||||
components.add(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < device.getNumAxes(); i++) {
|
|
||||||
Component.Identifier.Axis axis_id;
|
|
||||||
axis_id = (Component.Identifier.Axis) LinuxNativeTypesMap.getAbsAxisID(axisMap[i]);
|
|
||||||
LinuxJoystickAxis axis = new LinuxJoystickAxis(axis_id);
|
|
||||||
|
|
||||||
device.registerAxis(i, axis);
|
|
||||||
|
|
||||||
if(axisMap[i]==NativeDefinitions.ABS_HAT0X) {
|
|
||||||
hatBits[0] = axis;
|
|
||||||
} else if(axisMap[i]==NativeDefinitions.ABS_HAT0Y) {
|
|
||||||
hatBits[1] = axis;
|
|
||||||
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[0], hatBits[1]);
|
|
||||||
device.registerPOV((LinuxJoystickPOV)axis);
|
|
||||||
components.add(axis);
|
|
||||||
} else if(axisMap[i]==NativeDefinitions.ABS_HAT1X) {
|
|
||||||
hatBits[2] = axis;
|
|
||||||
} else if(axisMap[i]==NativeDefinitions.ABS_HAT1Y) {
|
|
||||||
hatBits[3] = axis;
|
|
||||||
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[2], hatBits[3]);
|
|
||||||
device.registerPOV((LinuxJoystickPOV)axis);
|
|
||||||
components.add(axis);
|
|
||||||
} else if(axisMap[i]==NativeDefinitions.ABS_HAT2X) {
|
|
||||||
hatBits[4] = axis;
|
|
||||||
} else if(axisMap[i]==NativeDefinitions.ABS_HAT2Y) {
|
|
||||||
hatBits[5] = axis;
|
|
||||||
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[4], hatBits[5]);
|
|
||||||
device.registerPOV((LinuxJoystickPOV)axis);
|
|
||||||
components.add(axis);
|
|
||||||
} else {
|
|
||||||
components.add(axis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LinuxJoystickAbstractController(device, (Component[])components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{});
|
|
||||||
}
|
|
||||||
|
|
||||||
private final void enumerateJoystickControllers(List controllers) {
|
|
||||||
File[] joystick_device_files = enumerateJoystickDeviceFiles("/dev/input");
|
|
||||||
if (joystick_device_files == null || joystick_device_files.length == 0) {
|
|
||||||
joystick_device_files = enumerateJoystickDeviceFiles("/dev");
|
|
||||||
if (joystick_device_files == null)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < joystick_device_files.length; i++) {
|
|
||||||
File event_file = joystick_device_files[i];
|
|
||||||
try {
|
|
||||||
String path = getAbsolutePathPrivileged(event_file);
|
|
||||||
LinuxJoystickDevice device = new LinuxJoystickDevice(path);
|
|
||||||
Controller controller = createJoystickFromJoystickDevice(device);
|
|
||||||
if (controller != null) {
|
|
||||||
controllers.add(controller);
|
|
||||||
devices.add(device);
|
|
||||||
} else
|
|
||||||
device.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logln("Failed to open device (" + event_file + "): " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static File[] enumerateJoystickDeviceFiles(final String dev_path) {
|
|
||||||
final File dev = new File(dev_path);
|
|
||||||
return listFilesPrivileged(dev, new FilenameFilter() {
|
|
||||||
public final boolean accept(File dir, String name) {
|
|
||||||
return name.startsWith("js");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getAbsolutePathPrivileged(final File file) {
|
|
||||||
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
|
||||||
public Object run() {
|
|
||||||
return file.getAbsolutePath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) {
|
|
||||||
return (File[])AccessController.doPrivileged(new PrivilegedAction() {
|
|
||||||
public Object run() {
|
|
||||||
return dir.listFiles(filter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private final void enumerateEventControllers(List controllers) {
|
|
||||||
final File dev = new File("/dev/input");
|
|
||||||
File[] event_device_files = listFilesPrivileged(dev, new FilenameFilter() {
|
|
||||||
public final boolean accept(File dir, String name) {
|
|
||||||
return name.startsWith("event");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (event_device_files == null)
|
|
||||||
return;
|
|
||||||
for (int i = 0; i < event_device_files.length; i++) {
|
|
||||||
File event_file = event_device_files[i];
|
|
||||||
try {
|
|
||||||
String path = getAbsolutePathPrivileged(event_file);
|
|
||||||
LinuxEventDevice device = new LinuxEventDevice(path);
|
|
||||||
try {
|
|
||||||
Controller controller = createControllerFromDevice(device);
|
|
||||||
if (controller != null) {
|
|
||||||
controllers.add(controller);
|
|
||||||
devices.add(device);
|
|
||||||
} else
|
|
||||||
device.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logln("Failed to create Controller: " + e.getMessage());
|
|
||||||
device.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
logln("Failed to open device (" + event_file + "): " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class ShutdownHook extends Thread {
|
|
||||||
public final void run() {
|
|
||||||
for (int i = 0; i < devices.size(); i++) {
|
|
||||||
try {
|
|
||||||
LinuxDevice device = (LinuxDevice)devices.get(i);
|
|
||||||
device.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logln("Failed to close device: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSupported() {
|
|
||||||
return supported;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -40,7 +40,7 @@ import java.util.ArrayList;
|
||||||
* is run on a single thread.
|
* is run on a single thread.
|
||||||
*/
|
*/
|
||||||
final class LinuxDeviceThread extends Thread {
|
final class LinuxDeviceThread extends Thread {
|
||||||
private final List tasks = new ArrayList();
|
private final List<LinuxDeviceTask> tasks = new ArrayList<>();
|
||||||
|
|
||||||
public LinuxDeviceThread() {
|
public LinuxDeviceThread() {
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
|
|
@ -50,7 +50,7 @@ final class LinuxDeviceThread extends Thread {
|
||||||
public synchronized final void run() {
|
public synchronized final void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!tasks.isEmpty()) {
|
if (!tasks.isEmpty()) {
|
||||||
LinuxDeviceTask task = (LinuxDeviceTask)tasks.remove(0);
|
LinuxDeviceTask task = tasks.remove(0);
|
||||||
task.doExecute();
|
task.doExecute();
|
||||||
synchronized (task) {
|
synchronized (task) {
|
||||||
task.notify();
|
task.notify();
|
||||||
|
|
@ -0,0 +1,477 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer. Redistributions in binary
|
||||||
|
* form must reproduce the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer in the documentation and/or other materials provided
|
||||||
|
* with the distribution.
|
||||||
|
* The name of the author may not be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
|
||||||
|
*/
|
||||||
|
package net.java.games.input;
|
||||||
|
|
||||||
|
import net.java.games.util.plugins.Plugin;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
|
/** Environment plugin for linux
|
||||||
|
* @author elias
|
||||||
|
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
|
*/
|
||||||
|
public final class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
|
||||||
|
private final static String LIBNAME = "jinput-linux";
|
||||||
|
private final static String POSTFIX64BIT = "64";
|
||||||
|
private static boolean supported = false;
|
||||||
|
|
||||||
|
private final Controller[] controllers;
|
||||||
|
private final List<LinuxDevice> devices = new ArrayList<LinuxDevice>();
|
||||||
|
private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static utility method for loading native libraries.
|
||||||
|
* It will try to load from either the path given by
|
||||||
|
* the net.java.games.input.librarypath property
|
||||||
|
* or through System.loadLibrary().
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void loadLibrary(final String lib_name) {
|
||||||
|
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||||
|
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
||||||
|
try {
|
||||||
|
if(lib_path != null)
|
||||||
|
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
||||||
|
else
|
||||||
|
System.loadLibrary(lib_name);
|
||||||
|
} catch(UnsatisfiedLinkError e) {
|
||||||
|
log("Failed to load library: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
supported = false;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getPrivilegedProperty(final String property) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static String getPrivilegedProperty(final String property, final String default_value) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property, default_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
String osName = getPrivilegedProperty("os.name", "").trim();
|
||||||
|
if(osName.equals("Linux")) {
|
||||||
|
supported = true;
|
||||||
|
if("i386".equals(getPrivilegedProperty("os.arch"))) {
|
||||||
|
loadLibrary(LIBNAME);
|
||||||
|
} else {
|
||||||
|
loadLibrary(LIBNAME + POSTFIX64BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static Object execute(LinuxDeviceTask task) throws IOException {
|
||||||
|
return device_thread.execute(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinuxEnvironmentPlugin() {
|
||||||
|
if(isSupported()) {
|
||||||
|
this.controllers = enumerateControllers();
|
||||||
|
log("Linux plugin claims to have found " + controllers.length + " controllers");
|
||||||
|
AccessController.doPrivileged((PrivilegedAction<Void>)() -> {
|
||||||
|
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
controllers = new Controller[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns a list of all controllers available to this environment,
|
||||||
|
* or an empty array if there are no controllers in this environment.
|
||||||
|
* @return Returns a list of all controllers available to this environment,
|
||||||
|
* or an empty array if there are no controllers in this environment.
|
||||||
|
*/
|
||||||
|
public final Controller[] getControllers() {
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Component[] createComponents(List<LinuxEventComponent> event_components, LinuxEventDevice device) {
|
||||||
|
LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
|
||||||
|
List<LinuxComponent> components = new ArrayList<>();
|
||||||
|
for(int i = 0; i < event_components.size(); i++) {
|
||||||
|
LinuxEventComponent event_component = event_components.get(i);
|
||||||
|
Component.Identifier identifier = event_component.getIdentifier();
|
||||||
|
|
||||||
|
if(identifier == Component.Identifier.Axis.POV) {
|
||||||
|
int native_code = event_component.getDescriptor().getCode();
|
||||||
|
switch(native_code) {
|
||||||
|
case NativeDefinitions.ABS_HAT0X:
|
||||||
|
povs[0][0] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT0Y:
|
||||||
|
povs[0][1] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT1X:
|
||||||
|
povs[1][0] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT1Y:
|
||||||
|
povs[1][1] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT2X:
|
||||||
|
povs[2][0] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT2Y:
|
||||||
|
povs[2][1] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT3X:
|
||||||
|
povs[3][0] = event_component;
|
||||||
|
break;
|
||||||
|
case NativeDefinitions.ABS_HAT3Y:
|
||||||
|
povs[3][1] = event_component;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log("Unknown POV instance: " + native_code);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if(identifier != null) {
|
||||||
|
LinuxComponent component = new LinuxComponent(event_component);
|
||||||
|
components.add(component);
|
||||||
|
device.registerComponent(event_component.getDescriptor(), component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < povs.length; i++) {
|
||||||
|
LinuxEventComponent x = povs[i][0];
|
||||||
|
LinuxEventComponent y = povs[i][1];
|
||||||
|
if(x != null && y != null) {
|
||||||
|
LinuxComponent controller_component = new LinuxPOV(x, y);
|
||||||
|
components.add(controller_component);
|
||||||
|
device.registerComponent(x.getDescriptor(), controller_component);
|
||||||
|
device.registerComponent(y.getDescriptor(), controller_component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component[] components_array = new Component[components.size()];
|
||||||
|
components.toArray(components_array);
|
||||||
|
return components_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
|
||||||
|
Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers());
|
||||||
|
if(mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null)
|
||||||
|
return mouse;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Keyboard createKeyboardFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
|
||||||
|
Keyboard keyboard = new LinuxKeyboard(device, components, new Controller[]{}, device.getRumblers());
|
||||||
|
return keyboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Controller createJoystickFromDevice(LinuxEventDevice device, Component[] components, Controller.Type type) throws IOException {
|
||||||
|
Controller joystick = new LinuxAbstractController(device, components, new Controller[]{}, device.getRumblers(), type);
|
||||||
|
return joystick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException {
|
||||||
|
List<LinuxEventComponent> event_components = device.getComponents();
|
||||||
|
Component[] components = createComponents(event_components, device);
|
||||||
|
Controller.Type type = device.getType();
|
||||||
|
|
||||||
|
if(type == Controller.Type.MOUSE) {
|
||||||
|
return createMouseFromDevice(device, components);
|
||||||
|
} else if(type == Controller.Type.KEYBOARD) {
|
||||||
|
return createKeyboardFromDevice(device, components);
|
||||||
|
} else if(type == Controller.Type.STICK || type == Controller.Type.GAMEPAD) {
|
||||||
|
return createJoystickFromDevice(device, components, type);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Controller[] enumerateControllers() {
|
||||||
|
List<Controller> controllers = new ArrayList<>();
|
||||||
|
List<Controller> eventControllers = new ArrayList<>();
|
||||||
|
List<Controller> jsControllers = new ArrayList<>();
|
||||||
|
enumerateEventControllers(eventControllers);
|
||||||
|
enumerateJoystickControllers(jsControllers);
|
||||||
|
|
||||||
|
for(int i = 0; i < eventControllers.size(); i++) {
|
||||||
|
for(int j = 0; j < jsControllers.size(); j++) {
|
||||||
|
Controller evController = eventControllers.get(i);
|
||||||
|
Controller jsController = jsControllers.get(j);
|
||||||
|
|
||||||
|
// compare
|
||||||
|
// Check if the nodes have the same name
|
||||||
|
if(evController.getName().equals(jsController.getName())) {
|
||||||
|
// Check they have the same component count
|
||||||
|
Component[] evComponents = evController.getComponents();
|
||||||
|
Component[] jsComponents = jsController.getComponents();
|
||||||
|
if(evComponents.length == jsComponents.length) {
|
||||||
|
boolean foundADifference = false;
|
||||||
|
// check the component pairs are of the same type
|
||||||
|
for(int k = 0; k < evComponents.length; k++) {
|
||||||
|
// Check the type of the component is the same
|
||||||
|
if(!(evComponents[k].getIdentifier() == jsComponents[k].getIdentifier())) {
|
||||||
|
foundADifference = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!foundADifference) {
|
||||||
|
controllers.add(new LinuxCombinedController((LinuxAbstractController) eventControllers.remove(i), (LinuxJoystickAbstractController) jsControllers.remove(j)));
|
||||||
|
i--;
|
||||||
|
j--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controllers.addAll(eventControllers);
|
||||||
|
controllers.addAll(jsControllers);
|
||||||
|
|
||||||
|
Controller[] controllers_array = new Controller[controllers.size()];
|
||||||
|
controllers.toArray(controllers_array);
|
||||||
|
return controllers_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Component.Identifier.Button getButtonIdentifier(int index) {
|
||||||
|
switch(index) {
|
||||||
|
case 0:
|
||||||
|
return Component.Identifier.Button._0;
|
||||||
|
case 1:
|
||||||
|
return Component.Identifier.Button._1;
|
||||||
|
case 2:
|
||||||
|
return Component.Identifier.Button._2;
|
||||||
|
case 3:
|
||||||
|
return Component.Identifier.Button._3;
|
||||||
|
case 4:
|
||||||
|
return Component.Identifier.Button._4;
|
||||||
|
case 5:
|
||||||
|
return Component.Identifier.Button._5;
|
||||||
|
case 6:
|
||||||
|
return Component.Identifier.Button._6;
|
||||||
|
case 7:
|
||||||
|
return Component.Identifier.Button._7;
|
||||||
|
case 8:
|
||||||
|
return Component.Identifier.Button._8;
|
||||||
|
case 9:
|
||||||
|
return Component.Identifier.Button._9;
|
||||||
|
case 10:
|
||||||
|
return Component.Identifier.Button._10;
|
||||||
|
case 11:
|
||||||
|
return Component.Identifier.Button._11;
|
||||||
|
case 12:
|
||||||
|
return Component.Identifier.Button._12;
|
||||||
|
case 13:
|
||||||
|
return Component.Identifier.Button._13;
|
||||||
|
case 14:
|
||||||
|
return Component.Identifier.Button._14;
|
||||||
|
case 15:
|
||||||
|
return Component.Identifier.Button._15;
|
||||||
|
case 16:
|
||||||
|
return Component.Identifier.Button._16;
|
||||||
|
case 17:
|
||||||
|
return Component.Identifier.Button._17;
|
||||||
|
case 18:
|
||||||
|
return Component.Identifier.Button._18;
|
||||||
|
case 19:
|
||||||
|
return Component.Identifier.Button._19;
|
||||||
|
case 20:
|
||||||
|
return Component.Identifier.Button._20;
|
||||||
|
case 21:
|
||||||
|
return Component.Identifier.Button._21;
|
||||||
|
case 22:
|
||||||
|
return Component.Identifier.Button._22;
|
||||||
|
case 23:
|
||||||
|
return Component.Identifier.Button._23;
|
||||||
|
case 24:
|
||||||
|
return Component.Identifier.Button._24;
|
||||||
|
case 25:
|
||||||
|
return Component.Identifier.Button._25;
|
||||||
|
case 26:
|
||||||
|
return Component.Identifier.Button._26;
|
||||||
|
case 27:
|
||||||
|
return Component.Identifier.Button._27;
|
||||||
|
case 28:
|
||||||
|
return Component.Identifier.Button._28;
|
||||||
|
case 29:
|
||||||
|
return Component.Identifier.Button._29;
|
||||||
|
case 30:
|
||||||
|
return Component.Identifier.Button._30;
|
||||||
|
case 31:
|
||||||
|
return Component.Identifier.Button._31;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) {
|
||||||
|
List<AbstractComponent> components = new ArrayList<>();
|
||||||
|
byte[] axisMap = device.getAxisMap();
|
||||||
|
char[] buttonMap = device.getButtonMap();
|
||||||
|
LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6];
|
||||||
|
|
||||||
|
for(int i = 0; i < device.getNumButtons(); i++) {
|
||||||
|
Component.Identifier button_id = LinuxNativeTypesMap.getButtonID(buttonMap[i]);
|
||||||
|
if(button_id != null) {
|
||||||
|
LinuxJoystickButton button = new LinuxJoystickButton(button_id);
|
||||||
|
device.registerButton(i, button);
|
||||||
|
components.add(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < device.getNumAxes(); i++) {
|
||||||
|
Component.Identifier.Axis axis_id;
|
||||||
|
axis_id = (Component.Identifier.Axis) LinuxNativeTypesMap.getAbsAxisID(axisMap[i]);
|
||||||
|
LinuxJoystickAxis axis = new LinuxJoystickAxis(axis_id);
|
||||||
|
|
||||||
|
device.registerAxis(i, axis);
|
||||||
|
|
||||||
|
if(axisMap[i] == NativeDefinitions.ABS_HAT0X) {
|
||||||
|
hatBits[0] = axis;
|
||||||
|
} else if(axisMap[i] == NativeDefinitions.ABS_HAT0Y) {
|
||||||
|
hatBits[1] = axis;
|
||||||
|
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[0], hatBits[1]);
|
||||||
|
device.registerPOV((LinuxJoystickPOV) axis);
|
||||||
|
components.add(axis);
|
||||||
|
} else if(axisMap[i] == NativeDefinitions.ABS_HAT1X) {
|
||||||
|
hatBits[2] = axis;
|
||||||
|
} else if(axisMap[i] == NativeDefinitions.ABS_HAT1Y) {
|
||||||
|
hatBits[3] = axis;
|
||||||
|
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[2], hatBits[3]);
|
||||||
|
device.registerPOV((LinuxJoystickPOV) axis);
|
||||||
|
components.add(axis);
|
||||||
|
} else if(axisMap[i] == NativeDefinitions.ABS_HAT2X) {
|
||||||
|
hatBits[4] = axis;
|
||||||
|
} else if(axisMap[i] == NativeDefinitions.ABS_HAT2Y) {
|
||||||
|
hatBits[5] = axis;
|
||||||
|
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[4], hatBits[5]);
|
||||||
|
device.registerPOV((LinuxJoystickPOV) axis);
|
||||||
|
components.add(axis);
|
||||||
|
} else {
|
||||||
|
components.add(axis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LinuxJoystickAbstractController(device, components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{});
|
||||||
|
}
|
||||||
|
|
||||||
|
private final void enumerateJoystickControllers(List<Controller> controllers) {
|
||||||
|
File[] joystick_device_files = enumerateJoystickDeviceFiles("/dev/input");
|
||||||
|
if(joystick_device_files == null || joystick_device_files.length == 0) {
|
||||||
|
joystick_device_files = enumerateJoystickDeviceFiles("/dev");
|
||||||
|
if(joystick_device_files == null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < joystick_device_files.length; i++) {
|
||||||
|
File event_file = joystick_device_files[i];
|
||||||
|
try {
|
||||||
|
String path = getAbsolutePathPrivileged(event_file);
|
||||||
|
LinuxJoystickDevice device = new LinuxJoystickDevice(path);
|
||||||
|
Controller controller = createJoystickFromJoystickDevice(device);
|
||||||
|
if(controller != null) {
|
||||||
|
controllers.add(controller);
|
||||||
|
devices.add(device);
|
||||||
|
} else
|
||||||
|
device.close();
|
||||||
|
} catch(IOException e) {
|
||||||
|
log("Failed to open device (" + event_file + "): " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static File[] enumerateJoystickDeviceFiles(final String dev_path) {
|
||||||
|
final File dev = new File(dev_path);
|
||||||
|
return listFilesPrivileged(dev, new FilenameFilter() {
|
||||||
|
public final boolean accept(File dir, String name) {
|
||||||
|
return name.startsWith("js");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getAbsolutePathPrivileged(final File file) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) {
|
||||||
|
return AccessController.doPrivileged((PrivilegedAction<File[]>) () -> {
|
||||||
|
File[] files = dir.listFiles(filter);
|
||||||
|
if(files == null) {
|
||||||
|
log("dir " + dir.getName() + " exists: " + dir.exists() + ", is writable: " + dir.isDirectory());
|
||||||
|
files = new File[]{};
|
||||||
|
} else {
|
||||||
|
Arrays.sort(files, Comparator.comparing(File::getName));
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private final void enumerateEventControllers(List<Controller> controllers) {
|
||||||
|
final File dev = new File("/dev/input");
|
||||||
|
File[] event_device_files = listFilesPrivileged(dev, (File dir, String name) -> name.startsWith("event"));
|
||||||
|
|
||||||
|
if(event_device_files == null)
|
||||||
|
return;
|
||||||
|
for(int i = 0; i < event_device_files.length; i++) {
|
||||||
|
File event_file = event_device_files[i];
|
||||||
|
try {
|
||||||
|
String path = getAbsolutePathPrivileged(event_file);
|
||||||
|
LinuxEventDevice device = new LinuxEventDevice(path);
|
||||||
|
try {
|
||||||
|
Controller controller = createControllerFromDevice(device);
|
||||||
|
if(controller != null) {
|
||||||
|
controllers.add(controller);
|
||||||
|
devices.add(device);
|
||||||
|
} else
|
||||||
|
device.close();
|
||||||
|
} catch(IOException e) {
|
||||||
|
log("Failed to create Controller: " + e.getMessage());
|
||||||
|
device.close();
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
log("Failed to open device (" + event_file + "): " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class ShutdownHook extends Thread {
|
||||||
|
public final void run() {
|
||||||
|
for(int i = 0; i < devices.size(); i++) {
|
||||||
|
try {
|
||||||
|
LinuxDevice device = devices.get(i);
|
||||||
|
device.close();
|
||||||
|
} catch(IOException e) {
|
||||||
|
log("Failed to close device: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSupported() {
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -35,12 +35,12 @@ import java.util.ArrayList;
|
||||||
* @author elias
|
* @author elias
|
||||||
*/
|
*/
|
||||||
final class LinuxEventDevice implements LinuxDevice {
|
final class LinuxEventDevice implements LinuxDevice {
|
||||||
private final Map component_map = new HashMap();
|
private final Map<LinuxAxisDescriptor, LinuxComponent> component_map = new HashMap<>();
|
||||||
private final Rumbler[] rumblers;
|
private final Rumbler[] rumblers;
|
||||||
private final long fd;
|
private final long fd;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final LinuxInputID input_id;
|
private final LinuxInputID input_id;
|
||||||
private final List components;
|
private final List<LinuxEventComponent> components;
|
||||||
private final Controller.Type type;
|
private final Controller.Type type;
|
||||||
|
|
||||||
/* Closed state variable that protects the validity of the file descriptor.
|
/* Closed state variable that protects the validity of the file descriptor.
|
||||||
|
|
@ -83,10 +83,10 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int countComponents(List components, Class id_type, boolean relative) {
|
private final static int countComponents(List<LinuxEventComponent> components, Class<?> id_type, boolean relative) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < components.size(); i++) {
|
for (int i = 0; i < components.size(); i++) {
|
||||||
LinuxEventComponent component = (LinuxEventComponent)components.get(i);
|
LinuxEventComponent component = components.get(i);
|
||||||
if (id_type.isInstance(component.getIdentifier()) && relative == component.isRelative())
|
if (id_type.isInstance(component.getIdentifier()) && relative == component.isRelative())
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
@ -94,29 +94,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Controller.Type guessType() throws IOException {
|
private final Controller.Type guessType() throws IOException {
|
||||||
Controller.Type type_from_usages = guessTypeFromUsages();
|
List<LinuxEventComponent> components = getComponents();
|
||||||
if (type_from_usages == Controller.Type.UNKNOWN)
|
|
||||||
return guessTypeFromComponents();
|
|
||||||
else
|
|
||||||
return type_from_usages;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Controller.Type guessTypeFromUsages() throws IOException {
|
|
||||||
byte[] usage_bits = getDeviceUsageBits();
|
|
||||||
if (isBitSet(usage_bits, NativeDefinitions.USAGE_MOUSE))
|
|
||||||
return Controller.Type.MOUSE;
|
|
||||||
else if (isBitSet(usage_bits, NativeDefinitions.USAGE_KEYBOARD))
|
|
||||||
return Controller.Type.KEYBOARD;
|
|
||||||
else if (isBitSet(usage_bits, NativeDefinitions.USAGE_GAMEPAD))
|
|
||||||
return Controller.Type.GAMEPAD;
|
|
||||||
else if (isBitSet(usage_bits, NativeDefinitions.USAGE_JOYSTICK))
|
|
||||||
return Controller.Type.STICK;
|
|
||||||
else
|
|
||||||
return Controller.Type.UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Controller.Type guessTypeFromComponents() throws IOException {
|
|
||||||
List components = getComponents();
|
|
||||||
if (components.size() == 0)
|
if (components.size() == 0)
|
||||||
return Controller.Type.UNKNOWN;
|
return Controller.Type.UNKNOWN;
|
||||||
int num_rel_axes = countComponents(components, Component.Identifier.Axis.class, true);
|
int num_rel_axes = countComponents(components, Component.Identifier.Axis.class, true);
|
||||||
|
|
@ -140,7 +118,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
int num_gamepad_button_traits = 0;
|
int num_gamepad_button_traits = 0;
|
||||||
// count button traits
|
// count button traits
|
||||||
for (int i = 0; i < components.size(); i++) {
|
for (int i = 0; i < components.size(); i++) {
|
||||||
LinuxEventComponent component = (LinuxEventComponent)components.get(i);
|
LinuxEventComponent component = components.get(i);
|
||||||
if (component.getButtonTrait() == Controller.Type.MOUSE)
|
if (component.getButtonTrait() == Controller.Type.MOUSE)
|
||||||
num_mouse_button_traits++;
|
num_mouse_button_traits++;
|
||||||
else if (component.getButtonTrait() == Controller.Type.KEYBOARD)
|
else if (component.getButtonTrait() == Controller.Type.KEYBOARD)
|
||||||
|
|
@ -180,19 +158,19 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Rumbler[] enumerateRumblers() {
|
private final Rumbler[] enumerateRumblers() {
|
||||||
List rumblers = new ArrayList();
|
List<Rumbler> rumblers = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
int num_effects = getNumEffects();
|
int num_effects = getNumEffects();
|
||||||
if (num_effects <= 0)
|
if (num_effects <= 0)
|
||||||
return (Rumbler[])rumblers.toArray(new Rumbler[]{});
|
return rumblers.toArray(new Rumbler[]{});
|
||||||
byte[] ff_bits = getForceFeedbackBits();
|
byte[] ff_bits = getForceFeedbackBits();
|
||||||
if (isBitSet(ff_bits, NativeDefinitions.FF_RUMBLE) && num_effects > rumblers.size()) {
|
if (isBitSet(ff_bits, NativeDefinitions.FF_RUMBLE) && num_effects > rumblers.size()) {
|
||||||
rumblers.add(new LinuxRumbleFF(this));
|
rumblers.add(new LinuxRumbleFF(this));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LinuxEnvironmentPlugin.logln("Failed to enumerate rumblers: " + e.getMessage());
|
LinuxEnvironmentPlugin.log("Failed to enumerate rumblers: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return (Rumbler[])rumblers.toArray(new Rumbler[]{});
|
return rumblers.toArray(new Rumbler[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Rumbler[] getRumblers() {
|
public final Rumbler[] getRumblers() {
|
||||||
|
|
@ -227,7 +205,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final LinuxComponent mapDescriptor(LinuxAxisDescriptor desc) {
|
public final LinuxComponent mapDescriptor(LinuxAxisDescriptor desc) {
|
||||||
return (LinuxComponent)component_map.get(desc);
|
return component_map.get(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Controller.PortType getPortType() throws IOException {
|
public final Controller.PortType getPortType() throws IOException {
|
||||||
|
|
@ -265,7 +243,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
private final static native void nGetAbsInfo(long fd, int abs_axis, LinuxAbsInfo abs_info) throws IOException;
|
private final static native void nGetAbsInfo(long fd, int abs_axis, LinuxAbsInfo abs_info) throws IOException;
|
||||||
|
|
||||||
private final void addKeys(List components) throws IOException {
|
private final void addKeys(List<LinuxEventComponent> components) throws IOException {
|
||||||
byte[] bits = getKeysBits();
|
byte[] bits = getKeysBits();
|
||||||
for (int i = 0; i < bits.length*8; i++) {
|
for (int i = 0; i < bits.length*8; i++) {
|
||||||
if (isBitSet(bits, i)) {
|
if (isBitSet(bits, i)) {
|
||||||
|
|
@ -275,7 +253,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void addAbsoluteAxes(List components) throws IOException {
|
private final void addAbsoluteAxes(List<LinuxEventComponent> components) throws IOException {
|
||||||
byte[] bits = getAbsoluteAxesBits();
|
byte[] bits = getAbsoluteAxesBits();
|
||||||
for (int i = 0; i < bits.length*8; i++) {
|
for (int i = 0; i < bits.length*8; i++) {
|
||||||
if (isBitSet(bits, i)) {
|
if (isBitSet(bits, i)) {
|
||||||
|
|
@ -285,7 +263,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void addRelativeAxes(List components) throws IOException {
|
private final void addRelativeAxes(List<LinuxEventComponent> components) throws IOException {
|
||||||
byte[] bits = getRelativeAxesBits();
|
byte[] bits = getRelativeAxesBits();
|
||||||
for (int i = 0; i < bits.length*8; i++) {
|
for (int i = 0; i < bits.length*8; i++) {
|
||||||
if (isBitSet(bits, i)) {
|
if (isBitSet(bits, i)) {
|
||||||
|
|
@ -295,12 +273,12 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List getComponents() {
|
public final List<LinuxEventComponent> getComponents() {
|
||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List getDeviceComponents() throws IOException {
|
private final List<LinuxEventComponent> getDeviceComponents() throws IOException {
|
||||||
List components = new ArrayList();
|
List<LinuxEventComponent> components = new ArrayList<>();
|
||||||
byte[] evtype_bits = getEventTypeBits();
|
byte[] evtype_bits = getEventTypeBits();
|
||||||
if (isBitSet(evtype_bits, NativeDefinitions.EV_KEY))
|
if (isBitSet(evtype_bits, NativeDefinitions.EV_KEY))
|
||||||
addKeys(components);
|
addKeys(components);
|
||||||
|
|
@ -342,15 +320,6 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
}
|
}
|
||||||
private final static native void nGetBits(long fd, int ev_type, byte[] evtype_bits) throws IOException;
|
private final static native void nGetBits(long fd, int ev_type, byte[] evtype_bits) throws IOException;
|
||||||
|
|
||||||
private final byte[] getDeviceUsageBits() throws IOException {
|
|
||||||
byte[] bits = new byte[NativeDefinitions.USAGE_MAX/8 + 1];
|
|
||||||
if (getVersion() >= 0x010001) {
|
|
||||||
nGetDeviceUsageBits(fd, bits);
|
|
||||||
}
|
|
||||||
return bits;
|
|
||||||
}
|
|
||||||
private final static native void nGetDeviceUsageBits(long fd, byte[] type_bits) throws IOException;
|
|
||||||
|
|
||||||
public final synchronized void pollKeyStates() throws IOException {
|
public final synchronized void pollKeyStates() throws IOException {
|
||||||
nGetKeyStates(fd, key_states);
|
nGetKeyStates(fd, key_states);
|
||||||
}
|
}
|
||||||
|
|
@ -391,6 +360,7 @@ final class LinuxEventDevice implements LinuxDevice {
|
||||||
throw new IOException("Device is closed");
|
throw new IOException("Device is closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
protected void finalize() throws IOException {
|
protected void finalize() throws IOException {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ abstract class LinuxForceFeedbackEffect implements Rumbler {
|
||||||
write_task.write(0);
|
write_task.write(0);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LinuxEnvironmentPlugin.logln("Failed to rumble: " + e);
|
LinuxEnvironmentPlugin.log("Failed to rumble: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ final class LinuxJoystickAbstractController extends AbstractController {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final boolean getNextDeviceEvent(Event event) throws IOException {
|
protected final boolean getNextDeviceEvent(Event event) throws IOException {
|
||||||
return false;
|
return device.getNextEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -28,8 +28,6 @@ package net.java.games.input;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author elias
|
* @author elias
|
||||||
|
|
@ -48,8 +46,8 @@ final class LinuxJoystickDevice implements LinuxDevice {
|
||||||
private final Event event = new Event();
|
private final Event event = new Event();
|
||||||
private final LinuxJoystickButton[] buttons;
|
private final LinuxJoystickButton[] buttons;
|
||||||
private final LinuxJoystickAxis[] axes;
|
private final LinuxJoystickAxis[] axes;
|
||||||
private final Map povXs = new HashMap();
|
private final Map<Integer, LinuxJoystickPOV> povXs = new HashMap<>();
|
||||||
private final Map povYs = new HashMap();
|
private final Map<Integer, LinuxJoystickPOV> povYs = new HashMap<>();
|
||||||
private final byte[] axisMap;
|
private final byte[] axisMap;
|
||||||
private final char[] buttonMap;
|
private final char[] buttonMap;
|
||||||
|
|
||||||
|
|
@ -102,12 +100,12 @@ final class LinuxJoystickDevice implements LinuxDevice {
|
||||||
if (axis != null) {
|
if (axis != null) {
|
||||||
float value = (float)joystick_event.getValue()/AXIS_MAX_VALUE;
|
float value = (float)joystick_event.getValue()/AXIS_MAX_VALUE;
|
||||||
axis.setValue(value);
|
axis.setValue(value);
|
||||||
if(povXs.containsKey(new Integer(index))) {
|
if(povXs.containsKey(index)) {
|
||||||
LinuxJoystickPOV pov = (LinuxJoystickPOV)(povXs.get(new Integer(index)));
|
LinuxJoystickPOV pov = povXs.get(index);
|
||||||
pov.updateValue();
|
pov.updateValue();
|
||||||
event.set(pov, pov.getPollData(), joystick_event.getNanos());
|
event.set(pov, pov.getPollData(), joystick_event.getNanos());
|
||||||
} else if(povYs.containsKey(new Integer(index))) {
|
} else if(povYs.containsKey(index)) {
|
||||||
LinuxJoystickPOV pov = (LinuxJoystickPOV)(povYs.get(new Integer(index)));
|
LinuxJoystickPOV pov = povYs.get(index);
|
||||||
pov.updateValue();
|
pov.updateValue();
|
||||||
event.set(pov, pov.getPollData(), joystick_event.getNanos());
|
event.set(pov, pov.getPollData(), joystick_event.getNanos());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -150,8 +148,8 @@ final class LinuxJoystickDevice implements LinuxDevice {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
povXs.put(new Integer(xIndex),pov);
|
povXs.put(xIndex,pov);
|
||||||
povYs.put(new Integer(yIndex),pov);
|
povYs.put(yIndex,pov);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final synchronized boolean getNextEvent(Event event) throws IOException {
|
public final synchronized boolean getNextEvent(Event event) throws IOException {
|
||||||
|
|
@ -233,6 +231,7 @@ final class LinuxJoystickDevice implements LinuxDevice {
|
||||||
throw new IOException("Device is closed");
|
throw new IOException("Device is closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
protected void finalize() throws IOException {
|
protected void finalize() throws IOException {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ public class LinuxJoystickPOV extends LinuxJoystickAxis {
|
||||||
else if (last_x == 1 && last_y == 1)
|
else if (last_x == 1 && last_y == 1)
|
||||||
setValue(Component.POV.DOWN_RIGHT);
|
setValue(Component.POV.DOWN_RIGHT);
|
||||||
else {
|
else {
|
||||||
LinuxEnvironmentPlugin.logln("Unknown values x = " + last_x + " | y = " + last_y);
|
LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
|
||||||
setValue(Component.POV.OFF);
|
setValue(Component.POV.OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
*/
|
*/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping utility class between native type ints and string names or
|
* Mapping utility class between native type ints and string names or
|
||||||
* Key.Identifiers
|
* Key.Identifiers
|
||||||
|
|
@ -32,6 +34,7 @@ package net.java.games.input;
|
||||||
*/
|
*/
|
||||||
class LinuxNativeTypesMap {
|
class LinuxNativeTypesMap {
|
||||||
private static LinuxNativeTypesMap INSTANCE = new LinuxNativeTypesMap();
|
private static LinuxNativeTypesMap INSTANCE = new LinuxNativeTypesMap();
|
||||||
|
private static Logger log = Logger.getLogger(LinuxNativeTypesMap.class.getName());
|
||||||
|
|
||||||
private final Component.Identifier relAxesIDs[];
|
private final Component.Identifier relAxesIDs[];
|
||||||
private final Component.Identifier absAxesIDs[];
|
private final Component.Identifier absAxesIDs[];
|
||||||
|
|
@ -305,10 +308,52 @@ class LinuxNativeTypesMap {
|
||||||
buttonIDs[NativeDefinitions.BTN_TL2] = Component.Identifier.Button.LEFT_THUMB2;
|
buttonIDs[NativeDefinitions.BTN_TL2] = Component.Identifier.Button.LEFT_THUMB2;
|
||||||
buttonIDs[NativeDefinitions.BTN_TR2] = Component.Identifier.Button.RIGHT_THUMB2;
|
buttonIDs[NativeDefinitions.BTN_TR2] = Component.Identifier.Button.RIGHT_THUMB2;
|
||||||
buttonIDs[NativeDefinitions.BTN_SELECT] = Component.Identifier.Button.SELECT;
|
buttonIDs[NativeDefinitions.BTN_SELECT] = Component.Identifier.Button.SELECT;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_START] = Component.Identifier.Button.START;
|
||||||
buttonIDs[NativeDefinitions.BTN_MODE] = Component.Identifier.Button.MODE;
|
buttonIDs[NativeDefinitions.BTN_MODE] = Component.Identifier.Button.MODE;
|
||||||
buttonIDs[NativeDefinitions.BTN_THUMBL] = Component.Identifier.Button.LEFT_THUMB3;
|
buttonIDs[NativeDefinitions.BTN_THUMBL] = Component.Identifier.Button.LEFT_THUMB3;
|
||||||
buttonIDs[NativeDefinitions.BTN_THUMBR] = Component.Identifier.Button.RIGHT_THUMB3;
|
buttonIDs[NativeDefinitions.BTN_THUMBR] = Component.Identifier.Button.RIGHT_THUMB3;
|
||||||
|
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY1] = Component.Identifier.Button.EXTRA_1;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY2] = Component.Identifier.Button.EXTRA_2;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY3] = Component.Identifier.Button.EXTRA_3;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY4] = Component.Identifier.Button.EXTRA_4;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY5] = Component.Identifier.Button.EXTRA_5;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY6] = Component.Identifier.Button.EXTRA_6;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY7] = Component.Identifier.Button.EXTRA_7;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY8] = Component.Identifier.Button.EXTRA_8;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY9] = Component.Identifier.Button.EXTRA_9;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY10] = Component.Identifier.Button.EXTRA_10;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY11] = Component.Identifier.Button.EXTRA_11;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY12] = Component.Identifier.Button.EXTRA_12;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY13] = Component.Identifier.Button.EXTRA_13;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY14] = Component.Identifier.Button.EXTRA_14;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY15] = Component.Identifier.Button.EXTRA_15;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY16] = Component.Identifier.Button.EXTRA_16;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY17] = Component.Identifier.Button.EXTRA_17;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY18] = Component.Identifier.Button.EXTRA_18;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY19] = Component.Identifier.Button.EXTRA_19;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY20] = Component.Identifier.Button.EXTRA_20;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY21] = Component.Identifier.Button.EXTRA_21;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY22] = Component.Identifier.Button.EXTRA_22;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY23] = Component.Identifier.Button.EXTRA_23;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY24] = Component.Identifier.Button.EXTRA_24;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY25] = Component.Identifier.Button.EXTRA_25;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY26] = Component.Identifier.Button.EXTRA_26;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY27] = Component.Identifier.Button.EXTRA_27;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY28] = Component.Identifier.Button.EXTRA_28;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY29] = Component.Identifier.Button.EXTRA_29;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY30] = Component.Identifier.Button.EXTRA_30;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY31] = Component.Identifier.Button.EXTRA_31;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY32] = Component.Identifier.Button.EXTRA_32;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY33] = Component.Identifier.Button.EXTRA_33;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY34] = Component.Identifier.Button.EXTRA_34;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY35] = Component.Identifier.Button.EXTRA_35;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY36] = Component.Identifier.Button.EXTRA_36;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY37] = Component.Identifier.Button.EXTRA_37;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY38] = Component.Identifier.Button.EXTRA_38;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY39] = Component.Identifier.Button.EXTRA_39;
|
||||||
|
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY40] = Component.Identifier.Button.EXTRA_40;
|
||||||
|
|
||||||
// Digitiser
|
// Digitiser
|
||||||
buttonIDs[NativeDefinitions.BTN_TOOL_PEN] = Component.Identifier.Button.TOOL_PEN;
|
buttonIDs[NativeDefinitions.BTN_TOOL_PEN] = Component.Identifier.Button.TOOL_PEN;
|
||||||
buttonIDs[NativeDefinitions.BTN_TOOL_RUBBER] = Component.Identifier.Button.TOOL_RUBBER;
|
buttonIDs[NativeDefinitions.BTN_TOOL_RUBBER] = Component.Identifier.Button.TOOL_RUBBER;
|
||||||
|
|
@ -385,8 +430,9 @@ class LinuxNativeTypesMap {
|
||||||
case NativeDefinitions.BTN_TR :
|
case NativeDefinitions.BTN_TR :
|
||||||
case NativeDefinitions.BTN_TL2 :
|
case NativeDefinitions.BTN_TL2 :
|
||||||
case NativeDefinitions.BTN_TR2 :
|
case NativeDefinitions.BTN_TR2 :
|
||||||
case NativeDefinitions.BTN_SELECT :
|
case NativeDefinitions.BTN_SELECT :
|
||||||
case NativeDefinitions.BTN_MODE :
|
case NativeDefinitions.BTN_START :
|
||||||
|
case NativeDefinitions.BTN_MODE :
|
||||||
case NativeDefinitions.BTN_THUMBL :
|
case NativeDefinitions.BTN_THUMBL :
|
||||||
case NativeDefinitions.BTN_THUMBR :
|
case NativeDefinitions.BTN_THUMBR :
|
||||||
return Controller.Type.GAMEPAD;
|
return Controller.Type.GAMEPAD;
|
||||||
|
|
@ -755,7 +801,7 @@ class LinuxNativeTypesMap {
|
||||||
try {
|
try {
|
||||||
retval = INSTANCE.relAxesIDs[nativeID];
|
retval = INSTANCE.relAxesIDs[nativeID];
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
System.out.println("INSTANCE.relAxesIDis only " + INSTANCE.relAxesIDs.length + " long, so " + nativeID + " not contained");
|
log.warning("INSTANCE.relAxesIDis only " + INSTANCE.relAxesIDs.length + " long, so " + nativeID + " not contained");
|
||||||
//ignore, pretend it was null
|
//ignore, pretend it was null
|
||||||
}
|
}
|
||||||
if(retval == null) {
|
if(retval == null) {
|
||||||
|
|
@ -773,7 +819,7 @@ class LinuxNativeTypesMap {
|
||||||
try {
|
try {
|
||||||
retval = INSTANCE.absAxesIDs[nativeID];
|
retval = INSTANCE.absAxesIDs[nativeID];
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
System.out.println("INSTANCE.absAxesIDs is only " + INSTANCE.absAxesIDs.length + " long, so " + nativeID + " not contained");
|
log.warning("INSTANCE.absAxesIDs is only " + INSTANCE.absAxesIDs.length + " long, so " + nativeID + " not contained");
|
||||||
//ignore, pretend it was null
|
//ignore, pretend it was null
|
||||||
}
|
}
|
||||||
if(retval == null) {
|
if(retval == null) {
|
||||||
|
|
@ -791,11 +837,11 @@ class LinuxNativeTypesMap {
|
||||||
try {
|
try {
|
||||||
retval = INSTANCE.buttonIDs[nativeID];
|
retval = INSTANCE.buttonIDs[nativeID];
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
System.out.println("INSTANCE.buttonIDs is only " + INSTANCE.buttonIDs.length + " long, so " + nativeID + " not contained");
|
log.warning("INSTANCE.buttonIDs is only " + INSTANCE.buttonIDs.length + " long, so " + nativeID + " not contained");
|
||||||
//ignore, pretend it was null
|
//ignore, pretend it was null
|
||||||
}
|
}
|
||||||
if(retval == null) {
|
if(retval == null) {
|
||||||
retval = Component.Identifier.Key.UNKNOWN;
|
retval = Component.Identifier.Button.UNKNOWN;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ final class LinuxPOV extends LinuxComponent {
|
||||||
else if (last_x == 1 && last_y == 1)
|
else if (last_x == 1 && last_y == 1)
|
||||||
return Component.POV.DOWN_RIGHT;
|
return Component.POV.DOWN_RIGHT;
|
||||||
else {
|
else {
|
||||||
LinuxEnvironmentPlugin.logln("Unknown values x = " + last_x + " | y = " + last_y);
|
LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
|
||||||
return Component.POV.OFF;
|
return Component.POV.OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -43,9 +43,9 @@ final class LinuxRumbleFF extends LinuxForceFeedbackEffect {
|
||||||
weak_magnitude = (int)(0xc000*intensity);
|
weak_magnitude = (int)(0xc000*intensity);
|
||||||
} else if (intensity > 0.3333333f) {
|
} else if (intensity > 0.3333333f) {
|
||||||
strong_magnitude = (int)(0x8000*intensity);
|
strong_magnitude = (int)(0x8000*intensity);
|
||||||
weak_magnitude = (int)(0xc000*0);
|
weak_magnitude = 0;
|
||||||
} else {
|
} else {
|
||||||
strong_magnitude = (int)(0x8000*0);
|
strong_magnitude = 0;
|
||||||
weak_magnitude = (int)(0xc000*intensity);
|
weak_magnitude = (int)(0xc000*intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@ package net.java.games.input;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is generated from /usr/include/linux/input.h please do not edit
|
* This file is generated from /usr/src/linux-headers-3.2.0-38-generic/include/linux/input.h please do not edit
|
||||||
*/
|
*/
|
||||||
class NativeDefinitions {
|
class NativeDefinitions {
|
||||||
public static final int EV_VERSION = 0x010001;
|
public static final int EV_VERSION = 0x010001;
|
||||||
|
|
@ -11,6 +11,7 @@ class NativeDefinitions {
|
||||||
public static final int EV_REL = 0x02;
|
public static final int EV_REL = 0x02;
|
||||||
public static final int EV_ABS = 0x03;
|
public static final int EV_ABS = 0x03;
|
||||||
public static final int EV_MSC = 0x04;
|
public static final int EV_MSC = 0x04;
|
||||||
|
public static final int EV_SW = 0x05;
|
||||||
public static final int EV_LED = 0x11;
|
public static final int EV_LED = 0x11;
|
||||||
public static final int EV_SND = 0x12;
|
public static final int EV_SND = 0x12;
|
||||||
public static final int EV_REP = 0x14;
|
public static final int EV_REP = 0x14;
|
||||||
|
|
@ -18,6 +19,7 @@ class NativeDefinitions {
|
||||||
public static final int EV_PWR = 0x16;
|
public static final int EV_PWR = 0x16;
|
||||||
public static final int EV_FF_STATUS = 0x17;
|
public static final int EV_FF_STATUS = 0x17;
|
||||||
public static final int EV_MAX = 0x1f;
|
public static final int EV_MAX = 0x1f;
|
||||||
|
public static final int EV_CNT = (EV_MAX+1);
|
||||||
public static final int KEY_RESERVED = 0;
|
public static final int KEY_RESERVED = 0;
|
||||||
public static final int KEY_ESC = 1;
|
public static final int KEY_ESC = 1;
|
||||||
public static final int KEY_1 = 2;
|
public static final int KEY_1 = 2;
|
||||||
|
|
@ -137,8 +139,10 @@ class NativeDefinitions {
|
||||||
public static final int KEY_KPEQUAL = 117;
|
public static final int KEY_KPEQUAL = 117;
|
||||||
public static final int KEY_KPPLUSMINUS = 118;
|
public static final int KEY_KPPLUSMINUS = 118;
|
||||||
public static final int KEY_PAUSE = 119;
|
public static final int KEY_PAUSE = 119;
|
||||||
|
public static final int KEY_SCALE = 120;
|
||||||
public static final int KEY_KPCOMMA = 121;
|
public static final int KEY_KPCOMMA = 121;
|
||||||
public static final int KEY_HANGUEL = 122;
|
public static final int KEY_HANGEUL = 122;
|
||||||
|
public static final int KEY_HANGUEL = KEY_HANGEUL;
|
||||||
public static final int KEY_HANJA = 123;
|
public static final int KEY_HANJA = 123;
|
||||||
public static final int KEY_YEN = 124;
|
public static final int KEY_YEN = 124;
|
||||||
public static final int KEY_LEFTMETA = 125;
|
public static final int KEY_LEFTMETA = 125;
|
||||||
|
|
@ -169,6 +173,7 @@ class NativeDefinitions {
|
||||||
public static final int KEY_WWW = 150;
|
public static final int KEY_WWW = 150;
|
||||||
public static final int KEY_MSDOS = 151;
|
public static final int KEY_MSDOS = 151;
|
||||||
public static final int KEY_COFFEE = 152;
|
public static final int KEY_COFFEE = 152;
|
||||||
|
public static final int KEY_SCREENLOCK = KEY_COFFEE;
|
||||||
public static final int KEY_DIRECTION = 153;
|
public static final int KEY_DIRECTION = 153;
|
||||||
public static final int KEY_CYCLEWINDOWS = 154;
|
public static final int KEY_CYCLEWINDOWS = 154;
|
||||||
public static final int KEY_MAIL = 155;
|
public static final int KEY_MAIL = 155;
|
||||||
|
|
@ -197,6 +202,8 @@ class NativeDefinitions {
|
||||||
public static final int KEY_SCROLLDOWN = 178;
|
public static final int KEY_SCROLLDOWN = 178;
|
||||||
public static final int KEY_KPLEFTPAREN = 179;
|
public static final int KEY_KPLEFTPAREN = 179;
|
||||||
public static final int KEY_KPRIGHTPAREN = 180;
|
public static final int KEY_KPRIGHTPAREN = 180;
|
||||||
|
public static final int KEY_NEW = 181;
|
||||||
|
public static final int KEY_REDO = 182;
|
||||||
public static final int KEY_F13 = 183;
|
public static final int KEY_F13 = 183;
|
||||||
public static final int KEY_F14 = 184;
|
public static final int KEY_F14 = 184;
|
||||||
public static final int KEY_F15 = 185;
|
public static final int KEY_F15 = 185;
|
||||||
|
|
@ -213,6 +220,7 @@ class NativeDefinitions {
|
||||||
public static final int KEY_PAUSECD = 201;
|
public static final int KEY_PAUSECD = 201;
|
||||||
public static final int KEY_PROG3 = 202;
|
public static final int KEY_PROG3 = 202;
|
||||||
public static final int KEY_PROG4 = 203;
|
public static final int KEY_PROG4 = 203;
|
||||||
|
public static final int KEY_DASHBOARD = 204;
|
||||||
public static final int KEY_SUSPEND = 205;
|
public static final int KEY_SUSPEND = 205;
|
||||||
public static final int KEY_CLOSE = 206;
|
public static final int KEY_CLOSE = 206;
|
||||||
public static final int KEY_PLAY = 207;
|
public static final int KEY_PLAY = 207;
|
||||||
|
|
@ -239,7 +247,24 @@ class NativeDefinitions {
|
||||||
public static final int KEY_KBDILLUMTOGGLE = 228;
|
public static final int KEY_KBDILLUMTOGGLE = 228;
|
||||||
public static final int KEY_KBDILLUMDOWN = 229;
|
public static final int KEY_KBDILLUMDOWN = 229;
|
||||||
public static final int KEY_KBDILLUMUP = 230;
|
public static final int KEY_KBDILLUMUP = 230;
|
||||||
|
public static final int KEY_SEND = 231;
|
||||||
|
public static final int KEY_REPLY = 232;
|
||||||
|
public static final int KEY_FORWARDMAIL = 233;
|
||||||
|
public static final int KEY_SAVE = 234;
|
||||||
|
public static final int KEY_DOCUMENTS = 235;
|
||||||
|
public static final int KEY_BATTERY = 236;
|
||||||
|
public static final int KEY_BLUETOOTH = 237;
|
||||||
|
public static final int KEY_WLAN = 238;
|
||||||
|
public static final int KEY_UWB = 239;
|
||||||
public static final int KEY_UNKNOWN = 240;
|
public static final int KEY_UNKNOWN = 240;
|
||||||
|
public static final int KEY_VIDEO_NEXT = 241;
|
||||||
|
public static final int KEY_VIDEO_PREV = 242;
|
||||||
|
public static final int KEY_BRIGHTNESS_CYCLE = 243;
|
||||||
|
public static final int KEY_BRIGHTNESS_ZERO = 244;
|
||||||
|
public static final int KEY_DISPLAY_OFF = 245;
|
||||||
|
public static final int KEY_WIMAX = 246;
|
||||||
|
public static final int KEY_RFKILL = 247;
|
||||||
|
public static final int KEY_MICMUTE = 248;
|
||||||
public static final int BTN_MISC = 0x100;
|
public static final int BTN_MISC = 0x100;
|
||||||
public static final int BTN_0 = 0x100;
|
public static final int BTN_0 = 0x100;
|
||||||
public static final int BTN_1 = 0x101;
|
public static final int BTN_1 = 0x101;
|
||||||
|
|
@ -299,11 +324,13 @@ class NativeDefinitions {
|
||||||
public static final int BTN_TOOL_FINGER = 0x145;
|
public static final int BTN_TOOL_FINGER = 0x145;
|
||||||
public static final int BTN_TOOL_MOUSE = 0x146;
|
public static final int BTN_TOOL_MOUSE = 0x146;
|
||||||
public static final int BTN_TOOL_LENS = 0x147;
|
public static final int BTN_TOOL_LENS = 0x147;
|
||||||
|
public static final int BTN_TOOL_QUINTTAP = 0x148;
|
||||||
public static final int BTN_TOUCH = 0x14a;
|
public static final int BTN_TOUCH = 0x14a;
|
||||||
public static final int BTN_STYLUS = 0x14b;
|
public static final int BTN_STYLUS = 0x14b;
|
||||||
public static final int BTN_STYLUS2 = 0x14c;
|
public static final int BTN_STYLUS2 = 0x14c;
|
||||||
public static final int BTN_TOOL_DOUBLETAP = 0x14d;
|
public static final int BTN_TOOL_DOUBLETAP = 0x14d;
|
||||||
public static final int BTN_TOOL_TRIPLETAP = 0x14e;
|
public static final int BTN_TOOL_TRIPLETAP = 0x14e;
|
||||||
|
public static final int BTN_TOOL_QUADTAP = 0x14f;
|
||||||
public static final int BTN_WHEEL = 0x150;
|
public static final int BTN_WHEEL = 0x150;
|
||||||
public static final int BTN_GEAR_DOWN = 0x150;
|
public static final int BTN_GEAR_DOWN = 0x150;
|
||||||
public static final int BTN_GEAR_UP = 0x151;
|
public static final int BTN_GEAR_UP = 0x151;
|
||||||
|
|
@ -371,6 +398,33 @@ class NativeDefinitions {
|
||||||
public static final int KEY_DIGITS = 0x19d;
|
public static final int KEY_DIGITS = 0x19d;
|
||||||
public static final int KEY_TEEN = 0x19e;
|
public static final int KEY_TEEN = 0x19e;
|
||||||
public static final int KEY_TWEN = 0x19f;
|
public static final int KEY_TWEN = 0x19f;
|
||||||
|
public static final int KEY_VIDEOPHONE = 0x1a0;
|
||||||
|
public static final int KEY_GAMES = 0x1a1;
|
||||||
|
public static final int KEY_ZOOMIN = 0x1a2;
|
||||||
|
public static final int KEY_ZOOMOUT = 0x1a3;
|
||||||
|
public static final int KEY_ZOOMRESET = 0x1a4;
|
||||||
|
public static final int KEY_WORDPROCESSOR = 0x1a5;
|
||||||
|
public static final int KEY_EDITOR = 0x1a6;
|
||||||
|
public static final int KEY_SPREADSHEET = 0x1a7;
|
||||||
|
public static final int KEY_GRAPHICSEDITOR = 0x1a8;
|
||||||
|
public static final int KEY_PRESENTATION = 0x1a9;
|
||||||
|
public static final int KEY_DATABASE = 0x1aa;
|
||||||
|
public static final int KEY_NEWS = 0x1ab;
|
||||||
|
public static final int KEY_VOICEMAIL = 0x1ac;
|
||||||
|
public static final int KEY_ADDRESSBOOK = 0x1ad;
|
||||||
|
public static final int KEY_MESSENGER = 0x1ae;
|
||||||
|
public static final int KEY_DISPLAYTOGGLE = 0x1af;
|
||||||
|
public static final int KEY_SPELLCHECK = 0x1b0;
|
||||||
|
public static final int KEY_LOGOFF = 0x1b1;
|
||||||
|
public static final int KEY_DOLLAR = 0x1b2;
|
||||||
|
public static final int KEY_EURO = 0x1b3;
|
||||||
|
public static final int KEY_FRAMEBACK = 0x1b4;
|
||||||
|
public static final int KEY_FRAMEFORWARD = 0x1b5;
|
||||||
|
public static final int KEY_CONTEXT_MENU = 0x1b6;
|
||||||
|
public static final int KEY_MEDIA_REPEAT = 0x1b7;
|
||||||
|
public static final int KEY_10CHANNELSUP = 0x1b8;
|
||||||
|
public static final int KEY_10CHANNELSDOWN = 0x1b9;
|
||||||
|
public static final int KEY_IMAGES = 0x1ba;
|
||||||
public static final int KEY_DEL_EOL = 0x1c0;
|
public static final int KEY_DEL_EOL = 0x1c0;
|
||||||
public static final int KEY_DEL_EOS = 0x1c1;
|
public static final int KEY_DEL_EOS = 0x1c1;
|
||||||
public static final int KEY_INS_LINE = 0x1c2;
|
public static final int KEY_INS_LINE = 0x1c2;
|
||||||
|
|
@ -396,7 +450,83 @@ class NativeDefinitions {
|
||||||
public static final int KEY_FN_F = 0x1e2;
|
public static final int KEY_FN_F = 0x1e2;
|
||||||
public static final int KEY_FN_S = 0x1e3;
|
public static final int KEY_FN_S = 0x1e3;
|
||||||
public static final int KEY_FN_B = 0x1e4;
|
public static final int KEY_FN_B = 0x1e4;
|
||||||
public static final int KEY_MAX = 0x1ff;
|
public static final int KEY_BRL_DOT1 = 0x1f1;
|
||||||
|
public static final int KEY_BRL_DOT2 = 0x1f2;
|
||||||
|
public static final int KEY_BRL_DOT3 = 0x1f3;
|
||||||
|
public static final int KEY_BRL_DOT4 = 0x1f4;
|
||||||
|
public static final int KEY_BRL_DOT5 = 0x1f5;
|
||||||
|
public static final int KEY_BRL_DOT6 = 0x1f6;
|
||||||
|
public static final int KEY_BRL_DOT7 = 0x1f7;
|
||||||
|
public static final int KEY_BRL_DOT8 = 0x1f8;
|
||||||
|
public static final int KEY_BRL_DOT9 = 0x1f9;
|
||||||
|
public static final int KEY_BRL_DOT10 = 0x1fa;
|
||||||
|
public static final int KEY_NUMERIC_0 = 0x200;
|
||||||
|
public static final int KEY_NUMERIC_1 = 0x201;
|
||||||
|
public static final int KEY_NUMERIC_2 = 0x202;
|
||||||
|
public static final int KEY_NUMERIC_3 = 0x203;
|
||||||
|
public static final int KEY_NUMERIC_4 = 0x204;
|
||||||
|
public static final int KEY_NUMERIC_5 = 0x205;
|
||||||
|
public static final int KEY_NUMERIC_6 = 0x206;
|
||||||
|
public static final int KEY_NUMERIC_7 = 0x207;
|
||||||
|
public static final int KEY_NUMERIC_8 = 0x208;
|
||||||
|
public static final int KEY_NUMERIC_9 = 0x209;
|
||||||
|
public static final int KEY_NUMERIC_STAR = 0x20a;
|
||||||
|
public static final int KEY_NUMERIC_POUND = 0x20b;
|
||||||
|
public static final int KEY_CAMERA_FOCUS = 0x210;
|
||||||
|
public static final int KEY_WPS_BUTTON = 0x211;
|
||||||
|
public static final int KEY_TOUCHPAD_TOGGLE = 0x212;
|
||||||
|
public static final int KEY_TOUCHPAD_ON = 0x213;
|
||||||
|
public static final int KEY_TOUCHPAD_OFF = 0x214;
|
||||||
|
public static final int KEY_CAMERA_ZOOMIN = 0x215;
|
||||||
|
public static final int KEY_CAMERA_ZOOMOUT = 0x216;
|
||||||
|
public static final int KEY_CAMERA_UP = 0x217;
|
||||||
|
public static final int KEY_CAMERA_DOWN = 0x218;
|
||||||
|
public static final int KEY_CAMERA_LEFT = 0x219;
|
||||||
|
public static final int KEY_CAMERA_RIGHT = 0x21a;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY = 0x2c0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY1 = 0x2c0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY2 = 0x2c1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY3 = 0x2c2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY4 = 0x2c3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY5 = 0x2c4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY6 = 0x2c5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY7 = 0x2c6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY8 = 0x2c7;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY9 = 0x2c8;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY10 = 0x2c9;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY11 = 0x2ca;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY12 = 0x2cb;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY13 = 0x2cc;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY14 = 0x2cd;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY15 = 0x2ce;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY16 = 0x2cf;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY17 = 0x2d0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY18 = 0x2d1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY19 = 0x2d2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY20 = 0x2d3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY21 = 0x2d4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY22 = 0x2d5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY23 = 0x2d6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY24 = 0x2d7;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY25 = 0x2d8;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY26 = 0x2d9;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY27 = 0x2da;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY28 = 0x2db;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY29 = 0x2dc;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY30 = 0x2dd;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY31 = 0x2de;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY32 = 0x2df;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY33 = 0x2e0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY34 = 0x2e1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY35 = 0x2e2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY36 = 0x2e3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY37 = 0x2e4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY38 = 0x2e5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY39 = 0x2e6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY40 = 0x2e7;
|
||||||
|
public static final int KEY_MIN_INTERESTING = KEY_MUTE;
|
||||||
|
public static final int KEY_MAX = 0x2ff;
|
||||||
|
public static final int KEY_CNT = (KEY_MAX+1);
|
||||||
public static final int REL_X = 0x00;
|
public static final int REL_X = 0x00;
|
||||||
public static final int REL_Y = 0x01;
|
public static final int REL_Y = 0x01;
|
||||||
public static final int REL_Z = 0x02;
|
public static final int REL_Z = 0x02;
|
||||||
|
|
@ -408,6 +538,7 @@ class NativeDefinitions {
|
||||||
public static final int REL_WHEEL = 0x08;
|
public static final int REL_WHEEL = 0x08;
|
||||||
public static final int REL_MISC = 0x09;
|
public static final int REL_MISC = 0x09;
|
||||||
public static final int REL_MAX = 0x0f;
|
public static final int REL_MAX = 0x0f;
|
||||||
|
public static final int REL_CNT = (REL_MAX+1);
|
||||||
public static final int ABS_X = 0x00;
|
public static final int ABS_X = 0x00;
|
||||||
public static final int ABS_Y = 0x01;
|
public static final int ABS_Y = 0x01;
|
||||||
public static final int ABS_Z = 0x02;
|
public static final int ABS_Z = 0x02;
|
||||||
|
|
@ -434,17 +565,29 @@ class NativeDefinitions {
|
||||||
public static final int ABS_TOOL_WIDTH = 0x1c;
|
public static final int ABS_TOOL_WIDTH = 0x1c;
|
||||||
public static final int ABS_VOLUME = 0x20;
|
public static final int ABS_VOLUME = 0x20;
|
||||||
public static final int ABS_MISC = 0x28;
|
public static final int ABS_MISC = 0x28;
|
||||||
|
public static final int ABS_MT_SLOT = 0x2f;
|
||||||
|
public static final int ABS_MT_TOUCH_MAJOR = 0x30;
|
||||||
|
public static final int ABS_MT_TOUCH_MINOR = 0x31;
|
||||||
|
public static final int ABS_MT_WIDTH_MAJOR = 0x32;
|
||||||
|
public static final int ABS_MT_WIDTH_MINOR = 0x33;
|
||||||
|
public static final int ABS_MT_ORIENTATION = 0x34;
|
||||||
|
public static final int ABS_MT_POSITION_X = 0x35;
|
||||||
|
public static final int ABS_MT_POSITION_Y = 0x36;
|
||||||
|
public static final int ABS_MT_TOOL_TYPE = 0x37;
|
||||||
|
public static final int ABS_MT_BLOB_ID = 0x38;
|
||||||
|
public static final int ABS_MT_TRACKING_ID = 0x39;
|
||||||
|
public static final int ABS_MT_PRESSURE = 0x3a;
|
||||||
|
public static final int ABS_MT_DISTANCE = 0x3b;
|
||||||
|
public static final int ABS_MT_FIRST = ABS_MT_TOUCH_MAJOR;
|
||||||
|
public static final int ABS_MT_LAST = ABS_MT_DISTANCE;
|
||||||
public static final int ABS_MAX = 0x3f;
|
public static final int ABS_MAX = 0x3f;
|
||||||
public static final int USAGE_MOUSE = 0x00;
|
public static final int ABS_CNT = (ABS_MAX+1);
|
||||||
public static final int USAGE_JOYSTICK = 0x01;
|
|
||||||
public static final int USAGE_GAMEPAD = 0x02;
|
|
||||||
public static final int USAGE_KEYBOARD = 0x03;
|
|
||||||
public static final int USAGE_MAX = 0x0f;
|
|
||||||
public static final int BUS_PCI = 0x01;
|
public static final int BUS_PCI = 0x01;
|
||||||
public static final int BUS_ISAPNP = 0x02;
|
public static final int BUS_ISAPNP = 0x02;
|
||||||
public static final int BUS_USB = 0x03;
|
public static final int BUS_USB = 0x03;
|
||||||
public static final int BUS_HIL = 0x04;
|
public static final int BUS_HIL = 0x04;
|
||||||
public static final int BUS_BLUETOOTH = 0x05;
|
public static final int BUS_BLUETOOTH = 0x05;
|
||||||
|
public static final int BUS_VIRTUAL = 0x06;
|
||||||
public static final int BUS_ISA = 0x10;
|
public static final int BUS_ISA = 0x10;
|
||||||
public static final int BUS_I8042 = 0x11;
|
public static final int BUS_I8042 = 0x11;
|
||||||
public static final int BUS_XTKBD = 0x12;
|
public static final int BUS_XTKBD = 0x12;
|
||||||
|
|
@ -455,6 +598,9 @@ class NativeDefinitions {
|
||||||
public static final int BUS_ADB = 0x17;
|
public static final int BUS_ADB = 0x17;
|
||||||
public static final int BUS_I2C = 0x18;
|
public static final int BUS_I2C = 0x18;
|
||||||
public static final int BUS_HOST = 0x19;
|
public static final int BUS_HOST = 0x19;
|
||||||
|
public static final int BUS_GSC = 0x1A;
|
||||||
|
public static final int BUS_ATARI = 0x1B;
|
||||||
|
public static final int BUS_SPI = 0x1C;
|
||||||
public static final int FF_STATUS_STOPPED = 0x00;
|
public static final int FF_STATUS_STOPPED = 0x00;
|
||||||
public static final int FF_STATUS_PLAYING = 0x01;
|
public static final int FF_STATUS_PLAYING = 0x01;
|
||||||
public static final int FF_STATUS_MAX = 0x01;
|
public static final int FF_STATUS_MAX = 0x01;
|
||||||
|
|
@ -466,13 +612,23 @@ class NativeDefinitions {
|
||||||
public static final int FF_DAMPER = 0x55;
|
public static final int FF_DAMPER = 0x55;
|
||||||
public static final int FF_INERTIA = 0x56;
|
public static final int FF_INERTIA = 0x56;
|
||||||
public static final int FF_RAMP = 0x57;
|
public static final int FF_RAMP = 0x57;
|
||||||
|
public static final int FF_EFFECT_MIN = FF_RUMBLE;
|
||||||
|
public static final int FF_EFFECT_MAX = FF_RAMP;
|
||||||
public static final int FF_SQUARE = 0x58;
|
public static final int FF_SQUARE = 0x58;
|
||||||
public static final int FF_TRIANGLE = 0x59;
|
public static final int FF_TRIANGLE = 0x59;
|
||||||
public static final int FF_SINE = 0x5a;
|
public static final int FF_SINE = 0x5a;
|
||||||
public static final int FF_SAW_UP = 0x5b;
|
public static final int FF_SAW_UP = 0x5b;
|
||||||
public static final int FF_SAW_DOWN = 0x5c;
|
public static final int FF_SAW_DOWN = 0x5c;
|
||||||
public static final int FF_CUSTOM = 0x5d;
|
public static final int FF_CUSTOM = 0x5d;
|
||||||
|
public static final int FF_WAVEFORM_MIN = FF_SQUARE;
|
||||||
|
public static final int FF_WAVEFORM_MAX = FF_CUSTOM;
|
||||||
public static final int FF_GAIN = 0x60;
|
public static final int FF_GAIN = 0x60;
|
||||||
public static final int FF_AUTOCENTER = 0x61;
|
public static final int FF_AUTOCENTER = 0x61;
|
||||||
public static final int FF_MAX = 0x7f;
|
public static final int FF_MAX = 0x7f;
|
||||||
|
public static final int FF_CNT = (FF_MAX+1);
|
||||||
|
public static final int USAGE_MOUSE = 0x00;
|
||||||
|
public static final int USAGE_JOYSTICK = 0x01;
|
||||||
|
public static final int USAGE_GAMEPAD = 0x02;
|
||||||
|
public static final int USAGE_KEYBOARD = 0x03;
|
||||||
|
public static final int USAGE_MAX = 0x0f;
|
||||||
}
|
}
|
||||||
|
|
@ -112,20 +112,6 @@ JNIEXPORT jint JNICALL Java_net_java_games_input_LinuxEventDevice_nGetNumEffects
|
||||||
return num_effects;
|
return num_effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_net_java_games_input_LinuxEventDevice_nGetDeviceUsageBits(JNIEnv *env, jclass unused, jlong fd_address, jbyteArray usages_array) {
|
|
||||||
#if EV_VERSION >= 0x010001
|
|
||||||
int fd = (int)fd_address;
|
|
||||||
jsize len = (*env)->GetArrayLength(env, usages_array);
|
|
||||||
jbyte *usages = (*env)->GetByteArrayElements(env, usages_array, NULL);
|
|
||||||
if (usages == NULL)
|
|
||||||
return;
|
|
||||||
int res = ioctl(fd, EVIOCGUSAGE(len), usages);
|
|
||||||
(*env)->ReleaseByteArrayElements(env, usages_array, usages, 0);
|
|
||||||
if (res == -1)
|
|
||||||
throwIOException(env, "Failed to get device usages (%d)\n", errno);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_net_java_games_input_LinuxEventDevice_nGetBits(JNIEnv *env, jclass unused, jlong fd_address, jint evtype, jbyteArray bits_array) {
|
JNIEXPORT void JNICALL Java_net_java_games_input_LinuxEventDevice_nGetBits(JNIEnv *env, jclass unused, jlong fd_address, jint evtype, jbyteArray bits_array) {
|
||||||
int fd = (int)fd_address;
|
int fd = (int)fd_address;
|
||||||
jsize len = (*env)->GetArrayLength(env, bits_array);
|
jsize len = (*env)->GetArrayLength(env, bits_array);
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue