LE8 IR Remote help?

  • Hi.
    I'm a n0ob with LibreELEC and Linux but I have a fair amount of experience with computers, programming and electronics. Currently I'm trying to get a IR remote working by hooking up a IR receiver through GPIO. (Using TSOP32338)
    I've connected OUT (data) to GPIO 18, Vs to 3V3 and GND to GND.
    I've added device_tree_overlay=lirc-rpi to the last line of config.txt.

    Code
    NewPi:~ # dmesg | grep lirc_rpi
    [    3.547124] lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
    [    4.498173] lirc_rpi: auto-detected active high receiver on GPIO pin 18
    [    4.498392] lirc_rpi lirc_rpi: lirc_dev: driver lirc_rpi registered at minor = 0
    [    4.498395] lirc_rpi: driver registered!


    I'm not sure that the TSOP32338 is actually active high, it might be active low? Det datasheet isn't really super clear on that and this is my first experiment with a IR receiver.

    Code
    NewPi:~ # ps | grep lirc
      269 root       0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd
      421 root       0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
      425 root       0:26 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd
      527 root       0:00 grep lirc



    Code
    NewPi:~ # ls -l /dev/lirc0
    crw-------    1 root     root      243,   0 Feb 26 16:33 /dev/lirc0
    NewPi:~ # lsmod | grep lirc
    lirc_rpi                5930  0
    lirc_dev                7013  1 lirc_rpi
    rc_core                16649  1 lirc_dev



    Code
    NewPi:~ # irw /var/run/lirc/lircd-lirc0
    Cannot connect to socket /var/run/lirc/lircd-lirc0: No such file or directory


    Trying irrecord only get's me a no input detected and terminating after 10s.
    For some reason the Pi isn't recording any input from the remote control?
    Can someone please help me? I have no clue how to get this working and nothing that I've found through googling has helped.
    Am I missing some processes that should be running? Should I be adding a pullup or pulldown setting on GPIO 18?
    Adding a IR receiver is supposed to be easy but this is just driving me nuts.
    Please help! :huh:
    [hr]
    Ok, I've made some progress.
    Using irrecord I've successfully recorded the buttons on my remote.
    The irw command still isn't working.
    Where is the lircd.conf file supposed to be located? I placed it .config but that didn't work.


    Edit. Disabled CEC in the GUI (System>Settings>System>Input>Peripherals>;) and made an addition in Lircmap.xml. (.kodi/userdata/)

    Code
    <lircmap>
    <remote device="devinput">
    <start>KEY_HOME</start>
    </remote>
    </lircmap>


    No change, still doesn't work.


    Edit 2. Somehow lirc had been disabled, reenabling it again, the remote works at least to some degree. Laggy and somewhat unresponsive to the buttons but it works. :)

    Edited once, last by Kema ().


  • I've added device_tree_overlay=lirc-rpi to the last line of config.txt.


    FYI: I'd recommend using the gpio-ir overlay instead of lirc-rpi.


    gpio-ir uses the upstream Linux gpio_rc_recv driver and supports in-kernel decoding (aka ir-keytable configuration) - so MCE remotes (plus a few others) will work out of the box and you don't need to use userspace lirc.


    so long,


    Hias


  • That sounds interesting, how do I do that? Just change in the config.txt or what?


    Yes, exactly. This'll use the same gpio as lirc-rpi per default, so if you've been using lirc-rpi before your IR receiver will work with gpio-ir as well.


    Details about the gpio-ir DT parameters can be found in the overlays README (/flash/overlays/README) or here: linux/README at rpi-4.9.y · raspberrypi/linux · GitHub


    Instructions how to customize configuration via ir-keytable are in the thread linked by bubba2017: thread-7152-post-43745.html#pid43745


    BTW: gpio-ir can be used with userspace lirc as well if your remote isn't supported via in-kernel decoding.


    so long,


    Hias

  • Thank you so much, that worked like a charm. Imagine how much trouble I could have saved myself if I'd found that right away. :)

  • Is it possible to use longpress? Having an extra set of commands would be very handy.


  • Is it possible to use longpress? Having an extra set of commands would be very handy.


    Not as long as Kodi is using lirc input.


    Currently eventlircd translates linux input events (as generated by gpio-ir) into lirc events which are then read by kodi. This is done so that button translation can be done for a few remotes and because kodi doesn't support several buttons (like KEY_OK or KEY_CHANNELUP/DOWN) in "keyboard mode".


    You can disable eventlircd by creating an empty /storage/.config/udev.rules.d/98-eventlircd.rules file, then remote button presses will show up as keyboard events in kodi and longpress works.


    If you do this you also have to install a custom rc_keymap and change the KEY_OK mapping to KEY_ENTER - kodi without an "OK" button won't be too much fun :)


    so long,


    Hias

    Edited once, last by HiassofT ().

  • Thanks, that explains things. They say hindsight is always 20/20 and I realized that not having a specific stop button on the remote makes it really awkward.
    Is it possible to have the buttons meaning different things depending on other processes? Like if playing something...

  • Ok, something is not adding up here. I'm using a rc-5 remote. Trying to get "longpress" working.
    I created an empty "/storage/.config/udev.rules.d/98-eventlircd.rules" to disable eventlircd.
    I have a custom rc_keymap "/storage/.config/rc_keymaps/justboom"
    I have also a custom kodi keymap "/storage/.kodi/userdata/keymaps/remote.xml" I also tried renaming this to keyboard.xml.

    XML
    <?xml version="1.0" encoding="UTF-8"?>
    <keymap>
       <global>
          <keyboard>
             <enter mod="longpress">Stop</enter>
          </keyboard>
       </global>
    </keymap>


    Still, it doesn't work.
    I have confirmed that changing the key name in the rc_keymap changes what key is being pressed.
    I tried manually stopping eventlircd using "systemctl stop lircd".
    using "ir-keytable -c -w /storage/.config/rc_keymaps/justboom -t" I looked at the output from pressing the key. It records multiple KEY_DOWN (and finished with a KEY_UPand shows the same scancode used for a single press.
    It seems it's counting KEY_DOWN in fours.

    Code
    1494239079.299725: event type EV_KEY(0x01) key_down: KEY_ENTER(0x0001)
    1494239079.299725: event type EV_SYN(0x00).
    1494239079.413589: event type EV_MSC(0x04): scancode = 0x1015
    1494239079.413589: event type EV_SYN(0x00).
    1494239079.527475: event type EV_MSC(0x04): scancode = 0x1015
    1494239079.527475: event type EV_SYN(0x00).
    1494239079.601347: event type EV_MSC(0x04): scancode = 0x1015
    1494239079.601347: event type EV_SYN(0x00).
    1494239079.755245: event type EV_MSC(0x04): scancode = 0x1015


    I don't know if this actually means anything useful?
    Regardless, I'm kind of out of ideas at the moment. :/


    Edit.
    It would seem remapping a key works but longpress does not?

    Edited once, last by Kema ().

  • Just did a quick test here with my justboom remote and ran into an interesting issue, kodi didn't detect any button presses at all if eventlircd was bypassed.


    lsof clearly showed that kodi was using the input event device, but nothing at all showed up in kodi log (debugging enabled)

    Code
    LibreELEC:~ # lsof | grep /dev/input
    1350 /usr/lib/kodi/kodi.bin /dev/input/event0
    1350 /usr/lib/kodi/kodi.bin /dev/input/event1
    LibreELEC:~ # evtest
    No device specified, trying to scan all of /dev/input/event*
    Available devices:
    /dev/input/event0: Logitech K400
    /dev/input/event1: gpio_ir_recv
    Select the device event number [0-1]: ^C


    As I was pretty sure it worked with my hauppauge remote before I dug into that and could make it work if I added a (dummy) keymap entry for KEY_NUMERIC_0 - looks like this is enough to make kodi detect the remote as a keyboard (maybe kodi thinks this is a game controller otherwise - don't know for sure).


    Here's the working .config/rc_keymaps/justboom I've used for testing:


    With this keymap longpress-OK worked out of the box with kodi, default kodi keymap contains an entry to map longpress-enter to context menu.


    BTW: I needed to restart kodi after changing the keymap with ir-keytable -w ... on-the-fly, kodi only seems to test for "keyboard/non-keyboard" when it accesses the input device the first time.


    Snippet from default kodi keyboard.xml:

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


    And also visible in kodi.log :)

    Code
    17:36:39.358 T:1962061824 DEBUG: Keyboard: scancode: 0x1c, sym: 0x000d, unicode: 0x0000, modifier: 0x0
    17:36:39.891 T:1962061824 DEBUG: Previous line repeats 1 times.
    17:36:39.891 T:1962061824 DEBUG: OnKey: long-return (0x100f00d) pressed, action is ContextMenu


    BTW: I think you need to have both <key ...> and <key mod="longpress"...> in keyboard.xml to make longpress working in kodi. Also, the ~500ms delay for the first key-repeat showing up in evtest/ir-keytable is normal - this is the initial repeat delay:


    so long,


    Hias

  • There is a certain amount of irony connected to this.
    I to get the longpress to work following your instructions using the default keyboard.xml.
    However, it refuses to let me remap the function...
    (/storage/.kodi/userdata/keymaps/keyboard.xml)

    Code
    <keymap>
       <global>
          <keyboard>
             <enter>Select</enter>
             <enter mod="longpress">Stop</enter>
          </keyboard>
       </global>
    </keymap>


    is not getting the job done.

  • Enable debug logging in kodi and check kodi.log if it reported errors about the keyboard.xml file. Also check if the remote presses actually show up as keyboard events. If they show up as lirc events in the log, eventlircd is still translating the events.


    BTW: If you change anything it's best to reboot, this is the easiest way to make sure all new config files are picked up.


    so long,


    Hias

  • How do I check if the remote presses show up as keyboard events?
    So far I haven't seen button presses showing up in the kodi.log? Is there some setting I need to add? The only way that I've been able to see the codes for button presses have been by stopping eventlircd and stopping kodi. With kodi and eventlircd running I haven't been able to find any way to see the code for buttons pressed?
    I started with a clean install of LE8.0.1. Have installed Exodus and the stuff that came with that, LCDproc and XBMC LCDproc. No more and no less, perhaps I'm missing some diagnostic tools?
    My advancedsettings.xml is currently empty since I'm still working with the basics.
    [hr]
    These are the log posts I can find containing keyboard.xml

    Code
    17:33:11.655 T:1961762816    INFO: Loading special://xbmc/system/keymaps/keyboard.xml
    17:33:11.733 T:1961762816    INFO: Loading special://masterprofile/keymaps/keyboard.xml


    And I found some buttonpresses as well.


    13:46:41.448 is showing the longpress for the enter button ("ok" button named KEY_ENTER in justboom)
    Notice the longpress is actually logged as long-return?
    And the KEY_ENTER is recorded as return?
    Could this be the problem? In my custom keyboard.xml I've been using <enter> and <enter mod="longpress">. Should it be <return> and <return mod="longpress"> instead?
    And here are the error logs I could find.

    Code
    17:33:09.440 T:1961762816   ERROR: DBus: Error org.freedesktop.DBus.Error.ServiceUnknown - The name org.freedesktop.UPower was not provided by any .service files


    Only one error entry in total.
    [hr]
    Success! Using <return mod="longpress"> in the custom keyboard.xml file solved the issue. :D
    Thank you for all the help, you're a true hero.

    Edited once, last by Kema ().

  • Hi Hias,


    Just joined to let you know some experiences I'm having re IR fun and games..


    I'm running the latest x86 version LE on an Intel Nuc which utilises an inbuilt IR receiver, plus a HP MCE remote.


    This combination has been used previously on a Windows Kodi install for a few years with no issues.


    I'm getting the dreaded double press when LIRC is switched Off, however I believe it could well be a timing issue as pressing the key sharply will often not result in a double activation.


    I've tried rebooting etc after disabling LIRC with no changes, however I've also experienced issues when returning from sleep on occasion wherby despite LIRC being on, I get double presses again. This is then fixed by turning LIRC.. Off!!


    I'll try to nail down what sequence occurs for this to happen, if my wife doesn't kill me first. Her approval rating of the system is dropping. 8o