Separating the keycodes for Play and Pause buttons
#1
I'm using Kodi Leia RC4 on the latest CoreELEC build on my S905 box, with a universal remote control configured to act as an MCE remote, which is working fine for regular out-of-the-box remote keypresses.

However I want to configure the separate Play and Pause buttons on the remote have discrete actions (i.e. play for play only and pause for pause only, rather than both doing the same play/pause toggle function).

I've checked via ir-keytable and the two buttons are generating correct separate scancodes, which are triggering as KEY_PLAY and KEY_PAUSE events: 

MiniM8SII-CoreELEC:~ # ir-keytable -t
Testing events. Please, press CTRL-C to abort.
79922.337860: event type EV_MSC(0x04): scancode = 0x800f0416
79922.337860: event type EV_KEY(0x01) key_down: KEY_PLAY(0x00cf)
79922.337860: event type EV_SYN(0x00).
79922.490324: event type EV_MSC(0x04): scancode = 0x800f0416
79922.490324: event type EV_SYN(0x00).
79922.740133: event type EV_KEY(0x01) key_up: KEY_PLAY(0x00cf)
79922.740133: event type EV_SYN(0x00).
79924.583546: event type EV_MSC(0x04): scancode = 0x800f0418
79924.583546: event type EV_KEY(0x01) key_down: KEY_PAUSE(0x0077)
79924.583546: event type EV_SYN(0x00).
79924.740211: event type EV_MSC(0x04): scancode = 0x800f0418
79924.740211: event type EV_SYN(0x00).
79924.990113: event type EV_KEY(0x01) key_up: KEY_PAUSE(0x0077)
79924.990113: event type EV_SYN(0x00).


However in Kodi, both of these buttons seem to be getting mapped to the same id (230) so all that happens when I use the Kodi Keymap Editor addon to generate a gen.xmp file for the separate Play or Pause functions is:
<keyboard><key id="230">play</key></keyboard>
<keyboard><key id="230">pause</key></keyboard>


Any idea how I can get Kodi to see the separated KEY_PLAY and KEY_PAUSE button events so I can map them as I want?

Andre
Reply
#2
That's currently per design:

https://github.com/xbmc/xbmc/blob/817e7a...1598-L1606

You should also check the kodi logfile to see how the keys are interpreted inside Kodi.

For the lines above...if the actionID "PlayPause" is triggered, then we check if something is playing and if yes we also check if the playspeed is "1" (if (m_appPlayer.IsPlaying() && m_appPlayer.GetPlaySpeed() == 1)). If both are "true" we let the player pause the videoreturn OnAction(CAction(ACTION_PAUSE));. If one of them is "false" we decide to the let the player play:

cpp:

else
return OnAction(CAction(ACTION_PLAYER_PLAY));

That means, if the player is paused or in fast forward/backward (which would mean either m_appPlayer.IsPlaying() returns "false" or m_appPlayer.GetPlaySpeed() returns something not "1" (fast forward for example) it starts normal playback again.

To your problem...You can't have a "pause" being only pause at this moment. You can easily map the action "Play" to the play key, as that won't pause a video (it starts playing a highlighted item at your library) and you can map the action "Pause" to the pause key. But the action "Pause" will behave as a "play-pause" toggle. Whereas the action "Play", if something is currently on pause, will also start normal playback.

Your next steps should be, to identify how Kodi sees the keys you are pressing (Kodi logfile with debugging enabled) and then using a remote.xml (or a keyboard.xml ... depends how your remote is interpreted by Kodi. Some remotes are interpreted as keyboards and for sure it's most likely the case for S905 devices) and map the specific actions to the specific keys which are pressed.

But you can't have it completely seperated as pause is a "play-pause" toggle per design.
Reply
#3
(2019-01-07, 09:07)DaVu Wrote: But you can't have it completely seperated as pause is a "play-pause" toggle per design.
 Oh, that's annoying, I was sure I read somewhere that Leia was meant to have fixed that issue. OK, perhaps not a bug per se, but certainly an underlying design flaw for an otherwise amazingly configurable program. I really do prefer remote control buttons to actually do what they say on the tin - "play" and "pause" being completely separate and opposite functions in this case, and if you've got both buttons available then surely it makes sense to be able to use them? Rather like I always set up discrete 'On' and 'Off' functions on my universal remote for any device that I can, rather than only having 'Power' toggles - for one thing it makes macros or scripts a lot easier to trigger reliably.

Andre
Reply
#4
(2019-01-07, 09:07)DaVu Wrote: You should also check the kodi logfile to see how the keys are interpreted inside Kodi.
 Thanks, I'll see if I can find that. But the Keymap Editor addon returns the same value when either button is pressed (230), so I'd still need to get the separate KEY_PLAY and KEY_PAUSE values into Kodi somehow. At least that way I could make the Play button work properly.

Andre
Reply
#5
I enabled Kodi logging (I just enabled it, pressed Play and Pause, and disabled it again so as not to create a cluttered logfile) and it does seem to be seeing two separate keypresses:

13:04:16.077 T:4011844464   DEBUG: LIRC: - NEW cf 0 KEY_PLAY devinput (KEY_PLAY)
13:04:16.105 T:4088856496   DEBUG: HandleKey: homepage (0xea) pressed, action is PlayPause
13:04:17.889 T:4011844464   DEBUG: LIRC: - NEW 77 0 KEY_PAUSE devinput (KEY_PAUSE)
13:04:17.896 T:4088856496   DEBUG: HandleKey: blue (0xe6) pressed, action is Pause


How do I use gen.xml to react to the Play key separately to the Pause key, as Pause is triggering as id=230 in the Keymap Editor addon (I guess taken from that 0xe6 value in the log) but Play seems not to register? Do I just edit gen.xml manually to insert the correct Play value (presumably 234?) which the Editor is not detecting? Also, I wonder why it is referring to these as "homepage" and "blue" - or is that just because I was still in the Settings page when I did the test?

[Edit: Yes that worked, setting up a global <key id="230">pause</key><key id="234">play</key> detects both buttons separately - although as you said earlier, the pause button still acts as a play/pause facility, but I guess I'm stuck with that for now]

Andre
Reply
#6
(2019-01-07, 15:21)andrewilley Wrote: [Edit: Yes that worked, setting up a global <key id="230">pause</key><key id="234">play</key> detects both buttons separately - although as you said earlier, the pause button still acts as a play/pause facility, but I guess I'm stuck with that for now]
Ahhh..... I wanted that also! I didn't worry about the play button toggling between pause/unpause, but found it confusing that the pause button also resumed play. That explains it, and looks like you've got a fix there, thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Separating the keycodes for Play and Pause buttons0