Osmc: switch from lirc to ir-keytable

Hi again,

@sam_nazarko suggested here that I should switch from lirc to ir-keytable. I have the marantz-rc003pmcd remote that uses standard rc-5 for most of the keys, but some keys seem to use something different, and i have a suspicion (based on this) it’s rc-5x-20.

I saw online that the linux devs added support for this in the kernel and I’d like to evaluate it on the Vero V hardware (IR receiver) and OSMC.

I wrote this minimal keymap file to have working navigation:

$ cat /etc/rc_keymaps/marantz-rc003pmcd 
# table marantz_rc003pmcd type: rc-5
0x1457 KEY_OK
0x1450 KEY_UP
0x1451 KEY_DOWN
0x1455 KEY_LEFT
0x1456 KEY_RIGHT
0x1429 KEY_BACK
0x144f0a KEY_INFO

After I do systemctl stop eventlircd, I load this keymap:

$ sudo ir-keytable -c -w /etc/rc_keymaps/marantz-rc003pmcd 
Read marantz_rc003pmcd table
Old keytable cleared
Wrote 7 keycode(s) to driver
Protocols changed to rc-5

I can see with ir-keytable that the keys I press are properly recognized and they are associated with KEY_UP, KEY_DOWN etc:

$ ir-keytable -t
Testing events. Please, press CTRL-C to abort.
26525.760783: event type EV_MSC(0x04): scancode = 0x1456
26525.760783: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)
26525.760783: event type EV_SYN(0x00).
26525.910047: event type EV_MSC(0x04): scancode = 0x1456
26525.910047: event type EV_SYN(0x00).
26526.170030: event type EV_KEY(0x01) key_up: KEY_RIGHT(0x006a)
26526.170030: event type EV_SYN(0x00).
26527.036906: event type EV_MSC(0x04): scancode = 0x1455
26527.036906: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)
26527.036906: event type EV_SYN(0x00).
26527.190050: event type EV_MSC(0x04): scancode = 0x1455
26527.190050: event type EV_SYN(0x00).
26527.450027: event type EV_KEY(0x01) key_up: KEY_LEFT(0x0069)
26527.450027: event type EV_SYN(0x00).
26528.240441: event type EV_MSC(0x04): scancode = 0x1450
26528.240441: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)
26528.240441: event type EV_SYN(0x00).
26528.390063: event type EV_MSC(0x04): scancode = 0x1450
26528.390063: event type EV_SYN(0x00).
26528.650023: event type EV_KEY(0x01) key_up: KEY_UP(0x0067)
26528.650023: event type EV_SYN(0x00).
26529.297836: event type EV_MSC(0x04): scancode = 0x1451
26529.297836: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)
26529.297836: event type EV_SYN(0x00).
26529.450051: event type EV_MSC(0x04): scancode = 0x1451
26529.450051: event type EV_SYN(0x00).
26529.710029: event type EV_KEY(0x01) key_up: KEY_DOWN(0x006c)
26529.710029: event type EV_SYN(0x00).
26530.302562: event type EV_MSC(0x04): scancode = 0x1457
26530.302562: event type EV_KEY(0x01) key_down: KEY_OK(0x0160)
26530.302562: event type EV_SYN(0x00).
26530.450051: event type EV_MSC(0x04): scancode = 0x1457
26530.450051: event type EV_SYN(0x00).
26530.710025: event type EV_KEY(0x01) key_up: KEY_OK(0x0160)
26530.710025: event type EV_SYN(0x00).
26532.213489: event type EV_MSC(0x04): scancode = 0x1429
26532.213489: event type EV_KEY(0x01) key_down: KEY_BACK(0x009e)
26532.213489: event type EV_SYN(0x00).
26532.360049: event type EV_MSC(0x04): scancode = 0x1429
26532.360049: event type EV_SYN(0x00).
26532.620027: event type EV_KEY(0x01) key_up: KEY_BACK(0x009e)
26532.620027: event type EV_SYN(0x00).
26536.405123: event type EV_MSC(0x04): scancode = 0x144f0a
26536.405123: event type EV_KEY(0x01) key_down: KEY_INFO(0x0166)
26536.405123: event type EV_SYN(0x00).
26536.660023: event type EV_KEY(0x01) key_up: KEY_INFO(0x0166)
26536.660023: event type EV_SYN(0x00).
26537.590066: event type EV_MSC(0x04): scancode = 0x147f0e
26537.590066: event type EV_SYN(0x00).
26552.522106: event type EV_MSC(0x04): scancode = 0x1401
26552.522106: event type EV_SYN(0x00).
26553.146459: event type EV_MSC(0x04): scancode = 0x1402
26553.146459: event type EV_SYN(0x00).
26553.290050: event type EV_MSC(0x04): scancode = 0x1402
26553.290050: event type EV_SYN(0x00).
26553.660069: event type EV_MSC(0x04): scancode = 0x1403
26553.660069: event type EV_SYN(0x00).
26553.810072: event type EV_MSC(0x04): scancode = 0x1403
26553.810072: event type EV_SYN(0x00).
26554.228570: event type EV_MSC(0x04): scancode = 0x1405
26554.228570: event type EV_SYN(0x00).
26554.390048: event type EV_MSC(0x04): scancode = 0x1405
26554.390048: event type EV_SYN(0x00).
26554.820052: event type EV_MSC(0x04): scancode = 0x1406
26554.820052: event type EV_SYN(0x00).

However, nothing changes in the OSMC GUI, remote input doesn’t work.

Is something else “eating” up these events ? Do I need to configure something else to make this work that I am not aware of ?

At a minimum, I would at least try:

sudo systemctl stop eventlircd
sudo systemctl stop lircd_helper@lirc0
sudo systemctl stop system-lircd_helper.slice
sudo systemctl stop lircd_helper@event0
sudo systemctl stop lircd_helper@-dev-input-event0

The first 3 are ok, systemctl starting/stopping them works.

The last 2 don’t start, thery are stopped anyway, here’s journalctl output after trying to start (just to test) lircd_helper@event0:

Jan 12 12:16:52 osman sh[3462]: /bin/sh: 1: /var/run/lirc/lircd-event0.sh: not found
Jan 12 12:16:52 osman systemd[1]: lircd_helper@event0.service: Control process exited, code=exited, status=127/n/a
Jan 12 12:16:52 osman systemd[1]: lircd_helper@event0.service: Failed with result 'exit-code'.
Jan 12 12:16:52 osman systemd[1]: Failed to start lircd remote support.

Also:

$ ls /var/run/lirc/     
lircd  lircd-lirc0  lircd-lirc0.pid  lircd-lirc0.sh

Perhaps I should add that by stopping just the first 3 services, the remote still can’t control the mediacenter.

I think after you run ir-keytable and verify it is configured correctly, you’d then want to test output with:

mode2 -d /dev/input/event0

After this, you’d want to record a new LIRC profile with something like:

irrecord -d /dev/input/event0 ~/new-remote.conf

Cheers

Sam

Ok so I tried what you suggested on /dev/input/event0 and it didn’t work, I could not see input.

However, I poked around and noticed that /dev/input/event7 works for me, I can see input there when pressing the remote:

$ mode2 -d /dev/input/event7
Using driver devinput on device /dev/input/event7
Trying device: /dev/input/event7
Using device: /dev/input/event7
code: 0x5f59a165b1ab07000400040051140000
code: 0x5f59a165b1ab070001006c0001000000
code: 0x5f59a165b1ab07000000000000000000
code: 0x5f59a165adfd09000400040051140000
code: 0x5f59a165adfd09000000000000000000
code: 0x5f59a16529f50d0001006c0000000000

Then I used irrecord on /dev/input/event7 to make a new minimal remote config as you suggested:

begin remote

  name  marantz-rc003pmcd
  driver devinput
  bits           24
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  pre_data_bits   104
  pre_data       0x4000400
  gap          113384
  toggle_bit_mask 0x0
  frequency    38000

      begin codes
          KEY_POWER                0x00140C
          KEY_VOLUMEDOWN           0x001121
          KEY_VOLUMEUP             0x001120
          KEY_OK                   0x001457
          KEY_UP                   0x001450
          KEY_LEFT                 0x001455
          KEY_DOWN                 0x001451
          KEY_RIGHT                0x001456
          KEY_BACK                 0x001429
          KEY_INFO                 0x144F0A
      end codes

end remote

But still can’t navigate the GUI with the remote. I think it’s because or this event0 - event7 mixup but I don’t know how to fix it.

Did even more digging. I can successfully see that the kernel correctly generates these input events based solely on the ir-keytable that I loaded after disabling everything lirc related. So the question now is, why does osmc mediacenter doesn’t pick up these input events…

$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0:	gpio_keypad
/dev/input/event1:	aml_vkeypad
/dev/input/event2:	cec_input
/dev/input/event3:	input_btrcu
/dev/input/event4:	vad_keypad
/dev/input/event5:	OSMC Remote Controller OSMC Remote Controller
/dev/input/event6:	OSMC Remote Controller OSMC Remote Controller
/dev/input/event7:	meson-ir
Select the device event number [0-7]: 7
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "meson-ir"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 103 (KEY_UP)
    Event code 105 (KEY_LEFT)
    Event code 106 (KEY_RIGHT)
    Event code 108 (KEY_DOWN)
    Event code 158 (KEY_BACK)
    Event code 352 (KEY_OK)
    Event code 358 (KEY_INFO)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Key repeat handling:
  Repeat type 20 (EV_REP)
    Repeat code 0 (REP_DELAY)
      Value    500
    Repeat code 1 (REP_PERIOD)
      Value    125
Properties:
Testing ... (interrupt to exit)




Event: time 1705149479.460632, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1455
Event: time 1705149479.460632, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
Event: time 1705149479.460632, -------------- SYN_REPORT ------------
Event: time 1705149479.574086, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1455
Event: time 1705149479.574086, -------------- SYN_REPORT ------------
Event: time 1705149479.722373, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1455
Event: time 1705149479.722373, -------------- SYN_REPORT ------------
Event: time 1705149479.962354, type 1 (EV_KEY), code 105 (KEY_LEFT), value 2
Event: time 1705149479.962354, -------------- SYN_REPORT ------------
Event: time 1705149479.982350, type 1 (EV_KEY), code 105 (KEY_LEFT), value 0
Event: time 1705149479.982350, -------------- SYN_REPORT ------------
Event: time 1705149480.708832, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1450
Event: time 1705149480.708832, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1705149480.708832, -------------- SYN_REPORT ------------
Event: time 1705149480.852388, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1450
Event: time 1705149480.852388, -------------- SYN_REPORT ------------
Event: time 1705149481.122345, type 1 (EV_KEY), code 103 (KEY_UP), value 0
Event: time 1705149481.122345, -------------- SYN_REPORT ------------
Event: time 1705149481.488084, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1456
Event: time 1705149481.488084, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
Event: time 1705149481.488084, -------------- SYN_REPORT ------------
Event: time 1705149481.642374, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1456
Event: time 1705149481.642374, -------------- SYN_REPORT ------------
Event: time 1705149481.902356, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 0
Event: time 1705149481.902356, -------------- SYN_REPORT ------------
Event: time 1705149482.194816, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1451
Event: time 1705149482.194816, type 1 (EV_KEY), code 108 (KEY_DOWN), value 1
Event: time 1705149482.194816, -------------- SYN_REPORT ------------
Event: time 1705149482.342374, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1451
Event: time 1705149482.342374, -------------- SYN_REPORT ------------
Event: time 1705149482.602352, type 1 (EV_KEY), code 108 (KEY_DOWN), value 0
Event: time 1705149482.602352, -------------- SYN_REPORT ------------

This is how I disable now lirc stuff:

systemctl stop eventlircd
systemctl stop lircd_helper@lirc0
systemctl stop system-lircd_helper.slice
rmmod ir_lirc_codec lirc_dev

Thanks for your patience

We put the meson-ir mode in to a raw mode by default.
It has two modes (once supports NEC decoding and one just measures pulses and duration)

When you start Kodi, I think you need to make sure ir-keytable is using the correct keymap and decoding mode. It might be defaulting to something like RC6. Supported and enabled protocol should be LIRC so that LIRC can pick up the events.

I think with ir-keytable -p lirc

Maybe I would’ve succeeded with your last advice but I had a Flirc device lying around and decided to test it. Mapping every key was very easy with the Flirc and I’ve also noticed that with the Flirc, I can keep the remote in any direction and still picks up the IR signal, it doesn’t have to be aligned line-of-sight with the Flirc. This was a big advantage for me compared to the embedded IR sensor on the Vero V which requires line-of-sight, so I decided to just use the Flirc and be done with it…

1 Like