[SOLVED] LibreELEC + PCTV 461e + XBox One Remote

  • Hello everybody!

    I searched the net for a while but did not find a solution for my problem. So I am hopeful, that somebody of you can help me out.

    I am running LibreELEC 8.0.2 on a RPi 3.

    An IR receiver is connected via GPIO. It is feeded with an XBox One Media Control.

    For Live-TV I am using an PCTV 461e USB stick (DVB-S/S2).

    Everything works fine until I connect the DVB-stick. From then on the responsiveness of the remote control is unreliable, since some of the button pushes are not recognized by Lirc/Kodi.

    In my opinion this behaviour is reasoned in the fact that the DVB-stick has got it's own IR receiver and therefore two IR receivers are working inside the system and interfere with each other.

    Part of dmesg output:

    If I run ir-keytable, I got the following output:

    Code
    # ir-keytable 
    Found /sys/class/rc/rc0/ (/dev/input/event0) with:
        Driver em28xx, table rc-pinnacle-pctv-hd
        Supported protocols: rc-5 nec rc-6 
        Enabled protocols: rc-5 
        Name: 1-1.3: em28178#0 IR
        bus: 3, vendor/product: 2013:0258, version: 0x0001
        Repeat delay = 500 ms, repeat period = 125 ms

    If I run ir-keytable without the DVB-stick attached to the RPi (the case when everything works fine!), the output is as follows:

    Code
    # ir-keytable 
    Couldn't find any node at /sys/class/rc/rc*.

    For my limited knowledge of lirc it seems strange that the best working config seems not to use the lirc components.

    Perhaps it is useful to know the lirc-processes that are running on my Pi:

    Code
    # ps -ef | grep -i lirc
      281 root       0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd
      420 root       0:00 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --output=/run/lirc/lircd-lirc0 --pidfile=/run/lirc/lircd-lirc0.pid --release=_LIRCUP /storage/.config/lircd.conf
      421 root       0:00 /usr/sbin/lircd-uinput --release=_LIRCUP /run/lirc/lircd-lirc0
      457 root       0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
      463 root       3:04 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd
      861 root       0:00 grep -i lirc

    I think that the solution for my problem is to disable the IR receiver of the DVB-stick, but I don't know how to achieve it.


    May somebody help me? Thank you very much in advance!

    Nico.

  • Looks like the Pinnacle driver (em28xx) has an option to disable IR. Create a file .config/modprobe.d/pinnacle-disable-ir.conf with the following content:

    Code
    options em28xx disable_ir=1

    alternatively, blacklisting the em28xx-rc module should also work

    Code
    blacklist em28xx-rc

    so long,

    Hias

  • Hello Hias!

    Thank you for your really quick answer!!!

    After creating the conf-file, ir-keytable says

    Code
    # ir-keytable 
    Couldn't find any node at /sys/class/rc/rc*.

    ... so your solution seems to work (since the DVB-stick is currently connected to my RPi).

    I will try a few hours in the evening and update this topic.

    Thank you very much for your great and fast help!

    Kind regards, Nico.

  • Hello HiassofT,

    I tried both of your proposals (creating .config/modprobe.d/pinnacle-disable-ir.conf and echo "blacklist em28xx-rc" > /storage/.config/modprobe.d/blacklist.confand restarting the RPi, of course) but the behaviour of the remote (not all button pushes are recognized) has not changed as long as the DVB-stick is connected to the RPi. When I disconnect it - even while the RPi and Kodi are running - the recognition is immediately good!

    Do you have some other ideas or recommendations for isolating the problem?

    Thank you in advance, Nico.

  • That looks like you are running into RPi issue #906 Issues · raspberrypi/linux · GitHub (sorry, stupid forum software thinks I'm posting spam because the title of the bug report contains the censored word "sens*t*ve" - just add 906 at the end of the URL to get to the details). Heavy USB traffic, like it's generated by DVB sticks, can interfere with proper operation of GPIIO IR receivers. Unfortunately there's no solution to that.

    Since your DVB stick has an IR receiver built in the best solution would be to use that, and disable the GPIO IR receiver (either by uncommenting the dtoverlay line in config.txt or by disabling lirc in LibreELEC settings).

    LibreELEC already ships with a keytable for the xbox one remote (let's hope it's the correct one) and the IR receiver of your DVB stick seems to support the remote protocol (NEC) as well.

    To get that working just create a .config/rc_maps.cfg file with the following content:

    Code
    * * xbox_one

    so long,

    Hias

  • Hello HiassofT ,

    first I want to thank you for your great, fast and useful help!!!

    It works great as you described. Kodi is now responding immediately to my button presses. I just had to place the IR receiver a little bit more visible since the IR transmitter of the PCTV 461e seems not to be as sensitive as a TSOP 4838.

    Thank you that you took the time to wrote such a detailed instruction!

    And I am sorry that I have to ask you again for another topic: The only problem that is left, is that some of the buttons seems not to be correctly assigned in the standard keymap for the XBOX One Remote: UP, DOWN, LEFT, RIGHT are all working great, but OK/Select and BACK (for example) are not recognized in Kodi.

    Can you tell me how to correct these codes in the keymap file? Is there a tool like lirc's mode2 to get the right codes for the various buttons on the remote? Unfortunatey these codes differ from that ones I recorded with irrecord.

    Or do I have to create some assignment instructions as I did with lircmap.xml to get these buttons working in Kodi?

    Another question is: although I disabled lirc (in config.txt and LibreELEC-Settings), there are some lirc processes running on my LibreELEC-Pi:

    Code
    # ps -ef | grep -i lirc
      266 root       0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd
      424 root       0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
      429 root       1:43 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd
      765 root       0:00 grep -i lirc

    Is that correct?

    Thank you very much for your help again!

    Kind regards!

  • In addition to my previous post:

    Perhaps some of the keys are not correctly assigned because it seems like there is a wrong table used:

    It seems that table rc-pinnacle-pctv-hd is used instead of xbox_one or am I wrong?

  • The eventlircd process running is fine, it's needed to feed the remote button presses into kodi.

    The table you are seeing in ir-keytable output is also OK, that's the name of default table loaded by the kerrnel and won't change if you override the map via ir-keytable. You can view the currently active map and protocol with "ir-keytable -r" - that should produce about the output as the table you loaded.

    Here's a thread with more details about working with ir-keytable: WD TV Live remote

    Since you already have a somewhat working configuration start with that, run "ir-keytable -t" to see if the scancodes are mapped correctly to KEY_ codes, and change your keymap file accordingly (change the 0x... scancodes in that file).

    If, for some reason, the correct KEY_ codes show up but don't make it into kodi, please run the following command after a fresh reboot (with kodi and everything else running) and post the output. Also your keymap file and rc_maps.cfg would be helpful.

    Code
    cat /proc/bus/input/devices
    lsof | grep /dev/input

    I've seen some odd reports that seemed like kodi picked up the input device (instead of eventlircd) and thus several buttons (like OK) weren't working. But so far I couldn't reproduce that issue reliably enough to analyze it. Maybe I'm barking up the wrong tree, but anyways, if you run into that every info will help me.

    so long,

    Hias

  • Hi HiassofT ,

    executing the commands that are described in the "WD TV Live"-Thread show, that the buttons "OK" and "BACK"/"EXIT" are successfully received:

    The codes are equal to the ones that are configured in the rc_keymaps-file, so my assumption that these are not correct was wrong.

    Here is the output of the both commands you mentioned:

    My rc_maps.cfg:

    Code
    # cat /storage/.config/rc_maps.cfg
    * * xbox_one

    The /storage/.kodi/userdata/keymaps/folder is empty. Could that be the reason for my problem?

    Thank you again for your help!!!

    Kind regards, Nico

  • Thanks for the info! Unfortunately I still could not reproduce the issue here (tried with gpio-ir and a hauppauge dvb-t stick).

    Could you post the contents of your xbox_one keymap and the output of this command:

    Code
    udevadm info -a -n /dev/input/event0

    Do you have an local udev rules in .config/udev.rules.d/?

    As a very wild guess, could you try to disable joystick support in Kodi (Add-ons->My Add-ons->Peripheral libraries->Joystick support, then disable that addon), and then reboot?

    so long,

    Hias

  • Hi HiassofT,

    my xbox_one keymap is:

    udevadm:

    udev-rules:

    Code
    # ls -la .config/udev.rules.d/
    total 4
    drwxr-xr-x    2 root     root          1024 May 19 16:01 .
    drwxr-xr-x   14 root     root          1024 Jul 28 11:45 ..
    -rw-r--r--    1 root     root          1170 May 19 16:01 README

    Regarding the test with disabled Joystick-support:

    I've already disabled this addon since I tried to reduce the possible interfering factors. So I've already tested it.

    If I should try with ENABLED Joystick-support again, please let me know.

    Thank you, that you stay furthermore on that topic!!!

    Best regards, Nico.

  • Damn, everything looks OK so far. But I'm not giving up yet :)

    Could you enabling debug logging in kodi, reboot, then press some buttons on the remote, and then get us the kodi log?

    Code
    paste .kodi/temp/kodi.log

    Then disable both kodi and eventlircd (via systemctl stop).

    Next start eventlircd and check via lsof (as above) if it had picked up the /dev/input/event0 device.

    If that worked, start kodi. Check again via lsof who is using the event0 device. Then press some buttons, tell us if that worked and grab another kodi log.

    so long,

    Hias

  • Hi HiassofT,

    thank you for your endurance :)

    Here are the outputs of the steps that I made in the order you specified:

    I think the relevant part is:

    Code
    23:06:36.839 T:1961955328   DEBUG: CLinuxInputDevice::KeyEvent: TranslateKey returned XBMCK_UNKNOWN from code(352)
    23:06:38.607 T:1961955328   DEBUG: Previous line repeats 5 times.
    23:06:38.607 T:1961955328   DEBUG: CLinuxInputDevice::KeyEvent: TranslateKey returned XBMCK_UNKNOWN from code(174)

    ... isn't it!?

    Regarding your question "[...] tell us if that worked [...]":


    the behaviour after the (re-)start of kodi via systemctl was not better than before (if I did understand your question right).

    But if I try to verify the same behaviour within the logfile, it is strange to see, that the second attempt seemed to be successful:

    First attempt:

    Second attempt:

    Code
    23:23:07.976 T:1961910272   DEBUG: OnKey: 166 (0xa6, obc89) pressed, action is Up
    23:23:10.152 T:1961910272   DEBUG: OnKey: 168 (0xa8, obc87) pressed, action is Right
    23:23:10.953 T:1961910272   DEBUG: OnKey: 11 (0x0b, obc244) pressed, action is Select
    23:23:14.674 T:1961910272   DEBUG: OnKey: 167 (0xa7, obc88) pressed, action is Down
    23:23:15.180 T:1961910272   DEBUG: OnKey: 11 (0x0b, obc244) pressed, action is Select
    23:23:17.566 T:1961910272   DEBUG: OnKey: 166 (0xa6, obc89) pressed, action is Up
    23:23:18.641 T:1961910272   DEBUG: OnKey: 11 (0x0b, obc244) pressed, action is Select
    23:23:19.572 T:1961910272   DEBUG: OnKey: 168 (0xa8, obc87) pressed, action is Right
    23:23:20.319 T:1961910272   DEBUG: OnKey: 11 (0x0b, obc244) pressed, action is Select
  • Thanks a lot for testing and for the logs!

    The core issue is that eventlircd isn't picking up the input device at all and therefore the button presses end up as keyboard input in kodi (and kodi doesn't "understand" many of the keycodes, thus the "TranslateKey returned XBMCK_UNKNOWN" messages).

    I have no idea why kodi suddenly seems to recognize the input as obc events in the second log. At the beginning of the log we have the "Keyboard: ..." and "OnKey: ..." messages as expected. Then the screensaver kicked in, after that there are no longer any "Keyboard: ..." events, only "OnKey: " with obcXXX codes. Odd.

    Coming back to the eventlircd issue, could you post the output of the following command?

    Code
    udevadm test -a add /sys/class/rc/rc0/input0/event0

    Then power down the RPi, unplug the DVB stick and power up the RPi without it. Then, run the following command:

    Code
    udevadm control -l debug

    Now plug in the DVB stick and then, after some 5 or 10 seconds, grab dmesg and journal output

    Code
    dmesg | paste
    journalctl -a | paste

    With this info I should hopefully get some clues where to start looking further - if it's an udev issue or an eventlircd issue.

    BTW: as a temporary workaround you can change the keytable to use keycodes that kodi understands. eg use KEY_ENTER instead of KEY_OK, KEY_BACK instead of KEY_EXIT etc.

    so long,

    Hias

  • Hi HiassofT,

    here is the output of the first udevadm command:

    You can find the dmesg output at: http://sprunge.us/NSEA

    and the journalctl output at: http://sprunge.us/ibKD

    I will try the workaround you mentioned - thank you for the hint!

    Best regards, Nico.

  • Hi HiassofT,

    your workaround performs good. But perhaps it is an important information for you, that the both keys KEY_ENTER and KEY_BACK are responding a bit slower to my button presses than the KEY_UP/DOWN/LEFT/RIGHT buttons for instance.

    One question for a better understanding of Kodi:

    how do one get the list of the keycodes that will be unterstood by kodi? Is it the list at http://kodi.wiki/view/Action_IDs with a leading "KEY_" before the ActionID!? Or do I have to take a look into the kodi sourcecode for it?

    Kind regards, Nico.

  • Thanks a lot, again, for testing!

    From the system/udev side everything looks fine, these were the 2 lines I was looking for:

    Code
    eventlircd_enable=true
    eventlircd_evmap=default.evmap

    So the problem most certainly resides in libudev or eventlircd. Unfortunatley eventlircd is very quiet and nothing was logged to the journal that could provide additional hints.

    Before I go down the rabbit hole of digging into eventlircd/libudev - which could take me a while - there's one last thing I'd like you to do: Could you do a quick test with the latest milhouse build, using your existing rc_maps.cfg config, and see if eventlircd picks up the input device there (post the output of "lsof | grep /dev/input")? That build contains a newer systemd version, so if it's really a libudev/systemd issue there's a slight chance that could already be fixed.

    Builds are available from here: LibreELEC Testbuilds for RaspberryPi (Kodi 18.0) (just pick the latest, currently #0802). But better use a separate SD card for testing - going back to 8.0.2 will result in a mess because several databases, addons etc will have been updated to newer versions.

    As for KEY_ENTER/BACK being slower: that's normal and caused by the long-press support in Kodi, configured via the default keyboard.xml file:

    Code
    <return>Select</return>
    <return mod="longpress">ContextMenu</return>
    <enter>Select</enter>
    <enter mod="longpress">ContextMenu</enter>
    ...


    That feature allows you to map different functions to a key/button, depending on if you press it shortly or longer. That feature is only available on keyboards, not on (remote-) events that come in via the lirc socket.

    For a full list of keycodes supported in Kodi best look into the source code (the keyMap definition at around line 120): xbmc/LinuxInputDevices.cpp at Krypton · xbmc/xbmc · GitHub

    so long,

    Hias

  • Hello HiassofT,

    thank you (again) for your detailed information and for your support!!!

    Of course I will test with the dev build. But this will take while since I have to order a new sd card. But I'll try to hurry and give you feedback asap!

    Best regards! Nico