#include <lib/base/init.h>
#include <lib/base/init_num.h>
-#include <lib/base/econfig.h>
#include <lib/base/eerror.h>
/*
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);
}
}
{
if (handle>=0)
close(handle);
- if (sn)
- delete sn;
}
void eRCInputEventDriver::keyPressed(int)
break;
if (enabled && !input->islocked())
for (std::list<eRCDevice*>::iterator i(listeners.begin()); i!=listeners.end(); ++i)
- (*i)->handleCode((int)&ev);
+ (*i)->handleCode((long)&ev);
}
}
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);
}
}
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()
{
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;
{
ASSERT( !instance);
instance=this;
- handle = -1;
locked = 0;
keyboardMode = kmNone;
}
return false;
}
-int eRCInput::lock()
+void eRCInput::lock()
{
locked=1;
- return handle;
+ for (std::map<std::string,eRCDevice*>::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<std::string,eRCDevice*>::iterator i=devices.begin(); i != devices.end(); ++i)
+ i->second->setExclusive(true);
}
void eRCInput::addDevice(const std::string &id, eRCDevice *dev)
if (i == devices.end())
{
eDebug("failed, possible choices are:");
- for (std::map<std::string,eRCDevice*>::iterator i=devices.begin(); i != devices.end(); ++i)
+ for (std::map<std::string,eRCDevice*>::iterator i=devices.begin(); i != devices.end(); ++i)
eDebug("%s", i->first.c_str());
return 0;
}