2#include <QCoreApplication>
7#include "libmythbase/mythconfig.h"
15#if CONFIG_JOYSTICK_MENU
28#if defined CONFIG_LIRC || CONFIG_APPLEREMOTE
32#define LOC QString("InputHandler: ")
54 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Starting");
61 config = QDir::homePath() +
"/.lircrc";
64 QString socket =
"/dev/lircd";
66 socket =
"/var/run/lirc/lircd";
68 m_lircThread =
new LIRC(
this,
GetMythDB()->GetSetting(
"LircSocket", socket),
"mythtv", config);
69 if (m_lircThread->Init())
71 m_lircThread->start();
75 m_lircThread->deleteLater();
76 m_lircThread =
nullptr;
81#if CONFIG_JOYSTICK_MENU
82 if (!m_joystickThread)
84 QString config =
GetConfDir() +
"/joystickmenurc";
86 if (m_joystickThread->Init(config))
87 m_joystickThread->start();
92 if (!m_appleRemoteListener)
97 m_appleRemote->setListener(m_appleRemoteListener);
98 m_appleRemote->startListening();
99 if (m_appleRemote->isListeningToRemote())
101 m_appleRemote->start();
106 delete m_appleRemote;
107 delete m_appleRemoteListener;
108 m_appleRemote =
nullptr;
109 m_appleRemoteListener =
nullptr;
117 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Stopping");
121 m_cecAdapter.Close();
124#if CONFIG_APPLEREMOTE
127 delete m_appleRemote;
128 delete m_appleRemoteListener;
129 m_appleRemote =
nullptr;
130 m_appleRemoteListener =
nullptr;
134#if CONFIG_JOYSTICK_MENU
135 if (m_joystickThread && Finishing)
137 if (m_joystickThread->isRunning())
139 m_joystickThread->Stop();
140 m_joystickThread->wait();
142 delete m_joystickThread;
143 m_joystickThread =
nullptr;
150 m_lircThread->deleteLater();
151 m_lircThread =
nullptr;
168#if CONFIG_APPLEREMOTE
171 if (
Event->type() == QEvent::WindowActivate)
172 m_appleRemote->startListening();
173 if (
Event->type() == QEvent::WindowDeactivate)
174 m_appleRemote->stopListening();
182 m_cecAdapter.Action(
Action);
189 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Locking input devices");
191 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Unlocking input devices");
194 m_cecAdapter.IgnoreKeys(Ignore);
213 QScopedPointer<QKeyEvent> key {
new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier) };
214 QObject* target =
nullptr;
217#if CONFIG_JOYSTICK_MENU
224 int keycode = jke->
key();
227 key.reset(
new QKeyEvent(jke->keyAction(), keycode, jke->keyModifiers()));
232 error = jke->getJoystickMenuText();
237#if CONFIG_LIRC || CONFIG_APPLEREMOTE
246 error = lke->lirctext();
250 key.reset(
new QKeyEvent(lke->keytype(), lke->key(), lke->modifiers(), lke->text()));
256 if (!
error.isEmpty())
258 LOG(VB_GENERAL, LOG_WARNING,
LOC +
259 QString(
"Attempt to convert key sequence '%1' to a Qt key sequence failed.").arg(
error));
266 QCoreApplication::sendEvent(target, key.data());
An action (for this plugin) consists of a description, and a set of key sequences.
static AppleRemote * Get()
static const Type kEventType
Interface between mythtv and lircd.
static const Type kEventType
static const unsigned kLIRCInvalidKeyCombo
static void ResetScreensaver()
static bool IsScreensaverAsleep()
QObject * GetTarget(QKeyEvent &Key)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)