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=new eSocketNotifier(eApp, handle, eSocketNotifier::Read);
18 CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
19 eRCInput::getInstance()->setFile(handle);
22 /* set console mode */
24 tcgetattr(handle, &t);
26 t.c_lflag &= ~(ECHO | ICANON | ECHOK | ECHOE | ECHONL);
27 tcsetattr(handle, TCSANOW,&t);
30 eRCConsoleDriver::~eRCConsoleDriver()
32 tcsetattr(handle,TCSANOW, &ot);
39 void eRCConsoleDriver::keyPressed(int)
41 unsigned char data[16];
42 unsigned char *d = data;
43 int num = read(handle, data, 16);
46 int km = input->getKeyboardMode();
48 if (km == eRCInput::kmNone)
53 // eDebug("console code %08x\n", *d);
54 if (km == eRCInput::kmAll)
58 if (*d == 27) // escape code
71 if (code < 32) /* control characters */
76 case 0x7E: // mute, einfg, entf
77 case 0x7F: // backspace
85 for (std::list<eRCDevice*>::iterator i(listeners.begin()); i!=listeners.end(); ++i)
87 // eDebug("ascii %08x", code);
88 (*i)->handleCode(code);
93 void eRCConsole::handleCode(long code)
95 input->keyPressed(eRCKey(this, code, eRCKey::flagAscii));
98 eRCConsole::eRCConsole(eRCDriver *driver)
99 : eRCDevice("Console", driver)
103 const char *eRCConsole::getDescription() const
108 const char *eRCConsole::getKeyDescription(const eRCKey &key) const
113 int eRCConsole::getKeyCompatibleCode(const eRCKey &key) const
120 eRCConsoleDriver driver;
123 eRCConsoleInit(): driver("/dev/vc/0"), device(&driver)
128 eAutoInitP0<eRCConsoleInit> init_rcconsole(eAutoInitNumbers::rc+1, "Console RC Driver");