Linux MCE Remote repeats too fast
#1
Bug 
Hi,

Running XBMC 11.0 under openSuse 12.1 (kernel 3.1.10); I'm running into the following problem : whenever I push a button of my remote control twice & fast, XBMC will interpret this as much more than 2 times key presses. Example: in the password field, if I push button '0' 2 times, fast; I will see more than 6 or 8 * (starts) appearing in the password field!

The remote itself is a Sony RM-MCE20E; the receiver is a ID 0609:0334 SMK Manufacturing, Inc. eHome Infrared Receiver.
Kernel sets the remote as a input
Code:
[    3.011117] input: Media Center Ed. eHome Infrared Remote Transceiver (0609:0334) as /devices/pci0000:00/0000:00:12.0/usb4/4-2/4-2:1.0/rc/rc0/input5

xbmc is setup with remoteaskeyboard enabled.

lirc is not running

ir-keytable gives
Code:
tv:/home/tv/Downloads # ir-keytable -V
IR keytable control version 0.8.5
tv:/home/tv/Downloads # ir-keytable -v
Found device /sys/class/rc/rc0/
Input sysfs node is /sys/class/rc/rc0/input5/
Event sysfs node is /sys/class/rc/rc0/input5/event5/
Parsing uevent /sys/class/rc/rc0/input5/event5/uevent
/sys/class/rc/rc0/input5/event5/uevent uevent MAJOR=13
/sys/class/rc/rc0/input5/event5/uevent uevent MINOR=69
/sys/class/rc/rc0/input5/event5/uevent uevent DEVNAME=input/event5
Parsing uevent /sys/class/rc/rc0/uevent
/sys/class/rc/rc0/uevent uevent NAME=rc-rc6-mce
/sys/class/rc/rc0/uevent uevent DRV_NAME=mceusb
input device is /dev/input/event5
/sys/class/rc/rc0/protocols protocol rc-5 (disabled)
/sys/class/rc/rc0/protocols protocol nec (disabled)
/sys/class/rc/rc0/protocols protocol rc-6 (enabled)
/sys/class/rc/rc0/protocols protocol jvc (disabled)
/sys/class/rc/rc0/protocols protocol sony (disabled)
/sys/class/rc/rc0/protocols protocol mce_kbd (disabled)
/sys/class/rc/rc0/protocols protocol lirc (disabled)
Found /sys/class/rc/rc0/ (/dev/input/event5) with:
    Driver mceusb, table rc-rc6-mce
    Supported protocols: NEC RC-5 RC-6 JVC SONY LIRC other
    Enabled protocols: RC-6
    Repeat delay = 500 ms, repeat period = 125 ms


When I try to reproduce the same behaviour if gedit or in gnome-terminal; I cannot; the remote behave correctly.

As a side note; setting the repeat delay and period did not work for me with ir-keytable. Instead, I had to use the options of gnome for the keyboard (as the remote is recognized as a keyboard in X11).

Any suggestion to fix this in XBMC ? Thx!
Reply
#2
You can have x11 ignore the remote by placing a file in e.g. /usr/share/X11/xorg.conf.d/ (or /usr/bib/X11/xorg.conf.d/ , depends on your system). Mine does look like this:
Section "InputClass"
Identifier "PHILIPS MCE USB IR Receiver- Spinel plus"
MatchProduct "PHILIPS MCE USB IR Receiver- Spinel plus"
MatchIsKeyboard "true"
Option "Ignore" "true"
EndSection

Gnome settings for keyboards don't have any impact because X11 key repeats are ignored by SDL. It simulates key repeats internally.
Reply
#3
Thx for your reply FernetMenta.

I wanted to try your suggestion but I'm a bit lost on the devices detected by X11. Also can you explain the goal of ignoring device by X11 ?

My X11 detects the following

Code:
[     5.768] (II) Media Center Ed. eHome Infrared Remote Transceiver (0609:0334): Configuring as keyboard
[     5.773] (II) MCE IR Keyboard/Mouse (mceusb): Configuring as mouse
[     5.773] (II) MCE IR Keyboard/Mouse (mceusb): Configuring as keyboard

All three are related to the USB IR module.

Which one should I ignore in X11 config ? Also, one device shows as both a keyboard and a mouse.
Reply
#4
I don't know your setup but you mentioned ir-keytable, so I assume you are using Lirc. If you don't ignore your remote in X11, you might get undefined behavior. Check http://www.lirc.org/html/devinput.html and run the following command:
Code:
for i in /sys/class/input/input* ; do echo -n "$(basename "$i"): "; cat "$i/name"; done

It should not give you duplicate devices (you posted what xorg has seen)

Another option could be eventlirc. Not sure but I think it would do this implicitly for you.
Reply
#5
I'm not using LIRC.

dmesg shows

Code:
[    3.002117] input: Media Center Ed. eHome Infrared Remote Transceiver (0609:0334) as /devices/pci0000:00/0000:00:12.0/usb4/4-2/4-2:1.0/rc/rc0/input5
[    3.002243] input: MCE IR Keyboard/Mouse (mceusb) as /devices/virtual/input/input6



But anyway, is there any settings for SDL controlling the keypress repeats ?
Reply
#6
Key repeats start after 500ms when holding a key. Do you notice any difference between keyboard and remote regarding key repeat? If so it's most likely a problem of the ir receiver or driver.
Reply
#7
Well, the settings of repeats via ir-keytable do not work for me.

I was able to change repeat delays via the gnome keyboard settings screen, and it applies on both my keyboard and the remote (when I test the keyboard in gedit for example).

Unfortunately, it does not hold true whenever I use xbmc...

How xbmc process key press events ? What's the flow ?
Reply
#8
The application registers for keyboard and mouse events using Xlib. A message handler calls XNextEvent. Xlib signals key repeats by a key release event followed immediately be a key press event with the same scan code. Those key repeats are ignored and generated internally by SDL. The initial delay is 500ms. If you notice any key repeats before this time there is something wrong with the events we get from Xlib. Maybe your remote does not send key repeats in the way they are specified (see above). This is why I ask how you keyboard behaves. Does it also repeat too fast or does it operate as expected?
Reply
#9
When I press a key twice fast on the keyboard, the expected behaviour occurs in xbmc. So it seems to be isolated to the remote. What I don't understand is that the remote behave correctly in the console, gedit, gnome-terminal, etc, it behaves just as the keyboard.

And in debug, I could see that a remote button pressed twice fast will make xbmc receives 6 or more SDL key codes instead of 2.

Any way to set the repeat behaviour of the remote under SDL ?
Reply
#10
There is nothing you can do about SDL which works correctly. It ignores key presses generated by xorg auto repeat and processes other events.
Your problem seems to be that the ir receiver or driver generates key press events when holding a button, maybe it does not recognize the toggle bit in the ir code.

You may want to try Lirc.
Reply
#11
Bug 
Hi again,

I think I've narrowed down the problem.

When testing the remote with the piece of code below, I can make the "bug" stop by increasing the interval's value given while calling SDL_EnableKeyRepeat. A value of 500 gives good result; while the value chosen in XBMC 11.0 (10ms) gives problems of too many repeats.

Where shall I open a bug report, XBMC or SDL ?

Thx
--
Issa


Code:
#include <SDL/SDL.h>

main(int argc, char *argv[])
{
    int quit = 0;
    int count = 0;
    SDL_Event event;

    if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }

    if (!SDL_SetVideoMode(320, 200, 0, 0)) {
        fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError());
        SDL_Quit();
        exit(1);
    }

    atexit(SDL_Quit);
    SDL_EnableUNICODE(1);
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 500);

    while (!quit) {
/*        if (SDL_WaitEvent(&event) < 1) {
            fprintf(stderr, "WaitEvent error: %s\n", SDL_GetError());
            exit(1);
        }
*/
        if (SDL_PollEvent(&event) < 1) {
            continue;
        }

        switch (event.type) {
        case SDL_KEYDOWN:
            printf("Key pressed:\n");
            printf("    state: %i\n", event.key.state);
            printf("    SDL sim: %i\n", event.key.keysym.sym);
            printf("    modifiers: %i\n", event.key.keysym.mod);
            printf("    unicode: %i (if enabled with SDL_EnableUNICODE)\n", event.key.keysym.unicode);

        break;

        case SDL_KEYUP:
            printf("Key released:\n");
            printf("    state: %i\n", event.key.state);
            printf("    SDL sim: %i\n", event.key.keysym.sym);
            printf("    modifiers: %i\n", event.key.keysym.mod);
            printf("    unicode: %i (if enabled with SDL_EnableUNICODE)\n", event.key.keysym.unicode);
        break;

        case SDL_QUIT:
            printf("Request to quit\n");
            quit = 1;
        break;

        case SDL_USEREVENT:
            printf("User event:\n");
            printf("    code:  %i\n", event.user.code);
            printf("    data1: %p\n", event.user.data1);
            printf("    data2: %p\n", event.user.data2);
        break;
        }

        printf("%i\n", ++count);
    }
}
Reply
#12
Thanks, flopma. I've noticed the same issue.

I'd report it to both.
SDL appears to have an issue in that it is issuing far more keypresses than its receiving.

XBMC has an issue that you can't control how keypresses are managed. advancedsettings.xml used to be the place for this (see: http://wiki.xbmc.org/index.php?title=Use...erepeat.3E) but that doesn't appear to work with Eden - which is critical in cases like this.

Keep us updated!
Luke.
Reply
#13
Hi,

I have the same problem with XBMCBuntu Eden. This would work perfectly if it was possible to control the delay and period in ir-keytable.

Cheers,

Ross
Maintainer of Enigma2 PVR addon: repo, docschangelog
How to create a full debug: here
Reply
#14
If you run the command ir-keytable it will show you the current delay and repeat period, running ir-keytable -P 1000 -D 1000 will change the delay and repeat to 1000. I have found running the command after boot in terminal works and sticks, unfortunately if you set the P and D in a startup script such as rc.local the values don't stick and are reset to default. The strange thing is if you monitor the text on screen while booting you can see that the values are set, so they are being reset later in the process. I don't know the solution other than running the P and D commands manually, possibly running them later in the boot process will make them stick, I just don't know.

Mike
If I have been of help, please add to my reputation as a way of saying thanks, it's free.
Reply
#15
I tried using the console to set the period and delay values but onscreen in XBMC I don't see them reflected. The repeating problem still exists. Should I be setting these before starting XBMC?

If I can get it working manually I should able to get it set just before XBMC starts.
Maintainer of Enigma2 PVR addon: repo, docschangelog
How to create a full debug: here
Reply

Logout Mark Read Team Forum Stats Members Help
MCE Remote repeats too fast0