Software, electronics and anything else

On IR remotes

In the process of trying out MythTV, Kodi and the like, I’ve discovered that IR remotes are really irritating on Linux with an enormous amount of out of date documentation. Some of the useful breakdowns or guides I found are:

From that, you can see that ir-keytable is the best and really only tool to use. It can list all IR receivers:

pvr@pvr:~$ sudo ir-keytable
Found /sys/class/rc/rc0/ with:
        Name: ITE8708 CIR transceiver
        Driver: ite-cir
        Default keymap: rc-rc6-mce
        Input device: /dev/input/event7
        LIRC device: /dev/lirc0
        Attached BPF protocols: Operation not supported
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
        Enabled kernel protocols: lirc rc-5
        bus: 25, vendor/product: 1283:0000, version: 0x0000
        Repeat delay = 500 ms, repeat period = 125 ms

And it can help you determine if your remote is detected:

pvr@pvr:~$ sudo ir-keytable -t
Testing events. Please, press CTRL-C to abort.
809.329593: lirc protocol(rc5): scancode = 0x1e0b toggle=1
809.329616: event type EV_MSC(0x04): scancode = 0x1e0b
809.329616: event type EV_KEY(0x01) key_down: KEY_RED(0x018e)
809.329616: event type EV_SYN(0x00).
809.443478: lirc protocol(rc5): scancode = 0x1e0b toggle=1
809.443494: event type EV_MSC(0x04): scancode = 0x1e0b
809.443494: event type EV_SYN(0x00).
809.580103: event type EV_KEY(0x01) key_up: KEY_RED(0x018e)
809.580103: event type EV_SYN(0x00).

On Linux Mint, and I assume Ubuntu and Debian due to their shared base, it loads a default keymap on boot based on the name of the driver of the IR device you are using. That means that if like me you’re using some random remote, you need to change this default device. The mapping is specified in /etc/rc_maps.cfg, and by running ir-keytable directly you can see what it’s doing. In my case:

pvr@pvr:~$ sudo ir-keytable -a /etc/rc_maps.cfg -v
Found device /sys/class/rc/rc0/
....
Parsing uevent /sys/class/rc/rc0/uevent
/sys/class/rc/rc0/uevent uevent NAME=rc-rc6-mce
/sys/class/rc/rc0/uevent uevent DRV_NAME=ite-cir
/sys/class/rc/rc0/uevent uevent DEV_NAME=ITE8708 CIR transceiver
...
Keymap for ite-cir, rc-rc6-mce is on rc6_mce.toml file.

I cut out a lot of the less important lines to show only the important ones. In particular, you can see that the device is named rc-rc6-mce and it’s mapping to the rc6_mce.toml file. If you open up /etc/rc_maps.cfg, you can see the link:

*      rc-rc6-mce               rc6_mce.toml

So, if like me you have a random remote, you only need to find the appropriate remote file in /lib/udev/rc_keymaps/ and change the line to refer to your file. In my case:

*       rc-rc6-mce               hauppauge.toml

One thought on “On IR remotes

  1. What is wrong with this? Why does it not “just work” like Ubuntu claims?

    /etc/rc_keymaps/rc6_mce.toml has cotents:
    # Generated with gen_keytables . pl from drivers/media/rc/keymaps/rc-rc6-mce.c
    [[protocols]]
    name = “rc6_mce”
    protocol = “rc6”
    variant = “rc6_mce”
    [protocols.scancodes]
    0x800f0400 = “KEY_NUMERIC_0”
    0x800f0401 = “KEY_NUMERIC_1”
    0x800f0402 = “KEY_NUMERIC_2”
    0x800f0403 = “KEY_NUMERIC_3”
    0x800f0404 = “KEY_NUMERIC_4”
    0x800f0405 = “KEY_NUMERIC_5”
    0x800f0406 = “KEY_NUMERIC_6”
    0x800f0407 = “KEY_NUMERIC_7”
    0x800f0408 = “KEY_NUMERIC_8”
    0x800f0409 = “KEY_NUMERIC_9”
    0x800f040a = “KEY_DELETE”
    0x800f040b = “KEY_ENTER”
    0x800f040c = “KEY_SLEEP”
    0x800f040d = “KEY_MEDIA”
    0x800f040e = “KEY_MUTE”
    0x800f040f = “KEY_INFO”
    0x800f0410 = “KEY_VOLUMEUP”
    0x800f0411 = “KEY_VOLUMEDOWN”
    0x800f0412 = “KEY_CHANNELUP”
    0x800f0413 = “KEY_CHANNELDOWN”
    0x800f0414 = “KEY_FASTFORWARD”
    0x800f0415 = “KEY_REWIND”
    0x800f0416 = “KEY_PLAY”
    0x800f0417 = “KEY_RECORD”
    0x800f0418 = “KEY_PAUSE”
    0x800f0419 = “KEY_STOP”
    0x800f041a = “KEY_NEXT”
    0x800f041b = “KEY_PREVIOUS”
    0x800f041c = “KEY_NUMERIC_POUND”
    0x800f041d = “KEY_NUMERIC_STAR”
    0x800f041e = “KEY_UP”
    0x800f041f = “KEY_DOWN”
    0x800f0420 = “KEY_LEFT”
    0x800f0421 = “KEY_RIGHT”
    0x800f0422 = “KEY_OK”
    0x800f0423 = “KEY_EXIT”
    0x800f0424 = “KEY_DVD”
    0x800f0425 = “KEY_TUNER”
    0x800f0426 = “KEY_EPG”
    0x800f0427 = “KEY_ZOOM”
    0x800f0432 = “KEY_MODE”
    0x800f0433 = “KEY_PRESENTATION”
    0x800f0434 = “KEY_EJECTCD”
    0x800f043a = “KEY_BRIGHTNESSUP”
    0x800f0446 = “KEY_TV”
    0x800f0447 = “KEY_AUDIO”
    0x800f0448 = “KEY_PVR”
    0x800f0449 = “KEY_CAMERA”
    0x800f044a = “KEY_VIDEO”
    0x800f044c = “KEY_LANGUAGE”
    0x800f044d = “KEY_TITLE”
    0x800f044e = “KEY_PRINT”
    0x800f0450 = “KEY_RADIO”
    0x800f045a = “KEY_SUBTITLE”
    0x800f045b = “KEY_RED”
    0x800f045c = “KEY_GREEN”
    0x800f045d = “KEY_YELLOW”
    0x800f045e = “KEY_BLUE”
    0x800f0465 = “KEY_POWER2”
    0x800f0469 = “KEY_MESSENGER”
    0x800f046e = “KEY_PLAYPAUSE”
    0x800f046f = “KEY_PLAYER”
    0x800f0480 = “KEY_BRIGHTNESSDOWN”
    0x800f0481 = “KEY_PLAYPAUSE”
    ….
    loading the config file:
    mythtv@tivofront:/etc/rc_keymaps$ sudo ir-keytable -c -w rc6_mce.toml
    Read rc6_mce table
    Old keytable cleared
    Wrote 64 keycode(s) to driver
    Protocols changed to rc-6

    then running a test:
    mythtv@tivofront:/etc/rc_keymaps$ sudo ir-keytable -t
    Testing events. Please, press CTRL-C to abort.
    299.153492: lirc protocol(rc6_mce): scancode = 0x800f0422 toggle=1
    299.153520: event type EV_MSC(0x04): scancode = 0x800f0422
    299.153520: event type EV_KEY(0x01) key_down: KEY_OK(0x0160)
    299.153520: event type EV_SYN(0x00).
    299.288173: event type EV_KEY(0x01) key_up: KEY_OK(0x0160)
    299.288173: event type EV_SYN(0x00).

    Why does the test return a code of 0x0160 for the KEY_OK when it is clearly defined as 0x800f0422 = “KEY_OK” in the config file? The config file has no such hex code above FF. This seems to be the problem, but I can’t figure out how ir-keytable gets some other config file to assign button presses to. Does anyone know where else it might be getting this info?

    /etc/rc_maps.cfg:
    #
    # Keymaps table
    #
    # This table creates an association between a keycode file and a kernel
    # driver. It can be used to automatically override a keycode definition.
    #
    # Although not yet tested, it is mented to be added at udev.
    #
    # To use, you just need to run:
    # ./ir-keytable -a
    #
    # Or, if the remote is not the first device:
    # ./ir-keytable -a -s rc1 # for RC at rc1
    #

    # Format:
    # driver – name of the driver provided via uevent – use * for any driver
    # table – RC keymap table, provided via uevent – use * for any table
    # file – file name. If directory is not specified, it will default to
    # /etc/rc_keymaps.
    # For example:
    # driver table file
    # cx8800 * ./keycodes/rc5_hauppauge_new.toml
    # * rc-avermedia-m135a-rm-jx ./keycodes/kworld_315u.toml
    # saa7134 rc-avermedia-m135a-rm-jx ./keycodes/keycodes/nec_terratec_cinergy_xs.toml
    # em28xx * ./keycodes/kworld_315u.toml
    # * * ./keycodes/rc5_hauppauge_new.toml

    # Table to automatically load the rc maps for the bundled IR’s provided with the
    # devices supported by the linux kernel

    #driver table file
    * rc-adstech-dvb-t-pci adstech_dvb_t_pci.toml
    * rc-alink-dtu-m alink_dtu_m.toml
    * rc-anysee anysee.toml
    * rc-apac-viewcomp apac_viewcomp.toml
    * rc-astrometa-t2hybrid astrometa_t2hybrid.toml
    * rc-asus-pc39 asus_pc39.toml
    * rc-asus-ps3-100 asus_ps3_100.toml
    * rc-ati-tv-wonder-hd-600 ati_tv_wonder_hd_600.toml
    * rc-ati-x10 ati_x10.toml
    * rc-avermedia-a16d avermedia_a16d.toml
    * rc-avermedia-cardbus avermedia_cardbus.toml
    * rc-avermedia-dvbt avermedia_dvbt.toml
    * rc-avermedia-m135a avermedia_m135a.toml
    * rc-avermedia-m733a-rm-k6 avermedia_m733a_rm_k6.toml
    * rc-avermedia-rm-ks avermedia_rm_ks.toml
    * rc-avermedia avermedia.toml
    * rc-avertv-303 avertv_303.toml
    * rc-azurewave-ad-tu700 azurewave_ad_tu700.toml
    * rc-beelink-gs1 beelink_gs1.toml
    * rc-behold-columbus behold_columbus.toml
    * rc-behold behold.toml
    * rc-budget-ci-old budget_ci_old.toml
    * rc-cec cec.toml
    * rc-cinergy-1400 cinergy_1400.toml
    * rc-cinergy cinergy.toml
    * rc-ct-90405 ct_90405.toml
    * rc-d680-dmb d680_dmb.toml
    * rc-delock-61959 delock_61959.toml
    * rc-dib0700-nec dib0700_nec.toml
    * rc-dib0700-rc5 dib0700_rc5.toml
    * rc-digitalnow-tinytwin digitalnow_tinytwin.toml
    * rc-digittrade digittrade.toml
    * rc-dm1105-nec dm1105_nec.toml
    * rc-dntv-live-dvb-t dntv_live_dvb_t.toml
    * rc-dntv-live-dvbt-pro dntv_live_dvbt_pro.toml
    * rc-dtt200u dtt200u.toml
    * rc-dvbsky dvbsky.toml
    * rc-dvico-mce dvico_mce.toml
    * rc-dvico-portable dvico_portable.toml
    * rc-em-terratec em_terratec.toml
    * rc-encore-enltv-fm53 encore_enltv_fm53.toml
    * rc-encore-enltv encore_enltv.toml
    * rc-encore-enltv2 encore_enltv2.toml
    * rc-evga-indtube evga_indtube.toml
    * rc-eztv eztv.toml
    * rc-flydvb flydvb.toml
    * rc-flyvideo flyvideo.toml
    * rc-fusionhdtv-mce fusionhdtv_mce.toml
    * rc-gadmei-rm008z gadmei_rm008z.toml
    * rc-geekbox geekbox.toml
    * rc-genius-tvgo-a11mce genius_tvgo_a11mce.toml
    * rc-gotview7135 gotview7135.toml
    * rc-hauppauge hauppauge.toml
    * rc-hisi-poplar hisi_poplar.toml
    * rc-hisi-tv-demo hisi_tv_demo.toml
    * rc-imon-mce imon_mce.toml
    * rc-imon-pad imon_pad.toml
    * rc-imon-rsc imon_rsc.toml
    * rc-iodata-bctv7e iodata_bctv7e.toml
    * rc-it913x-v1 it913x_v1.toml
    * rc-it913x-v2 it913x_v2.toml
    * rc-kaiomy kaiomy.toml
    * rc-khadas khadas.toml
    * rc-khamsin khamsin.toml
    * rc-kworld-315u kworld_315u.toml
    * rc-kworld-pc150u kworld_pc150u.toml
    * rc-kworld-plus-tv-analog kworld_plus_tv_analog.toml
    * rc-leadtek-y04g0051 leadtek_y04g0051.toml
    * rc-lme2510 lme2510.toml
    * rc-manli manli.toml
    * rc-mecool-kii-pro mecool_kii_pro.toml
    * rc-mecool-kiii-pro mecool_kiii_pro.toml
    * rc-medion-x10-digitainer medion_x10_digitainer.toml
    * rc-medion-x10-or2x medion_x10_or2x.toml
    * rc-medion-x10 medion_x10.toml
    * rc-minix-neo minix_neo.toml
    * rc-msi-digivox-ii msi_digivox_ii.toml
    * rc-msi-digivox-iii msi_digivox_iii.toml
    * rc-msi-tvanywhere-plus msi_tvanywhere_plus.toml
    * rc-msi-tvanywhere msi_tvanywhere.toml
    * rc-nebula nebula.toml
    * rc-nec-terratec-cinergy-xs nec_terratec_cinergy_xs.toml
    * rc-norwood norwood.toml
    * rc-npgtech npgtech.toml
    * rc-odroid odroid.toml
    * rc-pctv-sedna pctv_sedna.toml
    * rc-pine64 pine64.toml
    * rc-pinnacle-color pinnacle_color.toml
    * rc-pinnacle-grey pinnacle_grey.toml
    * rc-pinnacle-pctv-hd pinnacle_pctv_hd.toml
    * rc-pixelview-002t pixelview_002t.toml
    * rc-pixelview-mk12 pixelview_mk12.toml
    * rc-pixelview-new pixelview_new.toml
    * rc-pixelview pixelview.toml
    * rc-powercolor-real-angel powercolor_real_angel.toml
    * rc-proteus-2309 proteus_2309.toml
    * rc-purpletv purpletv.toml
    * rc-pv951 pv951.toml
    * rc-rc6-mce rc6_mce.toml
    * rc-real-audio-220-32-keys real_audio_220_32_keys.toml
    * rc-reddo reddo.toml
    * rc-snapstream-firefly snapstream_firefly.toml
    * rc-streamzap streamzap.toml
    * rc-su3000 su3000.toml
    * rc-tanix-tx3mini tanix_tx3mini.toml
    * rc-tanix-tx5max tanix_tx5max.toml
    * rc-tbs-nec tbs_nec.toml
    * rc-technisat-ts35 technisat_ts35.toml
    * rc-technisat-usb2 technisat_usb2.toml
    * rc-terratec-cinergy-c-pci terratec_cinergy_c_pci.toml
    * rc-terratec-cinergy-s2-hd terratec_cinergy_s2_hd.toml
    * rc-terratec-cinergy-xs terratec_cinergy_xs.toml
    * rc-terratec-slim-2 terratec_slim_2.toml
    * rc-terratec-slim terratec_slim.toml
    * rc-tevii-nec tevii_nec.toml
    * rc-tivo tivo.toml
    * rc-total-media-in-hand-02 total_media_in_hand_02.toml
    * rc-total-media-in-hand total_media_in_hand.toml
    * rc-trekstor trekstor.toml
    * rc-tt-1500 tt_1500.toml
    * rc-twinhan-dtv-cab-ci twinhan_dtv_cab_ci.toml
    * rc-twinhan1027 twinhan_vp1027_dvbs.toml
    * rc-vega-s9x vega_s9x.toml
    * rc-videomate-k100 videomate_k100.toml
    * rc-videomate-s350 videomate_s350.toml
    * rc-videomate-tv-pvr videomate_tv_pvr.toml
    * rc-videostrong-kii-pro kii_pro.toml
    * rc-wetek-hub wetek_hub.toml
    * rc-wetek-play2 wetek_play2.toml
    * rc-winfast-usbii-deluxe winfast_usbii_deluxe.toml
    * rc-winfast winfast.toml
    * rc-x96max x96max.toml
    * rc-xbox-dvd xbox_dvd.toml
    * rc-zx-irdec zx_irdec.toml
    # * * af9005.toml # found in af9005-remote.c
    # * * az6027.toml # found in az6027.c
    # * * cinergyt2.toml # found in cinergyT2-core.c
    # * * dibusb.toml # found in dibusb-common.c
    # * * digitv.toml # found in digitv.c
    # * * megasky.toml # found in m920x.c
    # * * tvwalkertwin.toml # found in m920x.c
    # * * pinnacle310e.toml # found in m920x.c
    # * * haupp.toml # found in nova-t-usb2.c
    # * * opera1.toml # found in opera1.c
    # * * vp702x.toml # found in vp702x.c

    How do we make ir-keytable respond only to the mapping we want mythtv to get? Everything else seems to work, but why is this so difficult? Clean install on 22.04. LIRC & LIRCD are not installed.

    mythtv@tivofront:/etc$ sudo ir-keytable
    Found /sys/class/rc/rc0/ with:
    Name: Media Center Ed. eHome Infrared Remote Transceiver (1784:0011)
    Driver: mceusb
    Default keymap: rc-rc6-mce
    Input device: /dev/input/event7
    LIRC device: /dev/lirc0
    Attached BPF protocols: Operation not supported
    Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm
    Enabled kernel protocols: lirc rc-6
    bus: 3, vendor/product: 1784:0011, version: 0x0100
    Repeat delay = 500 ms, repeat period = 125 ms

Leave a Reply

Your email address will not be published. Required fields are marked *