[mythtv] Question regarding LIRC support and gContext->getCurrentLocation()

Navaho Gunleg navahogunleg at gmail.com
Tue May 30 11:14:11 UTC 2006

  Hi guys,

I've been using MythTV with a remote for quite some time without any
problems. There's only this one thing: the remote doesn't have that
many buttons and I really would like to have these mapped
/differently/, depending on where in MythTV I'm at, if you get the
idea. So, when I am in the Teletext-menu, I could assign the Red
button to F2, and in any other screen, the Red button sends the 'D'
(for Delete). (Basically, in a way like the regular key-strokes are
handled, having specific assignments depending on the 'context'.)

In order to expand the LIRC support, to configure this I was thinking
something like this in the lircrc file:
  config=D Teletext_Menu:F2
In the above example it means that, the default key assignment is 'D',
but when we're in the Teletext menu, it should send F2. (To set a
loose ':' as config without it getting interpreted as a
'<Location>:<Key>'-thing one could escape it, like '\:', but those are
trivial things to deal with later. First things first..)

I started tinkering around to see where I could retrieve such
information. As the LIRC stuff is handled from a seperate thread,
there's only a few directions in where to look.

So, apart from remapping /all/ MythTV keys, and the remote to suit
these (which I won't do because I really would like to retain the
default key-mappings for when I connect a keyboard), I concluded that
there are three things to do:

I discovered mainWindow->currentWidget() returning the current
widget's name, but this is not always a relevant value (it stays
'video playback window' even when the teletext screen has popped up)
-- that's probably a logical action as the teletext window is just a
part of the playback window. So I figured using references to the
currentWidget would get too hairy. (I would have to check the name,
and then check its members to figure out the state of the teletext
screen if it's the playback window, etcetera. Possible, sure, but too
prone to errors, assuming types by RTTI, and breakage if other code
gets modified -- you know what I mean.)

Additionally, I have found the gContext->getCurrentLocation() which
seems to return a relatively useful string, such as 'Playback' when
watching TV, and  'PlayMusic' when in MythMusic. Initially I was
thinking this was exactly the value I was looking for; only when I got
it running I noticed this doesn't tell me if we're displaying teletext
or not.

So my first question is regarding this issue is what
getCurrentLocation()'s actual use is and whether this may be (ab)used
for the use I'm thinking of? Is this there for debugging / logging
purposes only? Because if it is, I can imagine it not being a problem
it getting to accurate (for instance, getting updated from
NuppelVideoPlayer when Teletext is enabled)?  (Or it would be even
better to somehow get this sync'ed with the keypress handling

It really would be the perfect candidate as it current already returns
a useful string -- and this would require the least amount of
modifications throughout. (This solution is what I have now

The last, and definitely least, possibility is introducing an
'lircContext' member in gContext that gets updated whenever something
is activated; like when MythMusic is activated or when the Teletext
screen has popped up... Of course, this is the last thing I'd want to
do -- this would require modifications everywhere the focus changes.

My last question is, what do you generally think about this idea?
Imagining this to be a useful addition, that surely one of you guys
already have thought about expanding LIRC in this way? Or, that the
way that LIRC support has been implemented is already under review?
(For instance, in the future, maybe that config=DELETE
Teletext:MENUGREEN can be passed, and the LIRC thread then sends the
appropriate keypress as it's configured.) Because if so, I'd really
like to share some ideas...

Thanks in advance for any replies.


More information about the mythtv-dev mailing list