• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kremotecontrol

  • sources
  • kde-4.12
  • kdeutils
  • kremotecontrol
  • libkremotecontrol
  • backends
  • lirc
lircremotecontrol.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) <2009> Michael Zanetti <michael_zanetti@gmx.net>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18 */
19 
20 #include "lircremotecontrol.h"
21 #include "lircclient.h"
22 
23 #include <kdebug.h>
24 
25 class LircRemoteControlPrivate
26 {
27 public:
28  LircRemoteControlPrivate(const QString &name);
29 
30  QString name;
31  LircClient *m_client;
32 
33 
34 };
35 
36 LircRemoteControlPrivate::LircRemoteControlPrivate(const QString &n)
37  : name(n)
38 {
39  m_client = LircClient::self();
40 }
41 
42 LircRemoteControl::LircRemoteControl(const QString &name)
43  : RemoteControl(), d(new LircRemoteControlPrivate(name))
44 {
45  connect(d->m_client, SIGNAL(commandReceived(QString,QString,int)), this, SLOT(commandReceived(QString,QString,int)));
46 }
47 
48 LircRemoteControl::~LircRemoteControl()
49 {
50  kDebug() << "deleting remote" << d->name;
51  delete d;
52 }
53 
54 QString LircRemoteControl::name() const
55 {
56  return d->name;
57 }
58 
59 QList<RemoteControlButton> LircRemoteControl::buttons() const
60 {
61  QList<RemoteControlButton> retList;
62  foreach(const QString &buttonName, d->m_client->buttons(d->name)){
63  if(lircButtonToRemoteControlButton(buttonName) != RemoteControlButton::Unknown){
64  retList.append(RemoteControlButton(d->name, lircButtonToRemoteControlButton(buttonName)));
65  } else {
66  retList.append(RemoteControlButton(d->name, formatNamespaceButton(buttonName)));
67  }
68  }
69  return retList;
70 }
71 
72 void LircRemoteControl::commandReceived(const QString &remote, const QString &button, int repeatCounter){
73  if(remote == d->name){
74  if(lircButtonToRemoteControlButton(button) != RemoteControlButton::Unknown){
75  emit buttonPressed(RemoteControlButton(remote, lircButtonToRemoteControlButton(button), repeatCounter));
76  } else {
77  emit buttonPressed(RemoteControlButton(remote, formatNamespaceButton(button), repeatCounter));
78  }
79  }
80 }
81 
82 RemoteControlButton::ButtonId LircRemoteControl::lircButtonToRemoteControlButton(const QString &buttonName) const{
83  // Numbers
84  if(buttonName == "KEY_0"){
85  return RemoteControlButton::Number0;
86  } else if(buttonName == "KEY_1"){
87  return RemoteControlButton::Number1;
88  } else if(buttonName == "KEY_2"){
89  return RemoteControlButton::Number2;
90  } else if(buttonName == "KEY_3"){
91  return RemoteControlButton::Number3;
92  } else if(buttonName == "KEY_4"){
93  return RemoteControlButton::Number4;
94  } else if(buttonName == "KEY_5"){
95  return RemoteControlButton::Number5;
96  } else if(buttonName == "KEY_6"){
97  return RemoteControlButton::Number6;
98  } else if(buttonName == "KEY_7"){
99  return RemoteControlButton::Number7;
100  } else if(buttonName == "KEY_8"){
101  return RemoteControlButton::Number8;
102  } else if(buttonName == "KEY_9"){
103  return RemoteControlButton::Number9;
104 
105  // Media control
106  } else if(buttonName == "KEY_PLAY"){
107  return RemoteControlButton::Play;
108  } else if(buttonName == "KEY_PAUSE"){
109  return RemoteControlButton::Pause;
110  } else if(buttonName == "KEY_PLAYPAUSE"){
111  return RemoteControlButton::PlayPause;
112  } else if(buttonName == "KEY_STOP"){
113  return RemoteControlButton::Stop;
114  } else if(buttonName == "KEY_FORWARD"){
115  return RemoteControlButton::Forward;
116  } else if(buttonName == "KEY_BACK"){
117  return RemoteControlButton::Backward;
118  } else if(buttonName == "KEY_FASTFORWARD"){
119  return RemoteControlButton::FastForward;
120  } else if(buttonName == "KEY_REWIND"){
121  return RemoteControlButton::Rewind;
122  } else if(buttonName == "KEY_CHANNELDOWN"){
123  return RemoteControlButton::ChannelDown;
124  } else if(buttonName == "KEY_CHANNELUP"){
125  return RemoteControlButton::ChannelUp;
126  } else if(buttonName == "KEY_VOLUMEDOWN"){
127  return RemoteControlButton::VolumeDown;
128  } else if(buttonName == "KEY_VOLUMEUP"){
129  return RemoteControlButton::VolumeUp;
130  } else if(buttonName == "KEY_MUTE"){
131  return RemoteControlButton::Mute;
132  } else if(buttonName == "KEY_INFO"){
133  return RemoteControlButton::Info;
134  } else if(buttonName == "KEY_EJECTCD"){
135  return RemoteControlButton::Eject;
136  } else if(buttonName == "KEY_POWER"){
137  return RemoteControlButton::Power;
138 
139  // Navigation
140  } else if(buttonName == "KEY_UP"){
141  return RemoteControlButton::Up;
142  } else if(buttonName == "KEY_DOWN"){
143  return RemoteControlButton::Down;
144  } else if(buttonName == "KEY_LEFT"){
145  return RemoteControlButton::Left;
146  } else if(buttonName == "KEY_RIGHT"){
147  return RemoteControlButton::Right;
148  } else if(buttonName == "KEY_SELECT"){
149  return RemoteControlButton::Select;
150  } else if(buttonName == "KEY_BACK"){
151  return RemoteControlButton::Back;
152  } else if(buttonName == "KEY_MENU"){
153  return RemoteControlButton::Menu;
154 
155  // Jump points
156  } else if(buttonName == "KEY_AUX"){
157  return RemoteControlButton::Aux;
158  } else if(buttonName == "KEY_CD"){
159  return RemoteControlButton::CD;
160  } else if(buttonName == "KEY_DVD"){
161  return RemoteControlButton::DVD;
162  } else if(buttonName == "KEY_EPG"){
163  return RemoteControlButton::EPG;
164  } else if(buttonName == "KEY_FAVORITES"){
165  return RemoteControlButton::Favorites;
166  } else if(buttonName == "KEY_HELP"){
167  return RemoteControlButton::Help;
168  } else if(buttonName == "KEY_HOME"){
169  return RemoteControlButton::Home;
170 // Not defined in LIRC (yet)
171 /* } else if(buttonName == "KEY_MUSIC"){
172  return RemoteControlButton::Music;*/
173  } else if(buttonName == "KEY_TEXT"){
174  return RemoteControlButton::Text;
175  } else if(buttonName == "KEY_TV"){
176  return RemoteControlButton::TV;
177 
178  // Colors
179  } else if(buttonName == "KEY_BLUE"){
180  return RemoteControlButton::Blue;
181  } else if(buttonName == "KEY_GREEN"){
182  return RemoteControlButton::Green;
183  } else if(buttonName == "KEY_RED"){
184  return RemoteControlButton::Red;
185  } else if(buttonName == "KEY_YELLOW"){
186  return RemoteControlButton::Yellow;
187 
188  // Not in lirc namespace or in RemoteControlButton::ButtonID
189  } else {
190  return RemoteControlButton::Unknown;
191  }
192 }
193 
194 QString LircRemoteControl::formatNamespaceButton(const QString &buttonName) const {
195  QString newName = buttonName;
196  if(buttonName.startsWith("KEY_")){
197  newName.remove("KEY_");
198  newName = newName.left(1) + newName.mid(1).toLower();
199  } else if(buttonName.startsWith("BUTTON_")){
200  newName.replace("BUTTON_", "Button");
201  newName = newName.left(7) + newName.mid(7).toLower();
202  } else {
203  newName = buttonName;
204  }
205  return newName;
206 }
207 
208 #include "lircremotecontrol.moc"
RemoteControlButton::VolumeUp
Definition: remotecontrolbutton.h:59
RemoteControlButton::Number7
Definition: remotecontrolbutton.h:43
RemoteControlButton::EPG
Definition: remotecontrolbutton.h:78
RemoteControlButton::Pause
Definition: remotecontrolbutton.h:49
RemoteControlButton::Eject
Definition: remotecontrolbutton.h:62
LircRemoteControl::~LircRemoteControl
virtual ~LircRemoteControl()
Definition: lircremotecontrol.cpp:48
RemoteControlButton::ChannelDown
Definition: remotecontrolbutton.h:56
RemoteControlButton::Stop
Definition: remotecontrolbutton.h:51
RemoteControlButton::TV
Definition: remotecontrolbutton.h:84
RemoteControlButton::Menu
Definition: remotecontrolbutton.h:72
RemoteControlButton::Info
Definition: remotecontrolbutton.h:61
RemoteControlButton::Forward
Definition: remotecontrolbutton.h:52
LircRemoteControl::LircRemoteControl
LircRemoteControl(const QString &name)
Definition: lircremotecontrol.cpp:42
RemoteControlButton::Play
Definition: remotecontrolbutton.h:48
RemoteControlButton::Down
Definition: remotecontrolbutton.h:67
RemoteControlButton::Right
Definition: remotecontrolbutton.h:69
RemoteControlButton::Number0
Definition: remotecontrolbutton.h:36
LircClient::self
static LircClient * self()
Get the instance,.
Definition: lircclient.cpp:57
RemoteControlButton::Mute
Definition: remotecontrolbutton.h:60
LircClient
Definition: lircclient.h:37
RemoteControlButton::Aux
Definition: remotecontrolbutton.h:75
RemoteControlButton::VolumeDown
Definition: remotecontrolbutton.h:58
RemoteControlButton::Red
Definition: remotecontrolbutton.h:89
RemoteControlButton::Number9
Definition: remotecontrolbutton.h:45
RemoteControlButton::Yellow
Definition: remotecontrolbutton.h:90
RemoteControlButton::Number4
Definition: remotecontrolbutton.h:40
RemoteControlButton::CD
Definition: remotecontrolbutton.h:76
RemoteControlButton::Blue
Definition: remotecontrolbutton.h:87
RemoteControl
Definition: remotecontrol.h:35
lircremotecontrol.h
RemoteControlButton::Number8
Definition: remotecontrolbutton.h:44
RemoteControlButton::PlayPause
Definition: remotecontrolbutton.h:50
RemoteControlButton::Home
Definition: remotecontrolbutton.h:81
RemoteControlButton::Number3
Definition: remotecontrolbutton.h:39
RemoteControlButton::ChannelUp
Definition: remotecontrolbutton.h:57
RemoteControlButton::Unknown
Definition: remotecontrolbutton.h:34
RemoteControlButton::Number1
Definition: remotecontrolbutton.h:37
LircRemoteControl::buttonPressed
void buttonPressed(const RemoteControlButton &button)
RemoteControlButton::Favorites
Definition: remotecontrolbutton.h:79
LircRemoteControl::name
virtual QString name() const
Definition: lircremotecontrol.cpp:54
RemoteControlButton::Green
Definition: remotecontrolbutton.h:88
RemoteControlButton::Up
Definition: remotecontrolbutton.h:66
RemoteControlButton::Back
Definition: remotecontrolbutton.h:71
lircclient.h
RemoteControlButton::Rewind
Definition: remotecontrolbutton.h:55
RemoteControlButton::Left
Definition: remotecontrolbutton.h:68
LircRemoteControl::buttons
virtual QList< RemoteControlButton > buttons() const
Definition: lircremotecontrol.cpp:59
RemoteControlButton::ButtonId
ButtonId
Definition: remotecontrolbutton.h:33
RemoteControlButton::Number5
Definition: remotecontrolbutton.h:41
RemoteControlButton::Backward
Definition: remotecontrolbutton.h:53
RemoteControlButton::Text
Definition: remotecontrolbutton.h:83
RemoteControlButton::Power
Definition: remotecontrolbutton.h:63
RemoteControlButton::Help
Definition: remotecontrolbutton.h:80
RemoteControlButton
Definition: remotecontrolbutton.h:30
RemoteControlButton::DVD
Definition: remotecontrolbutton.h:77
RemoteControlButton::FastForward
Definition: remotecontrolbutton.h:54
RemoteControlButton::Number2
Definition: remotecontrolbutton.h:38
RemoteControlButton::Select
Definition: remotecontrolbutton.h:70
RemoteControlButton::Number6
Definition: remotecontrolbutton.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kremotecontrol

Skip menu "kremotecontrol"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal