Modify all plugins to include a rescanControllers method.
This commit is contained in:
parent
b374f106c7
commit
243fb16c45
@ -37,13 +37,8 @@
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.security.AccessController;
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +66,9 @@ 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);
|
||||||
@ -85,17 +83,12 @@ public abstract class ControllerEnvironment {
|
|||||||
/**
|
/**
|
||||||
* List of controller listeners
|
* List of controller listeners
|
||||||
*/
|
*/
|
||||||
protected final ArrayList<ControllerListener> controllerListeners = new ArrayList<>();
|
protected final ArrayList controllerListeners = new ArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,6 +96,11 @@ public abstract class ControllerEnvironment {
|
|||||||
* or an empty array if there are no controllers in this environment.
|
* or an empty array if there are no controllers in this environment.
|
||||||
*/
|
*/
|
||||||
public abstract Controller[] getControllers();
|
public abstract Controller[] getControllers();
|
||||||
|
/**
|
||||||
|
* Rescans the devices and provides a list of new controllers.
|
||||||
|
* @return a list of all controllers available to this environment.
|
||||||
|
*/
|
||||||
|
public abstract Controller[] rescanControllers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener for controller state change events.
|
* Adds a listener for controller state change events.
|
||||||
@ -133,9 +131,9 @@ public abstract class ControllerEnvironment {
|
|||||||
*/
|
*/
|
||||||
protected void fireControllerAdded(Controller c) {
|
protected void fireControllerAdded(Controller c) {
|
||||||
ControllerEvent ev = new ControllerEvent(c);
|
ControllerEvent ev = new ControllerEvent(c);
|
||||||
Iterator<ControllerListener> it = controllerListeners.iterator();
|
Iterator it = controllerListeners.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next().controllerAdded(ev);
|
((ControllerListener)it.next()).controllerAdded(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,9 +143,9 @@ public abstract class ControllerEnvironment {
|
|||||||
*/
|
*/
|
||||||
protected void fireControllerRemoved(Controller c) {
|
protected void fireControllerRemoved(Controller c) {
|
||||||
ControllerEvent ev = new ControllerEvent(c);
|
ControllerEvent ev = new ControllerEvent(c);
|
||||||
Iterator<ControllerListener> it = controllerListeners.iterator();
|
Iterator it = controllerListeners.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next().controllerRemoved(ev);
|
((ControllerListener)it.next()).controllerRemoved(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,4 +156,4 @@ public abstract class ControllerEnvironment {
|
|||||||
public static ControllerEnvironment getDefaultEnvironment() {
|
public static ControllerEnvironment getDefaultEnvironment() {
|
||||||
return defaultEnvironment;
|
return defaultEnvironment;
|
||||||
}
|
}
|
||||||
}
|
} // ControllerEnvironment
|
@ -1,4 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
|
* %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.
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -29,20 +35,24 @@
|
|||||||
* You acknowledge that this software is not designed or intended for us in
|
* You acknowledge that this software is not designed or intended for us in
|
||||||
* the design, construction, operation or maintenance of any nuclear facility
|
* the design, construction, operation or maintenance of any nuclear facility
|
||||||
*
|
*
|
||||||
*/
|
*****************************************************************************/
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import net.java.games.util.plugins.Plugins;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.java.games.util.plugins.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default controller environment.
|
* The default controller environment.
|
||||||
*
|
*
|
||||||
@ -62,23 +72,34 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void loadLibrary(final String lib_name) {
|
static void loadLibrary(final String lib_name) {
|
||||||
AccessController.doPrivileged((PrivilegedAction<String>) () -> {
|
AccessController.doPrivileged(
|
||||||
|
new PrivilegedAction() {
|
||||||
|
public final Object run() {
|
||||||
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
String lib_path = System.getProperty("net.java.games.input.librarypath");
|
||||||
if (lib_path != null)
|
if (lib_path != null)
|
||||||
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
|
||||||
else
|
else
|
||||||
System.loadLibrary(lib_name);
|
System.loadLibrary(lib_name);
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property) {
|
static String getPrivilegedProperty(final String property) {
|
||||||
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property));
|
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
return System.getProperty(property);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String getPrivilegedProperty(final String property, final String default_value) {
|
static String getPrivilegedProperty(final String property, final String default_value) {
|
||||||
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property, default_value));
|
return (String)AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
return System.getProperty(property, default_value);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +107,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
*/
|
*/
|
||||||
private ArrayList<Controller> controllers;
|
private ArrayList<Controller> controllers;
|
||||||
|
|
||||||
private Collection<String> loadedPluginNames = new ArrayList<>();
|
private Collection loadedPlugins = new ArrayList();
|
||||||
|
private ArrayList<ControllerEnvironment> environments = new ArrayList<ControllerEnvironment>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public no-arg constructor.
|
* Public no-arg constructor.
|
||||||
@ -98,67 +120,129 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
* Returns a list of all controllers available to this environment,
|
* Returns a list of all controllers available to this environment,
|
||||||
* or an empty array if there are no controllers in this environment.
|
* or an empty array if there are no controllers in this environment.
|
||||||
*/
|
*/
|
||||||
public Controller[] getControllers()
|
public Controller[] getControllers() {
|
||||||
{
|
if (controllers == null) {
|
||||||
reloadControllers();
|
// Controller list has not been scanned.
|
||||||
|
controllers = new ArrayList<Controller>();
|
||||||
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
scanControllers();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//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")) {
|
||||||
|
String osName = getPrivilegedProperty("os.name", "").trim();
|
||||||
|
if(osName.equals("Linux")) {
|
||||||
|
pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
|
||||||
|
} else if(osName.equals("Mac OS X")) {
|
||||||
|
pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
|
||||||
|
} else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7")) {
|
||||||
|
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
||||||
|
} else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
|
||||||
|
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
|
||||||
|
} else if (osName.startsWith("Windows")) {
|
||||||
|
log.warning("Found unknown Windows version: " + osName);
|
||||||
|
log.warning("Attempting to use default windows plug-in.");
|
||||||
|
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
||||||
|
} else {
|
||||||
|
log.warning("Trying to use default plugin, OS name " + osName +" not recognised");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:");
|
||||||
|
while(pluginClassTok.hasMoreTokens()) {
|
||||||
|
String className = pluginClassTok.nextToken();
|
||||||
|
try {
|
||||||
|
if(!loadedPlugins.contains(className)) {
|
||||||
|
log.fine("Loading: " + className);
|
||||||
|
Class ceClass = Class.forName(className);
|
||||||
|
ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance();
|
||||||
|
if(ce.isSupported()) {
|
||||||
|
environments.add(ce);
|
||||||
|
addControllers(ce.getControllers());
|
||||||
|
loadedPlugins.add(ce.getClass().getName());
|
||||||
|
} else {
|
||||||
|
logln(ceClass.getName() + " is not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!environments.isEmpty()){
|
||||||
|
Controller[] newScanControllers = environments.get(0).getControllers();
|
||||||
|
Controller[] ret = new Controller[newScanControllers.length];
|
||||||
|
for(int i = 0; i < newScanControllers.length; i++){
|
||||||
|
ret[i] = newScanControllers[i];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Controller[] ret = new Controller[controllers.size()];
|
Controller[] ret = new Controller[controllers.size()];
|
||||||
Iterator<Controller> it = controllers.iterator();
|
Iterator<Controller> it = controllers.iterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (it.hasNext())
|
while (it.hasNext()) {
|
||||||
{
|
ret[i] = (Controller)it.next();
|
||||||
ret[i] = it.next();
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private void reloadControllers()
|
* Returns a list of all controllers available to this environment,
|
||||||
{
|
* or an empty array if there are no controllers in this environment.
|
||||||
controllers = new ArrayList<>();
|
*/
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> scanControllers());
|
public Controller[] rescanControllers() {
|
||||||
//Check the properties for specified controller classes
|
if(!environments.isEmpty()){
|
||||||
String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
|
Controller[] newScanControllers = environments.get(0).rescanControllers();
|
||||||
if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
|
// need to add controllers that were connected
|
||||||
String osName = getPrivilegedProperty("os.name", "").trim();
|
for(int i = 0; i < newScanControllers.length; i++){
|
||||||
if(osName.equals("Linux")) {
|
boolean controllerExist = false;
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
|
for(Controller controller:controllers){
|
||||||
} else if(osName.equals("Mac OS X")) {
|
if(newScanControllers[i] == controller){
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
|
controllerExist = true;
|
||||||
} else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7") || osName.equals("Windows 8") || osName.equals("Windows 8.1") || osName.equals("Windows 10")) {
|
break;
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
}
|
||||||
} else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
|
}
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
|
if(!controllerExist){
|
||||||
} else if (osName.startsWith("Windows")) {
|
controllers.add(newScanControllers[i]);
|
||||||
log.warning("Found unknown Windows version: " + osName);
|
}
|
||||||
log.warning("Attempting to use default windows plug-in.");
|
}
|
||||||
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
|
ArrayList<Controller> removeControllers = new ArrayList<Controller>();
|
||||||
} else {
|
// need to remove controllers that have disconnected
|
||||||
log.warning("Trying to use default plugin, OS name " + osName +" not recognised");
|
for(Controller controller:controllers){
|
||||||
}
|
boolean controllerExist = false;
|
||||||
}
|
for(int i = 0; i < newScanControllers.length; i++){
|
||||||
|
if(controller == newScanControllers[i]){
|
||||||
StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:");
|
controllerExist = true;
|
||||||
while(pluginClassTok.hasMoreTokens()) {
|
break;
|
||||||
String className = pluginClassTok.nextToken();
|
}
|
||||||
try {
|
}
|
||||||
log.fine("Loading: " + className);
|
if(!controllerExist){
|
||||||
Class<?> ceClass = Class.forName(className);
|
//controllers.remove(controller);
|
||||||
ControllerEnvironment ce = (ControllerEnvironment) ceClass.getDeclaredConstructor().newInstance();
|
removeControllers.add(controller);
|
||||||
if(ce.isSupported()) {
|
}
|
||||||
addControllers(ce.getControllers());
|
}
|
||||||
loadedPluginNames.add(ce.getClass().getName());
|
for(Controller controller: removeControllers){
|
||||||
} else {
|
controllers.remove(controller);
|
||||||
log(ceClass.getName() + " is not supported");
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller[] ret = new Controller[controllers.size()];
|
||||||
|
Iterator<Controller> it = controllers.iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ret[i] = (Controller)it.next();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is jeff's new plugin code using Jeff's Plugin manager */
|
/* This is jeff's new plugin code using Jeff's Plugin manager */
|
||||||
private Void scanControllers() {
|
private void scanControllers() {
|
||||||
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
|
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
|
||||||
if(pluginPathName == null) {
|
if(pluginPathName == null) {
|
||||||
pluginPathName = "controller";
|
pluginPathName = "controller";
|
||||||
@ -168,8 +252,6 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
File.separator + "lib"+File.separator + pluginPathName);
|
File.separator + "lib"+File.separator + pluginPathName);
|
||||||
scanControllersAt(getPrivilegedProperty("user.dir")+
|
scanControllersAt(getPrivilegedProperty("user.dir")+
|
||||||
File.separator + pluginPathName);
|
File.separator + pluginPathName);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanControllersAt(String path) {
|
private void scanControllersAt(String path) {
|
||||||
@ -179,19 +261,19 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Plugins plugins = new Plugins(file);
|
Plugins plugins = new Plugins(file);
|
||||||
@SuppressWarnings("unchecked")
|
Class[] envClasses = plugins.getExtends(ControllerEnvironment.class);
|
||||||
Class<ControllerEnvironment>[] envClasses = plugins.getExtends(ControllerEnvironment.class);
|
|
||||||
for(int i=0;i<envClasses.length;i++){
|
for(int i=0;i<envClasses.length;i++){
|
||||||
try {
|
try {
|
||||||
ControllerEnvironment.log("ControllerEnvironment "+
|
ControllerEnvironment.logln("ControllerEnvironment "+
|
||||||
envClasses[i].getName()
|
envClasses[i].getName()
|
||||||
+" loaded by "+envClasses[i].getClassLoader());
|
+" loaded by "+envClasses[i].getClassLoader());
|
||||||
ControllerEnvironment ce = envClasses[i].getDeclaredConstructor().newInstance();
|
ControllerEnvironment ce = (ControllerEnvironment)
|
||||||
|
envClasses[i].newInstance();
|
||||||
if(ce.isSupported()) {
|
if(ce.isSupported()) {
|
||||||
addControllers(ce.getControllers());
|
addControllers(ce.getControllers());
|
||||||
loadedPluginNames.add(ce.getClass().getName());
|
loadedPlugins.add(ce.getClass().getName());
|
||||||
} else {
|
} else {
|
||||||
log(envClasses[i].getName() + " is not supported");
|
logln(envClasses[i].getName() + " is not supported");
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -121,6 +121,10 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen
|
|||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Controller[] rescanControllers() {
|
||||||
|
return enumerateControllers();
|
||||||
|
}
|
||||||
|
|
||||||
private final static Component[] createComponents(List<LinuxEventComponent> event_components, LinuxEventDevice device) {
|
private final static Component[] createComponents(List<LinuxEventComponent> event_components, LinuxEventDevice device) {
|
||||||
LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
|
LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
|
||||||
List<LinuxComponent> components = new ArrayList<>();
|
List<LinuxComponent> components = new ArrayList<>();
|
||||||
|
@ -84,6 +84,11 @@ public class DirectAndRawInputEnvironmentPlugin extends ControllerEnvironment {
|
|||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Controller[] rescanControllers() {
|
||||||
|
controllers=null;
|
||||||
|
return getControllers();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.java.games.input.ControllerEnvironment#isSupported()
|
* @see net.java.games.input.ControllerEnvironment#isSupported()
|
||||||
*/
|
*/
|
||||||
|
@ -138,6 +138,10 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im
|
|||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Controller[] rescanControllers() {
|
||||||
|
return enumControllers(window);
|
||||||
|
}
|
||||||
|
|
||||||
private final Component[] createComponents(IDirectInputDevice device, boolean map_mouse_buttons) {
|
private final Component[] createComponents(IDirectInputDevice device, boolean map_mouse_buttons) {
|
||||||
List<DIDeviceObject> device_objects = device.getObjects();
|
List<DIDeviceObject> device_objects = device.getObjects();
|
||||||
List<DIComponent> controller_components = new ArrayList<>();
|
List<DIComponent> controller_components = new ArrayList<>();
|
||||||
|
@ -121,6 +121,11 @@ public final class RawInputEnvironmentPlugin extends ControllerEnvironment imple
|
|||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Controller[] rescanControllers() {
|
||||||
|
RawInputEventQueue queue = new RawInputEventQueue();
|
||||||
|
return enumControllers(queue);
|
||||||
|
}
|
||||||
|
|
||||||
private final static SetupAPIDevice lookupSetupAPIDevice(String device_name, List<SetupAPIDevice> setupapi_devices) {
|
private final static SetupAPIDevice lookupSetupAPIDevice(String device_name, List<SetupAPIDevice> setupapi_devices) {
|
||||||
/* First, replace # with / in the device name, since that
|
/* First, replace # with / in the device name, since that
|
||||||
* seems to be the format in raw input device name
|
* seems to be the format in raw input device name
|
||||||
|
@ -120,12 +120,19 @@ public class WinTabEnvironmentPlugin extends ControllerEnvironment implements Pl
|
|||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Controller[] rescanControllers() {
|
||||||
|
winTabContext.close();
|
||||||
|
winTabContext = new WinTabContext(window);
|
||||||
|
winTabContext.open();
|
||||||
|
return winTabContext.getControllers();
|
||||||
|
}
|
||||||
|
|
||||||
private final class ShutdownHook extends Thread {
|
private final class ShutdownHook extends Thread {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
/* Release the devices to kill off active force feedback effects */
|
/* Release the devices to kill off active force feedback effects */
|
||||||
for (int i = 0; i < active_devices.size(); i++) {
|
/*for (int i = 0; i < active_devices.size(); i++) {
|
||||||
// TODO free the devices
|
// TODO free the devices
|
||||||
}
|
}*/
|
||||||
//Close the context
|
//Close the context
|
||||||
winTabContext.close();
|
winTabContext.close();
|
||||||
/* We won't release the window since it is
|
/* We won't release the window since it is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user