當前位置: 首頁>>代碼示例>>Java>>正文


Java InputDevice.SOURCE_TOUCHPAD屬性代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:googleglass,項目名稱:gdk-apidemo-sample,代碼行數:21,代碼來源:TouchpadView.java

示例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;
        }
    }
}
 
開發者ID:longzheng,項目名稱:PTVGlass,代碼行數:15,代碼來源:TouchpadView.java

示例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");
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:54,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:DocuSignDev,項目名稱:android-test-kit,代碼行數:5,代碼來源:InputManagerEventInjectionStrategy.java


注:本文中的android.view.InputDevice.SOURCE_TOUCHPAD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。