public Joystick[] loadJoysticks(InputManager inputManager){ ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment(); Controller[] cs = ce.getControllers(); List<Joystick> list = new ArrayList<Joystick>(); for( Controller c : ce.getControllers() ) { if (c.getType() == Controller.Type.KEYBOARD || c.getType() == Controller.Type.MOUSE) continue; logger.log(Level.FINE, "Attempting to create joystick for: \"{0}\"", c); // Try to create it like a joystick JInputJoystick stick = new JInputJoystick(inputManager, this, c, list.size(), c.getName()); for( Component comp : c.getComponents() ) { stick.addComponent(comp); } // If it has no axes then we'll assume it's not // a joystick if( stick.getAxisCount() == 0 ) { logger.log(Level.FINE, "Not a joystick: {0}", c); continue; } joystickIndex.put(c, stick); list.add(stick); } joysticks = list.toArray( new JInputJoystick[list.size()] ); return joysticks; }
private void initializeIdentifiers() { for (Component component : joystickController.getComponents()) { identifiers.add(component.getIdentifier()); } }
private void initializeIdentifiers() { for (Component component : joystickController.getComponents()) { identifiers.add(component.getIdentifier()); } }
GamepadInputDevice(Controller controller){ if(controller==null) throw new NullPointerException("Passed Controller intolerably null."); this.controller = controller; controller.setEventQueueSize(256); eventQueue = controller.getEventQueue(); System.out.println("CONTROLLER: "+controller.getClass().getName()); controllerSources = new ArrayList<GamepadControllerSource>(controller.getComponents().length); //System.out.println("Rumblers: "+controller.getRumblers().length); //controller.getRumblers()[0].rumble(1f); for(net.java.games.input.Component comp : controller.getComponents()){ GamepadControllerSource gcs = new GamepadControllerSource(comp); controllerSources.add(gcs); controllerSourceMap.put(comp, gcs); nameMap.put(comp.getName(),gcs); System.out.println("Component found: "+comp.getName()); }//end for(components) gamepadEventThread.start(); }//end consructor
protected ControllerInfo getControllerInfo(final Controller controller) { final List<String> axisNames = Lists.newArrayList(); final List<String> buttonNames = Lists.newArrayList(); for (final Component comp : controller.getComponents()) { if (comp.getIdentifier() instanceof Identifier.Axis) { axisNames.add(comp.getName()); } else if (comp.getIdentifier() instanceof Identifier.Button) { buttonNames.add(comp.getName()); } } return new ControllerInfo(controller.getName(), axisNames, buttonNames); }
private Component getControllerComponentByName(String name) { Component[] components = inputController.getComponents(); if (components != null) { // First search for the identifier name for (int i = 0; i < components.length; i++) { if (name.equals(components[i].getIdentifier().getName())) { return components[i]; } } // Second search for the component name for (int i = 0; i < components.length; i++) { if (name.equals(components[i].getName())) { return components[i]; } } } return null; }
Component[] evComponents = evController.getComponents(); Component[] jsComponents = jsController.getComponents(); if(evComponents.length==jsComponents.length) { boolean foundADifference = false;
private Component getControllerComponent(String identifierName) { Controller controller = getSelectedController(); if (controller == null) { return null; } Component[] components = controller.getComponents(); if (components == null) { return null; } for (int i = 0; i < components.length; i++) { if (identifierName.equals(components[i].getIdentifier().getName())) { return components[i]; } } return null; }
Component[] evComponents = evController.getComponents(); Component[] jsComponents = jsController.getComponents(); if(evComponents.length == jsComponents.length) { boolean foundADifference = false;
public ControllerWindow(JFrame frame,Controller ca){ super(ca.getName()); this.setName(ca.getName()); this.ca = ca; Container c = this.getContentPane(); c.setLayout(new BorderLayout()); Component[] components = ca.getComponents(); System.out.println("Component count = "+components.length); if (components.length>0) { int width = (int)Math.ceil(Math.sqrt(components.length)); JPanel p = new JPanel(); p.setLayout(new GridLayout(width,0)); for(int j=0;j<components.length;j++){ addAxis(p,components[j]); } c.add(new JScrollPane(p),BorderLayout.CENTER); } setSize(400,400); setLocation(50,50); setVisible(true); }
public ControllerWindow(JFrame frame,Controller ca){ super(ca.getName()); this.setName(ca.getName()); this.ca = ca; Container c = this.getContentPane(); c.setLayout(new BorderLayout()); Component[] components = ca.getComponents(); System.out.println("Component count = "+components.length); if (components.length>0) { int width = (int)Math.ceil(Math.sqrt(components.length)); JPanel p = new JPanel(); p.setLayout(new GridLayout(width,0)); for(int j=0;j<components.length;j++){ addAxis(p,components[j]); } c.add(new JScrollPane(p),BorderLayout.CENTER); } setSize(400,400); setLocation(50,50); setVisible(true); }
System.out.println(ca[i].getName()); System.out.println("Type: "+ca[i].getType().toString()); Component[] components = ca[i].getComponents(); System.out.println("Component Count: "+components.length); for(int j=0;j<components.length;j++){
this.name = name; axes = c.getComponents();
this.name = name; axes = c.getComponents();
Component[] components = firstMouse.getComponents(); StringBuffer buffer = new StringBuffer();
public Joystick[] loadJoysticks(InputManager inputManager){ ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment(); Controller[] cs = ce.getControllers(); List<Joystick> list = new ArrayList<Joystick>(); for( Controller c : ce.getControllers() ) { if (c.getType() == Controller.Type.KEYBOARD || c.getType() == Controller.Type.MOUSE) continue; logger.log(Level.FINE, "Attempting to create joystick for: \"{0}\"", c); // Try to create it like a joystick JInputJoystick stick = new JInputJoystick(inputManager, this, c, list.size(), c.getName()); for( Component comp : c.getComponents() ) { stick.addComponent(comp); } // If it has no axes then we'll assume it's not // a joystick if( stick.getAxisCount() == 0 ) { logger.log(Level.FINE, "Not a joystick: {0}", c); continue; } joystickIndex.put(c, stick); list.add(stick); } joysticks = list.toArray( new JInputJoystick[list.size()] ); return joysticks; }
this.name = name; axes = c.getComponents();
Component[] axes = c.getComponents();
public synchronized void init() { if (_inited) { return; } try { ControllerEnvironment.getDefaultEnvironment(); for (final Controller controller : ControllerEnvironment.getDefaultEnvironment().getControllers()) { if (controller.getType() != Type.KEYBOARD && controller.getType() != Type.MOUSE) { _controllers.add(getControllerInfo(controller)); for (final Component component : controller.getComponents()) { ControllerState.NOTHING.set(controller.getName(), component.getIdentifier().getName(), 0); } } } } catch (final Exception e) { e.printStackTrace(); } finally { _inited = true; } }
@Override public void update() { final boolean couldPoll = this.controller.poll(); if (!couldPoll) { this.dispose(); } final Event event = new Event(); while (this.controller.getEventQueue().getNextEvent(event)) { this.handlePollEvents(event); } for (Component comp : this.controller.getComponents()) { if (Math.abs(comp.getPollData()) > this.getDeadZone(comp.getIdentifier())) { this.handlePressed(comp); } else { this.handleRelease(comp); } } }