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))
86 eDebug("Input device \"%s\" is %sa keyboard.", id.c_str(), iskeyboard ? "" : "not ");
90 const char *eRCDeviceInputDev::getDescription() const
95 class eInputDeviceInit
97 ePtrList<eRCInputEventDriver> m_drivers;
98 ePtrList<eRCDeviceInputDev> m_devices;
107 sprintf(filename, "/dev/input/event%d", i);
108 if (stat(filename, &s))
110 eRCInputEventDriver *p;
111 m_drivers.push_back(p = new eRCInputEventDriver(filename));
112 m_devices.push_back(new eRCDeviceInputDev(p));
115 eDebug("Found %d input devices!", i);
120 while (m_drivers.size())
122 delete m_devices.back();
123 m_devices.pop_back();
124 delete m_drivers.back();
125 m_drivers.pop_back();
130 eAutoInitP0<eInputDeviceInit> init_rcinputdev(eAutoInitNumbers::rc+1, "input device driver");