1 #include <lib/driver/rcinput.h>
3 #include <lib/base/eerror.h>
6 #include <linux/input.h>
9 #include <lib/base/ebase.h>
10 #include <lib/base/init.h>
11 #include <lib/base/init_num.h>
12 #include <lib/driver/input_fake.h>
14 void eRCDeviceInputDev::handleCode(long rccode)
16 struct input_event *ev = (struct input_event *)rccode;
20 // eDebug("%x %x %x", ev->value, ev->code, ev->type);
25 int km = iskeyboard ? input->getKeyboardMode() : eRCInput::kmNone;
27 // eDebug("keyboard mode %d", km);
29 if (km == eRCInput::kmAll)
32 if (km == eRCInput::kmAscii)
34 // eDebug("filtering.. %d", ev->code);
35 bool filtered = ( ev->code > 0 && ev->code < 61 );
62 /*emit*/ input->keyPressed(eRCKey(this, ev->code, eRCKey::flagBreak));
65 /*emit*/ input->keyPressed(eRCKey(this, ev->code, 0));
68 /*emit*/ input->keyPressed(eRCKey(this, ev->code, eRCKey::flagRepeat));
73 eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver)
74 :eRCDevice(driver->getDeviceName(), driver), iskeyboard(false)
80 if (!strncasecmp(&id[idx++], "KEYBOARD", 8))
87 eDebug("Input device \"%s\" is %sa keyboard.", id.c_str(), iskeyboard ? "" : "not ");
90 void eRCDeviceInputDev::setExclusive(bool b)
93 driver->setExclusive(b);
96 const char *eRCDeviceInputDev::getDescription() const
101 class eInputDeviceInit
103 ePtrList<eRCInputEventDriver> m_drivers;
104 ePtrList<eRCDeviceInputDev> m_devices;
113 sprintf(filename, "/dev/input/event%d", i);
114 if (stat(filename, &s))
116 eRCInputEventDriver *p;
117 m_drivers.push_back(p = new eRCInputEventDriver(filename));
118 m_devices.push_back(new eRCDeviceInputDev(p));
121 eDebug("Found %d input devices!", i);
126 while (m_drivers.size())
128 delete m_devices.back();
129 m_devices.pop_back();
130 delete m_drivers.back();
131 m_drivers.pop_back();
136 eAutoInitP0<eInputDeviceInit> init_rcinputdev(eAutoInitNumbers::rc+1, "input device driver");