MythTV master
AppleRemoteListener.cpp
Go to the documentation of this file.
1
3
4#include <QCoreApplication>
5#include <QKeySequence>
6#include <QString>
7#include "devices/lircevent.h"
8
10 bool pressedDown)
11{
12 QString code = nullptr;
13 bool separateRelease = false;
14
15 switch (button)
16 {
17 case AppleRemote::Up:
18 code="Up";
19 separateRelease=true;
20 break;
22 code="Down";
23 separateRelease=true;
24 break;
26 code="Esc";
27 break;
29 code="Enter";
30 break;
32 code="Right";
33 break;
35 code="Left";
36 break;
38 code="End";
39 separateRelease=true;
40 break;
42 code="Home";
43 separateRelease=true;
44 break;
46 code="M";
47 break;
50 code="P";
51 break;
53 return;
55 break;
56 }
57 QKeySequence a(code);
58 for (int i = 0; i < a.count(); i++)
59 {
60#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
61 int keycode = a[i];
62#else
63 int keycode = a[i].toCombined();
64#endif
65 if (pressedDown)
66 QCoreApplication::postEvent(mainWindow, new LircKeycodeEvent(
67 QEvent::KeyPress, keycode, Qt::NoModifier, code, code));
68
69 if (!separateRelease || !pressedDown)
70 QCoreApplication::postEvent(mainWindow, new LircKeycodeEvent(
71 QEvent::KeyRelease, keycode, Qt::NoModifier, code, code));
72 }
73}
void appleRemoteButton(AppleRemote::Event button, bool pressedDown) override