Java Code Examples for android.view.MotionEvent#AXIS_Z

The following examples show how to use android.view.MotionEvent#AXIS_Z . 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: ControllerMappingHelper.java    From citra_android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Scale an axis to be zero-centered with a proper range.
 */
public float scaleAxis(InputDevice inputDevice, int axis, float value)
{
  if (isDualShock4(inputDevice))
  {
    // Android doesn't have correct mappings for this controller's triggers. It reports them
    // as RX & RY, centered at -1.0, and with a range of [-1.0, 1.0]
    // Scale them to properly zero-centered with a range of [0.0, 1.0].
    if (axis == MotionEvent.AXIS_RX || axis == MotionEvent.AXIS_RY)
    {
      return (value + 1) / 2.0f;
    }
  }
  else if (isXboxOneWireless(inputDevice))
  {
    // Same as the DualShock 4, the mappings are missing.
    if (axis == MotionEvent.AXIS_Z || axis == MotionEvent.AXIS_RZ)
    {
      return (value + 1) / 2.0f;
    }
    if (axis == MotionEvent.AXIS_GENERIC_1)
    {
      // This axis is stuck at ~.5. Ignore it.
      return 0.0f;
    }
  }
  else if (isMogaPro2Hid(inputDevice))
  {
    // This controller has a broken axis that reports a constant value. Ignore it.
    if (axis == MotionEvent.AXIS_GENERIC_1)
    {
      return 0.0f;
    }
  }
  return value;
}
 
Example 2
Source File: GamepadMappings.java    From 365browser with Apache License 2.0 5 votes vote down vote up
UnknownGamepadMappings(int[] axes) {
    int hatAxesFound = 0;

    for (int axis : axes) {
        switch (axis) {
            case MotionEvent.AXIS_LTRIGGER:
            case MotionEvent.AXIS_BRAKE:
                mLeftTriggerAxis = axis;
                break;
            case MotionEvent.AXIS_RTRIGGER:
            case MotionEvent.AXIS_GAS:
            case MotionEvent.AXIS_THROTTLE:
                mRightTriggerAxis = axis;
                break;
            case MotionEvent.AXIS_RX:
            case MotionEvent.AXIS_Z:
                mRightStickXAxis = axis;
                break;
            case MotionEvent.AXIS_RY:
            case MotionEvent.AXIS_RZ:
                mRightStickYAxis = axis;
                break;
            case MotionEvent.AXIS_HAT_X:
                hatAxesFound++;
                break;
            case MotionEvent.AXIS_HAT_Y:
                hatAxesFound++;
                break;
            default:
                break;
        }
    }

    if (hatAxesFound == 2) {
        mUseHatAxes = true;
    }
}
 
Example 3
Source File: GamepadMappings.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private static void mapZAndRZAxesToRightStick(float[] mappedAxes, float[] rawAxes) {
    mappedAxes[CanonicalAxisIndex.RIGHT_STICK_X] = rawAxes[MotionEvent.AXIS_Z];
    mappedAxes[CanonicalAxisIndex.RIGHT_STICK_Y] = rawAxes[MotionEvent.AXIS_RZ];
}
 
Example 4
Source File: AndroidJoystickJoyInput14.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected JoystickAxis addAxis(MotionRange motionRange) {

            String name = MotionEvent.axisToString(motionRange.getAxis());

            String original = MotionEvent.axisToString(motionRange.getAxis());
            if (motionRange.getAxis() == MotionEvent.AXIS_X) {
                original = JoystickAxis.X_AXIS;
            } else if (motionRange.getAxis() == MotionEvent.AXIS_Y) {
                original = JoystickAxis.Y_AXIS;
            } else if (motionRange.getAxis() == MotionEvent.AXIS_Z) {
                original = JoystickAxis.Z_AXIS;
            } else if (motionRange.getAxis() == MotionEvent.AXIS_RZ) {
                original = JoystickAxis.Z_ROTATION;
            } else if (motionRange.getAxis() == MotionEvent.AXIS_HAT_X) {
                original = JoystickAxis.POV_X;
            } else if (motionRange.getAxis() == MotionEvent.AXIS_HAT_Y) {
                original = JoystickAxis.POV_Y;
            }
            String logicalId = JoystickCompatibilityMappings.remapComponent( getName(), original );
            if( logicalId == null ? original != null : !logicalId.equals(original) ) {
                logger.log(Level.FINE, "Remapped: {0} to: {1}",
                        new Object[]{original, logicalId});
            }

            JoystickAxis axis = new DefaultJoystickAxis(getInputManager(),
                                                this,
                                                getAxisCount(),
                                                name,
                                                logicalId,
                                                true,
                                                true,
                                                motionRange.getFlat());

            if (motionRange.getAxis() == MotionEvent.AXIS_X) {
                xAxis = axis;
            }
            if (motionRange.getAxis() == MotionEvent.AXIS_Y) {
                yAxis = axis;
            }
            if (motionRange.getAxis() == MotionEvent.AXIS_HAT_X) {
                povX = axis;
            }
            if (motionRange.getAxis() == MotionEvent.AXIS_HAT_Y) {
                povY = axis;
            }

            addAxis(axis);
            axisIndex.put(motionRange.getAxis(), axis);
            return axis;
        }