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')) }
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') {
@ -71,6 +84,7 @@ pipeline {
agent {
label "linux"
}
when { branch 'master' }
steps {
unstash 'windows-natives'
unstash 'osx-natives'

View file

@ -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;
}
}

View file

@ -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;
/**
@ -70,9 +71,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);
@ -93,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);
}
}
/**

View file

@ -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<envClasses.length;i++){
try {
ControllerEnvironment.logln("ControllerEnvironment "+
ControllerEnvironment.log("ControllerEnvironment "+
envClasses[i].getName()
+" loaded by "+envClasses[i].getClassLoader());
ControllerEnvironment ce = (ControllerEnvironment)
@ -212,7 +212,7 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
addControllers(ce.getControllers());
loadedPlugins.add(ce.getClass().getName());
} else {
logln(envClasses[i].getName() + " is not supported");
log(envClasses[i].getName() + " is not supported");
}
} catch (Throwable e) {
e.printStackTrace();

View file

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

View file

@ -122,7 +122,7 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
major = Integer.parseInt(major_str);
minor = Integer.parseInt(minor_str);
} 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
return false;
}
@ -266,12 +266,12 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements
createControllersFromDevice(device, controllers);
device_used = old_size != controllers.size();
} catch (IOException e) {
logln("Failed to create controllers from device: " + device.getProductName());
log("Failed to create controllers from device: " + device.getProductName());
}
if (!device_used)
device.release();
} catch (IOException e) {
logln("Failed to enumerate device: " + e.getMessage());
log("Failed to enumerate device: " + e.getMessage());
}
}
} finally {

View file

@ -68,7 +68,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
else
System.loadLibrary(lib_name);
} catch(UnsatisfiedLinkError e) {
logln("Failed to load library: " + e.getMessage());
log("Failed to load library: " + e.getMessage());
e.printStackTrace();
supported = false;
}
@ -113,7 +113,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
public LinuxEnvironmentPlugin() {
if(isSupported()) {
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(
new PrivilegedAction() {
public final Object run() {
@ -170,7 +170,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
povs[3][1] = event_component;
break;
default:
logln("Unknown POV instance: " + native_code);
log("Unknown POV instance: " + native_code);
break;
}
} else if(identifier != null) {
@ -413,7 +413,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
} else
device.close();
} 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() {
File[] files = dir.listFiles(filter);
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[]{};
} else {
Arrays.sort(files, new Comparator() {
@ -476,11 +476,11 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
} else
device.close();
} catch(IOException e) {
logln("Failed to create Controller: " + e.getMessage());
log("Failed to create Controller: " + e.getMessage());
device.close();
}
} 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);
device.close();
} 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));
}
} 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[]{});
}

View file

@ -56,7 +56,7 @@ abstract class LinuxForceFeedbackEffect implements Rumbler {
write_task.write(0);
}
} 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)
setValue(Component.POV.DOWN_RIGHT);
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);
}
}

View file

@ -88,7 +88,7 @@ final class LinuxPOV extends LinuxComponent {
else if (last_x == 1 && last_y == 1)
return Component.POV.DOWN_RIGHT;
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;
}
}

View file

@ -129,7 +129,7 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im
throw e;
}
} catch (IOException e) {
logln("Failed to enumerate devices: " + e.getMessage());
log("Failed to enumerate devices: " + e.getMessage());
}
this.window = window;
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);
devices.add(device);
} 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();
createRumblers();
} 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
* axis mode be per-device not per-axis, so I'll just

View file

@ -64,7 +64,7 @@ final class IDirectInputEffect implements Rumbler {
} else
stop();
} 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();
controllers = enumControllers(queue);
} catch (IOException e) {
logln("Failed to enumerate devices: " + e.getMessage());
log("Failed to enumerate devices: " + e.getMessage());
}
}
this.controllers = controllers;

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2006 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* 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) {
String name = nGetName(deviceIndex);
WinTabEnvironmentPlugin.logln("Device " + deviceIndex + ", name: " + name);
WinTabEnvironmentPlugin.log("Device " + deviceIndex + ", name: " + name);
List componentsList = new ArrayList();
int[] axisDetails = nGetAxisDetails(deviceIndex, XAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("ZAxis not supported");
WinTabEnvironmentPlugin.log("ZAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, YAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("YAxis not supported");
WinTabEnvironmentPlugin.log("YAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, ZAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("ZAxis not supported");
WinTabEnvironmentPlugin.log("ZAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, NPressureAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("NPressureAxis not supported");
WinTabEnvironmentPlugin.log("NPressureAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, TPressureAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("TPressureAxis not supported");
WinTabEnvironmentPlugin.log("TPressureAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, OrientationAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("OrientationAxis not supported");
WinTabEnvironmentPlugin.log("OrientationAxis not supported");
} 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));
}
axisDetails = nGetAxisDetails(deviceIndex, RotationAxis);
if(axisDetails.length==0) {
WinTabEnvironmentPlugin.logln("RotationAxis not supported");
WinTabEnvironmentPlugin.log("RotationAxis not supported");
} 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));
}
String[] cursorNames = nGetCursorNames(deviceIndex);
componentsList.addAll(WinTabComponent.createCursors(context, deviceIndex, cursorNames));
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);
WinTabEnvironmentPlugin.logln("Device has " + numberOfButtons + " buttons");
WinTabEnvironmentPlugin.log("Device has " + numberOfButtons + " buttons");
componentsList.addAll(WinTabComponent.createButtons(context, deviceIndex, numberOfButtons));
Component[] components = (Component[])componentsList.toArray(new Component[0]);

View file

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

View file

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