Java Code Examples for net.java.games.input.ControllerEnvironment#getDefaultEnvironment()
The following examples show how to use
net.java.games.input.ControllerEnvironment#getDefaultEnvironment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JInputManager.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Init */ public static void initKeyboard() { controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); controllers = controllerEnvironment.getControllers(); for(int i = 0; i < controllers.length; i++) { Controller c = controllers[i]; if((c.getType() == Controller.Type.KEYBOARD) && (c instanceof Keyboard)) { if(NullpoMinoSlick.useJInputKeyboard) { log.debug("initKeyboard: Keyboard found"); } keyboard = (Keyboard)c; } } if((keyboard == null) && (NullpoMinoSlick.useJInputKeyboard)) { log.error("initKeyboard: Keyboard NOT FOUND"); // Linux if(System.getProperty("os.name").startsWith("Linux")) { log.error("If you can use sudo, try the following command and start NullpoMino again:"); log.error("sudo chmod go+r /dev/input/*"); } } }
Example 2
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
/** * output all controllers, their components, and some details about those components. */ static public void listAllControllers() { ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment(); Log.message("supported="+ce.isSupported()); Controller[] ca = ce.getControllers(); for(int i =0;i<ca.length;i++){ Component[] components = ca[i].getComponents(); Log.message("Controller "+i+":"+ca[i].getName()+" "+ca[i].getType().toString()); Log.message("Component Count: "+components.length); // Get this controllers components (buttons and axis) for(int j=0;j<components.length;j++){ Log.message("\t"+j+": "+components[j].getName() + " " + components[j].getIdentifier().getName() +" (" + (components[j].isRelative() ? "Relative" : "Absolute") + " " + (components[j].isAnalog()? "Analog" : "Digital") + ")"); } } }
Example 3
Source File: JInputTest.java From halfnes with GNU General Public License v3.0 | 4 votes |
@Test public void testJInput() { ControllerEnvironment controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); Controller[] controllers = controllerEnvironment.getControllers(); System.out.println(String.format("%s controllers found.", controllers.length)); Arrays.asList(controllers).forEach(controller -> { System.out.println(String.format(" %s (%s)", controller, controller.getType())); }); }