aboutsummaryrefslogtreecommitdiff
path: root/lib/driver/rcconsole.h
blob: 4af2a4c2134d80442f057163d0538800524290b4 (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
#ifndef __lib_driver_rcconsole_h
#define __lib_driver_rcconsole_h

#include <termios.h>
#include <lib/driver/rc.h>

class eRCConsoleDriver: public eRCDriver
{
	struct termios ot;
protected:
	int handle;
	eSocketNotifier *sn;
	void keyPressed(int);
public:
	eRCConsoleDriver(const char *filename);
	~eRCConsoleDriver();
	void flushBuffer() const
	{
		char data[16];
		if (handle != -1)
			while ( ::read(handle, data, 16) == 16 );
	}
	void lock() const
	{
		if ( sn )
			sn->stop();
	}
	void unlock() const
	{
		if ( sn )
			sn->start();
	}
};

class eRCConsole: public eRCDevice
{
public:
	void handleCode(long code);
	eRCConsole(eRCDriver *driver);
	const char *getDescription() const;
	const char *getKeyDescription(const eRCKey &key) const;
	int getKeyCompatibleCode(const eRCKey &key) const;
};

#endif