diff options
author | 2010-12-06 17:13:33 -0800 | |
---|---|---|
committer | 2010-12-07 17:35:26 -0800 | |
commit | 02d85b5021dc3e9c042e1e3426fae2f0a903595b (patch) | |
tree | cfd014e8539fbed0c51d586fec095d1969f0eed1 /libs/ui/InputReader.cpp | |
parent | b5a00fcb71426492f248ed49a0514a9b8d385065 (diff) |
Add support for fallback keycodes.
This change enables the framework to synthesize key events to implement
default behavior when an application does not handle a key.
For example, this change enables numeric keypad keys to perform
their associated special function when numlock is off.
The application is informed that it is processing a fallback keypress
so it can choose to ignore it.
Added a new keycode for switching applications.
Added ALT key deadkeys.
New default key mappings:
- ESC -> BACK
- Meta+ESC -> HOME
- Alt+ESC -> MENU
- Meta+Space -> SEARCH
- Meta+Tab -> APP_SWITCH
Fixed some comments.
Fixed some tests.
Change-Id: Id7f3b6645f3a350275e624547822f72652f3defe
Diffstat (limited to 'libs/ui/InputReader.cpp')
-rw-r--r-- | libs/ui/InputReader.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp index 9cc96adf39..51ed09f87e 100644 --- a/libs/ui/InputReader.cpp +++ b/libs/ui/InputReader.cpp @@ -745,17 +745,6 @@ KeyboardInputMapper::~KeyboardInputMapper() { void KeyboardInputMapper::initializeLocked() { mLocked.metaState = AMETA_NONE; mLocked.downTime = 0; - - initializeLedStateLocked(mLocked.capsLockLedState, LED_CAPSL); - initializeLedStateLocked(mLocked.numLockLedState, LED_NUML); - initializeLedStateLocked(mLocked.scrollLockLedState, LED_SCROLLL); - - updateLedStateLocked(true); -} - -void KeyboardInputMapper::initializeLedStateLocked(LockedState::LedState& ledState, int32_t led) { - ledState.avail = getEventHub()->hasLed(getDeviceId(), led); - ledState.on = false; } uint32_t KeyboardInputMapper::getSources() { @@ -786,6 +775,12 @@ void KeyboardInputMapper::configure() { // Configure basic parameters. configureParameters(); + + // Reset LEDs. + { + AutoMutex _l(mLock); + resetLedStateLocked(); + } } void KeyboardInputMapper::configureParameters() { @@ -813,6 +808,7 @@ void KeyboardInputMapper::reset() { // Synthesize key up event on reset if keys are currently down. if (mLocked.keyDowns.isEmpty()) { initializeLocked(); + resetLedStateLocked(); break; // done } @@ -953,6 +949,19 @@ int32_t KeyboardInputMapper::getMetaState() { } // release lock } +void KeyboardInputMapper::resetLedStateLocked() { + initializeLedStateLocked(mLocked.capsLockLedState, LED_CAPSL); + initializeLedStateLocked(mLocked.numLockLedState, LED_NUML); + initializeLedStateLocked(mLocked.scrollLockLedState, LED_SCROLLL); + + updateLedStateLocked(true); +} + +void KeyboardInputMapper::initializeLedStateLocked(LockedState::LedState& ledState, int32_t led) { + ledState.avail = getEventHub()->hasLed(getDeviceId(), led); + ledState.on = false; +} + void KeyboardInputMapper::updateLedStateLocked(bool reset) { updateLedStateForModifierLocked(mLocked.capsLockLedState, LED_CAPSL, AMETA_CAPS_LOCK_ON, reset); @@ -966,7 +975,7 @@ void KeyboardInputMapper::updateLedStateForModifierLocked(LockedState::LedState& int32_t led, int32_t modifier, bool reset) { if (ledState.avail) { bool desiredState = (mLocked.metaState & modifier) != 0; - if (ledState.on != desiredState) { + if (reset || ledState.on != desiredState) { getEventHub()->setLedState(getDeviceId(), led, desiredState); ledState.on = desiredState; } |