Bug 17500

Summary: Kernel autorepeat interrupts X softrepeat
Product: xorg Reporter: Tarmo Tänav <tarmo>
Component: Input/evdevAssignee: Peter Hutterer <peter.hutterer>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: freedesktop, ricpelo
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Tarmo Tänav 2008-09-09 07:39:05 UTC
When holding a key down keyboard repeat starts with softrepeat delay/rate settings and is interrupted temporarily when the kernel autorepeat delay/rate would have caused a character to be repeated if the kernel autorepeat would be used.

It's easiest to demonstrate the problem when setting "xset r rate 175 100; kbdrate -r 2 -d 1000" (incidentally also the settings that least disturb softrepeat). So when holding a key down the 175ms delay and 100/sec repeat rate works perfectly for 1000ms (exactly when the kernel repeat delay kicks in), then there's a shot interruption and the 100/sec rate is again continued and again interrupted, but this time after about 500ms (basically at 2/sec, which is the kernel repeate rate).

With default kbdrate settings (those set by xset itself, delay 250ms and 10.9 cps), the problem is even more annoying because the fast softrepeat rate only lasts for 250ms and then slows down to a very slow rate probably dictated by the 10.9 cps. So basically after the kernel repeat delay only the really slow kernel repeat rate applies as softrepeat seems to get no chance of doing anything between the short interruptions caused by the kernel autorepeat.

This is all with xorg-server 1.5.0, kernel 2.6.25, evdev 2.0.4.

I don't remember this problem to have existed with the kbd driver and unfortunately I'm no longer able to get the kbd driver to work (I think it gets confused by the event device which hal is providing and I'm not sure what to do about it).

Thank you,
Comment 1 Daniel Stone 2008-11-26 04:55:50 UTC
*** Bug 17925 has been marked as a duplicate of this bug. ***
Comment 2 Ricardo Perez 2008-11-26 05:22:54 UTC
I come from the duplicated bug 17925. My main issue is about the left, down & end keys:

When I press & hold the "down-arrow" key, the "left-arrow" key or the "End"
key, the delay (until the key starts to repeat) is longer than the other keys in the keyboard. I need to hold these keys pressed more time in order to
get repetition.

The issue, however, don't appear when you use the down-arrow key in the keypad
(the "2" key), the left-arrow in the keypad (the "4" key) or the "End" key in
the keypad (the "1" key).

More info is at https://bugs.freedesktop.org/show_bug.cgi?id=17925 .
Comment 3 Tarmo Tänav 2008-11-26 05:50:44 UTC
(In reply to comment #2)

For me the arrow keys start working like other keys after running "xset r 113; xset r 116; xset r 2".
Comment 4 Daniel Stone 2008-11-26 13:49:13 UTC
this is only compile-tested, not run-tested at all, but reasonably obvious, so:
http://people.freedesktop.org/~daniels/evdev-key-repeat.diff

(should probably look better than it does, but hey, i got up at 7am today.)
Comment 5 Tarmo Tänav 2008-11-26 14:59:47 UTC
This patch indeed makes autorepeat work nicely, but for some reason either due to this patch or due to using the master branch of evdev (patch doesn't apply to 2.0.7 and I'm just about to go to bed so not enough time to test without the patch) ctrl-C seems to either crash or just restart the X server, not sure which, all I can see is that I get to log in again. Will try to investigate tomorrow.

Thank you,
Comment 6 Tarmo Tänav 2008-11-26 15:06:48 UTC
So what happens seems to be that the key presses are sent to both X and console, so when I ctrl-C it interrupts the server and when I alt-F4 it closes a window in X but also switches to the fourth VT. But it looks like it happens even without this patch.
Comment 7 Daniel Stone 2008-11-26 19:43:37 UTC
ah yes, you need to upgrade your server when using evdev master.  glad to hear the repeat issue is fixed though.
Comment 8 Michael Chapman 2008-11-26 21:12:56 UTC
I too am having the problems described in this bug with xorg-x11-server 1.5.3 as shipped in Fedora 10.

I haven't tried that patch as yet, but I did poke the EVIOCSREP ioctl directly through a small Perl script. It certainly fixes the autorepeat issue for most keys, but it leaves the Left, Down and End keys with no autorepeat whatsoever.

Why would these three keys be handled differently to all the others?
Comment 9 Daniel Stone 2008-11-26 21:55:32 UTC
(In reply to comment #8)
> I too am having the problems described in this bug with xorg-x11-server 1.5.3
> as shipped in Fedora 10.
> 
> I haven't tried that patch as yet, but I did poke the EVIOCSREP ioctl directly
> through a small Perl script. It certainly fixes the autorepeat issue for most
> keys, but it leaves the Left, Down and End keys with no autorepeat whatsoever.
> 
> Why would these three keys be handled differently to all the others?

At a guess, your desktop environment is clobbering them, because the keycodes for up/down/left/right as used by evdev are the same as a few special keys (e.g. print screen) in pc105.
Comment 10 Ricardo Perez 2008-11-27 01:44:29 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > I too am having the problems described in this bug with xorg-x11-server 1.5.3
> > as shipped in Fedora 10.
> > 
> > I haven't tried that patch as yet, but I did poke the EVIOCSREP ioctl directly
> > through a small Perl script. It certainly fixes the autorepeat issue for most
> > keys, but it leaves the Left, Down and End keys with no autorepeat whatsoever.
> > 
> > Why would these three keys be handled differently to all the others?
> 
> At a guess, your desktop environment is clobbering them, because the keycodes
> for up/down/left/right as used by evdev are the same as a few special keys
> (e.g. print screen) in pc105.
> 

Daniel, I can reproduce the "Left, Down and End keys" issue with my Ubuntu 8.10 whatever the desktop environment I use: GNOME, KDE or Xfce.

See my comment #4 on Launchpad bugreport #278078:

https://bugs.edge.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/278078

https://bugs.edge.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/278078/comments/4
Comment 11 Ricardo Perez 2008-11-27 01:49:03 UTC
(In reply to comment #3)
> (In reply to comment #2)
> 
> For me the arrow keys start working like other keys after running "xset r 113;
> xset r 116; xset r 2".
> 

ricardo@kadath:~$ sudo xset r 113
ricardo@kadath:~$ sudo xset r 116
ricardo@kadath:~$ sudo xset r 2
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  102 (X_ChangeKeyboardControl)
  Value in failed request:  0x2
  Serial number of failed request:  7
  Current serial number in output stream:  9
ricardo@kadath:~$ 

Do you know why doesn't work with "r 2"?
Comment 12 Ricardo Perez 2008-11-27 01:57:13 UTC
(In reply to comment #3)
> (In reply to comment #2)
> 
> For me the arrow keys start working like other keys after running "xset r 113;
> xset r 116; xset r 2".
> 

+1! Works for me, too! Thank you very much. Now the Left key works as expected.

Could this fix go inside the X.Org source code in order to get these keys working without the need of the above three xset commands?
Comment 13 Tarmo Tänav 2008-11-27 02:15:33 UTC
(In reply to comment #11)
> Do you know why doesn't work with "r 2"?
> 

Sorry, it was actually "xset r 22", but it seems that the backspace works fine here now even without it. If you have any other keys that don't autorepeat then just use "xev" to find out the keycode and then "xset r keycode". I have no idea though what causes this issue for those keys.
Comment 14 Michael Chapman 2008-11-27 02:17:40 UTC
'xset r 113; xset r 115; xset r 116' fixes Left, End and Down respectively for me.

Daniel, you suggested it might be a desktop environment issue. I'm pretty sure this is not the case, since those three keys do not autorepeat if I simply start up X with 'startx /usr/bin/xterm'.
Comment 15 Daniel Stone 2008-11-27 16:26:56 UTC
ricardo: because the minimum keycode is 8.

michael: hmm, okay, i'll look into it; got half an idea as to what it might be.  ta.
Comment 16 Peter Hutterer 2008-12-18 02:51:10 UTC
This was fixed in the server with the following commit:

commit bbf811514d3cdf84790bad5b852942a4e636902b
Author:     Sascha Hlusiak <saschahlusiak@arcor.de>
AuthorDate: Mon Dec 8 12:24:39 2008 +0100

    ddxCtrls.c: XkbDDXUsesSoftRepeat always returns 1 now

And you need the matching evdev commit:
commit ece72ce9e97adae23b1932dc1334f63669196d56
Author:     Sascha Hlusiak <saschahlusiak@arcor.de>
AuthorDate: Mon Dec 8 12:27:34 2008 +0100

    Filter all repeated keys from kernel, because we do softrepeat in server
Comment 17 Ricardo Perez 2008-12-18 06:02:08 UTC
(In reply to comment #16)
> This was fixed in the server with the following commit:
> 
> commit bbf811514d3cdf84790bad5b852942a4e636902b
> Author:     Sascha Hlusiak <saschahlusiak@arcor.de>
> AuthorDate: Mon Dec 8 12:24:39 2008 +0100
> 
>     ddxCtrls.c: XkbDDXUsesSoftRepeat always returns 1 now
> 
> And you need the matching evdev commit:
> commit ece72ce9e97adae23b1932dc1334f63669196d56
> Author:     Sascha Hlusiak <saschahlusiak@arcor.de>
> AuthorDate: Mon Dec 8 12:27:34 2008 +0100
> 
>     Filter all repeated keys from kernel, because we do softrepeat in server
> 

Can anybody test this fix? What about the Left, Right and End keys issue?
Comment 18 Ricardo Perez 2009-01-13 12:41:24 UTC
The fix does NOT resolve the Left, Down and End keys issue, as an user reported here:

https://bugs.edge.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/264196/comments/43

He said that he need to use xset in order to get repetition with these keys. It's a workaround, but it's NOT a full fix.

I propose to reopen the bug #17925, because there's obviously not the same problem.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.