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);
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);
37 void eRCConsoleDriver::keyPressed(int)
39 unsigned char data[16];
40 unsigned char *d = data;
41 int num = read(handle, data, 16);
44 int km = input->getKeyboardMode();
46 if (km == eRCInput::kmNone)
51 // eDebug("console code %08x\n", *d);
52 if (km == eRCInput::kmAll)
56 if (*d == 27) // escape code
69 if (code < 32) /* control characters */
73 case 0x7E: // mute, einfg, entf
74 case 0x7F: // backspace
82 for (std::list<eRCDevice*>::iterator i(listeners.begin()); i!=listeners.end(); ++i)
84 // eDebug("ascii %08x", code);
85 (*i)->handleCode(code);
90 void eRCConsole::handleCode(long code)
92 input->keyPressed(eRCKey(this, code, eRCKey::flagAscii));
95 eRCConsole::eRCConsole(eRCDriver *driver)
96 : eRCDevice("Console", driver)
100 const char *eRCConsole::getDescription() const
105 const char *eRCConsole::getKeyDescription(const eRCKey &key) const
110 int eRCConsole::getKeyCompatibleCode(const eRCKey &key) const
117 eRCConsoleDriver driver;
120 eRCConsoleInit(): driver("/dev/vc/0"), device(&driver)
125 eAutoInitP0<eRCConsoleInit> init_rcconsole(eAutoInitNumbers::rc+1, "Console RC Driver");