Skip to content

Commit

Permalink
Input: stop autorepeat timer on key release
Browse files Browse the repository at this point in the history
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.

[dtor@mail.ru: This changes autorepeat behavior a bit since we now stop
 autorepeat even if key that is being released is not the one that is
 being auto-repeated, but I believe the new behavior is better.]

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Johannes Berg authored and Dmitry Torokhov committed Jan 30, 2009
1 parent b0ee0d3 commit e7b5c1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ static void input_start_autorepeat(struct input_dev *dev, int code)
}
}

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
Expand Down Expand Up @@ -167,6 +172,8 @@ static void input_handle_event(struct input_dev *dev,
__change_bit(code, dev->key);
if (value)
input_start_autorepeat(dev, code);
else
input_stop_autorepeat(dev);
}

disposition = INPUT_PASS_TO_HANDLERS;
Expand Down

0 comments on commit e7b5c1e

Please sign in to comment.