[mythtv] customizable keys

Mailing Lists mail_lists at shaw.ca
Sun Jun 29 19:30:11 EDT 2003


I have started looking into configurable keys, and I have an approach I 
think will work, but I wanted to get some feedback before I invested a 
great deal of time into it.  BTW: this is just pseudocode, so please don't 
reply correcting my syntax ;-)

#include <Qmap.h>
#include <Qstring.h>

class keymap {

   Qmap<Qstring, int> map;

public:
   keymap() {
   map["Up"] = Qt::Key_Up;
   map["Down"] = Qt::Key_Down;
   map["Left"] = Qt::Key_Left;
   map["Right"] = Qt::Key_Right;
   map["+"] = Qt::Key_Plus;
       .
       .
       .
   };

   int get(Qstring keyname) { return map[keyname]; }
   };


class translate {

   Qmap<Qstring, Qstring> map;
   keymap k_map;

public:
     bool read_from_db(void) {
         read the keyboard config from the database, into map.
         format (Function, Key) ie ("EPG Up", "Up") or ("TV CH+", "+")

         // I have a remote control where the up button doubles as pause, 
down doubles as stop, etc,
         // so I would like to see different keydefs for each mode (EPG, 
TV, Weather, etc)
         // that way the system will be fully customizable
     }
     int translate(Qstring k) {
         return k_map.get(map[k]);
     }

};

so you would just call translate::translate("Keyname") where ever you are 
collecting keypresses.

I would appreciate any comments,

Joe. 




More information about the mythtv-dev mailing list