Corrected repeat count for key repeat in input device.

Previously the key event repeat count was always zero when the repeated
key down events was generated by the input device in the Linux kernel.

Change-Id: I86b7fd2a75880bc54d052ef404c3654b7ed14c52
This commit is contained in:
Kristian Dreher
2010-02-23 08:50:58 +01:00
committed by Jean-Baptiste Queru
parent 855a9e6d12
commit 133bfdfa4a

View File

@@ -6435,18 +6435,30 @@ public class WindowManagerService extends IWindowManager.Stub
case RawInputEvent.CLASS_KEYBOARD:
KeyEvent ke = (KeyEvent)ev.event;
if (ke.isDown()) {
lastKey = ke;
downTime = curTime;
keyRepeatCount = 0;
lastKeyTime = curTime;
nextKeyTime = lastKeyTime
+ ViewConfiguration.getLongPressTimeout();
if (DEBUG_INPUT) Log.v(
TAG, "Received key down: first repeat @ "
+ nextKeyTime);
if (lastKey != null &&
ke.getKeyCode() == lastKey.getKeyCode()) {
keyRepeatCount++;
// Arbitrary long timeout to block
// repeating here since we know that
// the device driver takes care of it.
nextKeyTime = lastKeyTime + LONG_WAIT;
if (DEBUG_INPUT) Log.v(
TAG, "Received repeated key down");
} else {
downTime = curTime;
keyRepeatCount = 0;
nextKeyTime = lastKeyTime
+ ViewConfiguration.getLongPressTimeout();
if (DEBUG_INPUT) Log.v(
TAG, "Received key down: first repeat @ "
+ nextKeyTime);
}
lastKey = ke;
} else {
lastKey = null;
downTime = 0;
keyRepeatCount = 0;
// Arbitrary long timeout.
lastKeyTime = curTime;
nextKeyTime = curTime + LONG_WAIT;
@@ -6454,7 +6466,12 @@ public class WindowManagerService extends IWindowManager.Stub
TAG, "Received key up: ignore repeat @ "
+ nextKeyTime);
}
dispatchKey((KeyEvent)ev.event, 0, 0);
if (keyRepeatCount > 0) {
dispatchKey(KeyEvent.changeTimeRepeat(ke,
ke.getEventTime(), keyRepeatCount), 0, 0);
} else {
dispatchKey(ke, 0, 0);
}
mQueue.recycleEvent(ev);
break;
case RawInputEvent.CLASS_TOUCHSCREEN: