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

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

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

MotionEvent.axisToString介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void testAxisFromToString() {
 assertThat(MotionEvent.axisToString(MotionEvent.AXIS_RTRIGGER)).isEqualTo("AXIS_RTRIGGER");
 assertThat(MotionEvent.axisFromString("AXIS_RTRIGGER")).isEqualTo(MotionEvent.AXIS_RTRIGGER);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

if (joystick != null) {
  for (int androidAxis: joystick.getAndroidAxes()) {
    String axisName = MotionEvent.axisToString(androidAxis);
    float value = event.getAxisValue(androidAxis);
    int action = event.getAction();

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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;

代码示例来源: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: 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: bitcraze/crazyflie-android-client

@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;
}

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

TextColumn column = (TextColumn) mDataItems.get(id);
if (column == null) {
  column = new TextColumn(id, MotionEvent.axisToString(axis));
  mDataItems.put(id, column);

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

TextColumn column = (TextColumn) mDataItems.get(id);
if (column == null) {
  column = new TextColumn(id, MotionEvent.axisToString(axis));
  mDataItems.put(id, column);

相关文章