protected void addButton( Component comp ) { logger.log(Level.FINE, "Adding button: \"{0}\" id:" + comp.getIdentifier(), comp); Identifier id = comp.getIdentifier(); if( !(id instanceof Button) ) { throw new IllegalArgumentException( "Component is not an button:" + comp ); } String name = comp.getName(); String original = id.getName(); try { Integer.parseInt(original); } catch (NumberFormatException e){ original = String.valueOf(buttonIndex.size()); } String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( logicalId != original ) { logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); } JoystickButton button = new DefaultJoystickButton( getInputManager(), this, getButtonCount(), name, logicalId ); addButton(button); buttonIndex.put( comp, button ); }
String original = id.getName(); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( logicalId != original ) { id.getName() + "_x", comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_x", povX.getName() ); addAxis(povX); povY = new DefaultJoystickAxis( getInputManager(), this, getAxisCount(), JoystickAxis.POV_Y, id.getName() + "_y", comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_y", povY.getName() ); addAxis(povY);
public static Collection<WinTabButtonComponent> createButtons(WinTabContext context, int deviceIndex, int numberOfButtons) { List<WinTabButtonComponent> buttons = new ArrayList<>(); Identifier id; for(int i=0;i<numberOfButtons;i++) { try { Class<Identifier.Button> buttonIdClass = Identifier.Button.class; Field idField = buttonIdClass.getField("_" + i); id = (Identifier)idField.get(null); buttons.add(new WinTabButtonComponent(context, deviceIndex, id.getName(), id, i)); } catch (SecurityException|NoSuchFieldException|IllegalArgumentException|IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return buttons; }
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; } }
protected void addButton( Component comp ) { logger.log(Level.FINE, "Adding button: \"{0}\" id:" + comp.getIdentifier(), comp); Identifier id = comp.getIdentifier(); if( !(id instanceof Button) ) { throw new IllegalArgumentException( "Component is not an axis:" + comp ); } String name = comp.getName(); String original = id.getName(); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( name != original ) { logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); } JoystickButton button = new DefaultJoystickButton( getInputManager(), this, getButtonCount(), name, logicalId ); addButton(button); buttonIndex.put( comp, button ); }
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; }
public static Collection createCursors(WinTabContext context, int deviceIndex, String[] cursorNames) { Identifier id; List cursors = new ArrayList(); for(int i=0;i<cursorNames.length;i++) { if(cursorNames[i].matches("Puck")) { id = Identifier.Button.TOOL_FINGER; } else if(cursorNames[i].matches("Eraser.*")) { id = Identifier.Button.TOOL_RUBBER; } else { id = Identifier.Button.TOOL_PEN; } cursors.add(new WinTabCursorComponent(context, deviceIndex, id.getName(), id, i)); } return cursors; } }
private void handleRelease(Component comp) { final String name = comp.getIdentifier().getName(); if (!this.pressedComponents.contains(name)) { return; } this.pressedComponents.remove(name); for (final BiConsumer<String, Float> cons : this.releasedConsumer) { cons.accept(name, comp.getPollData()); } final List<Consumer<Float>> consumers = this.componentReleasedConsumer.get(comp.getIdentifier().getName()); if (consumers != null) { for (final Consumer<Float> cons : consumers) { cons.accept(comp.getPollData()); } } }
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; }
public static Collection<WinTabCursorComponent> createCursors(WinTabContext context, int deviceIndex, String[] cursorNames) { Identifier id; List<WinTabCursorComponent> cursors = new ArrayList<>(); for(int i=0;i<cursorNames.length;i++) { if(cursorNames[i].matches("Puck")) { id = Identifier.Button.TOOL_FINGER; } else if(cursorNames[i].matches("Eraser.*")) { id = Identifier.Button.TOOL_RUBBER; } else { id = Identifier.Button.TOOL_PEN; } cursors.add(new WinTabCursorComponent(context, deviceIndex, id.getName(), id, i)); } return cursors; } }
public LinuxJoystickButton(Component.Identifier button_id) { super(button_id.getName(), button_id); }
public LinuxComponent(LinuxEventComponent component) { super(component.getIdentifier().getName(), component.getIdentifier()); this.component = component; }
public OSXComponent(Component.Identifier id, OSXHIDElement element) { super(id.getName(), id); this.element = element; }
private void handlePressed(Component comp) { final String name = comp.getIdentifier().getName(); for (final BiConsumer<String, Float> cons : this.pressedConsumer) { cons.accept(name, comp.getPollData()); } if (this.componentPressedConsumer.containsKey(name)) { for (Consumer<Float> cons : this.componentPressedConsumer.get(name)) { cons.accept(comp.getPollData()); } } if (!this.pressedComponents.contains(name)) { this.pressedComponents.add(name); } }
public LinuxJoystickButton(Component.Identifier button_id) { super(button_id.getName(), button_id); }
private void handlePollEvents(Event event) { for (final BiConsumer<String, Float> cons : this.pollConsumer) { cons.accept(event.getComponent().getIdentifier().getName(), event.getValue()); } final List<Consumer<Float>> consumers = this.componentPollConsumer.get(event.getComponent().getIdentifier().getName()); if (consumers != null) { for (final Consumer<Float> cons : consumers) { cons.accept(event.getValue()); } } }
public LinuxComponent(LinuxEventComponent component) { super(component.getIdentifier().getName(), component.getIdentifier()); this.component = component; }
protected ControllerEvent createControllerEvent(final Controller controller, final Event event) { return new ControllerEvent(event.getNanos(), controller.getName(), event.getComponent().getIdentifier() .getName(), event.getValue()); }