当前位置: 首页>>代码示例>>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;未经允许,请勿转载。