Roku TV remote button presses register as duplicate events

I just got into coreelec and I wanted to get a roku IR remote working because it’s my personal favorite. It’s kind of an odd case though, because instead of having one command code per button, it actually has two. When you tap a button (as in press and immediately release) let’s say it sends 0x01. That’s all well and good. But when you hold a button, even for just a fraction of a second, it sends out 0x01 first…and then instead of constantly sending 0x01, it does the same but for 0x81, the same command but with the MSB set high. If pressing a button sent one command, and holding a button sent a different command, things would be fine, since you can just map multiple commands to the same event. But after doing that, since it’s always gonna send out 0x01 before the stream of 0x81, it registers as you pressing the button once, then immediately releasing before pressing and holding again. Really nasty. Take a look.

677.925248: event type EV_MSC(0x04): scancode = 0xeac72a
677.925248: event type EV_KEY(0x01) key_down: KEY_ENTER(0x001c)
677.925248: event type EV_SYN(0x00).
678.033119: event type EV_KEY(0x01) key_up: KEY_ENTER(0x001c)
678.033119: event type EV_MSC(0x04): scancode = 0xeac7aa
678.033119: event type EV_KEY(0x01) key_down: KEY_ENTER(0x001c)
678.033119: event type EV_SYN(0x00).
678.141031: event type EV_MSC(0x04): scancode = 0xeac7aa
678.141031: event type EV_SYN(0x00).
678.248924: event type EV_MSC(0x04): scancode = 0xeac7aa
678.248924: event type EV_SYN(0x00).
678.356861: event type EV_MSC(0x04): scancode = 0xeac7aa
678.356861: event type EV_SYN(0x00).
678.552037: event type EV_MSC(0x04): scancode = 0xeac7aa
678.552037: event type EV_SYN(0x00).
678.812025: event type EV_KEY(0x01) key_up: KEY_ENTER(0x001c)
678.812025: event type EV_SYN(0x00).

This is holding down the OK (enter) button for a second or so. I know about the remote wakeup mask. I don’t know what it does. But if anyone knows how to apply a mask to every scancode and exclude the MSB(s), that should solve the problem completely. Oh, and here’s my toml if you’re curious.

[[protocols]]
name = "Roku TV Remote"
protocol = "nec"
variant = "necx"
[protocols.scancodes]
0xeac717 = "KEY_POWER"
0xeac766 = "KEY_BACK"
0xeac703 = "KEY_HOME"
0xeac719 = "KEY_UP"
0xeac733 = "KEY_DOWN"
0xeac71e = "KEY_LEFT"
0xeac72d = "KEY_RIGHT"
0xeac72a = "KEY_ENTER"
0xeac778 = "KEY_RESTART"
0xeac761 = "KEY_CONTEXT_MENU"
0xeac734 = "KEY_REWIND"
0xeac74c = "KEY_PLAYPAUSE"
0xeac755 = "KEY_FASTFORWARD"
0xeac70f = "KEY_VOLUMEUP"
0xeac710 = "KEY_VOLUMEDOWN"
0xeac720 = "KEY_MUTE"
0xeac752 = "KEY_PROG1"
0xeac706 = "KEY_PROG2"
0xeac74d = "KEY_PROG3"
0xeac76c = "KEY_PROG4"

0xeac797 = "KEY_POWER"
0xeac7e6 = "KEY_BACK"
0xeac783 = "KEY_HOME"
0xeac799 = "KEY_UP"
0xeac7b3 = "KEY_DOWN"
0xeac79e = "KEY_LEFT"
0xeac7ad = "KEY_RIGHT"
0xeac7aa = "KEY_ENTER"
0xeac7f8 = "KEY_RESTART"
0xeac7e1 = "KEY_CONTEXT_MENU"
0xeac7b4 = "KEY_REWIND"
0xeac7cc = "KEY_PLAYPAUSE"
0xeac7d5 = "KEY_FASTFORWARD"
0xeac78f = "KEY_VOLUMEUP"
0xeac790 = "KEY_VOLUMEDOWN"
0xeac7a0 = "KEY_MUTE"
0xeac7d2 = "KEY_PROG1"
0xeac786 = "KEY_PROG2"
0xeac7cd = "KEY_PROG3"
0xeac7dc = "KEY_PROG4"

if this functionality doesn’t exist at all I think I’ll have to learn what a BPF is

Have you tried with kodi key mapper app to see what happens (it makes an gem.xml file that can overide programmed presses. )

Ive used it a few times when I cant make a key work from original function.

Use AmRemote format, it include more parameter like:

repeat_enable   = 1
release_delay	= 150
1 Like

yeah, it’s still gonna generate multiple events per single press so there isn’t really anything you can do

1 Like

Maybe this will help. It mentions that toml supports decoding raw IR pulses after kernel 5.3, so maybe it’s working in CE-NO (5.15)? With raw pulses you could define a button as a combinations of two codes, or however you like.

The command mode2 will show you the raw pulse times for any button press to help you out. IrScrutinizer may be a useful tool in the process. The raw pulses can be pasted in that app to show you a graphical representation as well as providing many other IR tools.

I haven’t tried anything yet, but I got a much newer roku tv remote and for some reason it sends scancode 0xcf30c0e1 whenever you release the OK button or one of the four shortcut buttons. Nothing else