Merge pull request #34 from jinput/issue/26

Issue/26
This commit is contained in:
Endolf 2018-05-25 16:50:15 +01:00 committed by GitHub
commit 165a4d74e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 66 additions and 48 deletions

14
Jenkinsfile vendored
View file

@ -7,6 +7,19 @@ pipeline {
} }
options { buildDiscarder(logRotator(numToKeepStr: '5')) } options { buildDiscarder(logRotator(numToKeepStr: '5')) }
stages { 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') { stage('Build natives') {
parallel { parallel {
stage('Build Windows natives') { stage('Build Windows natives') {
@ -71,6 +84,7 @@ pipeline {
agent { agent {
label "linux" label "linux"
} }
when { branch 'master' }
steps { steps {
unstash 'windows-natives' unstash 'windows-natives'
unstash 'osx-natives' unstash 'osx-natives'

View file

@ -183,7 +183,7 @@ public abstract class AbstractController implements Controller {
setDeviceEventQueueSize(size); setDeviceEventQueueSize(size);
event_queue = new EventQueue(size); event_queue = new EventQueue(size);
} catch (IOException e) { } catch (IOException e) {
ControllerEnvironment.logln("Failed to create new event queue of size " + size + ": " + e); ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e);
} }
} }
@ -233,7 +233,7 @@ public abstract class AbstractController implements Controller {
} }
return true; return true;
} catch (IOException e) { } catch (IOException e) {
ControllerEnvironment.logln("Failed to poll device: " + e.getMessage()); ControllerEnvironment.log("Failed to poll device: " + e.getMessage());
return false; return false;
} }
} }

View file

@ -43,6 +43,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@ -70,9 +71,6 @@ import java.util.logging.Logger;
* *
*/ */
public abstract class ControllerEnvironment { public abstract class ControllerEnvironment {
static void logln(String msg) {
log(msg + "\n");
}
static void log(String msg) { static void log(String msg) {
Logger.getLogger(ControllerEnvironment.class.getName()).info(msg); Logger.getLogger(ControllerEnvironment.class.getName()).info(msg);
@ -93,6 +91,11 @@ public abstract class ControllerEnvironment {
* Protected constructor for subclassing. * Protected constructor for subclassing.
*/ */
protected ControllerEnvironment() { protected ControllerEnvironment() {
if(System.getProperty("jinput.loglevel") != null) {
String loggerName = ControllerEnvironment.class.getPackage().getName();
Level level = Level.parse(System.getProperty("jinput.loglevel"));
Logger.getLogger(loggerName).setLevel(level);
}
} }
/** /**

View file

@ -162,7 +162,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
addControllers(ce.getControllers()); addControllers(ce.getControllers());
loadedPlugins.add(ce.getClass().getName()); loadedPlugins.add(ce.getClass().getName());
} else { } else {
logln(ceClass.getName() + " is not supported"); log(ceClass.getName() + " is not supported");
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -203,7 +203,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
Class[] envClasses = plugins.getExtends(ControllerEnvironment.class); Class[] envClasses = plugins.getExtends(ControllerEnvironment.class);
for(int i=0;i<envClasses.length;i++){ for(int i=0;i<envClasses.length;i++){
try { try {
ControllerEnvironment.logln("ControllerEnvironment "+ ControllerEnvironment.log("ControllerEnvironment "+
envClasses[i].getName() envClasses[i].getName()
+" loaded by "+envClasses[i].getClassLoader()); +" loaded by "+envClasses[i].getClassLoader());
ControllerEnvironment ce = (ControllerEnvironment) ControllerEnvironment ce = (ControllerEnvironment)
@ -212,7 +212,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
addControllers(ce.getControllers()); addControllers(ce.getControllers());
loadedPlugins.add(ce.getClass().getName()); loadedPlugins.add(ce.getClass().getName());
} else { } else {
logln(envClasses[i].getName() + " is not supported"); log(envClasses[i].getName() + " is not supported");
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -109,6 +109,7 @@
<argument>-classpath</argument> <argument>-classpath</argument>
<classpath/> <classpath/>
<argument>-Djava.library.path=${project.build.directory}/natives</argument> <argument>-Djava.library.path=${project.build.directory}/natives</argument>
<argument>-Djinput.loglevel=OFF</argument>
<argument>net.java.games.input.example.ReadAllEvents</argument> <argument>net.java.games.input.example.ReadAllEvents</argument>
</arguments> </arguments>
</configuration> </configuration>

View file

@ -122,7 +122,7 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
major = Integer.parseInt(major_str); major = Integer.parseInt(major_str);
minor = Integer.parseInt(minor_str); minor = Integer.parseInt(minor_str);
} catch (Exception e) { } catch (Exception e) {
logln("Exception occurred while trying to determine OS version: " + e); log("Exception occurred while trying to determine OS version: " + e);
// Best guess, no // Best guess, no
return false; return false;
} }
@ -266,12 +266,12 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
createControllersFromDevice(device, controllers); createControllersFromDevice(device, controllers);
device_used = old_size != controllers.size(); device_used = old_size != controllers.size();
} catch (IOException e) { } catch (IOException e) {
logln("Failed to create controllers from device: " + device.getProductName()); log("Failed to create controllers from device: " + device.getProductName());
} }
if (!device_used) if (!device_used)
device.release(); device.release();
} catch (IOException e) { } catch (IOException e) {
logln("Failed to enumerate device: " + e.getMessage()); log("Failed to enumerate device: " + e.getMessage());
} }
} }
} finally { } finally {

View file

@ -68,7 +68,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
else else
System.loadLibrary(lib_name); System.loadLibrary(lib_name);
} catch(UnsatisfiedLinkError e) { } catch(UnsatisfiedLinkError e) {
logln("Failed to load library: " + e.getMessage()); log("Failed to load library: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
supported = false; supported = false;
} }
@ -113,7 +113,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
public LinuxEnvironmentPlugin() { public LinuxEnvironmentPlugin() {
if(isSupported()) { if(isSupported()) {
this.controllers = enumerateControllers(); this.controllers = enumerateControllers();
logln("Linux plugin claims to have found " + controllers.length + " controllers"); log("Linux plugin claims to have found " + controllers.length + " controllers");
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction() {
public final Object run() { public final Object run() {
@ -170,7 +170,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
povs[3][1] = event_component; povs[3][1] = event_component;
break; break;
default: default:
logln("Unknown POV instance: " + native_code); log("Unknown POV instance: " + native_code);
break; break;
} }
} else if(identifier != null) { } else if(identifier != null) {
@ -413,7 +413,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
} else } else
device.close(); device.close();
} catch(IOException e) { } catch(IOException e) {
logln("Failed to open device (" + event_file + "): " + e.getMessage()); log("Failed to open device (" + event_file + "): " + e.getMessage());
} }
} }
} }
@ -440,7 +440,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
public Object run() { public Object run() {
File[] files = dir.listFiles(filter); File[] files = dir.listFiles(filter);
if(files == null) { if(files == null) {
logln("dir " + dir.getName() + " exists: " + dir.exists() + ", is writable: " + dir.isDirectory()); log("dir " + dir.getName() + " exists: " + dir.exists() + ", is writable: " + dir.isDirectory());
files = new File[]{}; files = new File[]{};
} else { } else {
Arrays.sort(files, new Comparator() { Arrays.sort(files, new Comparator() {
@ -476,11 +476,11 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
} else } else
device.close(); device.close();
} catch(IOException e) { } catch(IOException e) {
logln("Failed to create Controller: " + e.getMessage()); log("Failed to create Controller: " + e.getMessage());
device.close(); device.close();
} }
} catch(IOException e) { } catch(IOException e) {
logln("Failed to open device (" + event_file + "): " + e.getMessage()); log("Failed to open device (" + event_file + "): " + e.getMessage());
} }
} }
} }
@ -492,7 +492,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
LinuxDevice device = (LinuxDevice) devices.get(i); LinuxDevice device = (LinuxDevice) devices.get(i);
device.close(); device.close();
} catch(IOException e) { } catch(IOException e) {
logln("Failed to close device: " + e.getMessage()); log("Failed to close device: " + e.getMessage());
} }
} }
} }

View file

@ -168,7 +168,7 @@ final class LinuxEventDevice implements LinuxDevice {
rumblers.add(new LinuxRumbleFF(this)); rumblers.add(new LinuxRumbleFF(this));
} }
} catch (IOException e) { } catch (IOException e) {
LinuxEnvironmentPlugin.logln("Failed to enumerate rumblers: " + e.getMessage()); LinuxEnvironmentPlugin.log("Failed to enumerate rumblers: " + e.getMessage());
} }
return (Rumbler[])rumblers.toArray(new Rumbler[]{}); return (Rumbler[])rumblers.toArray(new Rumbler[]{});
} }

View file

@ -56,7 +56,7 @@ abstract class LinuxForceFeedbackEffect implements Rumbler {
write_task.write(0); write_task.write(0);
} }
} catch (IOException e) { } catch (IOException e) {
LinuxEnvironmentPlugin.logln("Failed to rumble: " + e); LinuxEnvironmentPlugin.log("Failed to rumble: " + e);
} }
} }

View file

@ -47,7 +47,7 @@ public class LinuxJoystickPOV extends LinuxJoystickAxis {
else if (last_x == 1 && last_y == 1) else if (last_x == 1 && last_y == 1)
setValue(Component.POV.DOWN_RIGHT); setValue(Component.POV.DOWN_RIGHT);
else { else {
LinuxEnvironmentPlugin.logln("Unknown values x = " + last_x + " | y = " + last_y); LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
setValue(Component.POV.OFF); setValue(Component.POV.OFF);
} }
} }

View file

@ -88,7 +88,7 @@ final class LinuxPOV extends LinuxComponent {
else if (last_x == 1 && last_y == 1) else if (last_x == 1 && last_y == 1)
return Component.POV.DOWN_RIGHT; return Component.POV.DOWN_RIGHT;
else { else {
LinuxEnvironmentPlugin.logln("Unknown values x = " + last_x + " | y = " + last_y); LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
return Component.POV.OFF; return Component.POV.OFF;
} }
} }

View file

@ -129,7 +129,7 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im
throw e; throw e;
} }
} catch (IOException e) { } catch (IOException e) {
logln("Failed to enumerate devices: " + e.getMessage()); log("Failed to enumerate devices: " + e.getMessage());
} }
this.window = window; this.window = window;
this.controllers = controllers; this.controllers = controllers;

View file

@ -82,7 +82,7 @@ final class IDirectInput {
IDirectInputDevice device = new IDirectInputDevice(window, address, instance_guid, product_guid, dev_type, dev_subtype, instance_name, product_name); IDirectInputDevice device = new IDirectInputDevice(window, address, instance_guid, product_guid, dev_type, dev_subtype, instance_name, product_name);
devices.add(device); devices.add(device);
} catch (IOException e) { } catch (IOException e) {
DirectInputEnvironmentPlugin.logln("Failed to initialize device " + product_name + " because of: " + e); DirectInputEnvironmentPlugin.log("Failed to initialize device " + product_name + " because of: " + e);
} }
} }

View file

@ -228,7 +228,7 @@ final class IDirectInputDevice {
enumEffects(); enumEffects();
createRumblers(); createRumblers();
} catch (IOException e) { } catch (IOException e) {
DirectInputEnvironmentPlugin.logln("Failed to create rumblers: " + e.getMessage()); DirectInputEnvironmentPlugin.log("Failed to create rumblers: " + e.getMessage());
} }
/* Some DirectInput lamer-designer made the device state /* Some DirectInput lamer-designer made the device state
* axis mode be per-device not per-axis, so I'll just * axis mode be per-device not per-axis, so I'll just

View file

@ -64,7 +64,7 @@ final class IDirectInputEffect implements Rumbler {
} else } else
stop(); stop();
} catch (IOException e) { } catch (IOException e) {
DirectInputEnvironmentPlugin.logln("Failed to set rumbler gain: " + e.getMessage()); DirectInputEnvironmentPlugin.log("Failed to set rumbler gain: " + e.getMessage());
} }
} }

View file

@ -122,7 +122,7 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple
queue = new RawInputEventQueue(); queue = new RawInputEventQueue();
controllers = enumControllers(queue); controllers = enumControllers(queue);
} catch (IOException e) { } catch (IOException e) {
logln("Failed to enumerate devices: " + e.getMessage()); log("Failed to enumerate devices: " + e.getMessage());
} }
} }
this.controllers = controllers; this.controllers = controllers;

View file

@ -1,4 +1,4 @@
/** /*
* Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com) * Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com)
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -79,73 +79,73 @@ public class WinTabDevice extends AbstractController {
public static WinTabDevice createDevice(WinTabContext context, int deviceIndex) { public static WinTabDevice createDevice(WinTabContext context, int deviceIndex) {
String name = nGetName(deviceIndex); String name = nGetName(deviceIndex);
WinTabEnvironmentPlugin.logln("Device " + deviceIndex + ", name: " + name); WinTabEnvironmentPlugin.log("Device " + deviceIndex + ", name: " + name);
List componentsList = new ArrayList(); List componentsList = new ArrayList();
int[] axisDetails = nGetAxisDetails(deviceIndex, XAxis); int[] axisDetails = nGetAxisDetails(deviceIndex, XAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("ZAxis not supported"); WinTabEnvironmentPlugin.log("ZAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("Xmin: " + axisDetails[0] + ", Xmax: " + axisDetails[1]); WinTabEnvironmentPlugin.log("Xmin: " + axisDetails[0] + ", Xmax: " + axisDetails[1]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, XAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, XAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, YAxis); axisDetails = nGetAxisDetails(deviceIndex, YAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("YAxis not supported"); WinTabEnvironmentPlugin.log("YAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("Ymin: " + axisDetails[0] + ", Ymax: " + axisDetails[1]); WinTabEnvironmentPlugin.log("Ymin: " + axisDetails[0] + ", Ymax: " + axisDetails[1]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, YAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, YAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, ZAxis); axisDetails = nGetAxisDetails(deviceIndex, ZAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("ZAxis not supported"); WinTabEnvironmentPlugin.log("ZAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("Zmin: " + axisDetails[0] + ", Zmax: " + axisDetails[1]); WinTabEnvironmentPlugin.log("Zmin: " + axisDetails[0] + ", Zmax: " + axisDetails[1]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, ZAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, ZAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, NPressureAxis); axisDetails = nGetAxisDetails(deviceIndex, NPressureAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("NPressureAxis not supported"); WinTabEnvironmentPlugin.log("NPressureAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("NPressMin: " + axisDetails[0] + ", NPressMax: " + axisDetails[1]); WinTabEnvironmentPlugin.log("NPressMin: " + axisDetails[0] + ", NPressMax: " + axisDetails[1]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, NPressureAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, NPressureAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, TPressureAxis); axisDetails = nGetAxisDetails(deviceIndex, TPressureAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("TPressureAxis not supported"); WinTabEnvironmentPlugin.log("TPressureAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("TPressureAxismin: " + axisDetails[0] + ", TPressureAxismax: " + axisDetails[1]); WinTabEnvironmentPlugin.log("TPressureAxismin: " + axisDetails[0] + ", TPressureAxismax: " + axisDetails[1]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, TPressureAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, TPressureAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, OrientationAxis); axisDetails = nGetAxisDetails(deviceIndex, OrientationAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("OrientationAxis not supported"); WinTabEnvironmentPlugin.log("OrientationAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("OrientationAxis mins/maxs: " + axisDetails[0] + "," + axisDetails[1] + ", " + axisDetails[2] + "," + axisDetails[3] + ", " + axisDetails[4] + "," + axisDetails[5]); WinTabEnvironmentPlugin.log("OrientationAxis mins/maxs: " + axisDetails[0] + "," + axisDetails[1] + ", " + axisDetails[2] + "," + axisDetails[3] + ", " + axisDetails[4] + "," + axisDetails[5]);
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, OrientationAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, OrientationAxis, axisDetails));
} }
axisDetails = nGetAxisDetails(deviceIndex, RotationAxis); axisDetails = nGetAxisDetails(deviceIndex, RotationAxis);
if(axisDetails.length==0) { if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("RotationAxis not supported"); WinTabEnvironmentPlugin.log("RotationAxis not supported");
} else { } else {
WinTabEnvironmentPlugin.logln("RotationAxis is supported (by the device, not by this plugin)"); WinTabEnvironmentPlugin.log("RotationAxis is supported (by the device, not by this plugin)");
componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, RotationAxis, axisDetails)); componentsList.addAll(WinTabComponent.createComponents(context, deviceIndex, RotationAxis, axisDetails));
} }
String[] cursorNames = nGetCursorNames(deviceIndex); String[] cursorNames = nGetCursorNames(deviceIndex);
componentsList.addAll(WinTabComponent.createCursors(context, deviceIndex, cursorNames)); componentsList.addAll(WinTabComponent.createCursors(context, deviceIndex, cursorNames));
for(int i=0;i<cursorNames.length;i++) { for(int i=0;i<cursorNames.length;i++) {
WinTabEnvironmentPlugin.logln("Cursor " + i + "'s name: " + cursorNames[i]); WinTabEnvironmentPlugin.log("Cursor " + i + "'s name: " + cursorNames[i]);
} }
int numberOfButtons = nGetMaxButtonCount(deviceIndex); int numberOfButtons = nGetMaxButtonCount(deviceIndex);
WinTabEnvironmentPlugin.logln("Device has " + numberOfButtons + " buttons"); WinTabEnvironmentPlugin.log("Device has " + numberOfButtons + " buttons");
componentsList.addAll(WinTabComponent.createButtons(context, deviceIndex, numberOfButtons)); componentsList.addAll(WinTabComponent.createButtons(context, deviceIndex, numberOfButtons));
Component[] components = (Component[])componentsList.toArray(new Component[0]); Component[] components = (Component[])componentsList.toArray(new Component[0]);

View file

@ -108,7 +108,7 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl
throw e; throw e;
} }
} catch (Exception e) { } catch (Exception e) {
logln("Failed to enumerate devices: " + e.getMessage()); log("Failed to enumerate devices: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
this.controllers = controllers; this.controllers = controllers;

View file

@ -137,7 +137,7 @@
<executions> <executions>
<execution> <execution>
<id>sign-artifacts</id> <id>sign-artifacts</id>
<phase>verify</phase> <phase>deploy</phase>
<goals> <goals>
<goal>sign</goal> <goal>sign</goal>
</goals> </goals>