本文整理汇总了Java中android.view.MotionEvent.getDevice方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.getDevice方法的具体用法?Java MotionEvent.getDevice怎么用?Java MotionEvent.getDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.getDevice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processJoystickInput
import android.view.MotionEvent; //导入方法依赖的package包/类
/**
* The ship directly handles joystick input.
*
* @param event
* @param historyPos
*/
private void processJoystickInput(MotionEvent event, int historyPos) {
// Get joystick position.
// Many game pads with two joysticks report the position of the
// second
// joystick
// using the Z and RZ axes so we also handle those.
// In a real game, we would allow the user to configure the axes
// manually.
if (null == mInputDevice) {
mInputDevice = event.getDevice();
}
float x = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_X, historyPos);
if (x == 0) {
x = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_HAT_X, historyPos);
}
if (x == 0) {
x = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_Z, historyPos);
}
float y = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_Y, historyPos);
if (y == 0) {
y = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_HAT_Y, historyPos);
}
if (y == 0) {
y = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_RZ, historyPos);
}
// Set the ship heading.
setHeading(x, y);
GameView.this.step(historyPos < 0 ? event.getEventTime() : event
.getHistoricalEventTime(historyPos));
}