IR-KEYTABLE without LIRC / LIRCD

  • I'm using GPIO IR receiver for recording IR remote buttons but I am facing inconsistency to record and execute remote key using LIRC. My question is if we can use remote key operation in my code via IR keytable approach, if yes kindly help and provide steps to perform same.

    Referring approach mentioned here

    Hi, please don't hijack my thread as your questions have nothing to do with it. You are wanting to use a GPIO IR receiver with LIRC. I am trying to use a USB receiver without LIRC, so your questions are totally irrelevant to this subject. Please create your own thread and ask your questions there.


  • I'm not too sure what any of that means but I did find the following code from the OpenELEC forums:

    Code
    ln -sf /dev/null /storage/.config/system.d/eventlircd.service
    sync && reboot

    This disables systemd's eventlircd service on following boots by overriding the normal /usr/lib/systemd/system/eventlircd.service file.

    Quote


    This fixes my issue after the reboot! All keys on the IR keyboard (remote) start working again. However, once I reboot for a second time, it stops working again. It looks to me like the above code creates a symbolic link from /dev/null to the LIRCD service which basically stops LIRCD from working completely. This is fine as it allows IR-KEYTABLE to work but I cannot figure out how this code should be implemented to work on every boot! :(

    At least I'm getting somewhere now and I know this is possible in LibreELEC.

    There is a nice picture in the yaVDR documentation describing the eventlircd input device handling on 3.3. Remote Control. There are differences in details to LibreELEC but it may help to get an idea how your IR receiver is working in the system.

  • When I said I'm not too sure about what any of that means, I was referring to your previous post that I had quoted.

    I am aware that the code I posted disables the eventlircd service, but it does not do it on subsequent boots unfortunately :(

    I need to find a way to permanently override the eventlircd service and stop it running. This is the last step in getting IR-KEYTABLE to handle all keyboard events!

    Maybe the developers would consider adding an option in the LibreELEC settings to allow the user to disable eventlircd as well as LIRC... Who do I need to contact to request this?


  • [..]
    Maybe the developers would consider adding an option in the LibreELEC settings to allow the user to disable eventlircd as well as LIRC... Who do I need to contact to request this?


    I'd also like to see this. And from the logic point of view the "Disable LIRC" button should also be linked to disabling eventlircd as well altogether.

    Your eventlircd discovery explains now why I wasn't able to use ir-keytable last week, when I first tried it. There seemed to be some kind of interference in keypresses and I didn't know how that could be, as I thought LIRC was disabled.

    I'm also looking forward to test this somehow as soon as it is solved.


  • I'd also like to see this. And from the logic point of view the "Disable LIRC" button should also be linked to disabling eventlircd as well altogether.

    Your eventlircd discovery explains now why I wasn't able to use ir-keytable last week, when I first tried it. There seemed to be some kind of interference in keypresses and I didn't know how that could be, as I thought LIRC was disabled.

    I'm also looking forward to test this somehow as soon as it is solved.

    Yes, I think those of us with IR keyboards should be given the option to disable both LIRC and EVENTLIRCD to enable us to exclusively use IR-KEYTABLE in-kernel.

    For me, running the command "systemctl stop eventlircd.service" allows me to see IR remote output in "ir-keytable -t".

    I am just installing Ubuntu on a spare PC and then I will attempt to compile my own copy of LibreELEC without the LIRC and EVENTLIRCD pacakges. If this builds successfully and subsequently works for my IR keyboard, I will put in a formal request for a feature to allow disabling EVENTLIRCD from the LibreELEC setup menu, similar to the option to disable LIRC.


  • When I said I'm not too sure about what any of that means, I was referring to your previous post that I had quoted.

    This disables the start of lircd via udev. You have asked about it.

    Quote


    I am aware that the code I posted disables the eventlircd service, but it does not do it on subsequent boots unfortunately :(

    Really? As long the link exists eventlircd is not started by systemd. Did you check with

    Code
    ps|grep eventlircd
  • There's currently no option to disable eventlircd, the service will be started unconditionally.

    But eventlircd is configurable via udev rules - it'll only grab the input devices matched by the udev rules and translate their input events into lirc events (the current udev rules basically matches all IR receivers, i.e. all remote commands are run through this translation service).

    So another possibility to (logically) disable eventlircd is to create an empty udev rule file - the button-presses should then show up as input/keyboard events in kodi instead of lirc events.

    Code
    : > /storage/.config/udev.rules.d/98-eventlircd.rules

    One benefit of not using eventlircd is that long-press button handling should work in kodi. I haven't checked for quite a while, but about half a year ago there was no longpress support for lirc remotes, but it did work well if eventlircd was bypassed.

    But there are also several drawbacks:

    Most importantly bypassing eventlircd isn't tested too well in LibreELEC so there could be bugs.

    One issue I ran into was that Kodi couldn't handle quite a lot of the default input events on the RPi - most prominently "KEY_OK" but also KEY_CHANNELUP/DOWN and several other ones don't work. I've posted some more info on this issue on the XBMC/Kodi bugtracker half a year ago: #15797 (XBMCK_UNKNOWN returned for some key codes, unable to map with key id=xxx) – Kodi - TRAC

    x86 and RPi are quite different though, on x86 you have X11 running and probably some additional input/event translation in between (not 100% sure, never tried running OpenELEC/LibreELEC on x86). On the RPi there's no X11 and Kodi will be directly talking to the Linux input/event interface.

    So: if you see some unsupported key messages in kodi.log you'll probably have to change the ir-keytable.

    It's still quite puzzling why you have a non-working remote after every other reboot.

    Could you enable debug logging in Kodi and then post the kodi.log after you got a non-working remote?

    Also, when the remote is not working, try stopping kodi and see if you can receive any events with ir-keytable -t.

    Maybe the culprit is also some X11 service or configuration - I won't rule out anything at this point:)

    so long,

    Hias

  • Have you tried going to lirc.org? There is a section on how to use ir-keytable, I don't know how different LE is. I always assUmed it used the same kernel as Ubuntu, I am probably wrong.

  • Using ir-keytable on LE is rather simple: just drop your keymap in .config/rc_keymaps and it'll be automatically picked up by ir-keytable -a (run from standard udev rule).

    I'm doing this for about half a year now on RPi, have this line in config.txt

    Code
    dtoverlay=gpio-ir,gpio_pin=5,gpio_pull=1,rc-map-name=rc-hauppauge


    and placed a slightly modified hauppauge keymap in rc_keymap.

    If you've done this before it's a piece of cake on LE as well :)

    so long,

    Hias

  • To turn off lircd.service permanently:

    Code
    systemctl disable lircd.service


    There could be several running. You will also need to check for lircmd.service, lircd.socket, lircd-setup.service, lirc-uinput.service, and irexec.service. These are all part of LIRC. All of them effect the way key presses are sent through. The easy way to check which services etc. are running is to use:

    Code
    systemctl list-unit-files


    This will list all the systemd units on your machine. You can search by pressing / then your search term.
    You will have to stop the automatic restart in udev if it exists as well.

    Also there should be several keymaps which can be loaded with the kernel. It is possible the only one loaded and or available is missing the keys you want to use. I cannot remember the command to list the available codes the kernel has to offer. It has been too long.

    Edited once, last by frstbscout (February 9, 2017 at 9:26 PM).


  • To turn off lircd.service permanently:

    Code
    systemctl disable lircd.service


    There could be several running. You will also need to check for lircmd.service, lircd.socket, lircd-setup.service, lirc-uinput.service, and irexec.service. These are all part of LIRC. All of them effect the way key presses are sent through. The easy way to check which services etc. are running is to use:

    Code
    systemctl list-unit-files


    This will list all the systemd units on your machine. You can search by pressing / then your search term.
    You will have to stop the automatic restart in udev if it exists as well.

    This won't work for LibreELEC. the [email protected] is activated via a udev rule, so disabling it won't do anything.


  • So another possibility to (logically) disable eventlircd is to create an empty udev rule file - the button-presses should then show up as input/keyboard events in kodi instead of lirc events.

    Code
    : > /storage/.config/udev.rules.d/98-eventlircd.rules

    OK from my experimentation, this code creates a blank 98-eventlircd.rules file but it does absolutely nothing to prevent eventlircd from working. :(
    [hr]

    I agree, initial setup is pretty simple, and I am able to get it working for IR remote control keys. BUT, IR keyboard keys such as KEY_C don't work!

    Edited once, last by NinjaMonkeyUK (February 12, 2017 at 6:53 PM).

  • OK from my experimentation, this code creates a blank 98-eventlircd.rules file but it does absolutely nothing to prevent eventlircd from working. :(


    eventlircd will be running but it won't grab any input devices and translate the input events to lirc events - at least it shouldn't :)

    so long,

    Hias

  • One thing I have noticed is that the output of IR-KEYTABLE changes sometimes:

    Code
    Found /sys/class/rc/rc0/ (/dev/input/event7) with:
            Driver mceusb, table rc-rc6-mce
            Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
            Enabled protocols: lirc rc-5
            Name: Media Center Ed. eHome Infrared
            bus: 3, vendor/product: 147a:e03e, version: 0x1001
            Repeat delay = 1000 ms, repeat period = 1000 ms

    "event7" sometimes appears as "event11" but I'm not sure this is related to my issue as sometimes all keys work when it is pointing to "event7" and other times they do not.

    This is so frustrating! I had it working for all keys on first boot this morning, but after a reboot only specific keys are working again! I KNOW it is possible for Kodi under LibreELEC to work with all IR keyboard commands because I've had it working. I just don't understand what is breaking it on reboot!
    [hr]
    Here are my Kodi logs:

    Kodi Log when full IR keyboard works (you can see on line 522 that key "c" has been recognised and processed to launch the context menu in Kodi)

    Kodi Log when only some IR controls work

    I have compared both files in NotePad++ with the Compare addon and can barely see any difference in the logs; certainly nothing standing out as the reason for the failures. This leads me to believe it is definitely NOT a Kodi issue, but more likely something behind the scenes.

    I'm still convinced it's an issue with key presses being intercepted by something in between IR-KEYTABLE and Kodi.

    LibreELEC developers, do you know what I could be alluding to?

    Edited once, last by NinjaMonkeyUK (February 13, 2017 at 2:17 PM).

  • OK so after further investigation, I have managed to create a complete list of key names that IR-KEYTABLE recognises. I ran a command to pull a list of current key names from IRRECORD:

    Code
    irrecord -l

    This gave me a list of 549 possible names, covering "KEY_" and "BTN_". Since I won't be using "BTN_" as this seems to refer to buttons on a controller, I removed these from the list and individually tested the remaining 435 "KEY_" names. Of these 435, 18 were not recognised at all by IR-KEYTABLE so I am left with 417 key names that I can use:

    List of 417 key names compatible with IR-KEYTABLE

    I tested these in blocks of 100 with a different keytable each time, in case you are wondering how I tested 400+ names.

    Now I know IR-KEYTABLE can receive IR signals and map them to these key names without issue, I need to know how and where these key names are translated into Kodi. Where does Kodi look when trying to match an IR signal to a key name?

  • XORG! :@

    It's xorg causing the issue. If I boot LibreELEC and the IR keyboard keys don't work, I run:

    Code
    systemctl restart xorg.service

    After that the additional keys magically work! This looks to be consistent behaviour so I believe this is the cause of my issue. I think the reason for the keys working sporadically is because on boot, sometimes my IR-KEYTABLE startup command in autostart.sh is getting loaded after xorg, meaning xorg doesn't recognise the new key names.

    Trust me to finally figure this out after I have ordered a Flirc! :rolleyes:

    So now I just need to figure out how to delay xorg on startup... preferably in autostart.sh but I guess this will have to be done in a udev rule. Any ideas? :)