[mythtv] Mythtv & Lirc

Xavier Hervy xavier.hervy at bluebottle.com
Wed Jan 30 23:35:12 UTC 2008


Hi,
I like to change the way mythtv handle lirc.
It would be helpful for the user point of view if in mythcontrol, 
instead of:
- mythtv PLAY p
- mythtv VOLUMEUP F10

we had :
- mythtv PLAY Play
- mythtv VOLUMEUP Vol+
the "real" name of the remote control button

AFAIK to be able to control an application with lirc we can use one of 
the following methods:
- use irxevent to map the control so the application don't need to bother.
- lirc library with a config file.
- lircd protocol.

MythTV use none of them but a mix between the first one and the second 
as in .lircrc the button must be map to key so MythTV can transform them 
as QKeyEvent.
For me it is a annoying problem as we can't use mythcontrol plugin as a 
reminder of how the button are mapped (unless we know by heart that '{' 
is for Vol- but I never use the keyboard so I don't remember) .


I thought we could change the implementation of the new widget as they 
don't use the QWidget any more.
instead of having:
virtual bool keyPressEvent(QKeyEvent *);
for MythUIType, we could have some thing like this :
virtual bool actionEvent(ActionEvent *);

with
class ActionEvent :
{
    ActionEvent (int type, QString name)
        QCustomEvent(type);action(name){
    }

    QString getName(){
        return name
    }
}

class KeyCustomEvent : public ActionEvent
{
    KeyCustomEvent(int type, QString name, QKeyEvent keyEvent) :
        ActionEvent(type, name),keyEvent(keyEvent){};
        getKeyEvent(){
             return keyEvent;
        }
    private:
         QKeyEvent keyEvent
}

class KeyCustomEvent : public ActionEvent
{
    KeyCustomEvent(int type, QString name, QKeyEvent keyEvent) :
        ActionEvent(type, name),keyEvent(keyEvent){};
        getKeyEvent(){
             return keyEvent;
        }
        virtual QString getAction(context);
    private:
         QKeyEvent keyEvent
}


class LircKeycodeEvent : public ActionEvent
{
  public:
    LircKeycodeEvent(int type, const QString &lirc_text, int key_code, 
bool key_down) :
            QCustomEvent(type, kLircKeycodeEventType), lirctext(lirc_text),
            keycode(key_code), keydown(key_down) {}

    QString getLircText()
    {
        return lirctext;
    }

    int getKeycode()
    {
        return keycode;
    }

    bool isKeyDown()
    {
        return keydown;
    }

  private:
    QString lirctext;
    int keycode;
    bool keydown;
};


this way, we don't have to rewrite to much code in each screen just 
replace keyPressEvent by actionEvent (ActionEvent might not be the 
appropriate name).
This job can be done at the same time as plugin are rewrite for the new ui.
What is working for a keyboard or a remote control via lirc, might be 
useful too for MouseGesture or other way to control myth gui.

Each class which inherit from the ActionEvent class should implement
- virtual static QStringList getActions(context);

then actionEvent method can be done like this:
MyWindow::actionEvent(ActionEvent * aEvent)
{
   QStringList actions = aEvent->getAction("TV Frontend");
    for (unsigned int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = false;
        for (unsigned int i = 0; i < actions.size() && !handled; i++)
        {
             handled = false;
             if (action == "SELECT")
                  //do stuff
             else if (action == "UP")
                  //do stuff
             else
                 handled = false;
        }
}

Am I missing something ?

The main reason why i would like to change this, is because I would like 
to create a generic help page available for each MythDialod, which would 
display the keybinding according to the input device used to open the 
help dialog:
For example :
- the user press F1, we could display  the keyboard binding ;
- the user press the Help button on his remote, we could display  the 
binding lirc (It would be event better to be able to make the difference 
between each lirc device as I like to use more than one and all 
different make).

Finally if the .lircrc file doesn't exist, we could generate a lircrc 
file in ~/.mythtv/ directory automatically using lircd protocol as 
irsend do :
/usr/bin/irsend LIST "" "" to get the list of remote
/usr/bin/irsend LIST "My remote" "" to get the list of button for one remote

The new method to handle lirc could also be used to make automatic 
configuration. Then the first time a mythfrontend is launch to configure 
have a wizard to configure each remote via a nice gui.
this could improve the mythtv "first impression".

Any thought ?


Xavier

----------------------------------------------------------------------
Finally - A spam blocker that actually works.
http://www.bluebottle.com/tag/4



More information about the mythtv-dev mailing list