X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5..2b47f0d63cb4d1bfb1979bc777795a834763db9a:/lib/driver/rc.cpp diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp index 790c5f6c..c56fde44 100644 --- a/lib/driver/rc.cpp +++ b/lib/driver/rc.cpp @@ -8,7 +8,6 @@ #include #include -#include #include /* @@ -35,12 +34,7 @@ * actions. have fun. */ -int eRCDevice::getKeyCompatibleCode(const eRCKey &) const -{ - return -1; -} - -eRCDevice::eRCDevice(eString id, eRCDriver *driver): driver(driver), id(id) +eRCDevice::eRCDevice(std::string id, eRCDriver *driver): driver(driver), id(id) { input=driver->getInput(); driver->addCodeListener(this); @@ -85,9 +79,8 @@ eRCShortDriver::eRCShortDriver(const char *filename): eRCDriver(eRCInput::getIns sn=0; } else { - sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read); + sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read); CONNECT(sn->activated, eRCShortDriver::keyPressed); - eRCInput::getInstance()->setFile(handle); } } @@ -95,8 +88,6 @@ eRCShortDriver::~eRCShortDriver() { if (handle>=0) close(handle); - if (sn) - delete sn; } void eRCInputEventDriver::keyPressed(int) @@ -108,7 +99,7 @@ void eRCInputEventDriver::keyPressed(int) break; if (enabled && !input->islocked()) for (std::list::iterator i(listeners.begin()); i!=listeners.end(); ++i) - (*i)->handleCode((int)&ev); + (*i)->handleCode((long)&ev); } } @@ -121,13 +112,12 @@ eRCInputEventDriver::eRCInputEventDriver(const char *filename): eRCDriver(eRCInp sn=0; } else { - sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read); + sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read); CONNECT(sn->activated, eRCInputEventDriver::keyPressed); - eRCInput::getInstance()->setFile(handle); } } -eString eRCInputEventDriver::getDeviceName() +std::string eRCInputEventDriver::getDeviceName() { char name[128]=""; if (handle >= 0) @@ -135,12 +125,20 @@ eString eRCInputEventDriver::getDeviceName() return name; } +void eRCInputEventDriver::setExclusive(bool b) +{ + if (handle >= 0) + { + int grab = b; + if (::ioctl(handle, EVIOCGRAB, grab) < 0) + perror("EVIOCGRAB"); + } +} + eRCInputEventDriver::~eRCInputEventDriver() { if (handle>=0) close(handle); - if (sn) - delete sn; } eRCConfig::eRCConfig() @@ -163,15 +161,10 @@ void eRCConfig::reload() { rdelay=500; rrate=100; - if ( eConfig::getInstance()->getKey("/ezap/rc/repeatRate", rrate) ) - save(); - eConfig::getInstance()->getKey("/ezap/rc/repeatDelay", rdelay); } void eRCConfig::save() { - eConfig::getInstance()->setKey("/ezap/rc/repeatRate", rrate); - eConfig::getInstance()->setKey("/ezap/rc/repeatDelay", rdelay); } eRCInput *eRCInput::instance; @@ -180,8 +173,8 @@ eRCInput::eRCInput() { ASSERT( !instance); instance=this; - handle = -1; locked = 0; + keyboardMode = kmNone; } eRCInput::~eRCInput() @@ -197,47 +190,44 @@ bool eRCInput::open() return false; } -int eRCInput::lock() +void eRCInput::lock() { locked=1; - return handle; + for (std::map::iterator i=devices.begin(); i != devices.end(); ++i) + i->second->setExclusive(false); } void eRCInput::unlock() { - if (locked) - locked=0; -} - -void eRCInput::setFile(int newh) -{ - handle=newh; + locked=0; + for (std::map::iterator i=devices.begin(); i != devices.end(); ++i) + i->second->setExclusive(true); } -void eRCInput::addDevice(const eString &id, eRCDevice *dev) +void eRCInput::addDevice(const std::string &id, eRCDevice *dev) { - devices.insert(std::pair(id, dev)); + devices.insert(std::pair(id, dev)); } -void eRCInput::removeDevice(const eString &id) +void eRCInput::removeDevice(const std::string &id) { devices.erase(id); } -eRCDevice *eRCInput::getDevice(const eString &id) +eRCDevice *eRCInput::getDevice(const std::string &id) { - std::map::iterator i=devices.find(id); + std::map::iterator i=devices.find(id); if (i == devices.end()) { eDebug("failed, possible choices are:"); - for (std::map::iterator i=devices.begin(); i != devices.end(); ++i) + for (std::map::iterator i=devices.begin(); i != devices.end(); ++i) eDebug("%s", i->first.c_str()); return 0; } return i->second; } -std::map &eRCInput::getDevices() +std::map &eRCInput::getDevices() { return devices; }