From aa699f5ffb4637a3760d6cc8721116a276d464a3 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 24 May 2018 20:52:18 +0100 Subject: [PATCH 01/66] Remove the log call that added extra new lines --- .../java/games/input/AbstractController.java | 4 +-- .../games/input/ControllerEnvironment.java | 3 -- .../input/DefaultControllerEnvironment.java | 6 ++-- .../games/input/OSXEnvironmentPlugin.java | 6 ++-- .../games/input/LinuxEnvironmentPlugin.java | 16 ++++----- .../java/games/input/LinuxEventDevice.java | 2 +- .../games/input/LinuxForceFeedbackEffect.java | 2 +- .../java/games/input/LinuxJoystickPOV.java | 2 +- .../java/net/java/games/input/LinuxPOV.java | 2 +- .../input/DirectInputEnvironmentPlugin.java | 2 +- .../net/java/games/input/IDirectInput.java | 2 +- .../java/games/input/IDirectInputDevice.java | 2 +- .../java/games/input/IDirectInputEffect.java | 2 +- .../input/RawInputEnvironmentPlugin.java | 2 +- .../games/input/WinTabButtonComponent.java | 2 +- .../net/java/games/input/WinTabDevice.java | 34 +++++++++---------- .../games/input/WinTabEnvironmentPlugin.java | 2 +- 17 files changed, 44 insertions(+), 47 deletions(-) diff --git a/coreAPI/src/main/java/net/java/games/input/AbstractController.java b/coreAPI/src/main/java/net/java/games/input/AbstractController.java index 02233df..5315d4e 100644 --- a/coreAPI/src/main/java/net/java/games/input/AbstractController.java +++ b/coreAPI/src/main/java/net/java/games/input/AbstractController.java @@ -183,7 +183,7 @@ public abstract class AbstractController implements Controller { setDeviceEventQueueSize(size); event_queue = new EventQueue(size); } 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 +233,7 @@ public abstract class AbstractController implements Controller { } return true; } catch (IOException e) { - ControllerEnvironment.logln("Failed to poll device: " + e.getMessage()); + ControllerEnvironment.log("Failed to poll device: " + e.getMessage()); return false; } } diff --git a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java index 17208f7..510436e 100644 --- a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java +++ b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java @@ -70,9 +70,6 @@ import java.util.logging.Logger; * */ public abstract class ControllerEnvironment { - static void logln(String msg) { - log(msg + "\n"); - } static void log(String msg) { Logger.getLogger(ControllerEnvironment.class.getName()).info(msg); diff --git a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java index 8540cec..468f24c 100644 --- a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java +++ b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java @@ -162,7 +162,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment { addControllers(ce.getControllers()); loadedPlugins.add(ce.getClass().getName()); } else { - logln(ceClass.getName() + " is not supported"); + log(ceClass.getName() + " is not supported"); } } } catch (Throwable e) { @@ -203,7 +203,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment { Class[] envClasses = plugins.getExtends(ControllerEnvironment.class); for(int i=0;i Date: Thu, 24 May 2018 20:54:29 +0100 Subject: [PATCH 02/66] Only deploy on master branch --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 10433d0..0871c79 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,7 @@ pipeline { agent { label "linux" } + when { branch 'master' } steps { unstash 'windows-natives' unstash 'osx-natives' From bd61698f168cf842ebe69399c9cd9379e28622fd Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 24 May 2018 21:33:54 +0100 Subject: [PATCH 03/66] Only sign on deploy --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4fb428..84f3983 100644 --- a/pom.xml +++ b/pom.xml @@ -137,7 +137,7 @@ sign-artifacts - verify + deploy sign From 5b799195e34ffdffb49e8447e1defe74f8d6376e Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 24 May 2018 21:54:32 +0100 Subject: [PATCH 04/66] Build core first --- Jenkinsfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0871c79..ca226fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,19 @@ pipeline { } options { buildDiscarder(logRotator(numToKeepStr: '5')) } 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') { From 771499a7cac0d6c254354d891a52439ca2340156 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 24 May 2018 21:57:01 +0100 Subject: [PATCH 05/66] Fix the javadoc jenkins archive --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca226fc..49bdb21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { } post { success { - archiveArtifacts artifacts: 'coreAPI/target/apidocs', fingerprint: true + archiveArtifacts artifacts: 'coreAPI/target/apidocs/**/*', fingerprint: true } } } From 5eb89d4e124d113f7c46396b244408cc5d997f84 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 24 May 2018 22:41:39 +0100 Subject: [PATCH 06/66] Disable logging option --- .../java/net/java/games/input/ControllerEnvironment.java | 6 ++++++ examples/pom.xml | 1 + 2 files changed, 7 insertions(+) diff --git a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java index 510436e..795c9f1 100644 --- a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java +++ b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java @@ -43,6 +43,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -90,6 +91,11 @@ public abstract class ControllerEnvironment { * Protected constructor for subclassing. */ 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); + } } /** diff --git a/examples/pom.xml b/examples/pom.xml index 3ce0cef..0589f16 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -109,6 +109,7 @@ -classpath -Djava.library.path=${project.build.directory}/natives + -Djinput.loglevel=OFF net.java.games.input.example.ReadAllEvents From b6253e440ea8d30a0dd67c7a6fe200b8bf955644 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 18:28:11 +0100 Subject: [PATCH 07/66] Start of a release pipeline build --- Jenkinsfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 49bdb21..6e39b3c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,6 +81,7 @@ pipeline { } } stage('Deploy') { + milestone() agent { label "linux" } @@ -101,5 +102,38 @@ pipeline { } } } + stage('Release') { + timeout(time:5, unit:'DAYS') { + milestone() + input { + message: "Do you wish to release?" + ok: "Release" + } + input { + message: "Are you sure, this cannot be undone?" + ok: "Release" + } + milestone() + } + agent { + label "linux" + } + steps { + 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" + sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot" + } + } + } } } \ No newline at end of file From ded17f08972147a557214ee3c34e46a09e6bd75d Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 19:10:10 +0100 Subject: [PATCH 08/66] Updates to plugins for release --- pom.xml | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 84f3983..b623396 100644 --- a/pom.xml +++ b/pom.xml @@ -128,6 +128,28 @@ + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + false + release + deploy + + @@ -147,14 +169,28 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - true - + + + + release + + + + org.sonatype.plugins + nexus-staging-maven-plugin + + false + + + + org.apache.maven.plugins + maven-release-plugin + + + + + \ No newline at end of file From f1b1b5a74fe3c5f355e224a90c462d2dff565eaa Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 19:13:55 +0100 Subject: [PATCH 09/66] Updates to plugins for release --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index b623396..1e19a76 100644 --- a/pom.xml +++ b/pom.xml @@ -148,6 +148,7 @@ false release deploy + @{project.version} From 76613c2c6ff59fb42dee02766e656411e96b0829 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 19:17:41 +0100 Subject: [PATCH 10/66] Jenkins file updates for release --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e39b3c..6ce1087 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -130,8 +130,8 @@ pipeline { 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" - sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot" + sh "mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs -DdryRun=true -Darguments=\"-Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs\" release:prepare" + sh "mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs -DdryRun=true -Darguments=\"-Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs\" release:perform" } } } From 12496a9fbbace521458a9b10b100aa567f655325 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 19:20:30 +0100 Subject: [PATCH 11/66] Don't use the release plugin --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ce1087..6e39b3c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -130,8 +130,8 @@ pipeline { globalMavenSettingsConfig: 'global-maven-settings-ossrh', mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts ) { - sh "mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs -DdryRun=true -Darguments=\"-Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs\" release:prepare" - sh "mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs -DdryRun=true -Darguments=\"-Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs\" release:perform" + sh "mvn -P windows,linux,osx,wintab versions:set -DremoveSnapshot" + sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot" } } } From 544e00cd5cd8c4c7aa5fa4b92877ca7a7be0d1cc Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 19:50:59 +0100 Subject: [PATCH 12/66] Use the nexus staging plugin for release --- Jenkinsfile | 8 ++++++-- pom.xml | 16 ---------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e39b3c..d2b775d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -130,8 +130,12 @@ pipeline { 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" - sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot" + sh "mvn -P windows,linux,osx,wintab,release versions:set -DremoveSnapshot" + 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 -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy" + sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" + sh "git commit -m 'Next development release' ." } } } diff --git a/pom.xml b/pom.xml index 1e19a76..b6786b7 100644 --- a/pom.xml +++ b/pom.xml @@ -139,18 +139,6 @@ true - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - true - false - release - deploy - @{project.version} - - @@ -186,10 +174,6 @@ false - - org.apache.maven.plugins - maven-release-plugin - From 8ba4395c2dc373c195fe0ef6c86661c7348ff8a9 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:06:03 +0100 Subject: [PATCH 13/66] Try and work out where milestone and input live. --- Jenkinsfile | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2b775d..ef10b09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,6 +87,7 @@ pipeline { } when { branch 'master' } steps { + milestone unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' @@ -102,23 +103,24 @@ pipeline { } } } + } + timeout(time:5, unit:'DAYS') { + input { + message: "Do you wish to release?" + ok: "Release" + } + input { + message: "Are you sure, this cannot be undone?" + ok: "Release" + } + } + stages{ stage('Release') { - timeout(time:5, unit:'DAYS') { - milestone() - input { - message: "Do you wish to release?" - ok: "Release" - } - input { - message: "Are you sure, this cannot be undone?" - ok: "Release" - } - milestone() - } agent { label "linux" } steps { + milestone unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' From d4ce65b28b1c2cc36e57897b6c90a81f3c3e516c Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:09:15 +0100 Subject: [PATCH 14/66] Try and work out where milestone and input live. --- Jenkinsfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ef10b09..8436fe1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -103,23 +103,22 @@ pipeline { } } } - } - timeout(time:5, unit:'DAYS') { - input { - message: "Do you wish to release?" - ok: "Release" - } - input { - message: "Are you sure, this cannot be undone?" - ok: "Release" - } - } - stages{ stage('Release') { agent { label "linux" } steps { + milestone + timeout(time:5, unit:'DAYS') { + input { + message: "Do you wish to release?" + ok: "Release" + } + input { + message: "Are you sure, this cannot be undone?" + ok: "Release" + } + } milestone unstash 'windows-natives' unstash 'osx-natives' From 97416d3813a83a02585076ef22f9f966dbe74403 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:09:45 +0100 Subject: [PATCH 15/66] Testing timeout --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8436fe1..a37b5ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -109,7 +109,7 @@ pipeline { } steps { milestone - timeout(time:5, unit:'DAYS') { + timeout(time:5, unit:'MINUTES') { input { message: "Do you wish to release?" ok: "Release" From b997ef8545d2a32000a39a1817549300b504adda Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:13:22 +0100 Subject: [PATCH 16/66] Milestone needs () --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a37b5ae..3ef7d81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,7 +87,7 @@ pipeline { } when { branch 'master' } steps { - milestone + milestone() unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' @@ -108,7 +108,7 @@ pipeline { label "linux" } steps { - milestone + milestone() timeout(time:5, unit:'MINUTES') { input { message: "Do you wish to release?" @@ -119,7 +119,7 @@ pipeline { ok: "Release" } } - milestone + milestone() unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' From c72d1fcb01f9976e90e60473e44721931e69c9cd Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:16:48 +0100 Subject: [PATCH 17/66] Input shouldn't have {} --- Jenkinsfile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3ef7d81..601313a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,7 +81,6 @@ pipeline { } } stage('Deploy') { - milestone() agent { label "linux" } @@ -110,14 +109,8 @@ pipeline { steps { milestone() timeout(time:5, unit:'MINUTES') { - input { - message: "Do you wish to release?" - ok: "Release" - } - input { - message: "Are you sure, this cannot be undone?" - ok: "Release" - } + input message: "Do you wish to release?", ok: "Release" + input message: "Are you sure, this cannot be undone?", ok: "Release" } milestone() unstash 'windows-natives' From bd571ad746f27c56d7d348e931c09441a1735282 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:22:09 +0100 Subject: [PATCH 18/66] Add ordinals to milestone --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 601313a..eb5d2e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,7 +86,7 @@ pipeline { } when { branch 'master' } steps { - milestone() + milestone(1) unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' @@ -107,12 +107,12 @@ pipeline { label "linux" } steps { - milestone() + milestone(2) timeout(time:5, unit:'MINUTES') { input message: "Do you wish to release?", ok: "Release" input message: "Are you sure, this cannot be undone?", ok: "Release" } - milestone() + milestone(3) unstash 'windows-natives' unstash 'osx-natives' unstash 'linux-natives' From a095351e4a2a1ad65c5d74dad239b00fd1069295 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:24:44 +0100 Subject: [PATCH 19/66] Try and get the version scriptlet working. --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb5d2e1..254b826 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -125,7 +125,9 @@ pipeline { mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts ) { sh "mvn -P windows,linux,osx,wintab,release versions:set -DremoveSnapshot" - VERSION_TAG = sh(script: "mvn -Dexpression=project.version help:evaluate | grep -e '^[[:digit:]]'", returnStdout: true).trim() + 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 -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy" sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" From b6ca29e9f1ab5e21a2ecf64890384f2c1b2cba9f Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:30:38 +0100 Subject: [PATCH 20/66] Move input out of an agent tied stage --- Jenkinsfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 254b826..1d3b5e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,16 +102,21 @@ pipeline { } } } - stage('Release') { - agent { - label "linux" - } + stage('Confirm release') { + agent none steps { milestone(2) timeout(time:5, unit:'MINUTES') { input message: "Do you wish to release?", ok: "Release" input message: "Are you sure, this cannot be undone?", ok: "Release" } + } + } + stage('Perform release') { + agent { + label "linux" + } + steps { milestone(3) unstash 'windows-natives' unstash 'osx-natives' From 9509787f0105c7cc75a1e1ee94ed9b781395f855 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:43:17 +0100 Subject: [PATCH 21/66] Use a parameterised build for release --- Jenkinsfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d3b5e8..b565328 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,9 @@ pipeline { jdk 'OpenJDK 9' } options { buildDiscarder(logRotator(numToKeepStr: '5')) } + parameters { + booleanParam(defaultValue: false, description: 'Perform Release', name: 'release') + } stages { stage('Build core') { agent { @@ -102,21 +105,17 @@ pipeline { } } } - stage('Confirm release') { - agent none - steps { - milestone(2) - timeout(time:5, unit:'MINUTES') { - input message: "Do you wish to release?", ok: "Release" - input message: "Are you sure, this cannot be undone?", ok: "Release" - } - } - } stage('Perform release') { agent { label "linux" } + when { + expression { + return params.release + } + } steps { +/* milestone(3) unstash 'windows-natives' unstash 'osx-natives' @@ -138,6 +137,8 @@ pipeline { sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" sh "git commit -m 'Next development release' ." } +*/ + echo "Release!" } } } From 99debb71a001a849beec0f15ac86683262bbec7e Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:52:21 +0100 Subject: [PATCH 22/66] Use a parameterised build for release --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b565328..a4ea1dc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -115,7 +115,6 @@ pipeline { } } steps { -/* milestone(3) unstash 'windows-natives' unstash 'osx-natives' @@ -137,8 +136,6 @@ pipeline { sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" sh "git commit -m 'Next development release' ." } -*/ - echo "Release!" } } } From a4c7d312d2b4d639d9db9082ece5ce334fcaeef0 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 20:59:46 +0100 Subject: [PATCH 23/66] Add the git push --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index a4ea1dc..a8231cf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,6 +135,7 @@ pipeline { sh "mvn -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy" sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" sh "git commit -m 'Next development release' ." + sh "git push" } } } From 6150206edba66d580cccfc6a7f3807f9e9d87515 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 21:00:38 +0100 Subject: [PATCH 24/66] Change the release stage name --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a8231cf..b4fcb31 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,7 +105,7 @@ pipeline { } } } - stage('Perform release') { + stage('Release') { agent { label "linux" } From c63b09a0479b61204baa0ebf9d5140e90872db3e Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 21:50:06 +0100 Subject: [PATCH 25/66] Hopefully fix the release not incrementing or commiting --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index b4fcb31..88ad60f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -133,6 +133,7 @@ pipeline { } sh "git tag -a ${VERSION_TAG} -m 'Release tag ${VERSION_TAG}'" sh "mvn -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy" + sh "mvn -P windows,linux,osx,wintab,release versions:revert" sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" sh "git commit -m 'Next development release' ." sh "git push" From 3bc6b827e056ea5e720c98075b4353e8959e7d69 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 21:51:40 +0100 Subject: [PATCH 26/66] Hopefully fix the release not incrementing or commiting --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88ad60f..c5b4d94 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -127,14 +127,14 @@ pipeline { 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,release versions:set -DremoveSnapshot" + 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 -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy" - sh "mvn -P windows,linux,osx,wintab,release versions:revert" - sh "mvn -P windows,linux,osx,wintab,release versions:set -DnextSnapshot" + 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" } From 974302e420db0b1948bcc776601fed4892ff86ef Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 21:52:45 +0100 Subject: [PATCH 27/66] Next development release --- Jenkinsfile | 2 +- applet/pom.xml | 2 +- coreAPI/pom.xml | 2 +- examples/pom.xml | 2 +- plugins/OSX/pom.xml | 2 +- plugins/awt/pom.xml | 2 +- plugins/linux/pom.xml | 2 +- plugins/pom.xml | 2 +- plugins/windows/pom.xml | 2 +- plugins/wintab/pom.xml | 2 +- pom.xml | 2 +- tests/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c5b4d94..57474cd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -136,7 +136,7 @@ pipeline { 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" + sh "git push --all" } } } diff --git a/applet/pom.xml b/applet/pom.xml index de79023..dab664b 100644 --- a/applet/pom.xml +++ b/applet/pom.xml @@ -7,7 +7,7 @@ net.java.jinput jinput-parent - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/coreAPI/pom.xml b/coreAPI/pom.xml index cb7ecfa..cb61a0b 100644 --- a/coreAPI/pom.xml +++ b/coreAPI/pom.xml @@ -7,7 +7,7 @@ net.java.jinput jinput-parent - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/examples/pom.xml b/examples/pom.xml index 0589f16..be655a8 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -7,7 +7,7 @@ net.java.jinput jinput-parent - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/OSX/pom.xml b/plugins/OSX/pom.xml index 0d08c28..de41b19 100644 --- a/plugins/OSX/pom.xml +++ b/plugins/OSX/pom.xml @@ -7,7 +7,7 @@ net.java.jinput plugins - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/awt/pom.xml b/plugins/awt/pom.xml index d7fbfdb..9f3d69f 100644 --- a/plugins/awt/pom.xml +++ b/plugins/awt/pom.xml @@ -7,7 +7,7 @@ net.java.jinput plugins - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/linux/pom.xml b/plugins/linux/pom.xml index c3b8d95..6cd37f0 100644 --- a/plugins/linux/pom.xml +++ b/plugins/linux/pom.xml @@ -7,7 +7,7 @@ net.java.jinput plugins - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/pom.xml b/plugins/pom.xml index 9cd4b0a..35e7b52 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -7,7 +7,7 @@ net.java.jinput jinput-parent - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/windows/pom.xml b/plugins/windows/pom.xml index 4228150..185f7a0 100644 --- a/plugins/windows/pom.xml +++ b/plugins/windows/pom.xml @@ -7,7 +7,7 @@ net.java.jinput plugins - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/plugins/wintab/pom.xml b/plugins/wintab/pom.xml index 4121eeb..d259150 100644 --- a/plugins/wintab/pom.xml +++ b/plugins/wintab/pom.xml @@ -7,7 +7,7 @@ net.java.jinput plugins - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ diff --git a/pom.xml b/pom.xml index b6786b7..03912ef 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jinput-parent pom JInput - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT Library for access to input devices. https://github.com/jinput/jinput diff --git a/tests/pom.xml b/tests/pom.xml index e5928b7..f4f4547 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -7,7 +7,7 @@ net.java.jinput jinput-parent - 2.0.8-SNAPSHOT + 2.0.9-SNAPSHOT ../ From 98a19dbb1a3223ff4ab09f51b6b3a6f6cea9b4b0 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 25 May 2018 22:26:29 +0100 Subject: [PATCH 28/66] Update to push tags --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 57474cd..14d503c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -136,7 +136,7 @@ pipeline { 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 --all" + sh "git push --follow-tags" } } } From 81c9c872cde9462116f877fe24fc279220243763 Mon Sep 17 00:00:00 2001 From: Endolf Date: Tue, 29 May 2018 21:43:15 +0100 Subject: [PATCH 29/66] Fixed compile warnings for core api --- .../java/games/input/AbstractController.java | 14 +--- .../games/input/ControllerEnvironment.java | 12 ++-- .../input/DefaultControllerEnvironment.java | 68 ++++++------------- .../java/games/input/PluginClassLoader.java | 10 +-- pom.xml | 9 ++- 5 files changed, 40 insertions(+), 73 deletions(-) diff --git a/coreAPI/src/main/java/net/java/games/input/AbstractController.java b/coreAPI/src/main/java/net/java/games/input/AbstractController.java index 5315d4e..5b12a8e 100644 --- a/coreAPI/src/main/java/net/java/games/input/AbstractController.java +++ b/coreAPI/src/main/java/net/java/games/input/AbstractController.java @@ -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. * Redistribution and use in source and binary forms, with or without * 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 * the design, construction, operation or maintenance of any nuclear facility * - *****************************************************************************/ + */ package net.java.games.input; import java.util.Map; -import java.util.List; import java.util.HashMap; -import java.util.ArrayList; import java.io.IOException; @@ -77,7 +69,7 @@ public abstract class AbstractController implements Controller { /** * Map from Component.Identifiers to Components */ - private final Map id_to_components = new HashMap(); + private final Map id_to_components = new HashMap<>(); 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. */ public final Component getComponent(Component.Identifier id) { - return (Component)id_to_components.get(id); + return id_to_components.get(id); } /** diff --git a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java index 795c9f1..6aa9ad8 100644 --- a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java +++ b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java @@ -85,7 +85,7 @@ public abstract class ControllerEnvironment { /** * List of controller listeners */ - protected final ArrayList controllerListeners = new ArrayList(); + protected final ArrayList controllerListeners = new ArrayList<>(); /** * Protected constructor for subclassing. @@ -133,9 +133,9 @@ public abstract class ControllerEnvironment { */ protected void fireControllerAdded(Controller c) { ControllerEvent ev = new ControllerEvent(c); - Iterator it = controllerListeners.iterator(); + Iterator it = controllerListeners.iterator(); while (it.hasNext()) { - ((ControllerListener)it.next()).controllerAdded(ev); + it.next().controllerAdded(ev); } } @@ -145,9 +145,9 @@ public abstract class ControllerEnvironment { */ protected void fireControllerRemoved(Controller c) { ControllerEvent ev = new ControllerEvent(c); - Iterator it = controllerListeners.iterator(); + Iterator it = controllerListeners.iterator(); while (it.hasNext()) { - ((ControllerListener)it.next()).controllerRemoved(ev); + it.next().controllerRemoved(ev); } } @@ -158,4 +158,4 @@ public abstract class ControllerEnvironment { public static ControllerEnvironment getDefaultEnvironment() { return defaultEnvironment; } -} // ControllerEnvironment +} \ No newline at end of file diff --git a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java index 468f24c..4aa3521 100644 --- a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java +++ b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java @@ -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. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,24 +29,20 @@ * 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; +import net.java.games.util.plugins.Plugins; + import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.StringTokenizer; import java.util.logging.Logger; -import net.java.games.util.plugins.*; - /** * The default controller environment. * @@ -72,42 +62,31 @@ class DefaultControllerEnvironment extends ControllerEnvironment { * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property, default_value)); } /** * List of all controllers in this environment */ - private ArrayList controllers; + private ArrayList controllers; - private Collection loadedPlugins = new ArrayList(); + private Collection loadedPluginNames = new ArrayList<>(); /** * Public no-arg constructor. @@ -122,13 +101,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment { public Controller[] getControllers() { if (controllers == null) { // Controller list has not been scanned. - controllers = new ArrayList(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - scanControllers(); - return null; - } - }); + controllers = new ArrayList<>(); + AccessController.doPrivileged((PrivilegedAction) () -> scanControllers()); //Check the properties for specified controller classes 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")) { @@ -154,13 +128,13 @@ class DefaultControllerEnvironment extends ControllerEnvironment { while(pluginClassTok.hasMoreTokens()) { String className = pluginClassTok.nextToken(); try { - if(!loadedPlugins.contains(className)) { + if(!loadedPluginNames.contains(className)) { log.fine("Loading: " + className); - Class ceClass = Class.forName(className); + Class ceClass = Class.forName(className); ControllerEnvironment ce = (ControllerEnvironment) ceClass.getDeclaredConstructor().newInstance(); if(ce.isSupported()) { addControllers(ce.getControllers()); - loadedPlugins.add(ce.getClass().getName()); + loadedPluginNames.add(ce.getClass().getName()); } else { log(ceClass.getName() + " is not supported"); } @@ -171,17 +145,17 @@ class DefaultControllerEnvironment extends ControllerEnvironment { } } Controller[] ret = new Controller[controllers.size()]; - Iterator it = controllers.iterator(); + Iterator it = controllers.iterator(); int i = 0; while (it.hasNext()) { - ret[i] = (Controller)it.next(); + ret[i] = it.next(); i++; } return ret; } /* This is jeff's new plugin code using Jeff's Plugin manager */ - private void scanControllers() { + private Void scanControllers() { String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath"); if(pluginPathName == null) { pluginPathName = "controller"; @@ -191,6 +165,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment { File.separator + "lib"+File.separator + pluginPathName); scanControllersAt(getPrivilegedProperty("user.dir")+ File.separator + pluginPathName); + + return null; } private void scanControllersAt(String path) { @@ -200,17 +176,17 @@ class DefaultControllerEnvironment extends ControllerEnvironment { } try { Plugins plugins = new Plugins(file); - Class[] envClasses = plugins.getExtends(ControllerEnvironment.class); + @SuppressWarnings("unchecked") + Class[] envClasses = plugins.getExtends(ControllerEnvironment.class); for(int i=0;i findClass(String name) throws ClassNotFoundException { // Try loading the class from the file system. byte[] b = loadClassData(name); diff --git a/pom.xml b/pom.xml index 03912ef..fde8b50 100644 --- a/pom.xml +++ b/pom.xml @@ -39,8 +39,8 @@ UTF-8 - 1.6 - 1.6 + 8 + 8 @@ -70,6 +70,11 @@ true true + + -Werror + -Xlint:all + -Xlint:-options + From 2bc8a793c85d42b0c2b4df54875301f5f1073462 Mon Sep 17 00:00:00 2001 From: Endolf Date: Tue, 29 May 2018 21:55:13 +0100 Subject: [PATCH 30/66] Fixed compile warnings for awt plugin --- .../main/java/net/java/games/input/AWTKeyboard.java | 13 ++++++------- .../main/java/net/java/games/input/AWTMouse.java | 11 +++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/plugins/awt/src/main/java/net/java/games/input/AWTKeyboard.java b/plugins/awt/src/main/java/net/java/games/input/AWTKeyboard.java index dafd4df..b30a39d 100644 --- a/plugins/awt/src/main/java/net/java/games/input/AWTKeyboard.java +++ b/plugins/awt/src/main/java/net/java/games/input/AWTKeyboard.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ import java.lang.reflect.Modifier; * @author elias */ final class AWTKeyboard extends Keyboard implements AWTEventListener { - private final List awt_events = new ArrayList(); + private final List awt_events = new ArrayList<>(); private Event[] processed_events; private int processed_events_index; @@ -54,7 +54,7 @@ final class AWTKeyboard extends Keyboard implements AWTEventListener { } private final static Component[] createComponents() { - List components = new ArrayList(); + List components = new ArrayList<>(); Field[] vkey_fields = KeyEvent.class.getFields(); for (int i = 0; i < vkey_fields.length; 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.NUMPADCOMMA)); 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) { @@ -96,13 +96,12 @@ final class AWTKeyboard extends Keyboard implements AWTEventListener { public final synchronized void eventDispatched(AWTEvent event) { if (event instanceof KeyEvent) - awt_events.add(event); + awt_events.add((KeyEvent)event); } public final synchronized void pollDevice() throws IOException { for (int i = 0; i < awt_events.size(); i++) { - KeyEvent event = (KeyEvent)awt_events.get(i); - processEvent(event); + processEvent(awt_events.get(i)); } awt_events.clear(); } diff --git a/plugins/awt/src/main/java/net/java/games/input/AWTMouse.java b/plugins/awt/src/main/java/net/java/games/input/AWTMouse.java index 37c8eee..8f8cb06 100644 --- a/plugins/awt/src/main/java/net/java/games/input/AWTMouse.java +++ b/plugins/awt/src/main/java/net/java/games/input/AWTMouse.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,6 @@ package net.java.games.input; import java.awt.AWTEvent; -import java.awt.Point; import java.awt.Toolkit; import java.awt.event.AWTEventListener; 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_BUTTON = 4; - private final List awt_events = new ArrayList(); - private final List processed_awt_events = new ArrayList(); + private final List awt_events = new ArrayList<>(); + private final List processed_awt_events = new ArrayList<>(); private int event_state = EVENT_X; @@ -115,7 +114,7 @@ final class AWTMouse extends Mouse implements AWTEventListener { Axis wheel = (Axis)getWheel(); wheel.setValue(0); for (int i = 0; i < awt_events.size(); i++) { - AWTEvent event = (AWTEvent)awt_events.get(i); + AWTEvent event = awt_events.get(i); processEvent(event); processed_awt_events.add(event); } @@ -126,7 +125,7 @@ final class AWTMouse extends Mouse implements AWTEventListener { while (true) { if (processed_awt_events.isEmpty()) return false; - AWTEvent awt_event = (AWTEvent)processed_awt_events.get(0); + AWTEvent awt_event = processed_awt_events.get(0); if (awt_event instanceof MouseWheelEvent) { MouseWheelEvent awt_wheel_event = (MouseWheelEvent)awt_event; long nanos = awt_wheel_event.getWhen()*1000000L; From 4b00766888051d41b0c53a84d6b364d0566bd06b Mon Sep 17 00:00:00 2001 From: Endolf Date: Tue, 29 May 2018 22:29:43 +0100 Subject: [PATCH 31/66] Fail on compiler warnings in the plugins --- plugins/OSX/pom.xml | 6 ------ plugins/linux/pom.xml | 6 ------ plugins/windows/pom.xml | 6 ------ plugins/wintab/pom.xml | 6 ------ 4 files changed, 24 deletions(-) diff --git a/plugins/OSX/pom.xml b/plugins/OSX/pom.xml index de41b19..bc30b9d 100644 --- a/plugins/OSX/pom.xml +++ b/plugins/OSX/pom.xml @@ -29,12 +29,6 @@ maven-compiler-plugin - - - -h - ${project.build.directory}/generated-sources/natives - - maven-antrun-plugin diff --git a/plugins/linux/pom.xml b/plugins/linux/pom.xml index 6cd37f0..348b2be 100644 --- a/plugins/linux/pom.xml +++ b/plugins/linux/pom.xml @@ -29,12 +29,6 @@ maven-compiler-plugin - - - -h - ${project.build.directory}/generated-sources/natives - - maven-antrun-plugin diff --git a/plugins/windows/pom.xml b/plugins/windows/pom.xml index 185f7a0..11cdc17 100644 --- a/plugins/windows/pom.xml +++ b/plugins/windows/pom.xml @@ -29,12 +29,6 @@ maven-compiler-plugin - - - -h - ${project.build.directory}/generated-sources/natives - - maven-antrun-plugin diff --git a/plugins/wintab/pom.xml b/plugins/wintab/pom.xml index d259150..57c1d6a 100644 --- a/plugins/wintab/pom.xml +++ b/plugins/wintab/pom.xml @@ -29,12 +29,6 @@ maven-compiler-plugin - - - -h - ${project.build.directory}/generated-sources/natives - - maven-antrun-plugin From 9c639cdfbc058f120c9903b778bf28d33beb662f Mon Sep 17 00:00:00 2001 From: Endolf Date: Tue, 29 May 2018 22:30:06 +0100 Subject: [PATCH 32/66] Mostly fixed compiler warnings --- .../java/games/input/LinuxEventDevice.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java b/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java index 45c45c3..033d03f 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -35,12 +35,12 @@ import java.util.ArrayList; * @author elias */ final class LinuxEventDevice implements LinuxDevice { - private final Map component_map = new HashMap(); + private final Map component_map = new HashMap<>(); private final Rumbler[] rumblers; private final long fd; private final String name; private final LinuxInputID input_id; - private final List components; + private final List components; private final Controller.Type type; /* Closed state variable that protects the validity of the file descriptor. @@ -83,10 +83,10 @@ final class LinuxEventDevice implements LinuxDevice { return type; } - private final static int countComponents(List components, Class id_type, boolean relative) { + private final static int countComponents(List components, Class id_type, boolean relative) { int count = 0; 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()) count++; } @@ -94,7 +94,7 @@ final class LinuxEventDevice implements LinuxDevice { } private final Controller.Type guessType() throws IOException { - List components = getComponents(); + List components = getComponents(); if (components.size() == 0) return Controller.Type.UNKNOWN; int num_rel_axes = countComponents(components, Component.Identifier.Axis.class, true); @@ -118,7 +118,7 @@ final class LinuxEventDevice implements LinuxDevice { int num_gamepad_button_traits = 0; // count button traits 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) num_mouse_button_traits++; else if (component.getButtonTrait() == Controller.Type.KEYBOARD) @@ -158,11 +158,11 @@ final class LinuxEventDevice implements LinuxDevice { } private final Rumbler[] enumerateRumblers() { - List rumblers = new ArrayList(); + List rumblers = new ArrayList<>(); try { int num_effects = getNumEffects(); if (num_effects <= 0) - return (Rumbler[])rumblers.toArray(new Rumbler[]{}); + return rumblers.toArray(new Rumbler[]{}); byte[] ff_bits = getForceFeedbackBits(); if (isBitSet(ff_bits, NativeDefinitions.FF_RUMBLE) && num_effects > rumblers.size()) { rumblers.add(new LinuxRumbleFF(this)); @@ -170,7 +170,7 @@ final class LinuxEventDevice implements LinuxDevice { } catch (IOException e) { LinuxEnvironmentPlugin.log("Failed to enumerate rumblers: " + e.getMessage()); } - return (Rumbler[])rumblers.toArray(new Rumbler[]{}); + return rumblers.toArray(new Rumbler[]{}); } public final Rumbler[] getRumblers() { @@ -205,7 +205,7 @@ final class LinuxEventDevice implements LinuxDevice { } public final LinuxComponent mapDescriptor(LinuxAxisDescriptor desc) { - return (LinuxComponent)component_map.get(desc); + return component_map.get(desc); } public final Controller.PortType getPortType() throws IOException { @@ -243,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 void addKeys(List components) throws IOException { + private final void addKeys(List components) throws IOException { byte[] bits = getKeysBits(); for (int i = 0; i < bits.length*8; i++) { if (isBitSet(bits, i)) { @@ -253,7 +253,7 @@ final class LinuxEventDevice implements LinuxDevice { } } - private final void addAbsoluteAxes(List components) throws IOException { + private final void addAbsoluteAxes(List components) throws IOException { byte[] bits = getAbsoluteAxesBits(); for (int i = 0; i < bits.length*8; i++) { if (isBitSet(bits, i)) { @@ -263,7 +263,7 @@ final class LinuxEventDevice implements LinuxDevice { } } - private final void addRelativeAxes(List components) throws IOException { + private final void addRelativeAxes(List components) throws IOException { byte[] bits = getRelativeAxesBits(); for (int i = 0; i < bits.length*8; i++) { if (isBitSet(bits, i)) { @@ -273,12 +273,12 @@ final class LinuxEventDevice implements LinuxDevice { } } - public final List getComponents() { + public final List getComponents() { return components; } - private final List getDeviceComponents() throws IOException { - List components = new ArrayList(); + private final List getDeviceComponents() throws IOException { + List components = new ArrayList<>(); byte[] evtype_bits = getEventTypeBits(); if (isBitSet(evtype_bits, NativeDefinitions.EV_KEY)) addKeys(components); From f0d7f6db03d6d5472f0ba2ad9c947c4073ae504b Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:02:27 +0100 Subject: [PATCH 33/66] Mostly fixed compiler warnings --- .../applet/JInputAppletResourceLoader.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java b/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java index 63a18b5..4d2e63e 100644 --- a/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java +++ b/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java @@ -50,19 +50,11 @@ public class JInputAppletResourceLoader { private int percentageDone = 0; private String getPrivilegedProperty(final String property) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property)); } private String setPrivilegedProperty(final String property, final String value) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.setProperty(property, value); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> System.setProperty(property, value)); } public void loadResources(URL codeBase) throws IOException { @@ -94,13 +86,13 @@ public class JInputAppletResourceLoader { JarFile localJarFile = new JarFile(new File(tempDir, nativeJar), true); - Enumeration jarEntries = localJarFile.entries(); + Enumeration jarEntries = localJarFile.entries(); int totalUncompressedBytes = 0; int totalUncompressedBytesWritten = 0; - List entriesToUse = new ArrayList(); + List entriesToUse = new ArrayList<>(); while(jarEntries.hasMoreElements()) { - JarEntry jarEntry = (JarEntry)jarEntries.nextElement(); + JarEntry jarEntry = jarEntries.nextElement(); String entryName = jarEntry.getName(); if(!entryName.startsWith("META-INF")) { totalUncompressedBytes+=jarEntry.getSize(); @@ -116,7 +108,7 @@ public class JInputAppletResourceLoader { } for(int i=0;i Date: Wed, 30 May 2018 17:04:07 +0100 Subject: [PATCH 34/66] Fail on compiler warnings in the plugins --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fde8b50..b665c6d 100644 --- a/pom.xml +++ b/pom.xml @@ -72,8 +72,9 @@ true -Werror - -Xlint:all - -Xlint:-options + -Xlint:all,-options + -h + ${project.build.directory}/generated-sources/natives From 516aed2c93cb5c238aec2fe756ea196f98793f1d Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:19:18 +0100 Subject: [PATCH 35/66] Fixed compile warnings --- .../input/RawInputEnvironmentPlugin.java | 43 +++++++------------ .../java/games/input/RawInputEventQueue.java | 9 +--- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/RawInputEnvironmentPlugin.java b/plugins/windows/src/main/java/net/java/games/input/RawInputEnvironmentPlugin.java index c6335ce..9d409aa 100644 --- a/plugins/windows/src/main/java/net/java/games/input/RawInputEnvironmentPlugin.java +++ b/plugins/windows/src/main/java/net/java/games/input/RawInputEnvironmentPlugin.java @@ -64,9 +64,7 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { try { String lib_path = System.getProperty("net.java.games.input.librarypath"); if (lib_path != null) @@ -78,25 +76,16 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple supported = false; } return null; - } }); } static String getPrivilegedProperty(final String property) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property, default_value)); } static { @@ -132,23 +121,23 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple return controllers; } - private final static SetupAPIDevice lookupSetupAPIDevice(String device_name, List setupapi_devices) { + private final static SetupAPIDevice lookupSetupAPIDevice(String device_name, List setupapi_devices) { /* First, replace # with / in the device name, since that * seems to be the format in raw input device name */ device_name = device_name.replaceAll("#", "\\\\").toUpperCase(); for (int i = 0; i < setupapi_devices.size(); i++) { - SetupAPIDevice device = (SetupAPIDevice)setupapi_devices.get(i); - if (device_name.indexOf(device.getInstanceId().toUpperCase()) != -1) + SetupAPIDevice device = setupapi_devices.get(i); + if (device_name.contains(device.getInstanceId().toUpperCase())) return device; } return null; } - private final static void createControllersFromDevices(RawInputEventQueue queue, List controllers, List devices, List setupapi_devices) throws IOException { - List active_devices = new ArrayList(); + private final static void createControllersFromDevices(RawInputEventQueue queue, List controllers, List devices, List setupapi_devices) throws IOException { + List active_devices = new ArrayList<>(); for (int i = 0; i < devices.size(); i++) { - RawDevice device = (RawDevice)devices.get(i); + RawDevice device = devices.get(i); SetupAPIDevice setupapi_device = lookupSetupAPIDevice(device.getName(), setupapi_devices); if (setupapi_device == null) { /* Either the device is an RDP or we failed to locate the @@ -166,13 +155,13 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple queue.start(active_devices); } - private final static native void enumerateDevices(RawInputEventQueue queue, List devices) throws IOException; + private final static native void enumerateDevices(RawInputEventQueue queue, List devices) throws IOException; private final Controller[] enumControllers(RawInputEventQueue queue) throws IOException { - List controllers = new ArrayList(); - List devices = new ArrayList(); + List controllers = new ArrayList<>(); + List devices = new ArrayList<>(); enumerateDevices(queue, devices); - List setupapi_devices = enumSetupAPIDevices(); + List setupapi_devices = enumSetupAPIDevices(); createControllersFromDevices(queue, controllers, devices, setupapi_devices); Controller[] controllers_array = new Controller[controllers.size()]; controllers.toArray(controllers_array); @@ -202,13 +191,13 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple * descriptive names and at the same time filter out the unwanted * RDP devices. */ - private final static List enumSetupAPIDevices() throws IOException { - List devices = new ArrayList(); + private final static List enumSetupAPIDevices() throws IOException { + List devices = new ArrayList<>(); nEnumSetupAPIDevices(getKeyboardClassGUID(), devices); nEnumSetupAPIDevices(getMouseClassGUID(), devices); return devices; } - private final static native void nEnumSetupAPIDevices(byte[] guid, List devices) throws IOException; + private final static native void nEnumSetupAPIDevices(byte[] guid, List devices) throws IOException; private final static native byte[] getKeyboardClassGUID(); private final static native byte[] getMouseClassGUID(); diff --git a/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java b/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java index 99f486d..4ea0306 100644 --- a/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java +++ b/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java @@ -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. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,12 +29,11 @@ * 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; import java.io.IOException; import java.util.List; -import java.util.ArrayList; import java.util.Set; import java.util.HashSet; From f5f30e17abb24e861ec84ecdb80d4daa73a00bab Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:38:20 +0100 Subject: [PATCH 36/66] Code tidy up --- .../net/java/games/input/applet/ControllerEventTestApplet.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java index 9127686..52911a8 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,6 @@ import java.applet.Applet; import java.io.IOException; import net.java.games.input.ControllerEventTest; -import net.java.games.input.applet.JInputAppletResourceLoader; public class ControllerEventTestApplet extends Applet { From b853018676ba30a7f176d88108c2bbb910fb2d46 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:38:55 +0100 Subject: [PATCH 37/66] Add serialVersionUID --- .../java/games/input/applet/ControllerEventTestApplet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java index 52911a8..9f82bea 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java @@ -32,7 +32,9 @@ import net.java.games.input.ControllerEventTest; public class ControllerEventTestApplet extends Applet { - public void init() { + private static final long serialVersionUID = 4250817143444220400L; + + public void init() { try { new JInputAppletResourceLoader().loadResources(getCodeBase()); } catch (IOException e) { From 5ba05aff6526d94dfcbeb48f7aa1a062ecaeef5f Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:39:34 +0100 Subject: [PATCH 38/66] Code tidy up --- .../java/games/input/applet/ControllerReadTestApplet.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java index 1f9fff2..2f9824a 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -29,10 +29,11 @@ import java.applet.Applet; import java.io.IOException; import net.java.games.input.ControllerReadTest; -import net.java.games.input.applet.JInputAppletResourceLoader; public class ControllerReadTestApplet extends Applet { + private static final long serialVersionUID = -2558493887683964119L; + public void init() { try { new JInputAppletResourceLoader().loadResources(getCodeBase()); From 4b8183ead9c3a23fe95b9d6b32184ec08b3327cc Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:42:06 +0100 Subject: [PATCH 39/66] Fixed compile warnings --- .../src/main/java/net/java/games/input/LinuxEventDevice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java b/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java index 033d03f..a69f9e8 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxEventDevice.java @@ -360,6 +360,7 @@ final class LinuxEventDevice implements LinuxDevice { throw new IOException("Device is closed"); } + @SuppressWarnings("deprecation") protected void finalize() throws IOException { close(); } From c9152a679d4a7128537177049562689ab3712b10 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:45:52 +0100 Subject: [PATCH 40/66] Fixed compile warnings --- .../main/java/net/java/games/input/LinuxDeviceThread.java | 4 ++-- .../src/main/java/net/java/games/input/LinuxRumbleFF.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxDeviceThread.java b/plugins/linux/src/main/java/net/java/games/input/LinuxDeviceThread.java index 62d1849..f550c24 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxDeviceThread.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxDeviceThread.java @@ -40,7 +40,7 @@ import java.util.ArrayList; * is run on a single thread. */ final class LinuxDeviceThread extends Thread { - private final List tasks = new ArrayList(); + private final List tasks = new ArrayList<>(); public LinuxDeviceThread() { setDaemon(true); @@ -50,7 +50,7 @@ final class LinuxDeviceThread extends Thread { public synchronized final void run() { while (true) { if (!tasks.isEmpty()) { - LinuxDeviceTask task = (LinuxDeviceTask)tasks.remove(0); + LinuxDeviceTask task = tasks.remove(0); task.doExecute(); synchronized (task) { task.notify(); diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxRumbleFF.java b/plugins/linux/src/main/java/net/java/games/input/LinuxRumbleFF.java index 578793a..046eb14 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxRumbleFF.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxRumbleFF.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * * 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); } else if (intensity > 0.3333333f) { strong_magnitude = (int)(0x8000*intensity); - weak_magnitude = (int)(0xc000*0); + weak_magnitude = 0; } else { - strong_magnitude = (int)(0x8000*0); + strong_magnitude = 0; weak_magnitude = (int)(0xc000*intensity); } From db8c6804b4a3b1ad155a1ced443b9bf2ed6b5940 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 17:53:20 +0100 Subject: [PATCH 41/66] Fixed compile warnings --- .../java/games/input/LinuxJoystickDevice.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxJoystickDevice.java b/plugins/linux/src/main/java/net/java/games/input/LinuxJoystickDevice.java index 0dcd5da..c749684 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxJoystickDevice.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxJoystickDevice.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * * 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.util.Map; import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; /** * @author elias @@ -48,8 +46,8 @@ final class LinuxJoystickDevice implements LinuxDevice { private final Event event = new Event(); private final LinuxJoystickButton[] buttons; private final LinuxJoystickAxis[] axes; - private final Map povXs = new HashMap(); - private final Map povYs = new HashMap(); + private final Map povXs = new HashMap<>(); + private final Map povYs = new HashMap<>(); private final byte[] axisMap; private final char[] buttonMap; @@ -102,12 +100,12 @@ final class LinuxJoystickDevice implements LinuxDevice { if (axis != null) { float value = (float)joystick_event.getValue()/AXIS_MAX_VALUE; axis.setValue(value); - if(povXs.containsKey(new Integer(index))) { - LinuxJoystickPOV pov = (LinuxJoystickPOV)(povXs.get(new Integer(index))); + if(povXs.containsKey(index)) { + LinuxJoystickPOV pov = povXs.get(index); pov.updateValue(); event.set(pov, pov.getPollData(), joystick_event.getNanos()); - } else if(povYs.containsKey(new Integer(index))) { - LinuxJoystickPOV pov = (LinuxJoystickPOV)(povYs.get(new Integer(index))); + } else if(povYs.containsKey(index)) { + LinuxJoystickPOV pov = povYs.get(index); pov.updateValue(); event.set(pov, pov.getPollData(), joystick_event.getNanos()); } else { @@ -150,8 +148,8 @@ final class LinuxJoystickDevice implements LinuxDevice { break; } } - povXs.put(new Integer(xIndex),pov); - povYs.put(new Integer(yIndex),pov); + povXs.put(xIndex,pov); + povYs.put(yIndex,pov); } public final synchronized boolean getNextEvent(Event event) throws IOException { @@ -233,6 +231,7 @@ final class LinuxJoystickDevice implements LinuxDevice { throw new IOException("Device is closed"); } + @SuppressWarnings("deprecation") protected void finalize() throws IOException { close(); } From 0cfd2ae7cd6ce6f0a04af5ad4e2eb2a48db849e3 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 18:14:58 +0100 Subject: [PATCH 42/66] Fixed compile warnings --- .../games/input/LinuxEnvironmentPlugin.java | 77 ++++++------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/plugins/linux/src/main/java/net/java/games/input/LinuxEnvironmentPlugin.java b/plugins/linux/src/main/java/net/java/games/input/LinuxEnvironmentPlugin.java index 633f832..035b8f7 100644 --- a/plugins/linux/src/main/java/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/plugins/linux/src/main/java/net/java/games/input/LinuxEnvironmentPlugin.java @@ -47,7 +47,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen private static boolean supported = false; private final Controller[] controllers; - private final List devices = new ArrayList(); + private final List devices = new ArrayList(); private final static LinuxDeviceThread device_thread = new LinuxDeviceThread(); /** @@ -58,9 +58,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { String lib_path = System.getProperty("net.java.games.input.librarypath"); try { if(lib_path != null) @@ -73,25 +71,16 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen supported = false; } return null; - } }); } static String getPrivilegedProperty(final String property) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); + return AccessController.doPrivileged((PrivilegedAction)() -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction)() -> System.getProperty(property, default_value)); } static { @@ -114,12 +103,9 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen if(isSupported()) { this.controllers = enumerateControllers(); log("Linux plugin claims to have found " + controllers.length + " controllers"); - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction)() -> { Runtime.getRuntime().addShutdownHook(new ShutdownHook()); return null; - } }); } else { controllers = new Controller[0]; @@ -135,11 +121,11 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen return controllers; } - private final static Component[] createComponents(List event_components, LinuxEventDevice device) { + private final static Component[] createComponents(List event_components, LinuxEventDevice device) { LinuxEventComponent[][] povs = new LinuxEventComponent[4][2]; - List components = new ArrayList(); + List components = new ArrayList<>(); for(int i = 0; i < event_components.size(); i++) { - LinuxEventComponent event_component = (LinuxEventComponent) event_components.get(i); + LinuxEventComponent event_component = event_components.get(i); Component.Identifier identifier = event_component.getIdentifier(); if(identifier == Component.Identifier.Axis.POV) { @@ -213,7 +199,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException { - List event_components = device.getComponents(); + List event_components = device.getComponents(); Component[] components = createComponents(event_components, device); Controller.Type type = device.getType(); @@ -228,16 +214,16 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } private final Controller[] enumerateControllers() { - List controllers = new ArrayList(); - List eventControllers = new ArrayList(); - List jsControllers = new ArrayList(); + 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); + Controller evController = eventControllers.get(i); + Controller jsController = jsControllers.get(j); // compare // Check if the nodes have the same name @@ -345,13 +331,13 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) { - List components = new ArrayList(); + 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]); + Component.Identifier button_id = LinuxNativeTypesMap.getButtonID(buttonMap[i]); if(button_id != null) { LinuxJoystickButton button = new LinuxJoystickButton(button_id); device.registerButton(i, button); @@ -391,10 +377,10 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } } - return new LinuxJoystickAbstractController(device, (Component[]) components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{}); + return new LinuxJoystickAbstractController(device, components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{}); } - private final void enumerateJoystickControllers(List controllers) { + 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"); @@ -428,39 +414,26 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen } private static String getAbsolutePathPrivileged(final File file) { - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return file.getAbsolutePath(); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> file.getAbsolutePath()); } private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) { - return (File[]) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged((PrivilegedAction) () -> { 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, new Comparator() { - public int compare(Object f1, Object f2) { - return ((File) f1).getName().compareTo(((File) f2).getName()); - } - }); + Arrays.sort(files, Comparator.comparing(File::getName)); } return files; - } }); } - private final void enumerateEventControllers(List controllers) { + 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"); - } - }); + 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++) { @@ -489,7 +462,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen public final void run() { for(int i = 0; i < devices.size(); i++) { try { - LinuxDevice device = (LinuxDevice) devices.get(i); + LinuxDevice device = devices.get(i); device.close(); } catch(IOException e) { log("Failed to close device: " + e.getMessage()); From 91428ceee012ad2aed84bc7289f0e6f4f9c91335 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 18:19:00 +0100 Subject: [PATCH 43/66] Fixed compile warnings --- .../net/java/games/input/RawKeyboard.java | 68 +++++++++---------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/RawKeyboard.java b/plugins/windows/src/main/java/net/java/games/input/RawKeyboard.java index 728284f..61a05ed 100644 --- a/plugins/windows/src/main/java/net/java/games/input/RawKeyboard.java +++ b/plugins/windows/src/main/java/net/java/games/input/RawKeyboard.java @@ -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; import java.io.IOException; @@ -59,7 +53,7 @@ final class RawKeyboard extends Keyboard { } private final static Component[] createKeyboardComponents(RawDevice device) { - List components = new ArrayList(); + List components = new ArrayList<>(); Field[] vkey_fields = RawIdentifierMap.class.getFields(); for (int i = 0; i < vkey_fields.length; i++) { Field vkey_field = vkey_fields[i]; @@ -74,7 +68,7 @@ final class RawKeyboard extends Keyboard { throw new RuntimeException(e); } } - return (Component[])components.toArray(new Component[]{}); + return components.toArray(new Component[]{}); } protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException { From d80d2ad2b20fa385206ef456571d198cddc73f7e Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 18:23:15 +0100 Subject: [PATCH 44/66] Fixed compile warnings --- .../java/net/java/games/input/RawInputEventQueue.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java b/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java index 4ea0306..823f5f5 100644 --- a/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java +++ b/plugins/windows/src/main/java/net/java/games/input/RawInputEventQueue.java @@ -44,9 +44,9 @@ import java.util.HashSet; final class RawInputEventQueue { private final Object monitor = new Object(); - private List devices; + private List devices; - public final void start(List devices) throws IOException { + public final void start(List devices) throws IOException { this.devices = devices; QueueThread queue = new QueueThread(); synchronized (monitor) { @@ -64,7 +64,7 @@ final class RawInputEventQueue { private final RawDevice lookupDevice(long handle) { for (int i = 0; i < devices.size(); i++) { - RawDevice device = (RawDevice)devices.get(i); + RawDevice device = devices.get(i); if (device.getHandle() == handle) return device; } @@ -126,10 +126,10 @@ final class RawInputEventQueue { } if (exception != null) return; - Set active_infos = new HashSet(); + Set active_infos = new HashSet<>(); try { for (int i = 0; i < devices.size(); i++) { - RawDevice device = (RawDevice)devices.get(i); + RawDevice device = devices.get(i); active_infos.add(device.getInfo()); } RawDeviceInfo[] active_infos_array = new RawDeviceInfo[active_infos.size()]; From 4ef9e03623892d092d7658be71fe22359699c9f0 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 18:41:48 +0100 Subject: [PATCH 45/66] Fixed compile warnings --- .../java/net/java/games/input/DataQueue.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/DataQueue.java b/plugins/windows/src/main/java/net/java/games/input/DataQueue.java index 8151d3f..4274699 100644 --- a/plugins/windows/src/main/java/net/java/games/input/DataQueue.java +++ b/plugins/windows/src/main/java/net/java/games/input/DataQueue.java @@ -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. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -38,6 +32,8 @@ *****************************************************************************/ package net.java.games.input; +import java.lang.reflect.InvocationTargetException; + /** * @author elias * @version 1.0 @@ -47,14 +43,12 @@ final class DataQueue { private int position; private int limit; - public DataQueue(int size, Class element_type) { + public DataQueue(int size, Class element_type) { this.elements= new Object[size]; for (int i = 0; i < elements.length; i++) { try { - elements[i] = element_type.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { + elements[i] = element_type.getDeclaredConstructor().newInstance(); + } catch (InstantiationException|IllegalAccessException|NoSuchMethodException|InvocationTargetException e) { throw new RuntimeException(e); } } From 59c21d42c52d266000e74ffbb2bf5e46197d7272 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 19:09:03 +0100 Subject: [PATCH 46/66] Fixed compile warnings --- .../java/net/java/games/input/DataQueue.java | 18 ++++---- .../java/games/input/IDirectInputDevice.java | 41 ++++++++----------- .../java/net/java/games/input/RawDevice.java | 32 +++++++-------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/DataQueue.java b/plugins/windows/src/main/java/net/java/games/input/DataQueue.java index 4274699..a530bc6 100644 --- a/plugins/windows/src/main/java/net/java/games/input/DataQueue.java +++ b/plugins/windows/src/main/java/net/java/games/input/DataQueue.java @@ -32,19 +32,21 @@ *****************************************************************************/ package net.java.games.input; +import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; /** * @author elias * @version 1.0 */ -final class DataQueue { - private final Object[] elements; +final class DataQueue { + private final T[] elements; private int position; private int limit; - public DataQueue(int size, Class element_type) { - this.elements= new Object[size]; + @SuppressWarnings("unchecked") + public DataQueue(int size, Class element_type) { + this.elements= (T[])Array.newInstance(element_type, size); for (int i = 0; i < elements.length; i++) { try { elements[i] = element_type.getDeclaredConstructor().newInstance(); @@ -68,12 +70,12 @@ final class DataQueue { return limit; } - public final Object get(int index) { + public final T get(int index) { assert index < limit; return elements[index]; } - public final Object get() { + public final T get() { if (!hasRemaining()) return null; return get(position++); @@ -91,7 +93,7 @@ final class DataQueue { } private final void swap(int index1, int index2) { - Object temp = elements[index1]; + T temp = elements[index1]; elements[index1] = elements[index2]; elements[index2] = temp; } @@ -113,7 +115,7 @@ final class DataQueue { this.position = position; } - public final Object[] getElements() { + public final T[] getElements() { return elements; } } diff --git a/plugins/windows/src/main/java/net/java/games/input/IDirectInputDevice.java b/plugins/windows/src/main/java/net/java/games/input/IDirectInputDevice.java index 928f398..3fb29f7 100644 --- a/plugins/windows/src/main/java/net/java/games/input/IDirectInputDevice.java +++ b/plugins/windows/src/main/java/net/java/games/input/IDirectInputDevice.java @@ -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. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -201,16 +195,16 @@ final class IDirectInputDevice { private final int dev_subtype; private final String instance_name; private final String product_name; - private final List objects = new ArrayList(); - private final List effects = new ArrayList(); - private final List rumblers = new ArrayList(); + private final List objects = new ArrayList<>(); + private final List effects = new ArrayList<>(); + private final List rumblers = new ArrayList<>(); private final int[] device_state; - private final Map object_to_component = new HashMap(); + private final Map object_to_component = new HashMap<>(); private final boolean axes_in_relative_mode; private boolean released; - private DataQueue queue; + private DataQueue queue; private int button_counter; private int current_format_offset; @@ -242,7 +236,7 @@ final class IDirectInputDevice { boolean all_relative = true; boolean has_axis = false; for (int i = 0; i < objects.size(); i++) { - DIDeviceObject obj = (DIDeviceObject)objects.get(i); + DIDeviceObject obj = objects.get(i); if (obj.isAxis()) { has_axis = true; if (!obj.isRelative()) { @@ -272,10 +266,10 @@ final class IDirectInputDevice { } public final Rumbler[] getRumblers() { - return (Rumbler[])rumblers.toArray(new Rumbler[]{}); + return rumblers.toArray(new Rumbler[]{}); } - private final List createRumblers() throws IOException { + private final List createRumblers() throws IOException { DIDeviceObject x_axis = lookupObjectByGUID(GUID_XAxis); // DIDeviceObject y_axis = lookupObjectByGUID(GUID_YAxis); if(x_axis == null/* || y_axis == null*/) @@ -283,7 +277,7 @@ final class IDirectInputDevice { DIDeviceObject[] axes = {x_axis/*, y_axis*/}; long[] directions = {0/*, 0*/}; for (int i = 0; i < effects.size(); i++) { - DIEffectInfo info = (DIEffectInfo)effects.get(i); + DIEffectInfo info = effects.get(i); if ((info.getEffectType() & 0xff) == DIEFT_PERIODIC && (info.getDynamicParams() & DIEP_GAIN) != 0) { rumblers.add(createPeriodicRumbler(axes, directions, info)); @@ -304,7 +298,7 @@ final class IDirectInputDevice { private final DIDeviceObject lookupObjectByGUID(int guid_id) { for (int i = 0; i < objects.size(); i++) { - DIDeviceObject object = (DIDeviceObject)objects.get(i); + DIDeviceObject object = objects.get(i); if (guid_id == object.getGUIDType()) return object; } @@ -321,11 +315,11 @@ final class IDirectInputDevice { * for the int size (4 bytes) */ int format_offset = event.getFormatOffset()/4; - return (DIDeviceObject)objects.get(format_offset); + return objects.get(format_offset); } public final DIComponent mapObject(DIDeviceObject object) { - return (DIComponent)object_to_component.get(object); + return object_to_component.get(object); } public final void registerComponent(DIDeviceObject object, DIComponent component) { @@ -342,7 +336,7 @@ final class IDirectInputDevice { } public synchronized final boolean getNextEvent(DIDeviceObjectData data) { - DIDeviceObjectData next_event = (DIDeviceObjectData)queue.get(); + DIDeviceObjectData next_event = queue.get(); if (next_event == null) return false; data.set(next_event); @@ -375,7 +369,7 @@ final class IDirectInputDevice { } private final static native int nUnacquire(long address); - private final boolean getDeviceData(DataQueue queue) throws IOException { + private final boolean getDeviceData(DataQueue queue) throws IOException { int res = nGetDeviceData(address, 0, queue, queue.getElements(), queue.position(), queue.remaining()); if (res != DI_OK && res != DI_BUFFEROVERFLOW) { if (res == DIERR_NOTACQUIRED) { @@ -386,7 +380,7 @@ final class IDirectInputDevice { } return true; } - private final static native int nGetDeviceData(long address, int flags, DataQueue queue, Object[] queue_elements, int position, int remaining); + private final static native int nGetDeviceData(long address, int flags, DataQueue queue, Object[] queue_elements, int position, int remaining); private final void getDeviceState(int[] device_state) throws IOException { int res = nGetDeviceState(address, device_state); @@ -420,7 +414,7 @@ final class IDirectInputDevice { return dev_type; } - public final List getObjects() { + public final List getObjects() { return objects; } @@ -509,7 +503,7 @@ final class IDirectInputDevice { int res = nSetBufferSize(address, size); if (res != DI_OK && res != DI_PROPNOEFFECT && res != DI_POLLEDDEVICE) throw new IOException("Failed to set buffer size (" + Integer.toHexString(res) + ")"); - queue = new DataQueue(size, DIDeviceObjectData.class); + queue = new DataQueue<>(size, DIDeviceObjectData.class); queue.position(queue.limit()); acquire(); } @@ -540,6 +534,7 @@ final class IDirectInputDevice { throw new IOException("Device is released"); } + @SuppressWarnings("deprecation") protected void finalize() { release(); } diff --git a/plugins/windows/src/main/java/net/java/games/input/RawDevice.java b/plugins/windows/src/main/java/net/java/games/input/RawDevice.java index 4841234..c7b0696 100644 --- a/plugins/windows/src/main/java/net/java/games/input/RawDevice.java +++ b/plugins/windows/src/main/java/net/java/games/input/RawDevice.java @@ -89,12 +89,12 @@ final class RawDevice { private final int type; /* Events from the event queue thread end here */ - private DataQueue keyboard_events; - private DataQueue mouse_events; + private DataQueue keyboard_events; + private DataQueue mouse_events; /* After processing in poll*(), the events are placed here */ - private DataQueue processed_keyboard_events; - private DataQueue processed_mouse_events; + private DataQueue processed_keyboard_events; + private DataQueue processed_mouse_events; /* mouse state */ private final boolean[] button_states = new boolean[5]; @@ -123,7 +123,7 @@ final class RawDevice { /* Careful, this is called from the event queue thread */ public final synchronized void addMouseEvent(long millis, int flags, int button_flags, int button_data, long raw_buttons, long last_x, long last_y, long extra_information) { if (mouse_events.hasRemaining()) { - RawMouseEvent event = (RawMouseEvent)mouse_events.get(); + RawMouseEvent event = mouse_events.get(); event.set(millis, flags, button_flags, button_data, raw_buttons, last_x, last_y, extra_information); } } @@ -131,7 +131,7 @@ final class RawDevice { /* Careful, this is called from the event queue thread */ public final synchronized void addKeyboardEvent(long millis, int make_code, int flags, int vkey, int message, long extra_information) { if (keyboard_events.hasRemaining()) { - RawKeyboardEvent event = (RawKeyboardEvent)keyboard_events.get(); + RawKeyboardEvent event = keyboard_events.get(); event.set(millis, make_code, flags, vkey, message, extra_information); } } @@ -140,10 +140,10 @@ final class RawDevice { relative_x = relative_y = wheel = 0; mouse_events.flip(); while (mouse_events.hasRemaining()) { - RawMouseEvent event = (RawMouseEvent)mouse_events.get(); + RawMouseEvent event = mouse_events.get(); boolean has_update = processMouseEvent(event); if (has_update && processed_mouse_events.hasRemaining()) { - RawMouseEvent processed_event = (RawMouseEvent)processed_mouse_events.get(); + RawMouseEvent processed_event = processed_mouse_events.get(); processed_event.set(event); } } @@ -153,10 +153,10 @@ final class RawDevice { public final synchronized void pollKeyboard() { keyboard_events.flip(); while (keyboard_events.hasRemaining()) { - RawKeyboardEvent event = (RawKeyboardEvent)keyboard_events.get(); + RawKeyboardEvent event = keyboard_events.get(); boolean has_update = processKeyboardEvent(event); if (has_update && processed_keyboard_events.hasRemaining()) { - RawKeyboardEvent processed_event = (RawKeyboardEvent)processed_keyboard_events.get(); + RawKeyboardEvent processed_event = processed_keyboard_events.get(); processed_event.set(event); } } @@ -250,7 +250,7 @@ final class RawDevice { processed_keyboard_events.compact(); return false; } - RawKeyboardEvent next_event = (RawKeyboardEvent)processed_keyboard_events.get(); + RawKeyboardEvent next_event = processed_keyboard_events.get(); event.set(next_event); processed_keyboard_events.compact(); return true; @@ -262,7 +262,7 @@ final class RawDevice { processed_mouse_events.compact(); return false; } - RawMouseEvent next_event = (RawMouseEvent)processed_mouse_events.get(); + RawMouseEvent next_event = processed_mouse_events.get(); if ((next_event.getFlags() & MOUSE_MOVE_ABSOLUTE) != 0) { event_relative_x = next_event.getLastX() - event_last_x; event_relative_y = next_event.getLastY() - event_last_y; @@ -284,10 +284,10 @@ final class RawDevice { } public final void setBufferSize(int size) { - keyboard_events = new DataQueue(size, RawKeyboardEvent.class); - mouse_events = new DataQueue(size, RawMouseEvent.class); - processed_keyboard_events = new DataQueue(size, RawKeyboardEvent.class); - processed_mouse_events = new DataQueue(size, RawMouseEvent.class); + keyboard_events = new DataQueue<>(size, RawKeyboardEvent.class); + mouse_events = new DataQueue<>(size, RawMouseEvent.class); + processed_keyboard_events = new DataQueue<>(size, RawKeyboardEvent.class); + processed_mouse_events = new DataQueue<>(size, RawMouseEvent.class); } public final int getType() { From a19b3c9fa317299264d763c95e7bc11b7c218f3f Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 19:11:46 +0100 Subject: [PATCH 47/66] Fixed compile warnings --- .../src/main/java/net/java/games/input/IDirectInput.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/IDirectInput.java b/plugins/windows/src/main/java/net/java/games/input/IDirectInput.java index c211261..e8c929b 100644 --- a/plugins/windows/src/main/java/net/java/games/input/IDirectInput.java +++ b/plugins/windows/src/main/java/net/java/games/input/IDirectInput.java @@ -48,7 +48,7 @@ import java.util.ArrayList; * @version 1.0 */ final class IDirectInput { - private final List devices = new ArrayList(); + private final List devices = new ArrayList<>(); private final long idirectinput_address; private final DummyWindow window; @@ -65,7 +65,7 @@ final class IDirectInput { } private final static native long createIDirectInput() throws IOException; - public final List getDevices() { + public final List getDevices() { return devices; } @@ -88,7 +88,7 @@ final class IDirectInput { public final void releaseDevices() { for (int i = 0; i < devices.size(); i++) { - IDirectInputDevice device = (IDirectInputDevice)devices.get(i); + IDirectInputDevice device = devices.get(i); device.release(); } } From 30304ba8f467f9fb127e05b626a046cce8df4fdb Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 19:18:31 +0100 Subject: [PATCH 48/66] Fixed compile warnings --- .../input/DirectInputEnvironmentPlugin.java | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/DirectInputEnvironmentPlugin.java b/plugins/windows/src/main/java/net/java/games/input/DirectInputEnvironmentPlugin.java index 65b5a73..ed507f9 100644 --- a/plugins/windows/src/main/java/net/java/games/input/DirectInputEnvironmentPlugin.java +++ b/plugins/windows/src/main/java/net/java/games/input/DirectInputEnvironmentPlugin.java @@ -64,10 +64,8 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { - try { + AccessController.doPrivileged((PrivilegedAction) () -> { + try { String lib_path = System.getProperty("net.java.games.input.librarypath"); if (lib_path != null) System.load(lib_path + File.separator + System.mapLibraryName(lib_name)); @@ -78,25 +76,16 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im supported = false; } return null; - } }); } static String getPrivilegedProperty(final String property) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property, default_value)); } static { @@ -112,7 +101,7 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im } private final Controller[] controllers; - private final List active_devices = new ArrayList(); + private final List active_devices = new ArrayList<>(); private final DummyWindow window; /** Creates new DirectInputEnvironment */ @@ -133,12 +122,9 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im } this.window = window; this.controllers = controllers; - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { Runtime.getRuntime().addShutdownHook(new ShutdownHook()); return null; - } }); } else { // These are final fields, so can't set them, then over ride @@ -153,10 +139,10 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im } private final Component[] createComponents(IDirectInputDevice device, boolean map_mouse_buttons) { - List device_objects = device.getObjects(); - List controller_components = new ArrayList(); + List device_objects = device.getObjects(); + List controller_components = new ArrayList<>(); for (int i = 0; i < device_objects.size(); i++) { - DIDeviceObject device_object = (DIDeviceObject)device_objects.get(i); + DIDeviceObject device_object = device_objects.get(i); Component.Identifier identifier = device_object.getIdentifier(); if (identifier == null) continue; @@ -214,12 +200,12 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im } private final Controller[] enumControllers(DummyWindow window) throws IOException { - List controllers = new ArrayList(); + List controllers = new ArrayList<>(); IDirectInput dinput = new IDirectInput(window); try { - List devices = dinput.getDevices(); + List devices = dinput.getDevices(); for (int i = 0; i < devices.size(); i++) { - IDirectInputDevice device = (IDirectInputDevice)devices.get(i); + IDirectInputDevice device = devices.get(i); Controller controller = createControllerFromDevice(device); if (controller != null) { controllers.add(controller); @@ -239,7 +225,7 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im public final void run() { /* Release the devices to kill off active force feedback effects */ for (int i = 0; i < active_devices.size(); i++) { - IDirectInputDevice device = (IDirectInputDevice)active_devices.get(i); + IDirectInputDevice device = active_devices.get(i); device.release(); } /* We won't release the window since it is @@ -251,4 +237,4 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im public boolean isSupported() { return supported; } -} // class DirectInputEnvironment +} \ No newline at end of file From b87aa830e8533538f3fcfd422ddf74a13b6d64bf Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 19:20:42 +0100 Subject: [PATCH 49/66] Fixed compile warnings --- .../src/main/java/net/java/games/input/IDirectInputEffect.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/IDirectInputEffect.java b/plugins/windows/src/main/java/net/java/games/input/IDirectInputEffect.java index 4f098ff..77de468 100644 --- a/plugins/windows/src/main/java/net/java/games/input/IDirectInputEffect.java +++ b/plugins/windows/src/main/java/net/java/games/input/IDirectInputEffect.java @@ -58,7 +58,7 @@ final class IDirectInputEffect implements Rumbler { try { checkReleased(); if (intensity > 0) { - int int_gain = (int)Math.round(intensity*IDirectInputDevice.DI_FFNOMINALMAX); + int int_gain = Math.round(intensity*IDirectInputDevice.DI_FFNOMINALMAX); setGain(int_gain); start(1, 0); } else @@ -115,6 +115,7 @@ final class IDirectInputEffect implements Rumbler { } private final static native int nStop(long address); + @SuppressWarnings("deprecation") protected void finalize() { release(); } From 981587abbc2bf290284812bb28984f4929cf0af1 Mon Sep 17 00:00:00 2001 From: Endolf Date: Wed, 30 May 2018 19:22:39 +0100 Subject: [PATCH 50/66] Fixed compile warnings --- .../java/games/input/DirectAndRawInputEnvironmentPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/windows/src/main/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java b/plugins/windows/src/main/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java index c789986..29b6c07 100644 --- a/plugins/windows/src/main/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java +++ b/plugins/windows/src/main/java/net/java/games/input/DirectAndRawInputEnvironmentPlugin.java @@ -53,7 +53,7 @@ public class DirectAndRawInputEnvironmentPlugin extends ControllerEnvironment { if(controllers == null) { boolean rawKeyboardFound = false; boolean rawMouseFound = false; - List tempControllers = new ArrayList(); + List tempControllers = new ArrayList<>(); Controller[] dinputControllers = dinputPlugin.getControllers(); Controller[] rawControllers = rawPlugin.getControllers(); for(int i=0;i Date: Thu, 31 May 2018 19:09:13 +0100 Subject: [PATCH 51/66] Fixed compile warnings --- .../net/java/games/input/ButtonUsage.java | 64 ++++++++--------- .../java/games/input/GenericDesktopUsage.java | 64 ++++++++--------- .../net/java/games/input/KeyboardUsage.java | 67 ++++++++--------- .../net/java/games/input/OSXHIDDevice.java | 56 +++++---------- .../main/java/net/java/games/input/Usage.java | 64 ++++++++--------- .../java/net/java/games/input/UsagePage.java | 72 +++++++++---------- 6 files changed, 167 insertions(+), 220 deletions(-) diff --git a/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java b/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java index d83dcb8..9b58e75 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java @@ -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; import java.util.Map; diff --git a/plugins/OSX/src/main/java/net/java/games/input/GenericDesktopUsage.java b/plugins/OSX/src/main/java/net/java/games/input/GenericDesktopUsage.java index 4c45fa4..4049d68 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/GenericDesktopUsage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/GenericDesktopUsage.java @@ -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; /** Generic Desktop Usages diff --git a/plugins/OSX/src/main/java/net/java/games/input/KeyboardUsage.java b/plugins/OSX/src/main/java/net/java/games/input/KeyboardUsage.java index 7621032..30f2383 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/KeyboardUsage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/KeyboardUsage.java @@ -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; -import java.util.Map; -import java.util.HashMap; - /** Mapping from Keyboard HID usages to Component.Identifier.Key * @author elias * @version 1.0 diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java index 40024c3..caaeef2 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java @@ -104,7 +104,7 @@ final class OSXHIDDevice { private final long device_address; private final long device_interface_address; - private final Map properties; + private final Map properties; private boolean released; @@ -130,7 +130,7 @@ final class OSXHIDDevice { return (String)properties.get(kIOHIDProductKey); } - private final OSXHIDElement createElementFromElementProperties(Map element_properties) { + private final OSXHIDElement createElementFromElementProperties(Map element_properties) { /* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey); // ignore elements that can't fit into the 32 bit value field of a hid event if (size > 32) @@ -161,12 +161,13 @@ final class OSXHIDDevice { } } - private final void addElements(List elements, Map properties) { + @SuppressWarnings("unchecked") + private final void addElements(List elements, Map properties) { Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey); if (elements_properties == null) return; for (int i = 0; i < elements_properties.length; i++) { - Map element_properties = (Map)elements_properties[i]; + Map element_properties = (Map)elements_properties[i]; OSXHIDElement element = createElementFromElementProperties(element_properties); if (element != null) { elements.add(element); @@ -175,28 +176,28 @@ final class OSXHIDDevice { } } - public final List getElements() { - List elements = new ArrayList(); + public final List getElements() { + List elements = new ArrayList<>(); addElements(elements, properties); return elements; } - private final static long getLongFromProperties(Map properties, String key, long default_value) { + private final static long getLongFromProperties(Map properties, String key, long default_value) { Long long_obj = (Long)properties.get(key); if (long_obj == null) return default_value; return long_obj.longValue(); } - private final static boolean getBooleanFromProperties(Map properties, String key, boolean default_value) { + private final static boolean getBooleanFromProperties(Map properties, String key, boolean default_value) { return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0; } - private final static int getIntFromProperties(Map properties, String key) { + private final static int getIntFromProperties(Map properties, String key) { return (int)getLongFromProperties(properties, key); } - private final static long getLongFromProperties(Map properties, String key) { + private final static long getLongFromProperties(Map properties, String key) { Long long_obj = (Long)properties.get(key); return long_obj.longValue(); } @@ -217,28 +218,6 @@ final class OSXHIDDevice { 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() { log.info(toString()); dumpMap("", properties); @@ -253,8 +232,8 @@ final class OSXHIDDevice { log.info(prefix + "}"); } - private final static void dumpMap(String prefix, Map map) { - Iterator keys = map.keySet().iterator(); + private final static void dumpMap(String prefix, Map map) { + Iterator keys = map.keySet().iterator(); while (keys.hasNext()) { Object key = keys.next(); Object value = map.get(key); @@ -262,23 +241,24 @@ final class OSXHIDDevice { dumpObject(prefix + "\t", value); } } - + + @SuppressWarnings("unchecked") private final static void dumpObject(String prefix, Object obj) { if (obj instanceof Long) { Long l = (Long)obj; log.info(prefix + "0x" + Long.toHexString(l.longValue())); } else if (obj instanceof Map) - dumpMap(prefix, (Map)obj); + dumpMap(prefix, (Map)obj); else if (obj.getClass().isArray()) dumpArray(prefix, (Object[])obj); else log.info(prefix + obj); } - private final Map getDeviceProperties() throws IOException { + private final Map getDeviceProperties() throws IOException { return nGetDeviceProperties(device_address); } - private final static native Map nGetDeviceProperties(long device_address) throws IOException; + private final static native Map nGetDeviceProperties(long device_address) throws IOException; public final synchronized void release() throws IOException { try { diff --git a/plugins/OSX/src/main/java/net/java/games/input/Usage.java b/plugins/OSX/src/main/java/net/java/games/input/Usage.java index 8b79b3a..356ee94 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/Usage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/Usage.java @@ -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; /** Generic Desktop Usages diff --git a/plugins/OSX/src/main/java/net/java/games/input/UsagePage.java b/plugins/OSX/src/main/java/net/java/games/input/UsagePage.java index bd50eab..59e0b9b 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/UsagePage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/UsagePage.java @@ -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; import java.lang.reflect.Method; @@ -77,7 +71,7 @@ final class UsagePage { /* ReservedPointofSalepages 0x8E - 0X8F */ 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 */ - private final Class usage_class; + private final Class usage_class; private final int usage_page_id; public final static UsagePage map(int page_id) { @@ -86,7 +80,7 @@ final class UsagePage { return map[page_id]; } - private UsagePage(int page_id, Class usage_class) { + private UsagePage(int page_id, Class usage_class) { map[page_id] = this; this.usage_class = usage_class; this.usage_page_id = page_id; @@ -104,8 +98,8 @@ final class UsagePage { if (usage_class == null) return null; try { - Method map_method = usage_class.getMethod("map", new Class[]{int.class}); - Object result = map_method.invoke(null, new Object[]{new Integer(usage_id)}); + Method map_method = usage_class.getMethod("map", int.class); + Object result = map_method.invoke(null, usage_id); return (Usage)result; } catch (Exception e) { throw new Error(e); From 88395eef770918c41236aaf750adb759aff1d905 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:15:35 +0100 Subject: [PATCH 52/66] Fixed compile warnings --- .../src/main/java/net/java/games/input/OSXHIDQueue.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java index 884c76a..79dd89e 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java @@ -47,7 +47,7 @@ import java.util.HashMap; * @version 1.0 */ final class OSXHIDQueue { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); private final long queue_address; private boolean released; @@ -80,7 +80,7 @@ final class OSXHIDQueue { } 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 { @@ -118,13 +118,13 @@ final class OSXHIDQueue { public final void addElement(OSXHIDElement element, OSXComponent component) throws IOException { 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; public final void removeElement(OSXHIDElement element) throws IOException { 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; From 7d3e5f31ae094effde0c7ddae64554aa1146f1f2 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:27:48 +0100 Subject: [PATCH 53/66] Fixed compile warnings --- .../games/input/OSXEnvironmentPlugin.java | 63 +++++++------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java index 38f59b8..f546de3 100755 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java @@ -67,9 +67,7 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { try { String lib_path = System.getProperty("net.java.games.input.librarypath"); if (lib_path != null) @@ -81,25 +79,16 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements supported = false; } return null; - } }); } static String getPrivilegedProperty(final String property) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); + return AccessController.doPrivileged((PrivilegedAction)() -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction)() -> System.getProperty(property, default_value)); } static { @@ -147,10 +136,10 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements return supported; } - private final static void addElements(OSXHIDQueue queue, List elements, List components, boolean map_mouse_buttons) throws IOException { - Iterator it = elements.iterator(); + private final static void addElements(OSXHIDQueue queue, List elements, List components, boolean map_mouse_buttons) throws IOException { + Iterator it = elements.iterator(); while (it.hasNext()) { - OSXHIDElement element = (OSXHIDElement)it.next(); + OSXHIDElement element = it.next(); Component.Identifier id = element.getIdentifier(); if (id == null) continue; @@ -169,8 +158,8 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements } } - private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List elements) throws IOException { - List components = new ArrayList(); + private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List elements) throws IOException { + List components = new ArrayList<>(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, false); @@ -180,12 +169,11 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements } Component[] components_array = new Component[components.size()]; components.toArray(components_array); - Keyboard keyboard = new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{}); - return keyboard; + return new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{}); } - private final static Mouse createMouseFromDevice(OSXHIDDevice device, List elements) throws IOException { - List components = new ArrayList(); + private final static Mouse createMouseFromDevice(OSXHIDDevice device, List elements) throws IOException { + List components = new ArrayList<>(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, true); @@ -204,8 +192,8 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements } } - private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List elements, Controller.Type type) throws IOException { - List components = new ArrayList(); + private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List elements, Controller.Type type) throws IOException { + List components = new ArrayList<>(); OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH); try { addElements(queue, elements, components, false); @@ -215,15 +203,14 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements } Component[] components_array = new Component[components.size()]; components.toArray(components_array); - AbstractController controller = new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type); - return controller; + return new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type); } - private final static void createControllersFromDevice(OSXHIDDevice device, List controllers) throws IOException { + private final static void createControllersFromDevice(OSXHIDDevice device, List controllers) throws IOException { UsagePair usage_pair = device.getUsagePair(); if (usage_pair == null) return; - List elements = device.getElements(); + List elements = device.getElements(); if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.MOUSE || usage_pair.getUsage() == GenericDesktopUsage.POINTER)) { Controller mouse = createMouseFromDevice(device, elements); @@ -231,26 +218,18 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements controllers.add(mouse); } else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.KEYBOARD || usage_pair.getUsage() == GenericDesktopUsage.KEYPAD)) { - Controller keyboard = createKeyboardFromDevice(device, elements); - if (keyboard != null) - controllers.add(keyboard); + controllers.add(createKeyboardFromDevice(device, elements)); } else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.JOYSTICK) { - Controller joystick = createControllerFromDevice(device, elements, Controller.Type.STICK); - if (joystick != null) - controllers.add(joystick); + controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK)); } else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.MULTI_AXIS_CONTROLLER) { - Controller multiaxis = createControllerFromDevice(device, elements, Controller.Type.STICK); - if (multiaxis != null) - controllers.add(multiaxis); + controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK)); } else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.GAME_PAD) { - Controller game_pad = createControllerFromDevice(device, elements, Controller.Type.GAMEPAD); - if (game_pad != null) - controllers.add(game_pad); + controllers.add(createControllerFromDevice(device, elements, Controller.Type.GAMEPAD)); } } private final static Controller[] enumerateControllers() { - List controllers = new ArrayList(); + List controllers = new ArrayList<>(); try { OSXHIDDeviceIterator it = new OSXHIDDeviceIterator(); try { From 83dd362c6510f9b6b5357aceb04e4a8b5e09fecf Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:28:49 +0100 Subject: [PATCH 54/66] Fix license --- .../games/input/OSXEnvironmentPlugin.java | 64 +++++++++---------- .../net/java/games/input/OSXHIDDevice.java | 64 +++++++++---------- .../net/java/games/input/OSXHIDQueue.java | 64 +++++++++---------- 3 files changed, 87 insertions(+), 105 deletions(-) diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java index f546de3..2278313 100755 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXEnvironmentPlugin.java @@ -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; import java.io.File; diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java index caaeef2..7ac4831 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDDevice.java @@ -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; import java.io.IOException; diff --git a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java index 79dd89e..f97cf6a 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java +++ b/plugins/OSX/src/main/java/net/java/games/input/OSXHIDQueue.java @@ -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; import java.io.IOException; From ad452077d406f3568c5db362daccb84c9fdaf3c1 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:31:37 +0100 Subject: [PATCH 55/66] Fixed compile warnings --- .../OSX/src/main/java/net/java/games/input/ButtonUsage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java b/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java index 9b58e75..8114805 100644 --- a/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java +++ b/plugins/OSX/src/main/java/net/java/games/input/ButtonUsage.java @@ -40,13 +40,13 @@ import java.util.HashMap; * @version 1.0 */ final class ButtonUsage implements Usage { - private final static Map map = new HashMap(); + private final static Map map = new HashMap<>(); private final int button_id; public final static ButtonUsage map(int button_id) { - Integer button_id_obj = new Integer(button_id); - ButtonUsage existing = (ButtonUsage)map.get(button_id_obj); + Integer button_id_obj = button_id; + ButtonUsage existing = map.get(button_id_obj); if (existing != null) return existing; ButtonUsage new_button = new ButtonUsage(button_id); From c77ad3226c8e47d691189368e73d83c5c9a9e639 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:39:58 +0100 Subject: [PATCH 56/66] Fixed compile warnings --- .../net/java/games/input/WinTabComponent.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/plugins/wintab/src/main/java/net/java/games/input/WinTabComponent.java b/plugins/wintab/src/main/java/net/java/games/input/WinTabComponent.java index 03bea98..a4c2ad9 100644 --- a/plugins/wintab/src/main/java/net/java/games/input/WinTabComponent.java +++ b/plugins/wintab/src/main/java/net/java/games/input/WinTabComponent.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -65,8 +65,8 @@ public class WinTabComponent extends AbstractComponent { return false; } - public static List createComponents(WinTabContext context, int parentDevice, int axisId, int[] axisRanges) { - List components = new ArrayList(); + public static List createComponents(WinTabContext context, int parentDevice, int axisId, int[] axisRanges) { + List components = new ArrayList<>(); Identifier id; switch(axisId) { case WinTabDevice.XAxis: @@ -110,26 +110,17 @@ public class WinTabComponent extends AbstractComponent { return components; } - public static Collection createButtons(WinTabContext context, int deviceIndex, int numberOfButtons) { - List buttons = new ArrayList(); + public static Collection createButtons(WinTabContext context, int deviceIndex, int numberOfButtons) { + List buttons = new ArrayList<>(); Identifier id; for(int i=0;i buttonIdClass = Identifier.Button.class; Field idField = buttonIdClass.getField("_" + i); id = (Identifier)idField.get(null); buttons.add(new WinTabButtonComponent(context, deviceIndex, id.getName(), id, i)); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchFieldException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (SecurityException|NoSuchFieldException|IllegalArgumentException|IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -184,9 +175,9 @@ public class WinTabComponent extends AbstractComponent { return (value - min)/bottom; } - public static Collection createCursors(WinTabContext context, int deviceIndex, String[] cursorNames) { + public static Collection createCursors(WinTabContext context, int deviceIndex, String[] cursorNames) { Identifier id; - List cursors = new ArrayList(); + List cursors = new ArrayList<>(); for(int i=0;i Date: Thu, 31 May 2018 19:42:43 +0100 Subject: [PATCH 57/66] Fixed compile warnings --- .../main/java/net/java/games/input/WinTabContext.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/wintab/src/main/java/net/java/games/input/WinTabContext.java b/plugins/wintab/src/main/java/net/java/games/input/WinTabContext.java index c774c0f..987f4a6 100644 --- a/plugins/wintab/src/main/java/net/java/games/input/WinTabContext.java +++ b/plugins/wintab/src/main/java/net/java/games/input/WinTabContext.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -47,17 +47,14 @@ public class WinTabContext { public synchronized void open() { this.hCTX = nOpen(window.getHwnd()); - List devices = new ArrayList(); + List devices = new ArrayList<>(); int numSupportedDevices = nGetNumberOfSupportedDevices(); for(int i=0;i Date: Thu, 31 May 2018 19:54:41 +0100 Subject: [PATCH 58/66] Fixed compile warnings --- .../games/input/WinTabEnvironmentPlugin.java | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/plugins/wintab/src/main/java/net/java/games/input/WinTabEnvironmentPlugin.java b/plugins/wintab/src/main/java/net/java/games/input/WinTabEnvironmentPlugin.java index 2a0d140..aa0c839 100644 --- a/plugins/wintab/src/main/java/net/java/games/input/WinTabEnvironmentPlugin.java +++ b/plugins/wintab/src/main/java/net/java/games/input/WinTabEnvironmentPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -44,9 +44,7 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl * */ static void loadLibrary(final String lib_name) { - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction) () -> { try { String lib_path = System.getProperty("net.java.games.input.librarypath"); if (lib_path != null) @@ -58,25 +56,16 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl supported = false; } return null; - } }); } - + static String getPrivilegedProperty(final String property) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property); - } - }); - } - + return AccessController.doPrivileged((PrivilegedAction)() -> 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); - } - }); + return AccessController.doPrivileged((PrivilegedAction)() -> System.getProperty(property, default_value)); } static { @@ -88,13 +77,13 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl } private final Controller[] controllers; - private final List active_devices = new ArrayList(); + private final List active_devices = new ArrayList<>(); private final WinTabContext winTabContext; /** Creates new DirectInputEnvironment */ public WinTabEnvironmentPlugin() { if(isSupported()) { - DummyWindow window = null; + DummyWindow window; WinTabContext winTabContext = null; Controller[] controllers = new Controller[]{}; try { @@ -113,12 +102,9 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl } this.controllers = controllers; this.winTabContext = winTabContext; - AccessController.doPrivileged( - new PrivilegedAction() { - public final Object run() { + AccessController.doPrivileged((PrivilegedAction)() -> { Runtime.getRuntime().addShutdownHook(new ShutdownHook()); return null; - } }); } else { winTabContext = null; From af914ca5e49fe8962e670ee21c79be7c7cbcd15d Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 19:57:36 +0100 Subject: [PATCH 59/66] Fixed compile warnings --- .../main/java/net/java/games/input/WinTabDevice.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/wintab/src/main/java/net/java/games/input/WinTabDevice.java b/plugins/wintab/src/main/java/net/java/games/input/WinTabDevice.java index 9b7ee72..b528b73 100644 --- a/plugins/wintab/src/main/java/net/java/games/input/WinTabDevice.java +++ b/plugins/wintab/src/main/java/net/java/games/input/WinTabDevice.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com) * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ public class WinTabDevice extends AbstractController { public final static int RotationAxis = 7; private WinTabContext context; - private List eventList = new ArrayList(); + private List eventList = new ArrayList<>(); private WinTabDevice(WinTabContext context, int index, String name, Component[] components) { super(name, components, new Controller[0], new Rumbler[0]); @@ -48,7 +48,7 @@ public class WinTabDevice extends AbstractController { protected boolean getNextDeviceEvent(Event event) throws IOException { if(eventList.size()>0) { - Event ourEvent = (Event)eventList.remove(0); + Event ourEvent = eventList.remove(0); event.set(ourEvent); return true; } else { @@ -80,7 +80,7 @@ public class WinTabDevice extends AbstractController { public static WinTabDevice createDevice(WinTabContext context, int deviceIndex) { String name = nGetName(deviceIndex); WinTabEnvironmentPlugin.log("Device " + deviceIndex + ", name: " + name); - List componentsList = new ArrayList(); + List componentsList = new ArrayList<>(); int[] axisDetails = nGetAxisDetails(deviceIndex, XAxis); if(axisDetails.length==0) { @@ -148,7 +148,7 @@ public class WinTabDevice extends AbstractController { WinTabEnvironmentPlugin.log("Device has " + numberOfButtons + " buttons"); componentsList.addAll(WinTabComponent.createButtons(context, deviceIndex, numberOfButtons)); - Component[] components = (Component[])componentsList.toArray(new Component[0]); + Component[] components = componentsList.toArray(new Component[0]); return new WinTabDevice(context, deviceIndex, name, components); } From 67902800abf58554ea4836ad99c64c077bb56a83 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 20:16:51 +0100 Subject: [PATCH 60/66] Fixed compile warnings --- .../net/java/games/input/applet/ControllerEventTestApplet.java | 1 + .../net/java/games/input/applet/ControllerReadTestApplet.java | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java index 9f82bea..4591129 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java @@ -30,6 +30,7 @@ import java.io.IOException; import net.java.games.input.ControllerEventTest; +@SuppressWarnings("deprecation") public class ControllerEventTestApplet extends Applet { private static final long serialVersionUID = 4250817143444220400L; diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java index 2f9824a..798f6ee 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java @@ -30,6 +30,7 @@ import java.io.IOException; import net.java.games.input.ControllerReadTest; +@SuppressWarnings("deprecation") public class ControllerReadTestApplet extends Applet { private static final long serialVersionUID = -2558493887683964119L; From 466e4a6bdb75e6d23f39566419e67b5ca4ce027e Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 20:36:30 +0100 Subject: [PATCH 61/66] Fixed compile warnings --- .../java/games/input/ControllerEventTest.java | 27 ++++++++------- .../java/games/input/ControllerReadTest.java | 28 +++++++++------- .../java/games/input/ControllerTextTest.java | 6 ---- .../java/net/java/games/input/RumbleTest.java | 33 ++++++++++++------- .../net/java/games/input/VersionTest.java | 30 ++++++++++++++--- .../applet/ControllerEventTestApplet.java | 3 +- .../applet/ControllerReadTestApplet.java | 3 +- 7 files changed, 82 insertions(+), 48 deletions(-) diff --git a/tests/src/main/java/net/java/games/input/ControllerEventTest.java b/tests/src/main/java/net/java/games/input/ControllerEventTest.java index a6069e7..f44fa93 100644 --- a/tests/src/main/java/net/java/games/input/ControllerEventTest.java +++ b/tests/src/main/java/net/java/games/input/ControllerEventTest.java @@ -46,6 +46,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.WindowConstants; import net.java.games.input.Component; import net.java.games.input.Controller; @@ -55,7 +56,10 @@ import net.java.games.input.Event; import net.java.games.input.Version; public class ControllerEventTest extends JFrame{ + private static final long serialVersionUID = -8266185848160199092L; + private static abstract class AxisPanel extends JPanel{ + private static final long serialVersionUID = -6200599064870672000L; Component axis; float data; @@ -79,6 +83,7 @@ public class ControllerEventTest extends JFrame{ } private static class DigitalAxisPanel extends AxisPanel { + private static final long serialVersionUID = -4729666037860134626L; JLabel digitalState = new JLabel(""); public DigitalAxisPanel(Component ax) { @@ -102,6 +107,7 @@ public class ControllerEventTest extends JFrame{ } private static class DigitalHatPanel extends AxisPanel { + private static final long serialVersionUID = -6582605379682496832L; JLabel digitalState = new JLabel(""); public DigitalHatPanel(Component ax) { @@ -145,6 +151,7 @@ public class ControllerEventTest extends JFrame{ } } private static class AnalogAxisPanel extends AxisPanel { + private static final long serialVersionUID = 7536173405896285590L; JLabel analogState = new JLabel(""); public AnalogAxisPanel(Component ax) { @@ -164,8 +171,9 @@ public class ControllerEventTest extends JFrame{ private static class ControllerWindow extends JFrame { + private static final long serialVersionUID = 8623977198558568961L; Controller ca; - Map axes_to_panels = new HashMap(); + Map axes_to_panels = new HashMap<>(); boolean disabled = false; public ControllerWindow(JFrame frame,Controller ca){ @@ -207,7 +215,7 @@ public class ControllerEventTest extends JFrame{ } private void addAxis(JPanel p, Component ax){ - JPanel p2; + AxisPanel p2; if (ax.isAnalog()) { p2 = new AnalogAxisPanel(ax); } else { @@ -234,14 +242,14 @@ public class ControllerEventTest extends JFrame{ EventQueue event_queue = ca.getEventQueue(); Event event = new Event(); while (event_queue.getNextEvent(event)) { - AxisPanel panel = (AxisPanel)axes_to_panels.get(event.getComponent()); + AxisPanel panel = axes_to_panels.get(event.getComponent()); panel.setPollData(event.getValue()); } } } static final long HEARTBEATMS =100; // 10th of a second - List controllers = new ArrayList(); + List controllers = new ArrayList<>(); public ControllerEventTest() { super("Controller Event Test. Version: " + Version.getVersion()); @@ -251,14 +259,12 @@ public class ControllerEventTest extends JFrame{ makeController(ca[i]); } - new Thread(new Runnable() { - public void run(){ + new Thread(() -> { try { while(true){ - for(Iterator i=controllers.iterator();i.hasNext();){ + for(Iterator i=controllers.iterator();i.hasNext();){ try { - ControllerWindow cw = (ControllerWindow)i.next(); - cw.poll(); + i.next().poll(); } catch (Exception e) { e.printStackTrace(); } @@ -268,11 +274,10 @@ public class ControllerEventTest extends JFrame{ } catch (Exception e) { e.printStackTrace(); } - } }).start(); pack(); setSize(400,400); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); } diff --git a/tests/src/main/java/net/java/games/input/ControllerReadTest.java b/tests/src/main/java/net/java/games/input/ControllerReadTest.java index ee3b85d..2d3a62b 100644 --- a/tests/src/main/java/net/java/games/input/ControllerReadTest.java +++ b/tests/src/main/java/net/java/games/input/ControllerReadTest.java @@ -49,13 +49,17 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.WindowConstants; import net.java.games.input.Component; import net.java.games.input.Controller; import net.java.games.input.ControllerEnvironment; public class ControllerReadTest extends JFrame{ + private static final long serialVersionUID = -7129976919159465311L; + private abstract static class AxisPanel extends JPanel{ + private static final long serialVersionUID = -2117191506803328790L; Component axis; float data; @@ -79,6 +83,7 @@ public class ControllerReadTest extends JFrame{ } private static class DigitalAxisPanel extends AxisPanel { + private static final long serialVersionUID = -4006900519933869168L; JLabel digitalState = new JLabel(""); public DigitalAxisPanel(Component ax) { @@ -102,6 +107,7 @@ public class ControllerReadTest extends JFrame{ } private static class DigitalHatPanel extends AxisPanel { + private static final long serialVersionUID = -3293100130201231029L; JLabel digitalState = new JLabel(""); public DigitalHatPanel(Component ax) { @@ -145,6 +151,7 @@ public class ControllerReadTest extends JFrame{ } } private static class AnalogAxisPanel extends AxisPanel { + private static final long serialVersionUID = -3220244985697453835L; JLabel analogState = new JLabel(""); public AnalogAxisPanel(Component ax) { @@ -164,8 +171,9 @@ public class ControllerReadTest extends JFrame{ private static class ControllerWindow extends JFrame { + private static final long serialVersionUID = 5812903945250431578L; Controller ca; - List axisList = new ArrayList(); + List axisList = new ArrayList<>(); boolean disabled = false; public ControllerWindow(JFrame frame,Controller ca){ @@ -207,7 +215,7 @@ public class ControllerReadTest extends JFrame{ } private void addAxis(JPanel p, Component ax){ - JPanel p2; + AxisPanel p2; if (ax.isAnalog()) { p2 = new AnalogAxisPanel(ax); } else { @@ -233,9 +241,9 @@ public class ControllerReadTest extends JFrame{ setDisabled(false); } //System.out.println("Polled "+ca.getName()); - for(Iterator i =axisList.iterator();i.hasNext();){ + for(Iterator i =axisList.iterator();i.hasNext();){ try { - ((AxisPanel)i.next()).poll(); + i.next().poll(); }catch (Exception e) { e.printStackTrace(); } @@ -244,7 +252,7 @@ public class ControllerReadTest extends JFrame{ } static final long HEARTBEATMS =100; // 10th of a second - List controllers = new ArrayList(); + List controllers = new ArrayList<>(); public ControllerReadTest() { super("Controller Read Test. Version: " + Version.getVersion()); @@ -254,13 +262,12 @@ public class ControllerReadTest extends JFrame{ makeController(ca[i]); } - new Thread(new Runnable() { - public void run(){ + new Thread(() ->{ try { while(true){ - for(Iterator i=controllers.iterator();i.hasNext();){ + for(Iterator i=controllers.iterator();i.hasNext();){ try { - ControllerWindow cw = (ControllerWindow)i.next(); + ControllerWindow cw = i.next(); cw.poll(); } catch (Exception e) { e.printStackTrace(); @@ -271,11 +278,10 @@ public class ControllerReadTest extends JFrame{ } catch (Exception e) { e.printStackTrace(); } - } }).start(); pack(); setSize(400,400); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); } diff --git a/tests/src/main/java/net/java/games/input/ControllerTextTest.java b/tests/src/main/java/net/java/games/input/ControllerTextTest.java index 8e28c99..d3bfa09 100644 --- a/tests/src/main/java/net/java/games/input/ControllerTextTest.java +++ b/tests/src/main/java/net/java/games/input/ControllerTextTest.java @@ -37,12 +37,6 @@ *****************************************************************************/ package net.java.games.input; -/** - * - * @author administrator - */ -import net.java.games.input.*; - public class ControllerTextTest { ControllerEnvironment ce; /** Creates a new instance of ControllerScanner */ diff --git a/tests/src/main/java/net/java/games/input/RumbleTest.java b/tests/src/main/java/net/java/games/input/RumbleTest.java index 4dc0725..5e3c59e 100644 --- a/tests/src/main/java/net/java/games/input/RumbleTest.java +++ b/tests/src/main/java/net/java/games/input/RumbleTest.java @@ -1,19 +1,30 @@ /* - * RumbleTest.java + * Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com) * - * Created on 01 December 2003, 23:02 + * 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.input.ControllerEnvironment; -import net.java.games.input.Controller; -import net.java.games.input.Rumbler; -import net.java.games.input.Version; - -/** - * - * @author Jeremy - */ public class RumbleTest { /** Creates a new instance of RumbleTest */ diff --git a/tests/src/main/java/net/java/games/input/VersionTest.java b/tests/src/main/java/net/java/games/input/VersionTest.java index caf2a44..f5831cf 100644 --- a/tests/src/main/java/net/java/games/input/VersionTest.java +++ b/tests/src/main/java/net/java/games/input/VersionTest.java @@ -1,12 +1,32 @@ +/* + * 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.input.Version; - public class VersionTest { - /** - * @param args - */ public static void main(String[] args) { System.out.println("JInput version: " + Version.getVersion()); } diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java index 4591129..2b398b6 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerEventTestApplet.java @@ -25,13 +25,12 @@ */ package net.java.games.input.applet; -import java.applet.Applet; import java.io.IOException; import net.java.games.input.ControllerEventTest; @SuppressWarnings("deprecation") -public class ControllerEventTestApplet extends Applet { +public class ControllerEventTestApplet extends java.applet.Applet { private static final long serialVersionUID = 4250817143444220400L; diff --git a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java index 798f6ee..92b57e0 100644 --- a/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java +++ b/tests/src/main/java/net/java/games/input/applet/ControllerReadTestApplet.java @@ -25,13 +25,12 @@ */ package net.java.games.input.applet; -import java.applet.Applet; import java.io.IOException; import net.java.games.input.ControllerReadTest; @SuppressWarnings("deprecation") -public class ControllerReadTestApplet extends Applet { +public class ControllerReadTestApplet extends java.applet.Applet { private static final long serialVersionUID = -2558493887683964119L; From 7ea0ebcc1fd034c22b6b33149057755ee166fcf3 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 21:03:48 +0100 Subject: [PATCH 62/66] Handle packaging changes in readme badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f42093..0fa03ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JInput -[![Maven Central](https://img.shields.io/maven-central/v/net.java.jinput/jinput.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/jinput) -[![Javadocs](http://www.javadoc.io/badge/net.java.jinput/jinput.svg)](http://www.javadoc.io/doc/net.java.jinput/jinput) +[![Maven Central](https://img.shields.io/maven-central/v/net.java.jinput/coreapi.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi) +[![Javadocs](http://www.javadoc.io/badge/net.java.jinput/coreapi.svg)](http://www.javadoc.io/doc/net.java.jinput/coreapi) Library for access to input devices. From 92f17913ca6ad4e630092c7abd5b6b8ce9e99f73 Mon Sep 17 00:00:00 2001 From: Endolf Date: Thu, 31 May 2018 21:07:03 +0100 Subject: [PATCH 63/66] Add information on log level changes. --- coreAPI/src/main/java/net/java/games/input/package.html | 1 + 1 file changed, 1 insertion(+) diff --git a/coreAPI/src/main/java/net/java/games/input/package.html b/coreAPI/src/main/java/net/java/games/input/package.html index 9e26d81..58c075f 100644 --- a/coreAPI/src/main/java/net/java/games/input/package.html +++ b/coreAPI/src/main/java/net/java/games/input/package.html @@ -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.
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)
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. \ No newline at end of file From 4f6269fdd2f7f11f55a5ae3a8970c5ec3643dc11 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 1 Jun 2018 15:04:43 +0100 Subject: [PATCH 64/66] Create a pom that allows all dependencies to be imported easily --- examples/pom.xml | 47 ++---------------------------- pom.xml | 1 + uberjar/pom.xml | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 uberjar/pom.xml diff --git a/examples/pom.xml b/examples/pom.xml index be655a8..bd84c87 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,54 +21,11 @@ - - net.java.jinput - coreapi - ${project.version} - ${project.groupId} - windows-plugin - ${project.version} - natives-windows - - - ${project.groupId} - osx-plugin - ${project.version} - natives-osx - - - ${project.groupId} - wintab-plugin - ${project.version} - natives-wintab - - - ${project.groupId} - linux-plugin - ${project.version} - natives-linux - - - ${project.groupId} - windows-plugin - ${project.version} - - - ${project.groupId} - osx-plugin - ${project.version} - - - ${project.groupId} - wintab-plugin - ${project.version} - - - ${project.groupId} - linux-plugin + jinput ${project.version} + pom diff --git a/pom.xml b/pom.xml index b665c6d..02d2436 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,7 @@ coreAPI plugins applet + uberjar examples tests diff --git a/uberjar/pom.xml b/uberjar/pom.xml new file mode 100644 index 0000000..a32bb8b --- /dev/null +++ b/uberjar/pom.xml @@ -0,0 +1,75 @@ + + 4.0.0 + jinput + pom + JInput - Uber jar + + + net.java.jinput + jinput-parent + 2.0.9-SNAPSHOT + ../ + + + + + ${project.groupId} + coreapi + ${project.version} + + + ${project.groupId} + windows-plugin + ${project.version} + natives-windows + + + ${project.groupId} + osx-plugin + ${project.version} + natives-osx + + + ${project.groupId} + wintab-plugin + ${project.version} + natives-wintab + + + ${project.groupId} + linux-plugin + ${project.version} + natives-linux + + + ${project.groupId} + windows-plugin + ${project.version} + + + ${project.groupId} + osx-plugin + ${project.version} + + + ${project.groupId} + wintab-plugin + ${project.version} + + + ${project.groupId} + linux-plugin + ${project.version} + + + + + + + com.googlecode.mavennatives + maven-nativedependencies-plugin + + + + + \ No newline at end of file From 06d9d5ca669d343e5e72f5b4808db742e2a6812d Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 1 Jun 2018 15:49:09 +0100 Subject: [PATCH 65/66] Build uber jars --- .gitignore | 1 + uberjar/pom.xml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 76dc67d..6a3d746 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ dist/ eclipse_bin/ *.iml .idea/ +dependency-reduced-pom.xml diff --git a/uberjar/pom.xml b/uberjar/pom.xml index a32bb8b..8012e3b 100644 --- a/uberjar/pom.xml +++ b/uberjar/pom.xml @@ -1,7 +1,7 @@ 4.0.0 jinput - pom + jar JInput - Uber jar @@ -69,6 +69,82 @@ com.googlecode.mavennatives maven-nativedependencies-plugin + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + default + package + + shade + + + + + net.java.jinput:osx-plugin:jar:natives-osx + net.java.jinput:linux-plugin:jar:natives-linux + net.java.jinput:windows-plugin:jar:natives-windows + net.java.jinput:wintab-plugin:jar:natives-wintab + + + true + false + false + + + + natives + package + + shade + + + + + net.java.jinput:osx-plugin + + **/*.jnilib + META-INF/**/* + + + + net.java.jinput:linux-plugin + + **/*.so + META-INF/**/* + + + + net.java.jinput:windows-plugin + + **/*.dll + META-INF/**/* + + + + net.java.jinput:wintab-plugin + + **/*.dll + META-INF/**/* + + + + + + net.java.jutils:jutils + net.java.jinput:jinput + net.java.jinput:coreapi + + + true + natives-all + false + + + + From 43ba12c160972d3942f1d05792e8ece7454ed672 Mon Sep 17 00:00:00 2001 From: Endolf Date: Fri, 1 Jun 2018 15:55:08 +0100 Subject: [PATCH 66/66] Move pom version declaration --- pom.xml | 5 +++++ uberjar/pom.xml | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02d2436..1d259e5 100644 --- a/pom.xml +++ b/pom.xml @@ -146,6 +146,11 @@ true + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + diff --git a/uberjar/pom.xml b/uberjar/pom.xml index 8012e3b..3ae7267 100644 --- a/uberjar/pom.xml +++ b/uberjar/pom.xml @@ -72,7 +72,6 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.1 default