本文整理汇总了Java中android.view.InputDevice.SOURCE_TOUCHPAD属性的典型用法代码示例。如果您正苦于以下问题:Java InputDevice.SOURCE_TOUCHPAD属性的具体用法?Java InputDevice.SOURCE_TOUCHPAD怎么用?Java InputDevice.SOURCE_TOUCHPAD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.InputDevice
的用法示例。
在下文中一共展示了InputDevice.SOURCE_TOUCHPAD属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupTouchpadHardwareResolution
/** Looks up the hardware resolution of the Glass touchpad. */
private void lookupTouchpadHardwareResolution() {
int[] deviceIds = InputDevice.getDeviceIds();
for (int deviceId : deviceIds) {
InputDevice device = InputDevice.getDevice(deviceId);
if ((device.getSources() & InputDevice.SOURCE_TOUCHPAD) != 0) {
logVerbose("Touchpad motion range: x-axis [%d, %d] y-axis [%d, %d]",
device.getMotionRange(MotionEvent.AXIS_X).getMin(),
device.getMotionRange(MotionEvent.AXIS_X).getMax(),
device.getMotionRange(MotionEvent.AXIS_Y).getMin(),
device.getMotionRange(MotionEvent.AXIS_Y).getMax());
mTouchpadHardwareWidth = device.getMotionRange(MotionEvent.AXIS_X).getRange();
mTouchpadHardwareHeight = device.getMotionRange(MotionEvent.AXIS_Y).getRange();
// Stop after we've seen the first touchpad device, because there might be multiple
// devices in this list if the user is currently screencasting with MyGlass. The
// first one will always be the hardware touchpad.
break;
}
}
}
示例2: lookupTouchpadHardwareResolution
/** Looks up the hardware resolution of the Glass touchpad. */
private void lookupTouchpadHardwareResolution() {
int[] deviceIds = InputDevice.getDeviceIds();
for (int deviceId : deviceIds) {
InputDevice device = InputDevice.getDevice(deviceId);
if ((device.getSources() & InputDevice.SOURCE_TOUCHPAD) != 0) {
mTouchpadHardwareWidth = device.getMotionRange(MotionEvent.AXIS_X).getRange();
mTouchpadHardwareHeight = device.getMotionRange(MotionEvent.AXIS_Y).getRange();
// Stop after we've seen the first touchpad device, because there might be multiple
// devices in this list if the user is currently screencasting with MyGlass. The
// first one will always be the hardware touchpad.
break;
}
}
}
示例3: checkUiChoice
/**
* Check if the input event make us think that user is on TV.
* If it is the case and if the Ui mode is not setup, then we propose to try the TV UI.
* @param event
*/
private void checkUiChoice(InputEvent event) {
// Make sure we go through this method only once
if (sUiChoiceCheckDone) {
return;
}
sUiChoiceCheckDone = true;
// No need to check more if this APK does not integrate the leanback UI (this is decided at build time)
if (!EntryActivity.isLeanbackUiAvailable()) {
return;
}
boolean probablyTv = false;
switch (event.getSource()) {
// All these case mean the user is probably on TV
case InputDevice.SOURCE_KEYBOARD:
case InputDevice.SOURCE_TOUCHPAD:
case InputDevice.SOURCE_DPAD:
case InputDevice.SOURCE_GAMEPAD:
case InputDevice.SOURCE_JOYSTICK:
case InputDevice.SOURCE_HDMI:
Log.d(TAG, "event source = "+event.getSource()+" -> probably TV");
probablyTv = true;
break;
case InputDevice.SOURCE_STYLUS:
case InputDevice.SOURCE_TOUCHSCREEN:
case InputDevice.SOURCE_TRACKBALL:
case InputDevice.SOURCE_MOUSE:
default:
Log.d(TAG, "event source = "+event.getSource()+" -> probably not TV");
probablyTv = false;
break;
}
if (!probablyTv) {
return;
}
final String uiMode = PreferenceManager.getDefaultSharedPreferences(this)
.getString(UiChoiceDialog.UI_CHOICE_LEANBACK_KEY, "unset");
// If the choice has not been done yet, ask user
if (uiMode.equals("unset") &&
!getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { // no UI choice to do on actual AndroidTV devices
new UiChoiceDialog().show(getFragmentManager(), "UiChoiceDialog");
}
}
示例4: isFromTouchpadInGlassDevice
private static boolean isFromTouchpadInGlassDevice(MotionEvent motionEvent) {
return (Build.DEVICE.contains("glass")
|| Build.DEVICE.contains("Glass") || Build.DEVICE.contains("wingman"))
&& ((motionEvent.getSource() & InputDevice.SOURCE_TOUCHPAD) != 0);
}