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

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

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

MotionEvent.getDevice介绍

暂无

代码示例

代码示例来源: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

mLastInputDevice = event.getDevice();

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

mLastInputDevice = event.getDevice();

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

InputDevice mInputDevice = event.getDevice();

代码示例来源:origin: bitcraze/crazyflie-android-client

public void dealWithMotionEvent(MotionEvent event){
  //Log.i(LOG_TAG, "Input device: " + event.getDevice().getName());
  /*if axis has a range of 1 (0 -> 1) instead of 2 (-1 -> 0) do not invert axis value,
  this is necessary for analog R1 (Brake) or analog R2 (Gas) shoulder buttons on PS3 controller*/
  if (event != null) {
    if (event.getDevice() != null) {
      InputDevice device = event.getDevice();
      mRightAnalogYAxisInvertFactor = (device.getMotionRange(mRightAnalogYAxis).getRange() == 1) ? 1 : -1;
      mLeftAnalogYAxisInvertFactor = (device.getMotionRange(mLeftAnalogYAxis).getRange() == 1) ? 1 : -1;
    } else {
      Log.w(LOG_TAG, "event.getDevice() == null! => event.getClass(): " + event.getClass());
    }
    // default axis are set to work with PS3 controller
    mControls.setRightAnalogX((float) event.getAxisValue(mRightAnalogXAxis));
    mControls.setRightAnalogY((float) (event.getAxisValue(mRightAnalogYAxis)) * mRightAnalogYAxisInvertFactor);
    mControls.setLeftAnalogX((float) event.getAxisValue(mLeftAnalogXAxis));
    mControls.setLeftAnalogY((float) (event.getAxisValue(mLeftAnalogYAxis)) * mLeftAnalogYAxisInvertFactor);
    mSplit_axis_yaw_right = (float) event.getAxisValue(mSplitAxisYawRightAxis);
    mSplit_axis_yaw_left = (float) event.getAxisValue(mSplitAxisYawLeftAxis);
  }
}

代码示例来源:origin: SachinVin/citra_android

return false;
InputDevice input = event.getDevice();

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

mInputDevice = event.getDevice();

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

public static boolean processJoystickInput(MotionEvent event, int historyPos) {
  InputDevice mInputDevice = event.getDevice();

代码示例来源:origin: SachinVin/citra_android

return true;
InputDevice input = event.getDevice();
List<InputDevice.MotionRange> motions = input.getMotionRanges();

相关文章