{
sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCShortDriver::keyPressed);
- eRCInput::getInstance()->setFile(handle);
}
}
{
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)
+ {
+ int grab = b;
+ if (::ioctl(handle, EVIOCGRAB, grab) < 0)
+ perror("EVIOCGRAB");
+ }
+}
+
eRCInputEventDriver::~eRCInputEventDriver()
{
if (handle>=0)
{
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;
}
* \param key The key to get the description for.
* \result User readable description of given key.
*/
+ virtual void setExclusive(bool b) { };
};
/**
~eRCDriver();
void enable(int en) { enabled=en; }
+ virtual void setExclusive(bool) { }
};
class eRCShortDriver: public eRCDriver
std::string getDeviceName();
eRCInputEventDriver(const char *filename);
~eRCInputEventDriver();
+ void setExclusive(bool b); // in exclusive mode data is not carried to console device
};
class eRCKey
class eRCInput: public Object
{
int locked;
- int handle;
static eRCInput *instance;
int keyboardMode;
#ifdef SWIG
void close();
bool open();
- void setFile(int handle);
-
/* This is only relevant for "keyboard"-styled input devices,
i.e. not plain remote controls. It's up to the input device
driver to decide wheter an input device is a keyboard or
void setKeyboardMode(int mode) { keyboardMode = mode; }
int getKeyboardMode() { return keyboardMode; }
static eRCInput *getInstance() { return instance; }
- int lock();
+ void lock();
void unlock();
int islocked() { return locked; }
};
{
sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
- eRCInput::getInstance()->setFile(handle);
}
/* set console mode */
break;
}
}
+ setExclusive(true);
eDebug("Input device \"%s\" is %sa keyboard.", id.c_str(), iskeyboard ? "" : "not ");
+}
+void eRCDeviceInputDev::setExclusive(bool b)
+{
+ driver->setExclusive(!iskeyboard && b);
}
const char *eRCDeviceInputDev::getDescription() const
void handleCode(long code);
eRCDeviceInputDev(eRCInputEventDriver *driver);
const char *getDescription() const;
+ void setExclusive(bool);
};
#endif