本文整理了Java中android.view.MotionEvent.getDevice()
方法的一些代码示例,展示了MotionEvent.getDevice()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getDevice()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称: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();
内容来源于网络,如有侵权,请联系作者删除!