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);
private void processControllerEvent(Component component, float value) { Component.Identifier id = component.getIdentifier(); if (log.isDebugEnabled()) { log.debug(String.format("Controller Event on %s(%s): %f", component.getName(), id.getName(), value)); Buttons |= button; } else { log.warn(String.format("Unknown Controller Button Event on %s(%s): %f", component.getName(), id.getName(), value)); Buttons |= PSP_CTRL_UP | PSP_CTRL_RIGHT; } else { log.warn(String.format("Unknown Controller Arrows Event on %s(%s): %f", component.getName(), id.getName(), value)); log.debug(String.format("Unknown Controller Event in DeadZone on %s(%s): %f", component.getName(), id.getName(), value)); log.debug(String.format("Unknown Keyboard Controller Event on %s(%s): %f", component.getName(), id.getName(), value)); log.warn(String.format("Unknown Controller Event on %s(%s): %f", component.getName(), id.getName(), value));
float value = event.getValue(); Identifier identifier = component.getIdentifier(); String identifierName = identifier.getName(); break; default: jpcsp.Controller.log.warn(String.format("Unknown Controller POV Event on %s(%s): %f for %s", component.getName(), identifier.getName(), value, targetKey.toString())); break; jpcsp.Controller.log.debug(String.format("Unknown Controller Event in DeadZone on %s(%s): %f for %s", component.getName(), identifier.getName(), value, targetKey.toString())); } else { jpcsp.Controller.log.warn(String.format("Unknown Controller Event on %s(%s): %f for %s", component.getName(), identifier.getName(), value, targetKey.toString()));
case XAxis: id = Identifier.Axis.X; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case YAxis: id = Identifier.Axis.Y; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case ZAxis: id = Identifier.Axis.Z; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case NPressureAxis: id = Identifier.Axis.X_FORCE; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case TPressureAxis: id = Identifier.Axis.Y_FORCE; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case OrientationAxis: id = Identifier.Axis.RX; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); id = Identifier.Axis.RY; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[2], axisRanges[3])); id = Identifier.Axis.RZ; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[4], axisRanges[5])); break; case RotationAxis:
case WinTabDevice.XAxis: id = Identifier.Axis.X; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case WinTabDevice.YAxis: id = Identifier.Axis.Y; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case WinTabDevice.ZAxis: id = Identifier.Axis.Z; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case WinTabDevice.NPressureAxis: id = Identifier.Axis.X_FORCE; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case WinTabDevice.TPressureAxis: id = Identifier.Axis.Y_FORCE; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); break; case WinTabDevice.OrientationAxis: id = Identifier.Axis.RX; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[0], axisRanges[1])); id = Identifier.Axis.RY; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[2], axisRanges[3])); id = Identifier.Axis.RZ; components.add(new WinTabComponent(context, parentDevice, id.getName(), id, axisRanges[4], axisRanges[5])); break; case WinTabDevice.RotationAxis:
String original = id.getName(); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( name != 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);
axes[j].getIdentifier().getName() };
System.out.println("Component "+j+": "+components[j].getName()); System.out.println(" Identifier: "+ components[j].getIdentifier().getName()); System.out.print(" ComponentType: "); if (components[j].isRelative()) {
public static Collection createButtons(WinTabContext context, int deviceIndex, int numberOfButtons) { List buttons = new ArrayList(); Identifier id; for(int i=0;i<numberOfButtons;i++) { try { Class 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 e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (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 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 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; }