android.view.MotionEvent.getHistoricalAxisValue()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(264)

本文整理了Java中android.view.MotionEvent.getHistoricalAxisValue()方法的一些代码示例,展示了MotionEvent.getHistoricalAxisValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getHistoricalAxisValue()方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getHistoricalAxisValue

MotionEvent.getHistoricalAxisValue介绍

暂无

代码示例

代码示例来源:origin: qiubiteme/android_api_demos

public boolean onJoystickMotion(MotionEvent event) {
  StringBuilder message = new StringBuilder();
  message.append(mDevice.getName()).append(" - Joystick Motion:\n");
  final int historySize = event.getHistorySize();
  for (int i = 0; i < mAxes.length; i++) {
    final int axis = mAxes[i];
    final float value = event.getAxisValue(axis);
    mAxisValues[i] = value;
    message.append("  ").append(MotionEvent.axisToString(axis)).append(": ");
    // Append all historical values in the batch.
    for (int historyPos = 0; historyPos < historySize; historyPos++) {
      message.append(event.getHistoricalAxisValue(axis, historyPos));
      message.append(", ");
    }
    // Append the current value.
    message.append(value);
    message.append("\n");
  }
  Log.i(TAG, message.toString());
  return true;
}

代码示例来源:origin: li2/learning-android-open-source

public boolean onJoystickMotion(MotionEvent event) {
  StringBuilder message = new StringBuilder();
  message.append(mDevice.getName()).append(" - Joystick Motion:\n");
  final int historySize = event.getHistorySize();
  for (int i = 0; i < mAxes.length; i++) {
    final int axis = mAxes[i];
    final float value = event.getAxisValue(axis);
    mAxisValues[i] = value;
    message.append("  ").append(MotionEvent.axisToString(axis)).append(": ");
    // Append all historical values in the batch.
    for (int historyPos = 0; historyPos < historySize; historyPos++) {
      message.append(event.getHistoricalAxisValue(axis, historyPos));
      message.append(", ");
    }
    // Append the current value.
    message.append(value);
    message.append("\n");
  }
  Log.i(TAG, message.toString());
  return true;
}

代码示例来源:origin: stackoverflow.com

private static float getCenteredAxis(MotionEvent event,
    InputDevice device, int axis, int historyPos) {
  final InputDevice.MotionRange range =
      device.getMotionRange(axis, event.getSource());

  // A joystick at rest does not always report an absolute position of
  // (0,0). Use the getFlat() method to determine the range of values
  // bounding the joystick axis center.
  if (range != null) {
    final float flat = range.getFlat();
    final float value =
        historyPos < 0 ? event.getAxisValue(axis):
        event.getHistoricalAxisValue(axis, historyPos);

    // Ignore axis values that are within the 'flat' region of the
    // joystick axis center.
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: qiubiteme/android_api_demos

private static float getCenteredAxis(MotionEvent event, InputDevice device,
    int axis, int historyPos) {
  final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
  if (range != null) {
    final float flat = range.getFlat();
    final float value = historyPos < 0 ? event.getAxisValue(axis)
        : event.getHistoricalAxisValue(axis, historyPos);
    // Ignore axis values that are within the 'flat' region of the joystick axis center.
    // A joystick at rest does not always report an absolute position of (0,0).
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: li2/learning-android-open-source

private static float getCenteredAxis(MotionEvent event, InputDevice device,
    int axis, int historyPos) {
  final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
  if (range != null) {
    final float flat = range.getFlat();
    final float value = historyPos < 0 ? event.getAxisValue(axis)
        : event.getHistoricalAxisValue(axis, historyPos);
    // Ignore axis values that are within the 'flat' region of the joystick axis center.
    // A joystick at rest does not always report an absolute position of (0,0).
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: JimSeker/bluetooth

private static float getCenteredAxis(MotionEvent event, InputDevice device,
    int axis, int historyPos) {
  final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
  if (range != null) {
    final float flat = range.getFlat();
    final float value = historyPos < 0 ? event.getAxisValue(axis)
        : event.getHistoricalAxisValue(axis, historyPos);
    // Ignore axis values that are within the 'flat' region of the
    // joystick axis center.
    // A joystick at rest does not always report an absolute position of
    // (0,0).
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: gearvrf/GearVRf-Demos

private static float getCenteredAxis(MotionEvent event, InputDevice device,
    int axis, int historyPos) {
  final InputDevice.MotionRange range = device.getMotionRange(axis,
      event.getSource());
  // A joystick at rest does not always report an absolute position of
  // (0,0). Use the getFlat() method to determine the range of values
  // bounding the joystick axis center.
  if (range != null) {
    final float flat = range.getFlat();
    final float value = historyPos < 0 ? event.getAxisValue(axis)
        : event.getHistoricalAxisValue(axis, historyPos);
    // Ignore axis values that are within the 'flat' region of the
    // joystick axis center.
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: gearvrf/GearVRf-Demos

private static float getCenteredAxis(MotionEvent event, InputDevice device,
                   int axis, int historyPos) {
  final InputDevice.MotionRange range = device.getMotionRange(axis,
      event.getSource());
  // A joystick at rest does not always report an absolute position of
  // (0,0). Use the getFlat() method to determine the range of values
  // bounding the joystick axis center.
  if (range != null) {
    final float flat = range.getFlat();
    final float value = historyPos < 0 ? event.getAxisValue(axis)
        : event.getHistoricalAxisValue(axis, historyPos);
    // Ignore axis values that are within the 'flat' region of the
    // joystick axis center.
    if (Math.abs(value) > flat) {
      return value;
    }
  }
  return 0;
}

代码示例来源:origin: THEONE10211024/ApiDemos

event.getHistoricalTouchMinor(j, i),
event.getHistoricalOrientation(j, i),
event.getHistoricalAxisValue(MotionEvent.AXIS_DISTANCE, j, i),
event.getHistoricalAxisValue(MotionEvent.AXIS_TILT, j, i));

代码示例来源:origin: qiubiteme/android_api_demos

event.getHistoricalTouchMinor(j, i),
event.getHistoricalOrientation(j, i),
event.getHistoricalAxisValue(MotionEvent.AXIS_DISTANCE, j, i),
event.getHistoricalAxisValue(MotionEvent.AXIS_TILT, j, i));

相关文章