1 #include <lib/base/init.h>
2 #include <lib/base/init_num.h>
3 #include <lib/base/eerror.h>
4 #include <lib/driver/rcconsole.h>
8 eRCConsoleDriver::eRCConsoleDriver(const char *filename): eRCDriver(eRCInput::getInstance())
10 handle=open(filename, O_RDONLY|O_NONBLOCK);
13 eDebug("failed to open %s", filename);
17 sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
18 CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
21 /* set console mode */
23 tcgetattr(handle, &t);
25 t.c_lflag &= ~(ECHO | ICANON | ECHOK | ECHOE | ECHONL);
26 tcsetattr(handle, TCSANOW,&t);
29 eRCConsoleDriver::~eRCConsoleDriver()
31 tcsetattr(handle,TCSANOW, &ot);
36 void eRCConsoleDriver::keyPressed(int)
38 unsigned char data[16];
39 unsigned char *d = data;
40 int num = read(handle, data, 16);
43 int km = input->getKeyboardMode();
45 if (km == eRCInput::kmNone)
50 // eDebug("console code %08x\n", *d);
51 if (km == eRCInput::kmAll)
55 if (*d == 27) // escape code
68 if (code < 32) /* control characters */
72 case 0x7E: // mute, einfg, entf
73 case 0x7F: // backspace
81 for (std::list<eRCDevice*>::iterator i(listeners.begin()); i!=listeners.end(); ++i)
83 // eDebug("ascii %08x", code);
84 (*i)->handleCode(code);
89 void eRCConsole::handleCode(long code)
91 input->keyPressed(eRCKey(this, code, eRCKey::flagAscii));
94 eRCConsole::eRCConsole(eRCDriver *driver)
95 : eRCDevice("Console", driver)
99 const char *eRCConsole::getDescription() const
104 const char *eRCConsole::getKeyDescription(const eRCKey &key) const
109 int eRCConsole::getKeyCompatibleCode(const eRCKey &key) const
116 eRCConsoleDriver driver;
119 eRCConsoleInit(): driver("/dev/vc/0"), device(&driver)
124 eAutoInitP0<eRCConsoleInit> init_rcconsole(eAutoInitNumbers::rc+1, "Console RC Driver");