Skip to content

Commit 133bfdf

Browse files
Kristian DreherJean-Baptiste Queru
authored andcommitted
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
1 parent 855a9e6 commit 133bfdf

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

services/java/com/android/server/WindowManagerService.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6435,26 +6435,43 @@ private void process() {
64356435
case RawInputEvent.CLASS_KEYBOARD:
64366436
KeyEvent ke = (KeyEvent)ev.event;
64376437
if (ke.isDown()) {
6438-
lastKey = ke;
6439-
downTime = curTime;
6440-
keyRepeatCount = 0;
64416438
lastKeyTime = curTime;
6442-
nextKeyTime = lastKeyTime
6443-
+ ViewConfiguration.getLongPressTimeout();
6444-
if (DEBUG_INPUT) Log.v(
6445-
TAG, "Received key down: first repeat @ "
6446-
+ nextKeyTime);
6439+
if (lastKey != null &&
6440+
ke.getKeyCode() == lastKey.getKeyCode()) {
6441+
keyRepeatCount++;
6442+
// Arbitrary long timeout to block
6443+
// repeating here since we know that
6444+
// the device driver takes care of it.
6445+
nextKeyTime = lastKeyTime + LONG_WAIT;
6446+
if (DEBUG_INPUT) Log.v(
6447+
TAG, "Received repeated key down");
6448+
} else {
6449+
downTime = curTime;
6450+
keyRepeatCount = 0;
6451+
nextKeyTime = lastKeyTime
6452+
+ ViewConfiguration.getLongPressTimeout();
6453+
if (DEBUG_INPUT) Log.v(
6454+
TAG, "Received key down: first repeat @ "
6455+
+ nextKeyTime);
6456+
}
6457+
lastKey = ke;
64476458
} else {
64486459
lastKey = null;
64496460
downTime = 0;
6461+
keyRepeatCount = 0;
64506462
// Arbitrary long timeout.
64516463
lastKeyTime = curTime;
64526464
nextKeyTime = curTime + LONG_WAIT;
64536465
if (DEBUG_INPUT) Log.v(
64546466
TAG, "Received key up: ignore repeat @ "
64556467
+ nextKeyTime);
64566468
}
6457-
dispatchKey((KeyEvent)ev.event, 0, 0);
6469+
if (keyRepeatCount > 0) {
6470+
dispatchKey(KeyEvent.changeTimeRepeat(ke,
6471+
ke.getEventTime(), keyRepeatCount), 0, 0);
6472+
} else {
6473+
dispatchKey(ke, 0, 0);
6474+
}
64586475
mQueue.recycleEvent(ev);
64596476
break;
64606477
case RawInputEvent.CLASS_TOUCHSCREEN:

0 commit comments

Comments
 (0)