Mythtv keybindings and lirc mapping

Post Reply
muddysteel
Newcomer
Posts: 6
Joined: Sat Mar 04, 2017 6:46 pm
United States of America

Mythtv keybindings and lirc mapping

Post by muddysteel » Sat Mar 04, 2017 8:20 pm

Hi -

I'm finding the documentation around the Mythtv lirc mapping (lirc codes to Myth codes) lacks clarity around things like how the entries in 'lircrc' (mythtv) are interpreted and mapped once Myth fires up.

I'd like to fix this up a bit as I've been grinding away on MythTV across CentOS, SuSE and Ubuntu - close to having it ready for my spouse approved deployment to our living room. ;) Finalizing the remote bindings is my last hurdle..

So, before I start walking the code (focused on ./mythtv/libs/libmythui/lirc*) to figure stuff out, I thought I would ask the larger forum. (If anyone knows a thread that answer my query, please let me know! My searching has not found concrete results.)

In the MythTV 'lircrc' file, how are the different (MYSQL table) 'keybindings' mapped up, and in particular to a specific 'context'?

The core issue is:
  • lirc configured to generate the lirc command KEY_STOP
  • The need for KEY_STOP to have two separate behaviors depending on the MythTV context.
  • Because the one MythTV keyboard binding is already in use in both contexts.
Here's a more concrete scenario: The keyboard code "O" (well, technically, ASCII character 0x30) is mapped to "TV Playback" (Toggle channel browse) and "Music" (Stop). If I intuitively map the keyboard "O" to a single LIRC keycode (e.g., KEY_STOP), then the use on the physical remote of the 'STOP' button becomes counter-intuitive. Soooo... Does the Mythtv ./mythtv/lircrc file provide some undocumented feature that allows you to add MythTV "context" (the MYSQL keybindings table, 'context' column) for this kind of thing?

Something that, in effect does the following:
begin
prog = mythtv
context = Music
remote = mceusb
button = KEY_STOP
config = O
end
begin
prog = mythtv
context = TV Playback
remote = mceusb
button = KEY_STOP
config = Esc
end

TIA!

muddysteel
Newcomer
Posts: 6
Joined: Sat Mar 04, 2017 6:46 pm
United States of America

Re: Mythtv keybindings and lirc mapping

Post by muddysteel » Wed Mar 08, 2017 2:49 pm

So, processing of the '.mythtv/lircrc' follows the same handing as LIRC itself, which means there is no context shifting.

As the configuration file allows for multiple "config = " inside of each begin/end block, it's possible to send the required key event - it just takes awhile.

I'm going to invest some time in considering an enhancement to this very contained, low-level bit of the system. There are at least two enhancements that would be easy and have some good payback:

* There is an expensive scanf() called to do the initial parsing of the LIRC message/code. Since the LIRC code is fixed, a better approach is to start tokenizing immediately, and count the number of tokens (which occurs anyway) to decide if the message is in a "known" state.

* Consider the use of a hash table to lookup codes. Currently, LIRC code handle finds the corresponding MythTV config by scanning sequentially each time a remote code is received. This is also somewhat expensive and incurs linear search time, based on where in the configuration is the code. (If you have a heavily used code - say ENTER - be sure to place that at the top of your config.)

User avatar
pgbennett
Developer
Posts: 161
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: Mythtv keybindings and lirc mapping

Post by pgbennett » Wed Mar 08, 2017 4:09 pm

I don't know the answer, but you would be better served by asking your question in the Troubleshooting forum or the mythtv-users mailing list. This forum is for developers and so may not receive the correct attention.

muddysteel
Newcomer
Posts: 6
Joined: Sat Mar 04, 2017 6:46 pm
United States of America

Re: Mythtv keybindings and lirc mapping

Post by muddysteel » Thu Mar 09, 2017 2:39 am

Good point - however, this a-kind-of development question - there's no documentation on applying a "different" context (e.g, Music, TV, etc.) and my review of the code pretty much answers there isn't a mechanism.

I'll post out there, too, since someone may have done some work-around (like I'm doing - multiple' config = ' in one begin/end block).

Post Reply