use of android.hardware.input.InputManager in project android_frameworks_base by crdroidandroid.
the class KeyCharacterMap method load.
/**
* Loads the key character maps for the keyboard with the specified device id.
*
* @param deviceId The device id of the keyboard.
* @return The associated key character map.
* @throws {@link UnavailableException} if the key character map
* could not be loaded because it was malformed or the default key character map
* is missing from the system.
*/
public static KeyCharacterMap load(int deviceId) {
final InputManager im = InputManager.getInstance();
InputDevice inputDevice = im.getInputDevice(deviceId);
if (inputDevice == null) {
inputDevice = im.getInputDevice(VIRTUAL_KEYBOARD);
if (inputDevice == null) {
throw new UnavailableException("Could not load key character map for device " + deviceId);
}
}
return inputDevice.getKeyCharacterMap();
}
use of android.hardware.input.InputManager in project android_frameworks_base by AOSPA.
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();
}
use of android.hardware.input.InputManager in project android_frameworks_base by DirtyUnicorns.
the class KeyCharacterMap method load.
/**
* Loads the key character maps for the keyboard with the specified device id.
*
* @param deviceId The device id of the keyboard.
* @return The associated key character map.
* @throws {@link UnavailableException} if the key character map
* could not be loaded because it was malformed or the default key character map
* is missing from the system.
*/
public static KeyCharacterMap load(int deviceId) {
final InputManager im = InputManager.getInstance();
InputDevice inputDevice = im.getInputDevice(deviceId);
if (inputDevice == null) {
inputDevice = im.getInputDevice(VIRTUAL_KEYBOARD);
if (inputDevice == null) {
throw new UnavailableException("Could not load key character map for device " + deviceId);
}
}
return inputDevice.getKeyCharacterMap();
}
use of android.hardware.input.InputManager in project platform_frameworks_base by android.
the class KeyCharacterMap method load.
/**
* Loads the key character maps for the keyboard with the specified device id.
*
* @param deviceId The device id of the keyboard.
* @return The associated key character map.
* @throws {@link UnavailableException} if the key character map
* could not be loaded because it was malformed or the default key character map
* is missing from the system.
*/
public static KeyCharacterMap load(int deviceId) {
final InputManager im = InputManager.getInstance();
InputDevice inputDevice = im.getInputDevice(deviceId);
if (inputDevice == null) {
inputDevice = im.getInputDevice(VIRTUAL_KEYBOARD);
if (inputDevice == null) {
throw new UnavailableException("Could not load key character map for device " + deviceId);
}
}
return inputDevice.getKeyCharacterMap();
}
use of android.hardware.input.InputManager in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method triggerVirtualKeypress.
private void triggerVirtualKeypress(final int keyCode) {
new Thread(new Runnable() {
public void run() {
InputManager im = InputManager.getInstance();
long now = SystemClock.uptimeMillis();
final KeyEvent downEvent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_KEYBOARD);
final KeyEvent upEvent = KeyEvent.changeAction(downEvent, KeyEvent.ACTION_UP);
mIsVirtualKeypress = true;
im.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);
im.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);
mIsVirtualKeypress = false;
}
}).start();
}
Aggregations