本文整理匯總了Java中android.view.MotionEvent.getDeviceId方法的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.getDeviceId方法的具體用法?Java MotionEvent.getDeviceId怎麽用?Java MotionEvent.getDeviceId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.getDeviceId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onGenericMotionEvent
import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
mInputManager.onGenericMotionEvent(event);
// Check that the event came from a joystick or gamepad since a generic
// motion event could be almost anything. API level 18 adds the useful
// event.isFromSource() helper function.
int eventSource = event.getSource();
if ((((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) ||
((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK))
&& event.getAction() == MotionEvent.ACTION_MOVE) {
int id = event.getDeviceId();
if (-1 != id) {
Ship curShip = getShipForId(id);
if (curShip.onGenericMotionEvent(event)) {
return true;
}
}
}
return super.onGenericMotionEvent(event);
}
示例2: onGenericMotionEvent
import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public void onGenericMotionEvent(MotionEvent event) {
// detect new devices
int id = event.getDeviceId();
long[] timeArray = mDevices.get(id);
if (null == timeArray) {
notifyListeners(ON_DEVICE_ADDED, id);
timeArray = new long[1];
mDevices.put(id, timeArray);
}
long time = SystemClock.elapsedRealtime();
timeArray[0] = time;
}