mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-01-05 00:09:57 +01:00
added DefaultControllerEnvironment.loadLibrary convenience method for plugins. It will also respect the new net.java.games.input.librarypath property for locating natives (useful for applets). Removed the mac os x jinput-osx-legacy library loading, as it is not necessary anymore with the combined 10.3/10.4 library
This commit is contained in:
parent
d5ea04d3af
commit
4306f119c2
|
|
@ -92,6 +92,27 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||
private PluginClassLoader pluginLoader = new PluginClassLoader();
|
||||
|
||||
private Collection loadedPlugins = new ArrayList();
|
||||
|
||||
/**
|
||||
* Static utility method for loading native libraries.
|
||||
* It will try to load from either the path given by
|
||||
* the net.java.games.input.librarypath property
|
||||
* or through System.loadLibrary().
|
||||
*
|
||||
*/
|
||||
static void loadLibrary(final String lib_name) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public final Object run() {
|
||||
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
||||
if (lib_path != null)
|
||||
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
||||
else
|
||||
System.loadLibrary(lib_name);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Public no-arg constructor.
|
||||
|
|
|
|||
|
|
@ -56,21 +56,7 @@ import java.security.PrivilegedAction;
|
|||
*/
|
||||
public final class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugin {
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
if (isMacOSXEqualsOrBetterThan(10, 4)) {
|
||||
System.loadLibrary("jinput-osx");
|
||||
} else {
|
||||
// If we're not on 10.4 or later, try to load the legacy library first
|
||||
try {
|
||||
System.loadLibrary("jinput-osx-legacy");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.loadLibrary("jinput-osx");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
DefaultControllerEnvironment.loadLibrary("jinput-osx");
|
||||
}
|
||||
|
||||
private final static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required) {
|
||||
|
|
|
|||
|
|
@ -44,13 +44,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
|
|||
private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public final Object run() {
|
||||
System.loadLibrary("jinput-linux");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
DefaultControllerEnvironment.loadLibrary("jinput-linux");
|
||||
}
|
||||
|
||||
public final static Object execute(LinuxDeviceTask task) throws IOException {
|
||||
|
|
|
|||
|
|
@ -53,13 +53,7 @@ import net.java.games.util.plugins.Plugin;
|
|||
*/
|
||||
public final class DirectInputEnvironmentPlugin extends ControllerEnvironment implements Plugin {
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public final Object run() {
|
||||
System.loadLibrary("jinput-dx8");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
DefaultControllerEnvironment.loadLibrary("jinput-dx8");
|
||||
}
|
||||
|
||||
private final Controller[] controllers;
|
||||
|
|
|
|||
|
|
@ -53,13 +53,7 @@ import net.java.games.util.plugins.Plugin;
|
|||
*/
|
||||
public final class RawInputEnvironmentPlugin extends ControllerEnvironment implements Plugin {
|
||||
static {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public final Object run() {
|
||||
System.loadLibrary("jinput-raw");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
DefaultControllerEnvironment.loadLibrary("jinput-raw");
|
||||
}
|
||||
|
||||
private final Controller[] controllers;
|
||||
|
|
|
|||
Loading…
Reference in a new issue