input: input: stop autorepeat timer on key release
Subsystems (2)
PATCH 1/1 input: input: stop autorepeat timer on key release
Whenever you press and then release a key, the CPU wakes up three times:
* press
* release
* autorepeat timer exactly 250ms after press
The autorepeat timer has nothing to do, obviously, since you already have released the key, so stop it on key release.
--- drivers/input/input.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/input.c +7 -0
@@ -132,6 +132,11 @@ static void input_start_autorepeat(struc } } +static void input_stop_autorepeat (struct input_dev *dev) +{ +del_timer (&dev->timer); +} +#define INPUT_IGNORE_EVENT 0#define INPUT_PASS_TO_HANDLERS 1#define INPUT_PASS_TO_DEVICE 2
@@ -167,6 +172,8 @@ static void input_handle_event(struct in__change_bit (code, dev->key);if (value)input_start_autorepeat (dev, code); +else +input_stop_autorepeat (dev); } disposition =INPUT_PASS_TO_HANDLERS ;
Dmitry Torokhov
maintainerHi Johannes,
Quoted 9 lines · Johannes Berg
Whenever you press and then release a key, the CPU wakes up three times:
* press
* release
* autorepeat timer exactly 250ms after pressThe autorepeat timer has nothing to do, obviously, since you already have released the key, so stop it on key release.
This introduces a slight change in behaviour (the key that is released may not be one that is being autorepeated) but I think it still makes sense to do it.
Signature · 1 line
Dmitry
Quoted 9 lines · Dmitry Torokhov
Hi Johannes,
Quoted 6 lines · Johannes Berg
Whenever you press and then release a key, the CPU wakes up three times:
* press
* release
* autorepeat timer exactly 250ms after press
Quoted 7 lines
Quoted 3 lines
The autorepeat timer has nothing to do, obviously, since you already have released the key, so stop it on key release.
This introduces a slight change in behaviour (the key that is released may not be one that is being autorepeated) but I think it still makes sense to do it.
Hmm, good point, I thought it didn't, but it does when you press a, b wait, release a then b doesn't continue autorepeating. Seems like a corner case though, so I agree. We could fix that by checking which key is being autorepeated though, I'd think, see below (untested as of now)
johannes
drivers/input/input.c +10 -0
@@ -132,6 +132,14 @@ static void input_start_autorepeat(struc } } +static void input_stop_autorepeat (struct input_dev *dev,int code) +{ +if (dev->repeat_key != code) +return ; + +del_timer (&dev->timer); +} +#define INPUT_IGNORE_EVENT 0#define INPUT_PASS_TO_HANDLERS 1#define INPUT_PASS_TO_DEVICE 2
@@ -167,6 +175,8 @@ static void input_handle_event(struct in__change_bit (code, dev->key);if (value)input_start_autorepeat (dev, code); +else +input_stop_autorepeat (dev, code); } disposition =INPUT_PASS_TO_HANDLERS ;
Dmitry Torokhov
maintainerQuoted 14 lines · Johannes Berg
Quoted 13 lines · Dmitry Torokhov
Hi Johannes,
Quoted 9 lines · Johannes Berg
Whenever you press and then release a key, the CPU wakes up three times:
* press
* release
* autorepeat timer exactly 250ms after pressThe autorepeat timer has nothing to do, obviously, since you already have released the key, so stop it on key release.
Quoted 9 lines
Quoted 3 lines
This introduces a slight change in behaviour (the key that is released may not be one that is being autorepeated) but I think it still makes sense to do it.
Hmm, good point, I thought it didn't, but it does when you press a, b wait, release a then b doesn't continue autorepeating. Seems like a corner case though, so I agree. We could fix that by checking which key is being autorepeated though, I'd think, see below (untested as of now)
I actually think the original change was better - sometimes when shift or alt or ctrl key gets stuck it takes time to figure out what happened. If we stop autorepeat upon release of any key it will recover much quicker.
Signature · 1 line
Dmitry
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines
Quoted 3 lines
This introduces a slight change in behaviour (the key that is released may not be one that is being autorepeated) but I think it still makes sense to do it.
Hmm, good point, I thought it didn't, but it does when you press a, b wait, release a then b doesn't continue autorepeating. Seems like a corner case though, so I agree. We could fix that by checking which key is being autorepeated though, I'd think, see below (untested as of now)
Quoted 3 lines
I actually think the original change was better - sometimes when shift or alt or ctrl key gets stuck it takes time to figure out what happened. If we stop autorepeat upon release of any key it will recover much quicker.
Heh, good point too. Well, I was just confused by seeing the timer in there until I realised what was going on, so feel free to take either patch. :)
johannes