Search in sources :

Example 21 with InputManager

use of android.hardware.input.InputManager in project android_frameworks_base by DirtyUnicorns.

the class KeyboardUI method init.

// Shoud only be called on the handler thread
private void init() {
    Context context = mContext;
    mKeyboardName = context.getString(com.android.internal.R.string.config_packagedKeyboardName);
    if (TextUtils.isEmpty(mKeyboardName)) {
        if (DEBUG) {
            Slog.d(TAG, "No packaged keyboard name given.");
        }
        return;
    }
    LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(context, null);
    if (bluetoothManager == null) {
        if (DEBUG) {
            Slog.e(TAG, "Failed to retrieve LocalBluetoothManager instance");
        }
        return;
    }
    mEnabled = true;
    mCachedDeviceManager = bluetoothManager.getCachedDeviceManager();
    mLocalBluetoothAdapter = bluetoothManager.getBluetoothAdapter();
    mProfileManager = bluetoothManager.getProfileManager();
    bluetoothManager.getEventManager().registerCallback(new BluetoothCallbackHandler());
    Utils.setErrorListener(new BluetoothErrorListener());
    InputManager im = context.getSystemService(InputManager.class);
    im.registerOnTabletModeChangedListener(this, mHandler);
    mInTabletMode = im.isInTabletMode();
    processKeyboardState();
    mUIHandler = new KeyboardUIHandler();
}
Also used : Context(android.content.Context) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) InputManager(android.hardware.input.InputManager)

Example 22 with InputManager

use of android.hardware.input.InputManager in project android_frameworks_base by DirtyUnicorns.

the class KeyboardShortcuts method retrieveKeyCharacterMap.

/**
     * Retrieves a {@link KeyCharacterMap} and assigns it to mKeyCharacterMap. If the given id is an
     * existing device, that device's map is used. Otherwise, it checks first all available devices
     * and if there is a full keyboard it uses that map, otherwise falls back to the Virtual
     * Keyboard with its default map.
     */
private void retrieveKeyCharacterMap(int deviceId) {
    final InputManager inputManager = InputManager.getInstance();
    if (deviceId != -1) {
        final InputDevice inputDevice = inputManager.getInputDevice(deviceId);
        if (inputDevice != null) {
            mKeyCharacterMap = inputDevice.getKeyCharacterMap();
            return;
        }
    }
    final int[] deviceIds = inputManager.getInputDeviceIds();
    for (int i = 0; i < deviceIds.length; ++i) {
        final InputDevice inputDevice = inputManager.getInputDevice(deviceIds[i]);
        // resort.
        if (inputDevice.getId() != -1 && inputDevice.isFullKeyboard()) {
            mKeyCharacterMap = inputDevice.getKeyCharacterMap();
            return;
        }
    }
    final InputDevice inputDevice = inputManager.getInputDevice(-1);
    mKeyCharacterMap = inputDevice.getKeyCharacterMap();
}
Also used : InputDevice(android.view.InputDevice) InputManager(android.hardware.input.InputManager)

Example 23 with InputManager

use of android.hardware.input.InputManager in project android_frameworks_base by crdroidandroid.

the class PieAction method triggerVirtualKeypress.

public static void triggerVirtualKeypress(final int keyCode, boolean longpress) {
    InputManager im = InputManager.getInstance();
    long now = SystemClock.uptimeMillis();
    int downflags = 0;
    int upflags = 0;
    if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        downflags = upflags = KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE;
    } else {
        downflags = upflags = KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
    }
    if (longpress) {
        downflags |= KeyEvent.FLAG_LONG_PRESS;
    }
    final KeyEvent downEvent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, downflags, InputDevice.SOURCE_KEYBOARD);
    im.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
    final KeyEvent upEvent = new KeyEvent(now, now, KeyEvent.ACTION_UP, keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, upflags, InputDevice.SOURCE_KEYBOARD);
    im.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}
Also used : KeyEvent(android.view.KeyEvent) InputManager(android.hardware.input.InputManager)

Example 24 with InputManager

use of android.hardware.input.InputManager in project android_frameworks_base by crdroidandroid.

the class Action method triggerVirtualKeypress.

public static void triggerVirtualKeypress(final int keyCode, boolean longpress) {
    InputManager im = InputManager.getInstance();
    long now = SystemClock.uptimeMillis();
    int downflags = 0;
    int upflags = 0;
    if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        downflags = upflags = KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE;
    } else {
        downflags = upflags = KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
    }
    if (longpress) {
        downflags |= KeyEvent.FLAG_LONG_PRESS;
    }
    final KeyEvent downEvent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, downflags, InputDevice.SOURCE_KEYBOARD);
    im.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
    final KeyEvent upEvent = new KeyEvent(now, now, KeyEvent.ACTION_UP, keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, upflags, InputDevice.SOURCE_KEYBOARD);
    im.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}
Also used : KeyEvent(android.view.KeyEvent) InputManager(android.hardware.input.InputManager)

Aggregations

InputManager (android.hardware.input.InputManager)24 KeyEvent (android.view.KeyEvent)6 Context (android.content.Context)5 InputDevice (android.view.InputDevice)5 LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)5 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 PrintServiceInfo (android.printservice.PrintServiceInfo)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 InputMethodInfo (android.view.inputmethod.InputMethodInfo)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1