aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/driver/rc.cpp22
-rw-r--r--lib/driver/rc.h7
-rw-r--r--lib/driver/rcconsole.cpp1
-rw-r--r--lib/driver/rcinput.cpp6
-rw-r--r--lib/driver/rcinput.h1
5 files changed, 17 insertions, 20 deletions
diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp
index 8dab0201..c56fde44 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);
}
}
@@ -132,7 +130,7 @@ void eRCInputEventDriver::setExclusive(bool b)
if (handle >= 0)
{
int grab = b;
- if (::ioctl(handle, EVIOCGRAB, &grab) < 0)
+ if (::ioctl(handle, EVIOCGRAB, grab) < 0)
perror("EVIOCGRAB");
}
}
@@ -175,7 +173,6 @@ eRCInput::eRCInput()
{
ASSERT( !instance);
instance=this;
- handle = -1;
locked = 0;
keyboardMode = kmNone;
}
@@ -193,21 +190,18 @@ bool eRCInput::open()
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)
@@ -226,7 +220,7 @@ eRCDevice *eRCInput::getDevice(const std::string &id)
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;
}
diff --git a/lib/driver/rc.h b/lib/driver/rc.h
index ef0588c4..52909468 100644
--- a/lib/driver/rc.h
+++ b/lib/driver/rc.h
@@ -53,6 +53,7 @@ public:
* \param key The key to get the description for.
* \result User readable description of given key.
*/
+ virtual void setExclusive(bool b) { };
};
/**
@@ -89,6 +90,7 @@ public:
~eRCDriver();
void enable(int en) { enabled=en; }
+ virtual void setExclusive(bool) { }
};
class eRCShortDriver: public eRCDriver
@@ -174,7 +176,6 @@ public:
class eRCInput: public Object
{
int locked;
- int handle;
static eRCInput *instance;
int keyboardMode;
#ifdef SWIG
@@ -200,8 +201,6 @@ public:
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
@@ -238,7 +237,7 @@ public:
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; }
};
diff --git a/lib/driver/rcconsole.cpp b/lib/driver/rcconsole.cpp
index bcce5601..eb5aee3d 100644
--- a/lib/driver/rcconsole.cpp
+++ b/lib/driver/rcconsole.cpp
@@ -16,7 +16,6 @@ eRCConsoleDriver::eRCConsoleDriver(const char *filename): eRCDriver(eRCInput::ge
{
sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
- eRCInput::getInstance()->setFile(handle);
}
/* set console mode */
diff --git a/lib/driver/rcinput.cpp b/lib/driver/rcinput.cpp
index 0aada8df..e593087d 100644
--- a/lib/driver/rcinput.cpp
+++ b/lib/driver/rcinput.cpp
@@ -83,9 +83,13 @@ eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver)
break;
}
}
- driver->setExclusive(!iskeyboard);
+ 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
diff --git a/lib/driver/rcinput.h b/lib/driver/rcinput.h
index c7f56975..3b4579c5 100644
--- a/lib/driver/rcinput.h
+++ b/lib/driver/rcinput.h
@@ -10,6 +10,7 @@ public:
void handleCode(long code);
eRCDeviceInputDev(eRCInputEventDriver *driver);
const char *getDescription() const;
+ void setExclusive(bool);
};
#endif