本文整理匯總了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));
}