Index: libs/libmythtv/tv_play.cpp =================================================================== --- libs/libmythtv/tv_play.cpp (revision 10761) +++ libs/libmythtv/tv_play.cpp (working copy) @@ -39,6 +39,7 @@ #include "DVDRingBuffer.h" #include "datadirect.h" #include "sourceutil.h" +#include "mythkeysequence.h" #ifndef HAVE_ROUND #define round(x) ((int) ((x) + 0.5)) @@ -606,9 +607,9 @@ { query.next(); - QKeySequence keyseq(query.value(0).toString()); + MythKeySequence keyseq(query.value(0).toString()); - int keynum = keyseq[0]; + int keynum = keyseq[0]->value(); keynum &= ~Qt::UNICODE_ACCEL; keyList.prepend(new QKeyEvent(QEvent::KeyPress, keynum, 0, 0)); Index: libs/libmythui/mythmainwindow.cpp =================================================================== --- libs/libmythui/mythmainwindow.cpp (revision 10761) +++ libs/libmythui/mythmainwindow.cpp (working copy) @@ -35,6 +35,7 @@ #include "mythcontext.h" #include "mythdbcon.h" #include "mythgesture.h" +#include "mythkeysequence.h" /* from libmyth */ #include "screensaver.h" @@ -73,12 +74,18 @@ class KeyContext { public: - void AddMapping(int key, QString action) + void AddMapping(QString key, QString action) { actionMap[key].append(action); } + void AddMapping(int key, QString action) + { + QString keystr; + keystr.setNum(key); + actionMap[keystr].append(action); + } - bool GetMapping(int key, QStringList &actions) + bool GetMapping(QString key, QStringList &actions) { if (actionMap.count(key) > 0) { @@ -87,8 +94,15 @@ } return false; } + bool GetMapping(int key, QStringList &actions) + { + QString keystr; + keystr.setNum(key); + return GetMapping(keystr, actions); + } - QMap actionMap; + //QMap actionMap; + QMap actionMap; }; struct JumpData @@ -131,7 +145,8 @@ bool popwindows; QDict keyContexts; - QMap jumpMap; + //QMap jumpMap; + QMap jumpMap; QMap destinationMap; QMap mediaHandlerMap; QMap mediaPluginMap; @@ -592,6 +607,7 @@ 0, Qt::NoButton); QObject *key_target = getTarget(*key); QApplication::postEvent(key_target, key); + return; } return; } @@ -615,6 +631,7 @@ QKeyEvent *key = new QKeyEvent(QEvent::KeyPress, d->escapekey, 0, Qt::NoButton); QApplication::postEvent(this, key); + return; } return; } @@ -648,26 +665,66 @@ { actions.clear(); int keynum = d->TranslateKeyNum(e); + bool retval = false; + QString keystr; + keystr.setNum( keynum ); + +#ifdef USE_LIRC + /* If there's LIRC support, we must check for those here -- check the + * remoteXXXXX identifiers; + */ + if ((e->ascii( ) == 0) && (e->key( ) == 0) && (e->text( ).left(6) == "remote")) + { + VERBOSE(VB_GENERAL, QString("MythMainWindow::TranslateKeyPress() - Remote button '%1' received in context '%2'.") + .arg(e->text( )).arg(context.latin1()) ); + + if (allowJumps && + d->jumpMap.count(e->text()) > 0 && d->exitmenucallback == NULL) + { + d->exitingtomain = true; + d->exitmenucallback = d->jumpMap[ e->text() ]->callback; + QApplication::postEvent(this, new ExitToMainMenuEvent()); + return false; + } + + + if ((d->keyContexts[context]) && + (d->keyContexts[context]->GetMapping( e->text(), actions))) + { + retval = true; + } + + + if ((context != "Global") && + (d->keyContexts["Global"]->GetMapping( e->text(), actions ))) + { + retval = true; + } + + return retval; + } + +#endif // USE_LIRC + if (allowJumps && - d->jumpMap.count(keynum) > 0 && d->exitmenucallback == NULL) + d->jumpMap.count(keystr) > 0 && d->exitmenucallback == NULL) { d->exitingtomain = true; - d->exitmenucallback = d->jumpMap[keynum]->callback; + d->exitmenucallback = d->jumpMap[keystr]->callback; QApplication::postEvent(this, new ExitToMainMenuEvent()); return false; } - bool retval = false; if (d->keyContexts[context]) { - if (d->keyContexts[context]->GetMapping(keynum, actions)) + if (d->keyContexts[context]->GetMapping(keystr, actions)) retval = true; } if (context != "Global" && - d->keyContexts["Global"]->GetMapping(keynum, actions)) + d->keyContexts["Global"]->GetMapping(keystr, actions)) { retval = true; } @@ -680,7 +737,8 @@ KeyContext * keycontext = d->keyContexts[context]; if (keycontext == NULL) return; - QMap::Iterator it; + //QMap::Iterator it; + QMap::Iterator it; for (it = keycontext->actionMap.begin(); it != keycontext->actionMap.end(); it++) @@ -706,25 +764,31 @@ void MythMainWindow::BindKey(const QString &context, const QString &action, const QString &key) { - QKeySequence keyseq(key); + MythKeySequence keyseq(key); if (!d->keyContexts[context]) d->keyContexts.insert(context, new KeyContext()); for (unsigned int i = 0; i < keyseq.count(); i++) { - int keynum = keyseq[i]; + int keynum = keyseq[i]->value(); keynum &= ~Qt::UNICODE_ACCEL; + QString keystr; +#ifdef USE_LIRC + if(keyseq[i]->isRemote()) keystr = keyseq[i]->text(); + else // intensional +#endif // USE_LIRC + keystr.setNum( keynum ); QStringList dummyaction = ""; - if (d->keyContexts[context]->GetMapping(keynum, dummyaction)) + if (d->keyContexts[context]->GetMapping(keystr, dummyaction)) { VERBOSE(VB_GENERAL, QString("Key %1 is bound to multiple actions " "in context %2.") .arg(key).arg(context)); } - d->keyContexts[context]->AddMapping(keynum, action); + d->keyContexts[context]->AddMapping(keystr, action); //VERBOSE(VB_GENERAL, QString("Binding: %1 to action: %2 (%3)") // .arg(key).arg(action) // .arg(context)); @@ -811,7 +875,8 @@ return; } - QMap::Iterator it; + // QMap::Iterator it; + QMap::Iterator it; for (it = d->jumpMap.begin(); it != d->jumpMap.end(); ++it) { @@ -831,30 +896,35 @@ return; } - QKeySequence keyseq(key); + MythKeySequence keyseq(key); for (unsigned int i = 0; i < keyseq.count(); i++) { - int keynum = keyseq[i]; + int keynum = keyseq[i]->value(); keynum &= ~Qt::UNICODE_ACCEL; + QString keystr; +#ifdef USE_LIRC + if (keyseq[i]->isRemote()) keystr = keyseq[i]->text(); + else // intensional +#endif + keystr.setNum( keynum ); - if (d->jumpMap.count(keynum) == 0) + if (d->jumpMap.count( keystr ) == 0) { //VERBOSE(VB_GENERAL, QString("Binding: %1 to JumpPoint: %2") // .arg(keybind).arg(destination)); - - d->jumpMap[keynum] = &d->destinationMap[destination]; + + d->jumpMap[ keystr ] = &d->destinationMap[destination]; } else { - VERBOSE(VB_GENERAL, QString("Key %1 is already bound to a jump " - "point.").arg(key)); + VERBOSE(VB_GENERAL, QString("%1 is already bound to a jump " + "point.").arg(keystr)); } + //else + // VERBOSE(VB_GENERAL, QString("JumpPoint: %2 exists, no keybinding") + // .arg(destination)); } - //else - // VERBOSE(VB_GENERAL, QString("JumpPoint: %2 exists, no keybinding") - // .arg(destination)); - } void MythMainWindow::RegisterJump(const QString &destination, @@ -1202,8 +1272,34 @@ LircKeycodeEvent *lke = (LircKeycodeEvent *)ce; int keycode = lke->getKeycode(); - if (keycode) + if (lke->getLircText().left(6) == "remote") { + /* Attempt to send this to the application; + */ + VERBOSE(VB_GENERAL, QString("MythMainWindow::customEvent() - Sending '%1' to keypress-handler.") + .arg(lke->getLircText()) ); + + /* Send a press & release -- abusing the Unicode field for + * passing the LIRC logical identifier. + */ + QKeyEvent keyp( QEvent::KeyPress, 0, 0, 0, lke->getLircText( ) ); + QKeyEvent keyr( QEvent::KeyRelease, 0, 0, 0, lke->getLircText( ) ); + + QObject *key_target = getTarget(keyp); + + if (!key_target) + { + QApplication::sendEvent( this, &keyp ); + QApplication::sendEvent( this, &keyr ); + } + else + { + QApplication::sendEvent( key_target, &keyp ); + QApplication::sendEvent( key_target, &keyr ); + } + } + else if (keycode) + { gContext->ResetScreensaver(); if (gContext->GetScreenIsAsleep()) return; Index: libs/libmyth/lirc.cpp =================================================================== --- libs/libmyth/lirc.cpp (revision 10761) +++ libs/libmyth/lirc.cpp (working copy) @@ -15,6 +15,7 @@ #include "lirc.h" #include "lircevent.h" #include "util.h" +#include "mythkeysequence.h" #if (QT_VERSION < 0x030100) #error Native LIRC support requires Qt 3.1 or greater. @@ -72,7 +73,7 @@ while ((ret = lirc_code2char(lircConfig, ir, &code)) == 0 && code != NULL) { - QKeySequence a(code); + MythKeySequence a(code); int keycode = 0; @@ -85,13 +86,20 @@ for (unsigned int i = 0; i < a.count(); i++) { - keycode = a[i]; - - QApplication::postEvent(mainWindow, new LircKeycodeEvent(code, + if (a[i]->isRemote()) // is really bound to a remoteXXX + { + QApplication::postEvent(mainWindow, new LircKeycodeEvent( a[i]->text().latin1(), 0, true )); + } + else + { + keycode = a[i]->value( ); + QApplication::postEvent(mainWindow, new LircKeycodeEvent(code, keycode, true)); - QApplication::postEvent(mainWindow, new LircKeycodeEvent(code, + QApplication::postEvent(mainWindow, new LircKeycodeEvent(code, keycode, false)); + } + SpawnApp(); } } Index: libs/libmyth/jsmenu.cpp =================================================================== --- libs/libmyth/jsmenu.cpp (revision 10761) +++ libs/libmyth/jsmenu.cpp (working copy) @@ -32,6 +32,7 @@ #include #include "mythcontext.h" +#include "mythkeysequence.h" #include using namespace std; @@ -292,7 +293,7 @@ **--------------------------------------------------------------------------*/ void JoystickMenuClient::EmitKey(QString code) { - QKeySequence a(code); + MythKeySequence a(code); int keycode = 0; @@ -305,7 +306,7 @@ for (unsigned int i = 0; i < a.count(); i++) { - keycode = a[i]; + keycode = a[i]->value(); QApplication::postEvent(mainWindow, new JoystickKeycodeEvent(code, keycode, true)); Index: libs/libmyth/libmyth.pro =================================================================== --- libs/libmyth/libmyth.pro (revision 10761) +++ libs/libmyth/libmyth.pro (working copy) @@ -19,7 +19,7 @@ HEADERS += dbsettings.h screensaver-null.h output.h visual.h HEADERS += langsettings.h audiooutputnull.h mythsocket.h HEADERS += DisplayResScreen.h util-x11.h mythdeque.h qmdcodec.h -HEADERS += exitcodes.h virtualkeyboard.h mythobservable.h mythevent.h +HEADERS += exitcodes.h virtualkeyboard.h mythobservable.h mythevent.h mythkeysequence.h SOURCES += dialogbox.cpp lcddevice.cpp mythcontext.cpp mythwidgets.cpp SOURCES += oldsettings.cpp remotefile.cpp settings.cpp @@ -31,7 +31,7 @@ SOURCES += dbsettings.cpp screensaver.cpp screensaver-null.cpp output.cpp SOURCES += langsettings.cpp mythdbcon.cpp audiooutputnull.cpp SOURCES += DisplayResScreen.cpp util-x11.cpp qmdcodec.cpp -SOURCES += virtualkeyboard.cpp mythobservable.cpp mythsocket.cpp +SOURCES += virtualkeyboard.cpp mythobservable.cpp mythsocket.cpp mythkeysequence.cpp INCLUDEPATH += ../libmythsamplerate ../libmythsoundtouch ../.. ../ DEPENDPATH += ../libmythsamplerate ../libmythsoundtouch ../ ../libmythui