diff options
author | Karl Pickett <karl.pickett@gmail.com> | 2007-04-12 01:35:59 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-12 01:35:59 -0400 |
commit | 0de9550971a0ee614ea4f06655e8a49aa3a942a8 (patch) | |
tree | 4369291028718f6753d95978a9f91c7d1b9b18ef | |
parent | b7fd4a0aa52c95309219240bf9c5fd210a6e7061 (diff) |
Input: ati_remote - make button repeat sensitivity configurable
ati_remote causes repeats after only .23 seconds with my remote and
makes it hard to use comfortably. Make a precise way of setting the
repeat delay time in milliseconds and default it to 500ms. The old
behavior can be had by setting repeat_delay = 0.
Signed-off-by: Karl Pickett <karl.pickett@gmail.com>
Signed-off-by: Vincent Vanackere <vincent.vanackere@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/usb/input/ati_remote.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index 5d3ddb916668..471aab206443 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -120,6 +120,7 @@ | |||
120 | * behaviour. | 120 | * behaviour. |
121 | */ | 121 | */ |
122 | #define FILTER_TIME 60 /* msec */ | 122 | #define FILTER_TIME 60 /* msec */ |
123 | #define REPEAT_DELAY 500 /* msec */ | ||
123 | 124 | ||
124 | static unsigned long channel_mask; | 125 | static unsigned long channel_mask; |
125 | module_param(channel_mask, ulong, 0644); | 126 | module_param(channel_mask, ulong, 0644); |
@@ -133,6 +134,10 @@ static int repeat_filter = FILTER_TIME; | |||
133 | module_param(repeat_filter, int, 0644); | 134 | module_param(repeat_filter, int, 0644); |
134 | MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); | 135 | MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); |
135 | 136 | ||
137 | static int repeat_delay = REPEAT_DELAY; | ||
138 | module_param(repeat_delay, int, 0644); | ||
139 | MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec"); | ||
140 | |||
136 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) | 141 | #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) |
137 | #undef err | 142 | #undef err |
138 | #define err(format, arg...) printk(KERN_ERR format , ## arg) | 143 | #define err(format, arg...) printk(KERN_ERR format , ## arg) |
@@ -174,6 +179,8 @@ struct ati_remote { | |||
174 | unsigned char old_data[2]; /* Detect duplicate events */ | 179 | unsigned char old_data[2]; /* Detect duplicate events */ |
175 | unsigned long old_jiffies; | 180 | unsigned long old_jiffies; |
176 | unsigned long acc_jiffies; /* handle acceleration */ | 181 | unsigned long acc_jiffies; /* handle acceleration */ |
182 | unsigned long first_jiffies; | ||
183 | |||
177 | unsigned int repeat_count; | 184 | unsigned int repeat_count; |
178 | 185 | ||
179 | char name[NAME_BUFSIZE]; | 186 | char name[NAME_BUFSIZE]; |
@@ -501,21 +508,31 @@ static void ati_remote_input_report(struct urb *urb) | |||
501 | } | 508 | } |
502 | 509 | ||
503 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { | 510 | if (ati_remote_tbl[index].kind == KIND_FILTERED) { |
511 | unsigned long now = jiffies; | ||
512 | |||
504 | /* Filter duplicate events which happen "too close" together. */ | 513 | /* Filter duplicate events which happen "too close" together. */ |
505 | if (ati_remote->old_data[0] == data[1] && | 514 | if (ati_remote->old_data[0] == data[1] && |
506 | ati_remote->old_data[1] == data[2] && | 515 | ati_remote->old_data[1] == data[2] && |
507 | time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) { | 516 | time_before(now, ati_remote->old_jiffies + |
517 | msecs_to_jiffies(repeat_filter))) { | ||
508 | ati_remote->repeat_count++; | 518 | ati_remote->repeat_count++; |
509 | } else { | 519 | } else { |
510 | ati_remote->repeat_count = 0; | 520 | ati_remote->repeat_count = 0; |
521 | ati_remote->first_jiffies = now; | ||
511 | } | 522 | } |
512 | 523 | ||
513 | ati_remote->old_data[0] = data[1]; | 524 | ati_remote->old_data[0] = data[1]; |
514 | ati_remote->old_data[1] = data[2]; | 525 | ati_remote->old_data[1] = data[2]; |
515 | ati_remote->old_jiffies = jiffies; | 526 | ati_remote->old_jiffies = now; |
516 | 527 | ||
528 | /* Ensure we skip at least the 4 first duplicate events (generated | ||
529 | * by a single keypress), and continue skipping until repeat_delay | ||
530 | * msecs have passed | ||
531 | */ | ||
517 | if (ati_remote->repeat_count > 0 && | 532 | if (ati_remote->repeat_count > 0 && |
518 | ati_remote->repeat_count < 5) | 533 | (ati_remote->repeat_count < 5 || |
534 | time_before(now, ati_remote->first_jiffies + | ||
535 | msecs_to_jiffies(repeat_delay)))) | ||
519 | return; | 536 | return; |
520 | 537 | ||
521 | 538 | ||