X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdriver%2Frc.cpp;h=c1ff13ea7dee30a539a3520935d621b3a180c0d4;hp=d4664896fa75225722954ec1e657e32aa59e5625;hb=849b33656dc710cfa5f644a55680fd396ab1d8d7;hpb=87bfe5dfced0fb7a4e9839fdafa898261a39c86c diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp index d466489..c1ff13e 100644 --- a/lib/driver/rc.cpp +++ b/lib/driver/rc.cpp @@ -8,7 +8,6 @@ #include #include -#include #include /* @@ -80,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); } } @@ -90,8 +88,6 @@ eRCShortDriver::~eRCShortDriver() { if (handle>=0) close(handle); - if (sn) - delete sn; } void eRCInputEventDriver::keyPressed(int) @@ -103,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); } } @@ -116,9 +112,8 @@ 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); } } @@ -130,12 +125,23 @@ std::string eRCInputEventDriver::getDeviceName() return name; } +void eRCInputEventDriver::setExclusive(bool b) +{ + if (handle >= 0) + { + long evbits; + int grab = b; + if (::ioctl(handle, EVIOCGBIT(0, EV_MAX+1), &evbits) < 0) + perror("EVIOCGBIT"); + else if ((evbits & (1 << 0x1E)) && ::ioctl(handle, EVIOCGRAB, grab) < 0) + perror("EVIOCGRAB"); + } +} + eRCInputEventDriver::~eRCInputEventDriver() { if (handle>=0) close(handle); - if (sn) - delete sn; } eRCConfig::eRCConfig() @@ -158,15 +164,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; @@ -175,9 +176,8 @@ eRCInput::eRCInput() { ASSERT( !instance); instance=this; - handle = -1; locked = 0; - keyboardMode = kmAll; + keyboardMode = kmNone; } eRCInput::~eRCInput() @@ -193,21 +193,18 @@ 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 std::string &id, eRCDevice *dev) @@ -226,7 +223,7 @@ eRCDevice *eRCInput::getDevice(const std::string &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; }