X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdriver%2Frc.cpp;h=c1ff13ea7dee30a539a3520935d621b3a180c0d4;hp=8dab02013ba681285ede65264d024ddd76ba435a;hb=ba5ec76317a3bd96895506159b0d5bc1a1a6eecc;hpb=089c965d09e2af09a4731ff164e1b68b3daf8047 diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp index 8dab020..c1ff13e 100644 --- a/lib/driver/rc.cpp +++ b/lib/driver/rc.cpp @@ -81,7 +81,6 @@ eRCShortDriver::eRCShortDriver(const char *filename): eRCDriver(eRCInput::getIns { sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read); CONNECT(sn->activated, eRCShortDriver::keyPressed); - eRCInput::getInstance()->setFile(handle); } } @@ -115,7 +114,6 @@ eRCInputEventDriver::eRCInputEventDriver(const char *filename): eRCDriver(eRCInp { sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read); CONNECT(sn->activated, eRCInputEventDriver::keyPressed); - eRCInput::getInstance()->setFile(handle); } } @@ -131,8 +129,11 @@ void eRCInputEventDriver::setExclusive(bool b) { if (handle >= 0) { + long evbits; int grab = b; - if (::ioctl(handle, EVIOCGRAB, &grab) < 0) + if (::ioctl(handle, EVIOCGBIT(0, EV_MAX+1), &evbits) < 0) + perror("EVIOCGBIT"); + else if ((evbits & (1 << 0x1E)) && ::ioctl(handle, EVIOCGRAB, grab) < 0) perror("EVIOCGRAB"); } } @@ -175,7 +176,6 @@ eRCInput::eRCInput() { ASSERT( !instance); instance=this; - handle = -1; locked = 0; keyboardMode = kmNone; } @@ -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; }