Skip to content

03. Meson IR: Creating a KEYMAP file from scratch

betatester3016 edited this page Feb 4, 2022 · 8 revisions

Abstract

The Meson IR remote receiver driver is part of Linus Thorvalds Linux Kernel and allows the use of compatible infrared remote controllers on a Linux distribution with the driver enabled.

Two configuration files are required to control the IR remotes behavior: a key mapping file (KEYMAP), containing a table with an association between the scan codes and the corresponding kernel namespace, and the file rc_maps.cfg, binding the KEYMAP to the Meson IR protocol.

Basic instructions

  1. Connecting to CoreELEC

SSH into CoreELEC with default username and password (root/coreelec)

ssh root@ip_address

  1. Creating required files

touch KEYMAP

touch rc_maps.cfg

  1. Stopping services

systemctl stop kodi

systemctl stop eventlircd

  1. Scanning for IR Codes

Press a button on the remote control, then run in SSH:

dmesg -c

or

ir-keytable -p NEC,RC-5,RC-6,JVC,SONY -t

If the remote control is compatible there should be a message:

[ 9087.000717@0] meson-remote ff808040.meson-remote: invalid custom:0xae517f80

If there is no message, the remote is most likely incompatible.

  1. Finding the namespaces

run irrecord --list-namespace

  1. Entering the data into the KEYMAP file

run vi KEYMAP

the first line of the KEYMAP file should read:

  # table KEYMAP, type: PROTOCOL

followed by scan code corresponding namespace # comment:

  0x0000 KEY_MAP                 # IMPORTANT: separate scan code and KEY_MAP with a space
  0x0001 KEY_MAP2                # Example line 2

Next create a rc_maps.cfg file with the following contents:

  meson-ir * KEYMAP
  1. Storage locations

The KEYMAP file is stored in:

  /storage/.config/rc_keymaps/KEYMAP

The rc_maps.cfg file is stored in:

  /storage/.config/ 
  1. Testing the configuration

Finish by loading the keycode file and starting Kodi and eventlircd back up to test the changes.

  ir-keytable -a /storage/.config/rc_maps.cfg -s rc0
  systemctl start eventlircd
  systemctl start kodi

NOTE: The configuration will be loaded automatically when rebooting/powering on the device.

How to obtain the scan codes

run ir-keytable -t

 Testing events. Please, press CTRL-C to abort.

Push the buttons on the remote to view the scan codes and namespaces:

 2088.166794: event type EV_MSC(0x04): scancode = 0xdf1c
 2088.166794: event type EV_KEY(0x01) key_down: KEY_POWER(0x0003)
 2092.916069: event type EV_MSC(0x04): scancode = 0xdf18
 2092.916069: event type EV_KEY(0x01) key_down: KEY_MENU(0x008b)
 2090.058875: event type EV_MSC(0x04): scancode = 0xdff3
 2090.058875: event type EV_KEY(0x01) key_down: KEY_MUTE(0x0004)

Enter the data into the KEYMAP file:

 # table A95XF2, type: NEC
 0xdf1c KEY_POWER
 0xdf18 KEY_MENU
 0xdff3 KEY_MUTE

TOML

ce_logo

The following information applies to CoreELEC -ng ONLY!

CoreELEC -ng (version 19 and above) can also use the .toml file format.

The whole filename becomes then KEYMAP.toml

Please ensure KEYMAP.toml meets the .toml file structure including the sections:

   [[protocols]]
   [protocols.scancodes]

The .toml format explained.

Following keymaps can be merged into CoreELEC with the echo "meson-ir * KEYMAP.toml" > /storage/.config/rc_maps.cfg command.

Example:

   echo "meson-ir * kvim.toml" > /storage/.config/rc_maps.cfg

Samples

KEYMAP
KEYMAP.toml
rc_maps