[mythtv] patch to add native lirc support
Anduin Withers
awithers at anduin.com
Sun Aug 10 17:34:15 EDT 2003
"Hey Anduin that patch sucked! Now when I spawn other programs which also
take direct lirc input myth receives the keys as well."
Attached is a patch to fix that problem.
Introduced a new function into util.h, goes by myth_system(). Works just
like system() except if USE_LIRC is defined it will block the lirc events
from being processed during the system call.
lirc_mute.patch.txt and lircevent.cpp are all that is needed for mythtv.
Since part of this was to make controlling a spawned DVD player easier I'm
also including lirc_mute_dvd.patch.txt which simply uses myth_system()
instead of system() in the dvd module.
--
Anduin Withers
-------------- next part --------------
Index: libmyth.pro
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/libmyth.pro,v
retrieving revision 1.30
diff -u -r1.30 libmyth.pro
--- libmyth.pro 4 Aug 2003 22:09:43 -0000 1.30
+++ libmyth.pro 10 Aug 2003 23:13:49 -0000
@@ -38,8 +38,8 @@
using_lirc {
DEFINES += USE_LIRC
- HEADERS += lirc.h
- SOURCES += lirc.cpp
+ HEADERS += lirc.h lircevent.h
+ SOURCES += lirc.cpp lircevent.cpp
}
INSTALLS += inc
Index: lircevent.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/lircevent.h,v
retrieving revision 1.1
diff -u -r1.1 lircevent.h
--- lircevent.h 10 Aug 2003 14:56:39 -0000 1.1
+++ lircevent.h 10 Aug 2003 23:13:51 -0000
@@ -2,6 +2,7 @@
#define LIRCEVENT_H_
const int kLircKeycodeEventType = 23423;
+const int kLircMuteEventType = 23424;
class LircKeycodeEvent : public QCustomEvent
{
@@ -29,6 +30,34 @@
QString lirctext;
int keycode;
bool keydown;
+};
+
+class LircMuteEvent : public QCustomEvent
+{
+ public:
+ LircMuteEvent(bool mute_events) : QCustomEvent(kLircMuteEventType),
+ mute_lirc_events(mute_events) {}
+
+ bool eventsMuted()
+ {
+ return mute_lirc_events;
+ }
+
+ private:
+ bool mute_lirc_events;
+};
+
+
+class LircEventLock
+{
+ public:
+ LircEventLock(bool lock_events = true);
+ ~LircEventLock();
+ void lock();
+ void unlock();
+
+ private:
+ bool events_locked;
};
#endif
Index: mythdialogs.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythdialogs.cpp,v
retrieving revision 1.10
diff -u -r1.10 mythdialogs.cpp
--- mythdialogs.cpp 10 Aug 2003 14:56:39 -0000 1.10
+++ mythdialogs.cpp 10 Aug 2003 23:13:52 -0000
@@ -38,6 +38,7 @@
{
Init();
#ifdef USE_LIRC
+ ignore_lirc_keys = false;
pthread_t lirc_tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
@@ -124,7 +125,7 @@
void MythMainWindow::customEvent(QCustomEvent *ce)
{
#ifdef USE_LIRC
- if (ce->type() == kLircKeycodeEventType)
+ if (ce->type() == kLircKeycodeEventType && !ignore_lirc_keys)
{
LircKeycodeEvent *lke = (LircKeycodeEvent *)ce;
int keycode = lke->getKeycode();
@@ -172,6 +173,12 @@
<< lke->getLircText() << "' to a key sequence failed. Fix"
" your key mappings.\n";
}
+ }
+
+ if (ce->type() == kLircMuteEventType)
+ {
+ LircMuteEvent *lme = (LircMuteEvent *)ce;
+ ignore_lirc_keys = lme->eventsMuted();
}
#endif
}
Index: mythdialogs.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythdialogs.h,v
retrieving revision 1.8
diff -u -r1.8 mythdialogs.h
--- mythdialogs.h 10 Aug 2003 14:56:39 -0000 1.8
+++ mythdialogs.h 10 Aug 2003 23:13:52 -0000
@@ -50,6 +50,10 @@
int screenwidth, screenheight;
vector<QWidget *> widgetList;
+
+#ifdef USE_LIRC
+ bool ignore_lirc_keys;
+#endif
};
class MythDialog : public QFrame
Index: themedmenu.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/themedmenu.cpp,v
retrieving revision 1.51
diff -u -r1.51 themedmenu.cpp
--- themedmenu.cpp 7 Aug 2003 21:23:59 -0000 1.51
+++ themedmenu.cpp 10 Aug 2003 23:13:54 -0000
@@ -1691,7 +1691,7 @@
if (action.left(5) == "EXEC ")
{
QString rest = action.right(action.length() - 5);
- system(rest);
+ myth_system(rest);
}
else if (action.left(7) == "EXECTV ")
{
@@ -1707,7 +1707,7 @@
(const char*)strlist[2],
(const char*)strlist[3]);
- system(rest);
+ myth_system(rest);
strlist = QString("FREE_TUNER %1").arg(cardid);
gContext->SendReceiveStringList(strlist);
Index: util.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/util.cpp,v
retrieving revision 1.19
diff -u -r1.19 util.cpp
--- util.cpp 17 Jul 2003 00:20:54 -0000 1.19
+++ util.cpp 10 Aug 2003 23:13:55 -0000
@@ -19,6 +19,10 @@
#include <qpainter.h>
#include <qpixmap.h>
+#ifdef USE_LIRC
+#include "lircevent.h"
+#endif
+
bool WriteStringList(QSocket *socket, QStringList &list)
{
QString str = list.join("[]:[]");
@@ -255,3 +259,11 @@
return qRgb(sred, sgreen, sblue);
}
+int myth_system(const QString &command, int flags)
+{
+ #ifdef USE_LIRC
+ LircEventLock lirc_lock(!(flags & MYTH_SYSTEM_DONT_BLOCK_LIRC));
+ #endif
+
+ return system(command);
+}
Index: util.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/util.h,v
retrieving revision 1.8
diff -u -r1.8 util.h
--- util.h 17 Jul 2003 00:20:54 -0000 1.8
+++ util.h 10 Aug 2003 23:13:55 -0000
@@ -25,4 +25,7 @@
QRgb blendColors(QRgb source, QRgb add, int alpha);
+#define MYTH_SYSTEM_DONT_BLOCK_LIRC (1)
+int myth_system(const QString &command, int flags = 0);
+
#endif
-------------- next part --------------
Index: settings.pro
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/settings.pro,v
retrieving revision 1.2
diff -u -r1.2 settings.pro
--- settings.pro 4 Aug 2003 01:00:35 -0000 1.2
+++ settings.pro 10 Aug 2003 23:23:55 -0000
@@ -15,3 +15,5 @@
QMAKE_CFLAGS_RELEASE = -O3 -march=pentiumpro -fomit-frame-pointer
}
+CONFIG += using_lirc
+EXTRA_LIBS += -llirc_client
Index: mtd/mtd.pro
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/mtd/mtd.pro,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mtd.pro
--- mtd/mtd.pro 28 Jul 2003 15:34:52 -0000 1.1.1.1
+++ mtd/mtd.pro 10 Aug 2003 23:23:55 -0000
@@ -12,7 +12,7 @@
INSTALLS += target
-LIBS += -lmyth-$$LIBVERSION
+LIBS += -lmyth-$$LIBVERSION $$EXTRA_LIBS
HEADERS += ../mythdvd/config.h
Index: mythdvd/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/mythdvd/main.cpp,v
retrieving revision 1.4
diff -u -r1.4 main.cpp
--- mythdvd/main.cpp 30 Jul 2003 02:58:11 -0000 1.4
+++ mythdvd/main.cpp 10 Aug 2003 23:23:56 -0000
@@ -28,6 +28,7 @@
#include "config.h"
#include "settings.h"
#include "dvdripbox.h"
+#include "mythtv/util.h"
@@ -96,7 +97,7 @@
command_string = command_string.replace( QRegExp("%d"), dvd_device );
}
}
- system(command_string);
+ myth_system(command_string);
gContext->GetMainWindow()->raise();
gContext->GetMainWindow()->setActiveWindow();
gContext->GetMainWindow()->currentWidget()->setFocus();
Index: mythdvd/mythdvd.pro
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/mythdvd/mythdvd.pro,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mythdvd.pro
--- mythdvd/mythdvd.pro 28 Jul 2003 15:34:52 -0000 1.1.1.1
+++ mythdvd/mythdvd.pro 10 Aug 2003 23:23:56 -0000
@@ -18,7 +18,7 @@
INSTALLS += installfiles uifiles
-LIBS +=
+LIBS += $$EXTRA_LIBS
HEADERS += config.h settings.h
Index: mythdvd/titledialog.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/mythdvd/titledialog.cpp,v
retrieving revision 1.5
diff -u -r1.5 titledialog.cpp
--- mythdvd/titledialog.cpp 7 Aug 2003 20:26:35 -0000 1.5
+++ mythdvd/titledialog.cpp 10 Aug 2003 23:23:56 -0000
@@ -16,6 +16,7 @@
#include <qregexp.h>
#include "titledialog.h"
+#include "mythtv/util.h"
TitleDialog::TitleDialog(QSqlDatabase *ldb,
@@ -265,7 +266,7 @@
player_string = player_string.replace(QRegExp("%a"), QString("%1").arg(audio_track));
player_string = player_string.replace(QRegExp("%c"), QString("%1").arg(channels));
- system(player_string);
+ myth_system(player_string);
gContext->GetMainWindow()->raise();
gContext->GetMainWindow()->setActiveWindow();
gContext->GetMainWindow()->currentWidget()->setFocus();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lircevent.cpp
Type: application/octet-stream
Size: 735 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20030810/5068061e/lircevent.obj
More information about the mythtv-dev
mailing list