Can't get IR working using harmony mce keyboard

Currently, I’m using bluetooth to control kodi/osmc from my harmony hub using the harmony 950 remote. That works fine as long as there is no additional bluetooth device to be controlled due to limitations of harmony hub. I do have this situation, and thus I want to migrate towards IR control.

I hooked up an TSP IR receiver to my raspberry pi 3 and enhanced my harmony setup to include the device vendor=Microsoft, model=MCE keyboard. Within OSMC I did enable GPIO pin 17 for input, and selected rc6-mce as remote device.

Sadly, this doesn’t work at all. I did google for some hours without final conclusion. But I now know that my IR receiver is working and that linux is receiving IR events:

 ir-keytable -c -p all -t

will return different scancodes for different keypresses.

I did also discover the thread Enable support for IR RC MCE Keyboard on startup where someone did propose to use

 ir-keytable -p lirc -p rc-6 -p mce_kbd

Sadly this works only partly - e.g. the OK button now works and is processed by OSMC, but the direction buttons don’t. To check that I run

ir-keytable -t

seeing scancodes if the buttons don’t work, and nothing if the buttons did work.

Please give me a hint howto use harmony IR to control kodi.

Maybe I should use a different IR device within harmony? But which one to get as many supported keys as possible (for non-kodi actions during kodi harmony activity).

Or can someone provide a full featured lircd.conf for MCE keyboards?

BTW I’m using OSMC 2021-11 i.e. the current release of OSMC.

Regards, Michael

Additional info/question: I’m running triggerhappy in parallel to grab keyevents from /dev/input/event* - to my surprise no keyevent from IR keypresses are visible by thd --dump at all. I’d expect that any IR keypress (being handled by the kernel) should be visible to triggerhappy, too. Is my assumption wrong that IR keypresses are handled by the linux kernel?

The easiest method is to use a preset from My OSMC → Remotes.

Thanks for your quick answer.

I did that - I’ve selected the provided remote rc6-mce-lircd. And I’ve tried either to enable or disable RC6 (the extra button within My OSMC → Remotes, having no impact.

Today I’ve inspected the scancodes more closer - each one is sent exactly 3x and followed by 0x0 like e.g. for direction up

58046.580092: lirc protocol(mcir2-kbd): scancode = 0x5100
58046.680148: lirc protocol(mcir2-kbd): scancode = 0x5100
58046.780123: lirc protocol(mcir2-kbd): scancode = 0x5100
58046.880556: lirc protocol(mcir2-kbd): scancode = 0x0

My guess is that somehow the keytable has to be filled (from a “valid” lircd configuration file?) because ir-keytable returns rc-empty

Found /sys/class/rc/rc0/ (/dev/input/event0) with:
        Name: gpio_ir_recv
        Driver: gpio_ir_recv, table: rc-empty
        LIRC device: /dev/lirc0
        Attached BPF protocols: 
        Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon 
        Enabled kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd sharp xmp imon 
        bus: 25, vendor/product: 0001:0001, version: 0x0100
        Repeat delay = 500 ms, repeat period = 50 ms

I’ve further seen that within /etc/lirc my selection of rc6-mce-lircd is active because there is a soft link lircd.conf → rc6-mce-lircd.conf.

My conclusion: I might have to select some other device within harmony setup - as I wrote in my first post, currently I’m using Microsoft/MCE keyboard.

Regards, Michael

Additional info: I’ve created the new device Microsoft/Media Center Edition keyboard, and with that selection most keys are working (as of my writing sadly the Exit key is failing, but return works). But still ir-keytable reports rc-empty. My problem is that I simply do not know howto match the harmony device name with the OSMC device name. And of course I’m completely surprised that the two harmony devices MCE keybord and Media center environment keyboard work completely different - but that’s a harmony issue.
Neverrtheless I can’t go with that harmony device since many, many keys are missing e.g. despite being named “keyboard” all standard ASCII keys are missing. I need them for my non-kodi usecase.

Just now your christmas present arrived - your christmas edition of OSMC. But it did not help for my current problem.

But there is something new: Working codes use the rc6_mce protocol, failing codes mcir2-kbd:

61563.880160: lirc protocol(mcir2-kbd): scancode = 0x5100
61563.980101: lirc protocol(mcir2-kbd): scancode = 0x5100
61564.080154: lirc protocol(mcir2-kbd): scancode = 0x5100
61564.180486: lirc protocol(mcir2-kbd): scancode = 0x0
61566.440216: lirc protocol(rc6_mce): scancode = 0x800f0422 toggle=1
61566.540273: lirc protocol(rc6_mce): scancode = 0x800f0422 toggle=1
61566.660112: lirc protocol(rc6_mce): scancode = 0x800f0422 toggle=1

That again is completely confusing me - why should the very same harmony device use different IR protocols? And why are the (working) scancodes not included within any /etc/lirc/*.conf file? Maybe I’ve an answer - there is a second folder containing toml files. And my scancode is within /usr/lib/udev/rc_keymaps/rc6_mce.toml

Regards, Michael

Maybe a kernel bug - IR remote stops working with kernel 5.1 (Page 2) / Kernel & Hardware / Arch Linux Forums ? If it’s fixed within 5.12 I have to wait since OSMC is on 5.10.

BTW that is what dmesg is telling me w.r.t. IR:

[    8.647063] rc_core: IR keymap rc-lirc not found
[    8.647083] Registered IR keymap rc-empty
[    8.648434] rc rc0: lirc_dev: driver gpio_ir_recv registered at minor = 0, raw IR receiver, no transmitter
[ 1353.671846] rc_core: Loaded IR protocol module ir-rc6-decoder, but protocol rc-6 still not available
[ 1645.043142] rc_core: Loaded IR protocol module ir-rc6-decoder, but protocol rc-6 still not available
[ 1764.027854] IR RC5(x/sz) protocol handler initialized
[ 1764.078392] IR NEC protocol handler initialized
[ 1764.163680] rc_core: Loaded IR protocol module ir-rc6-decoder, but protocol rc-6 still not available
[ 1764.177438] IR JVC protocol handler initialized
[ 1764.228414] IR Sony protocol handler initialized
[ 1764.278665] IR SANYO protocol handler initialized
[ 1764.331698] IR Sharp protocol handler initialized
[ 1764.387952] IR MCE Keyboard/mouse protocol handler initialized
[ 1764.439871] IR XMP protocol handler initialized
[ 1764.502224] ir_imon_decoder: IR iMON protocol handler initialized
[ 2501.877227] rc_core: Loaded IR protocol module ir-rc6-decoder, but protocol rc-6 still not available
[ 3297.161411] rc_core: Loaded IR protocol module ir-rc6-decoder, but protocol rc-6 still not available
[61332.085986] IR RC6 protocol handler initialized

Sorry for adding more and more to this thread, but I’m continuosly searching for a solution to get as many keeys as possible from my harmony using IR…

Regards, Michael

PS: Now I’ll stop experimenting because suddenly my raspi crashed out of the blue (German saying). Hope someboby can provide some hints howto proceed.

After reading the IR description from LibreElec Infra-Red Remotes - LibreELEC.wiki I have an additinonal question: Should lircd be diabled within OSMC, too? Currently it is running by default

root       224  0.0  0.0   1936    84 ?        Ss   10:34   0:00 /usr/sbin/eventlircd --evmap=/etc/eventlircd.d --socket=/var/run/lirc/lircd -f
root       401  0.0  0.1   4116  1088 ?        Ss   10:34   0:00 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/var/run/lirc/lircd-lirc0 --pidfile=/var/run/lirc/lircd-lirc0.pid /etc/lirc/lircd.conf

Regards, Michael

I can’t really help with the lircd thing but I can tell you that on my own boxes I decided to bypass it entirely by using FLIRC USB devices. They were super easy to get going (on a PC you click the button/key you want and then the button on the remote and then repeat if your harmony is sending out alternating codes, one key sorted that quick, rinse and repeat). It is picked up by the OS as a multimedia keyboard so the only thing you would need to do on the SBC side of the equation is just Kodi keymapping for anything custom you want. You gain responsiveness, long-press support, and ability to use ctrl and alt combos.

I think there is also an open source project out there somewhere for you to make your own similar device with an Arduino if one was so inclined.

Thanks for your hint. Before I went to go with my supercheap TOS IR receiver I also investigated flirc being highly recommended everywhere. But on my raspi 3 of 4 USB ports are already in use, and I wanted the fourth to be free for backup or USB sticks.

Thus I decided to go with the TOS IR receiver.

And I’ve a new idea howto get a workaround for my “problem”. Since the only problem occurs when I use my fire TV stick (without kodi) utilizing bluetooth for remote control, I will use IR only within my harmony fire TV action. In principle I’m on a longer tour in circumventing problems within harmony software being completely OT here.

Thus my next step is to get real keypress events from my IR receiver currently only delivering scan codes to start some non-kodi actions. For kodi I’ll stay with bluetooth since it’s working flawlessly.

Regards, Michael
PS: To get an idea what I want to do with triggerhappy see e.g. [GUIDE] Keyboard shortcuts with triggerhappy - Guides - Volumio

In the meanwhile I’ve learned that eventlircd grabs all keypresses and forwards them towards lirc. If I disable this service

systemctl stop eventlircd

I can see the IR keypresses both by ir-keytable and - more important to me - by triggerhappy

thd --dump /dev/input/event*

now delivering

EV_KEY  KEY_OK  1       /dev/input/event0
# KEY_OK        1       command
EV_KEY  KEY_OK  0       /dev/input/event0
# KEY_OK        0       command
EV_KEY  KEY_UP  1       /dev/input/event0
# KEY_UP        1       command
EV_KEY  KEY_UP  0       /dev/input/event0
# KEY_UP        0       command

Thus I see when a key is pressed (1) and when it is released (0).

To get that I had to load the correct keymap by

ir-keytable -c -p rc-6 -w /usr/lib/udev/rc_keymaps/rc6_mce.toml

To make all this permanent I’ll disable the services lircd and eventlircd. And I will setup /etc/rc.local to initialize the IR keytable.

Does this might have any impact to normal OSMC operation (aside from disabling any IR remote - as intended)?

Regards, Michael

No – it should be fine.

Just to throw this out there as an option, instead of grabbing onto the input at the OS level you could use Kodi RunScript actions to do this function from Kodi itself. The advantage being that it is possible to use the same keys to do multiple functions. By this I mean that say you want to have the play button act as a play button for this external app then you could keymap in Kodi for the home screen such that it triggers an external script that sends the terminal command. Thus when you are in the video or music library, or during full screen playback then Kodi uses the play button as it normally does, but if you are on the home screen then that button triggers the external app.

Thanks for that hint. I tried that solution already some weeks ago when I was unaware of triggerhappy. It worked fine (with some drawbacks in kodi leia) but I use kodi not that often (typically once per week). Thus I want to stop kodi if not in use. May usecase works like that: starting kodi action with my harmony remote will send an unused keypress which is used by triggerhappy to start kodi, similar when I finish the kodi action. That works very well, and my raspi is free for my other applications. The main deficiency of course is that I carefully have to ensure to use “unused” keys to avoid wrong events. And those keypresses are NOT grabbed exclusively by triggerhappy, they are sent towards the currently active program as well.

My “main” problem is that all solutions for getting special handling suffer under bugs within the involved tools (I tried fakeroku giving unwanted multiple events during longpress, I tried bluetooth keyboard interferring with fire tv, I tried RunScript in leia failing to support the windows modifier, and triggerhappy can’t be reconfigured by its socket - bug being not fixed since some years afaik).

Sorry for this long OT post,
Michael

Thanks for your reply. lircd seems to be started by OSMC, thus I can’t stop it. During my tests OSCM once didn’t show anything but was running (including lircd). I could stop/start it afterwards. Hope that was an exceptional situation since my second try was successful.

Similar hope is that the harmony will do a safe switch between both bluetooth devices involved (fire tv and keyboard). It worked till now, but failed once after reconfiguration of the harmony device fire tv.

Regards, Michael

Finally my use of IR is working as wanted.

But for other readers here: I want to get IR keypreses send towards my raspberry and NOT towards kodi. I control kodi/osmc using the bluetooth connection from my harmony hub. Thus here I describe howto decouple IR from osmc.

I use IR to start raspi commands using triggerhappy. To reach that goal I did the following

Stop and disable eventlircd

systemctl stop eventlircd
systemctl mask eventlircd

Select the correct harmony device within harmony app named Microsoft/Media center environment.

Plugin TOS IR receiver and configure /boot/config-user. txt from within OSMC My OSMC-> hardware. Reboot.

Setup ir-keytable as described above.

Configure triggerhappy to react on IR commands.

Regards, Michael

On the long run, I’ve withdrawn to use bluetooth to control kodi. Instead now I use IR for that purpose. The reason is that Logitech harmony is very slowly in switching between different bluetooth connections. Instead IR is working much faster.

I’ve replaced triggerhappy now by lircexec (see the corresponding thread in this forum) to use some IR keys for my usecase. I even use two IR keys to start/stop kodi automatically from my harmony remote without any problem.

Regards, Michael