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)
76 if (strcasestr(id.c_str(), "keyboard") != NULL)
79 eDebug("Input device \"%s\" is %sa keyboard.", id.c_str(), iskeyboard ? "" : "not ");
82 void eRCDeviceInputDev::setExclusive(bool b)
85 driver->setExclusive(b);
88 const char *eRCDeviceInputDev::getDescription() const
93 class eInputDeviceInit
95 ePtrList<eRCInputEventDriver> m_drivers;
96 ePtrList<eRCDeviceInputDev> m_devices;
105 sprintf(filename, "/dev/input/event%d", i);
106 if (stat(filename, &s))
108 eRCInputEventDriver *p;
109 m_drivers.push_back(p = new eRCInputEventDriver(filename));
110 m_devices.push_back(new eRCDeviceInputDev(p));
113 eDebug("Found %d input devices!", i);
118 while (m_drivers.size())
120 delete m_devices.back();
121 m_devices.pop_back();
122 delete m_drivers.back();
123 m_drivers.pop_back();
128 eAutoInitP0<eInputDeviceInit> init_rcinputdev(eAutoInitNumbers::rc+1, "input device driver");