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


Java InputDevice.KEYBOARD_TYPE_ALPHABETIC屬性代碼示例

本文整理匯總了Java中android.view.InputDevice.KEYBOARD_TYPE_ALPHABETIC屬性的典型用法代碼示例。如果您正苦於以下問題:Java InputDevice.KEYBOARD_TYPE_ALPHABETIC屬性的具體用法?Java InputDevice.KEYBOARD_TYPE_ALPHABETIC怎麽用?Java InputDevice.KEYBOARD_TYPE_ALPHABETIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.InputDevice的用法示例。


在下文中一共展示了InputDevice.KEYBOARD_TYPE_ALPHABETIC屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Pass-through virtual navigation keys
    if ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
        return super.onKeyUp(keyCode, event);
    }

    boolean handled = false;
    boolean detectedGamepad = event.getDevice() != null && ((event.getDevice().getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK ||
            (event.getDevice().getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD);
    if (detectedGamepad || (event.getDevice() == null ||
            event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
    )) {
        // Always try the controller handler first, unless it's an alphanumeric keyboard device.
        // Otherwise, controller handler will eat keyboard d-pad events.
        handled = controllerHandler.handleButtonUp(event);
    }

    if (!handled) {
        // Try the keyboard handler
        short translated = KeyboardTranslator.translate(event.getKeyCode());
        if (translated == 0) {
            return super.onKeyUp(keyCode, event);
        }

        if (handleSpecialKeys(keyCode, false)) {
            return true;
        }

        // Pass through keyboard input if we're not grabbing
        if (!grabbedInput) {
            return super.onKeyUp(keyCode, event);
        }

        conn.sendKeyboardInput(translated, KeyboardPacket.KEY_UP, getModifierState(event));
    }

    return true;
}
 
開發者ID:moonlight-stream,項目名稱:moonlight-android,代碼行數:39,代碼來源:Game.java

示例2: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Pass-through virtual navigation keys
    if ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
        return super.onKeyDown(keyCode, event);
    }

    boolean handled = false;

    boolean detectedGamepad = event.getDevice() != null && ((event.getDevice().getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK ||
            (event.getDevice().getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD);
    if (detectedGamepad || (event.getDevice() == null ||
            event.getDevice().getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
    )) {
        // Always try the controller handler first, unless it's an alphanumeric keyboard device.
        // Otherwise, controller handler will eat keyboard d-pad events.
        handled = controllerHandler.handleButtonDown(event);
    }

    if (!handled) {
        // Try the keyboard handler
        short translated = KeyboardTranslator.translate(event.getKeyCode());
        if (translated == 0) {
            return super.onKeyDown(keyCode, event);
        }

        // Let this method take duplicate key down events
        if (handleSpecialKeys(keyCode, true)) {
            return true;
        }

        // Pass through keyboard input if we're not grabbing
        if (!grabbedInput) {
            return super.onKeyDown(keyCode, event);
        }

        conn.sendKeyboardInput(translated, KeyboardPacket.KEY_DOWN, getModifierState(event));
    }

    return true;
}
 
開發者ID:moonlight-stream,項目名稱:moonlight-android,代碼行數:41,代碼來源:Game.java


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