summaryrefslogtreecommitdiffstats
path: root/noatun/modules/infrared/lirc.h
blob: e5380c5c6c1dde77622f5331ff87e1cbbcdecc01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

#ifndef _LIRC_H_
#define _LIRC_H_

#include <qobject.h>
#include <qstringlist.h>
#include <qmap.h>

class QSocket;

typedef QMap<QString, QStringList> Remotes;

class Lirc : public QObject
{
Q_OBJECT
public:
	/**
	 * Constructor
	 */
	Lirc(QObject *parent);
	/**
	 * Destructor
	 */
	virtual ~Lirc();

	/**
	 * Returns true if the connection to lircd is operational
	 */
	bool isConnected() const { return m_socket; }
	/**
	 * The names of the remote configured controls
	 */
	const QStringList remotes() const;
	/**
	 * The names of the buttons for the specified
	 * remote control
	 */
	const QStringList buttons(const QString &remote) const
	{
			return m_remotes[remote];
	}

signals:
	/**
	 * Emitted when the list of controls / buttons was cmpletely read
	 */
	void remotesRead();
	/**
	 * Emitted when a IR command was received
	 * 
	 * The arguments are the name of the remote control used,
	 * the name of the button pressed and the repeat counter.
	 *
	 * The signal is emitted repeatedly as long as the button
	 * on the remote control remains pressed.
	 * The repeat counter starts with 0 and increases
	 * every time this signal is emitted.
	 */
	void commandReceived(const QString &, const QString &, int);
	
private slots:
	void slotRead();
	
private:
	void update();
	const QString readLine();
	void sendCommand(const QString &);
	
private:
	QSocket *m_socket;
	Remotes m_remotes;
};

#endif