public AndroidController(int deviceId, String name) { this.deviceId = deviceId; this.name = name; InputDevice device = InputDevice.getDevice(deviceId); int numAxes = 0; for (MotionRange range : device.getMotionRanges()) { if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { if (range.getAxis() != MotionEvent.AXIS_HAT_X && range.getAxis() != MotionEvent.AXIS_HAT_Y) { numAxes += 1; } else { povAxis = true; } } } axesIds = new int[numAxes]; axes = new float[numAxes]; int i = 0; for (MotionRange range : device.getMotionRanges()) { if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { if (range.getAxis() != MotionEvent.AXIS_HAT_X && range.getAxis() != MotionEvent.AXIS_HAT_Y) { axesIds[i++] = range.getAxis(); } } } }
List<MotionRange> motionRanges = dev.getMotionRanges(); for (MotionRange motionRange: motionRanges) { logger.log(Level.INFO, "motion range: {0}", motionRange.toString());
@Override public boolean onGenericMotion(View v, MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 && event.getAction() == MotionEvent.ACTION_MOVE) { List<MotionRange> motionRanges = event.getDevice().getMotionRanges(); for(MotionRange mr : motionRanges){ int axis = mr.getAxis(); if(event.getAxisValue(axis) > 0.5 || event.getAxisValue(axis) < -0.5){ Log.i(TAG, "Axis found: " + MotionEvent.axisToString(axis)); this.mAxisName = MotionEvent.axisToString(axis); mValueTextView.setText(mAxisName); } } }else{ Log.i(TAG, "Not a joystick event."); } return true; }
joystick.hats = new ArrayList<InputDevice.MotionRange>(); List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges(); Collections.sort(ranges, new RangeComparator()); for (InputDevice.MotionRange range : ranges ) {
public InputDeviceState(InputDevice device) { mDevice = device; int numAxes = 0; final List<MotionRange> ranges = device.getMotionRanges(); for (MotionRange range : ranges) { if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { numAxes += 1; } } mAxes = new int[numAxes]; mAxisValues = new float[numAxes]; int i = 0; for (MotionRange range : ranges) { if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { mAxes[i++] = range.getAxis(); } } mKeys = new SparseIntArray(); }
public InputDeviceState(InputDevice device) { mDevice = device; int numAxes = 0; final List<MotionRange> ranges = device.getMotionRanges(); for (MotionRange range : ranges) { if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { numAxes += 1; } } mAxes = new int[numAxes]; mAxisValues = new float[numAxes]; int i = 0; for (MotionRange range : ranges) { if (range.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { mAxes[i++] = range.getAxis(); } } mKeys = new SparseIntArray(); }
List<InputDevice.MotionRange> motionRanges = input.getMotionRanges();
List<InputDevice.MotionRange> motions = input.getMotionRanges();