Check the arch type before loading the native library

This commit is contained in:
endolf 2009-03-28 16:36:03 +00:00
parent b789b8cd52
commit c95cf4bddd
3 changed files with 25 additions and 17 deletions

View file

@ -59,10 +59,16 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
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);
try {
if (lib_path != null)
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
else
System.loadLibrary(lib_name);
} catch (UnsatisfiedLinkError e) {
logln("Failed to load library: " + e.getMessage());
e.printStackTrace();
supported = false;
}
return null;
}
});
@ -88,17 +94,11 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
static {
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.equals("Linux")) {
try {
if("i386".equals(getPrivilegedProperty("os.arch"))) {
loadLibrary(LIBNAME);
} else {
loadLibrary(LIBNAME + POSTFIX64BIT);
}
supported = true;
} catch (UnsatisfiedLinkError e) {
logln("Failed to load library: " + e.getMessage());
e.printStackTrace();
supported = false;
supported = true;
if("i386".equals(getPrivilegedProperty("os.arch"))) {
loadLibrary(LIBNAME);
} else {
loadLibrary(LIBNAME + POSTFIX64BIT);
}
}
}

View file

@ -103,7 +103,11 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.startsWith("Windows")) {
supported = true;
loadLibrary("jinput-dx8");
if("x86".equals(getPrivilegedProperty("os.arch"))) {
loadLibrary("jinput-dx8");
} else {
loadLibrary("jinput-dx8-64");
}
}
}

View file

@ -103,7 +103,11 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.startsWith("Windows")) {
supported = true;
loadLibrary("jinput-raw");
if("x86".equals(getPrivilegedProperty("os.arch"))) {
loadLibrary("jinput-raw");
} else {
loadLibrary("jinput-raw-64");
}
}
}