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)
92 driver->setExclusive(!iskeyboard && b);
95 const char *eRCDeviceInputDev::getDescription() const
100 class eInputDeviceInit
102 ePtrList<eRCInputEventDriver> m_drivers;
103 ePtrList<eRCDeviceInputDev> m_devices;
112 sprintf(filename, "/dev/input/event%d", i);
113 if (stat(filename, &s))
115 eRCInputEventDriver *p;
116 m_drivers.push_back(p = new eRCInputEventDriver(filename));
117 m_devices.push_back(new eRCDeviceInputDev(p));
120 eDebug("Found %d input devices!", i);
125 while (m_drivers.size())
127 delete m_devices.back();
128 m_devices.pop_back();
129 delete m_drivers.back();
130 m_drivers.pop_back();
135 eAutoInitP0<eInputDeviceInit> init_rcinputdev(eAutoInitNumbers::rc+1, "input device driver");