In most cases LibreELEC uses eventlircd as a shim to pass IR button presses from kernel to Kodi. This approach is stable and reliable, but has one rather major drawback: it’s impossible to use longpress events, which in fact halves the amount of actions you can bind to your IR remote buttons.
Alternative approach is to disable eventlircd altogether and use IR remote as a Linux keyboard device, so this is a way I went.
LibreELEC documentation says “Kodi ... doesn't cope well with Linux input events”, I’d say this is the understatement of the century, to put it mildly. Kodi keyboard handling system is archaic, weaving layer upon layer of abstractions, throwing away more and more of your keypresses, the deeper it goes.
To my understanding, the way IR keypress travels towards Kodi in is:
1) Linux kernel decodes IR signal and translates keypress to evdev scancode, based on IR remote .toml definition, loaded by ir-keytable.
2) Xkbcommon library assumes we got a standard pc105 keyboard and translates evdev code to something resembling xfree86 keycode, according to /usr/share/X11/xkb/keycodes/evdev
3) Xkbcommon library futher translates xfree86 keycode to xkb key name, mapping non-printable keys according to /usr/share/X11/xkb/symbols/inet
4) Kodi accepts a very limited subset of xkb key names, filtering them and mapping to Kodi internal keysyms, according to code in xbmc/platform/linux/input/LibInputKeyboard.cpp
5) Kodi goes through another layer of translations, from Kodi internal keysyms to Kodi internal vkeys and Kodi keynames, relevant code in xbmc/input/XBMC_keytable.cpp
6) Kodi once again translates, keynames are mapped to actions, based on default rules in /usr/share/kodi/system/keymaps/keyboard.xml and user customizations in ~/.kodi/userdata/keymaps/keyboard.xml
Every layer of this onion has some random historical subset or superset of non-printable keycodes hardcoded in, throwing away everything else, sometimes in completely illogical way. There is no way for user to bind directly to kernel evdev scancode, is all buried and hidden away. I’m afraid to look at the Windows or Android keyboard abstractions, probably not much saner.
But in the end I managed to dig through this spaghetti and made a .toml keymap for my IR remote, scraping together some 50 evdev keys Kodi actually lets through the cracks. Longpress events work for me now, yey. Hope my keymap can help someone with the same problem.
[[protocols]]
name = "myoldremote"
protocol = "nec"
variant = "necx"
[protocols.scancodes]
# IR EVDEV name EVDEV xkbcommon name Kodi internal keysym Kodi name Notes
#-------------------------------------------------------------------------------------------------------------------------------------------
0xbf10 = "KEY_MAIL" # 155 XKB_KEY_XF86Mail XBMCK_LAUNCH_MAIL launch_mail actual button is EJECT
0xbf46 = "KEY_MUTE" # 113 XKB_KEY_XF86AudioMute XBMCK_VOLUME_MUTE volume_mute
0xbf45 = "KEY_FAVORITES" # 364 XKB_KEY_XF86Favorites XBMCK_FAVORITES favorites actual button is MODE
0xbf43 = "KEY_POWER" # 116 XKB_KEY_XF86PowerOff XBMCK_POWER power
0xbf40 = "KEY_F1" # 59 XKB_KEY_F1 XBMCK_F1 f1 actual button is RED
0xbf1f = "KEY_F2" # 60 XKB_KEY_F2 XBMCK_F2 f2 actual button is GREEN
0xbf00 = "KEY_F3" # 61 XKB_KEY_F3 XBMCK_F3 f3 actual button is YELLOW
0xbf41 = "KEY_F4" # 62 XKB_KEY_F4 XBMCK_F4 f4 actual button is BLUE
0xbf0b = "KEY_1" # 2 XKB_KEY_1 XBMCK_1 one
0xbf0c = "KEY_2" # 3 XKB_KEY_2 XBMCK_2 two
0xbf0d = "KEY_3" # 4 XKB_KEY_3 XBMCK_3 three
0xbf0e = "KEY_4" # 5 XKB_KEY_4 XBMCK_4 four
0xbf0f = "KEY_5" # 6 XKB_KEY_5 XBMCK_5 five
0xbf01 = "KEY_6" # 7 XKB_KEY_6 XBMCK_6 six
0xbf11 = "KEY_7" # 8 XKB_KEY_7 XBMCK_7 seven
0xbf12 = "KEY_8" # 9 XKB_KEY_8 XBMCK_8 eight
0xbf13 = "KEY_9" # 10 XKB_KEY_9 XBMCK_9 nine
0xbf05 = "KEY_DELETE" # 111 XKB_KEY_Delete XBMCK_DELETE delete
0xbf0a = "KEY_0" # 11 XKB_KEY_0 XBMCK_0 zero
0xbf42 = "KEY_CAPSLOCK" # 58 XKB_KEY_Caps_Lock XBMCK_CAPSLOCK capslock actual button is SELECT/CAP/NUM
0xbf52 = "KEY_VOLUMEUP" # 115 XKB_KEY_XF86AudioRaiseVolume XBMCK_VOLUME_UP volume_up
0xbf53 = "KEY_VOLUMEDOWN" # 114 XKB_KEY_XF86AudioLowerVolume XBMCK_VOLUME_DOWN volume_down
0xbf06 = "KEY_SEARCH" # 217 XKB_KEY_XF86Search XBMCK_BROWSER_SEARCH browser_search
0xbf02 = "KEY_MEDIA" # 226 XKB_KEY_XF86AudioMedia XBMCK_LAUNCH_MEDIA_CENTER launch_media_select actual button is ZOOM
0xbf4e = "KEY_F12" # 88 XKB_KEY_F12 XBMCK_F12 f12 actual button is SETUP actual button is SETUP
0xbf4b = "KEY_PAGEUP" # 104 XKB_KEY_Page_Up XBMCK_PAGEUP pageup actual button is CHANNELUP
0xbf4c = "KEY_PAGEDOWN" # 109 XKB_KEY_Page_Down XBMCK_PAGEDOWN pagedown actual button is CHANNELUP
0xbf50 = "KEY_F10" # 68 XKB_KEY_F10 XBMCK_F10 f10 actual button is INFO
0xbf07 = "KEY_F11" # 87 XKB_KEY_F11 XBMCK_F11 f11 actual button is POPUP MENU
0xbf15 = "KEY_UP" # 103 XKB_KEY_Up XBMCK_UP up
0xbf16 = "KEY_DOWN" # 108 XKB_KEY_Down XBMCK_DOWN down
0xbf17 = "KEY_LEFT" # 105 XKB_KEY_Left XBMCK_LEFT left
0xbf18 = "KEY_RIGHT" # 106 XKB_KEY_Right XBMCK_RIGHT right
0xbf14 = "KEY_ENTER" # 28 XKB_KEY_Return XBMCK_RETURN return actual button is OK
0xbf04 = "KEY_BACK" # 158 XKB_KEY_XF86Back XBMCK_BROWSER_BACK browser_back actual button is RETURN
0xbf51 = "KEY_HOMEPAGE" # 172 XKB_KEY_XF86HomePage XBMCK_HOMEPAGE homepage actual button is TOP MENU
0xbf48 = "KEY_PLAY" # 207 XKB_KEY_XF86AudioPlay XBMCK_PLAY play_pause
0xbf1e = "KEY_PAUSECD" # 201 XKB_KEY_XF86AudioPause XBMCK_MEDIA_PLAY_PAUSE play_pause
0xbf49 = "KEY_PREVIOUSSONG" # 165 XKB_KEY_XF86AudioPrev XBMCK_MEDIA_PREV_TRACK prev_track
0xbf1d = "KEY_NEXTSONG" # 163 XKB_KEY_XF86AudioNext XBMCK_MEDIA_NEXT_TRACK next_track
0xbf19 = "KEY_STOPCD" # 166 XKB_KEY_XF86AudioStop XBMCK_MEDIA_STOP stop
0xbf1a = "KEY_PROG1" # 148 XKB_KEY_XF86Launch1 XBMCK_LAUNCH_APP2 launch_app2_pc_icon actual button is SLOW
0xbf1c = "KEY_REWIND" # 168 XKB_KEY_XF86AudioRewind XBMCK_MEDIA_REWIND rewind
0xbf1b = "KEY_FASTFORWARD" # 208 XKB_KEY_XF86AudioForward XBMCK_MEDIA_FASTFORWARD fastforward
0xbf54 = "KEY_F5" # 63 XKB_KEY_F5 XBMCK_F5 f5 actual button is SUBTITLE
0xbf4d = "KEY_F6" # 64 XKB_KEY_F6 XBMCK_F6 f6 actual button is ANGLE
0xbf44 = "KEY_F7" # 65 XKB_KEY_F7 XBMCK_F7 f7 actual button is AUDIO
0xbf4f = "KEY_F8" # 66 XKB_KEY_F8 XBMCK_F8 f8 actual button is REPEAT
0xbf47 = "KEY_F9" # 67 XKB_KEY_F9 XBMCK_F9 f9 actual button is SHUFFLE
0xbf03 = "KEY_WWW" # 150 XKB_KEY_XF86WWW XBMCK_LAUNCH_FILE_BROWSER launch_file_browser
Display More