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;
21  case AppleRemote::Down:
22  code="Down";
23  separateRelease=true;
24  break;
25  case AppleRemote::Menu:
26  code="Esc";
27  break;
29  code="Enter";
30  break;
31  case AppleRemote::Right:
32  code="Right";
33  break;
34  case AppleRemote::Left:
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  int keycode = a[i];
61 
62  if (pressedDown)
63  QCoreApplication::postEvent(mainWindow, new LircKeycodeEvent(
64  QEvent::KeyPress, keycode, Qt::NoModifier, code, code));
65 
66  if (!separateRelease || !pressedDown)
67  QCoreApplication::postEvent(mainWindow, new LircKeycodeEvent(
68  QEvent::KeyRelease, keycode, Qt::NoModifier, code, code));
69  }
70 }
AppleRemote::Select
@ Select
Definition: AppleRemote.h:29
AppleRemote::RightHold
@ RightHold
Definition: AppleRemote.h:32
AppleRemote::Down
@ Down
Definition: AppleRemote.h:27
AppleRemote::Event
Event
Definition: AppleRemote.h:24
AppleRemoteListener::mainWindow
QObject * mainWindow
Definition: AppleRemoteListener.h:16
AppleRemote::MenuHold
@ MenuHold
Definition: AppleRemote.h:34
AppleRemote::Menu
@ Menu
Definition: AppleRemote.h:28
AppleRemoteListener::appleRemoteButton
void appleRemoteButton(AppleRemote::Event button, bool pressedDown)
Definition: AppleRemoteListener.cpp:9
AppleRemote::Right
@ Right
Definition: AppleRemote.h:30
AppleRemoteListener.h
AppleRemote::PlayHold
@ PlayHold
Definition: AppleRemote.h:35
AppleRemote::Undefined
@ Undefined
Definition: AppleRemote.h:38
AppleRemote::ControlSwitched
@ ControlSwitched
Definition: AppleRemote.h:36
LircKeycodeEvent
Definition: lircevent.h:12
AppleRemote::Up
@ Up
Definition: AppleRemote.h:26
AppleRemote::Left
@ Left
Definition: AppleRemote.h:31
AppleRemote::LeftHold
@ LeftHold
Definition: AppleRemote.h:33
lircevent.h
AppleRemote::PlayPause
@ PlayPause
Definition: AppleRemote.h:37