Skip to content

Commit 352ac4b

Browse files
committed
Input: Move autorepeat to the event-passing phase
Preparing to split event filtering and event passing, move the autorepeat function to the point where the event is actually passed. Tested-by: Benjamin Tissoires <[email protected]> Tested-by: Ping Cheng <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Signed-off-by: Henrik Rydberg <[email protected]>
1 parent 0672120 commit 352ac4b

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

drivers/input/input.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz)
6969
return value;
7070
}
7171

72+
static void input_start_autorepeat(struct input_dev *dev, int code)
73+
{
74+
if (test_bit(EV_REP, dev->evbit) &&
75+
dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] &&
76+
dev->timer.data) {
77+
dev->repeat_key = code;
78+
mod_timer(&dev->timer,
79+
jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]));
80+
}
81+
}
82+
83+
static void input_stop_autorepeat(struct input_dev *dev)
84+
{
85+
del_timer(&dev->timer);
86+
}
87+
7288
/*
7389
* Pass event first through all filters and then, if event has not been
7490
* filtered out, through all open handles. This function is called with
@@ -105,6 +121,15 @@ static void input_pass_event(struct input_dev *dev,
105121
}
106122

107123
rcu_read_unlock();
124+
125+
/* trigger auto repeat for key events */
126+
if (type == EV_KEY && value != 2) {
127+
if (value)
128+
input_start_autorepeat(dev, code);
129+
else
130+
input_stop_autorepeat(dev);
131+
}
132+
108133
}
109134

110135
/*
@@ -142,22 +167,6 @@ static void input_repeat_key(unsigned long data)
142167
spin_unlock_irqrestore(&dev->event_lock, flags);
143168
}
144169

145-
static void input_start_autorepeat(struct input_dev *dev, int code)
146-
{
147-
if (test_bit(EV_REP, dev->evbit) &&
148-
dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] &&
149-
dev->timer.data) {
150-
dev->repeat_key = code;
151-
mod_timer(&dev->timer,
152-
jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]));
153-
}
154-
}
155-
156-
static void input_stop_autorepeat(struct input_dev *dev)
157-
{
158-
del_timer(&dev->timer);
159-
}
160-
161170
#define INPUT_IGNORE_EVENT 0
162171
#define INPUT_PASS_TO_HANDLERS 1
163172
#define INPUT_PASS_TO_DEVICE 2
@@ -252,11 +261,6 @@ static void input_handle_event(struct input_dev *dev,
252261

253262
__change_bit(code, dev->key);
254263
disposition = INPUT_PASS_TO_HANDLERS;
255-
256-
if (value)
257-
input_start_autorepeat(dev, code);
258-
else
259-
input_stop_autorepeat(dev);
260264
}
261265
}
262266
break;

0 commit comments

Comments
 (0)