Merge branch 'bug_167_bsbe2_tone_amplitude'
authorghost <andreas.monzner@multimedia-labs.de>
Tue, 29 Dec 2009 12:16:59 +0000 (13:16 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Tue, 29 Dec 2009 12:16:59 +0000 (13:16 +0100)
data/keymap.xml
lib/driver/rc.cpp
lib/driver/rc.h
lib/driver/rcconsole.cpp
lib/driver/rcinput.cpp
lib/driver/rcinput.h
lib/python/Screens/Satconfig.py

index 25538f8..9461d50 100755 (executable)
                <key id="KEY_BLUE" mapto="extensions" flags="b" />
        </map>
        
+       <map context="SatlistShortcutAction">
+               <key id="KEY_BLUE" mapto="nothingconnected" flags="b" />
+       </map>
+       
        <map context="InfobarChannelSelection">
                <key id="KEY_LEFT" mapto="zapUp" flags="mr" />
                <key id="KEY_RIGHT" mapto="zapDown" flags="mr" />
index c7acd11..c56fde4 100644 (file)
@@ -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);
        }
 }
 
@@ -127,6 +125,16 @@ std::string eRCInputEventDriver::getDeviceName()
        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)
@@ -165,7 +173,6 @@ eRCInput::eRCInput()
 {
        ASSERT( !instance);
        instance=this;
-       handle = -1;
        locked = 0;
        keyboardMode = kmNone;
 }
@@ -183,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)
@@ -216,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;
        }
index 9708ea7..5290946 100644 (file)
@@ -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
@@ -112,6 +114,7 @@ public:
        std::string getDeviceName();
        eRCInputEventDriver(const char *filename);
        ~eRCInputEventDriver();
+       void setExclusive(bool b); // in exclusive mode data is not carried to console device
 };
 
 class eRCKey
@@ -173,7 +176,6 @@ public:
 class eRCInput: public Object
 {
        int locked;     
-       int handle;
        static eRCInput *instance;
        int keyboardMode;
 #ifdef SWIG
@@ -199,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
@@ -237,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; }
 };
index bcce560..eb5aee3 100644 (file)
@@ -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 */
index d10d94f..e593087 100644 (file)
@@ -83,8 +83,13 @@ eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver)
                        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
index c7f5697..3b4579c 100644 (file)
@@ -10,6 +10,7 @@ public:
        void handleCode(long code);
        eRCDeviceInputDev(eRCInputEventDriver *driver);
        const char *getDescription() const;
+       void setExclusive(bool);
 };
 
 #endif
index 634d231..d5249b9 100644 (file)
@@ -5,7 +5,8 @@ from Components.ActionMap import ActionMap
 from Components.ConfigList import ConfigListScreen
 from Components.MenuList import MenuList
 from Components.NimManager import nimmanager
-from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, updateConfigElement
+from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, updateConfigElement,\
+       ConfigSatlist
 from Components.Sources.List import List
 from Screens.MessageBox import MessageBox
 from Screens.ChoiceBox import ChoiceBox
@@ -383,10 +384,11 @@ class NimSetup(Screen, ConfigListScreen):
 
                ConfigListScreen.__init__(self, self.list)
 
-               self["actions"] = ActionMap(["SetupActions"],
+               self["actions"] = ActionMap(["SetupActions", "SatlistShortcutAction"],
                {
                        "ok": self.keySave,
                        "cancel": self.keyCancel,
+                       "nothingconnected": self.nothingConnectedShortcut
                }, -2)
 
                self.slotid = slotid
@@ -423,6 +425,11 @@ class NimSetup(Screen, ConfigListScreen):
                # we need to call saveAll to reset the connectedTo choices
                self.saveAll()
                self.close()
+               
+       def nothingConnectedShortcut(self):
+               if type(self["config"].getCurrent()[1]) is ConfigSatlist:
+                       self["config"].getCurrent()[1].setValue("3601")
+                       self["config"].invalidateCurrent()
                        
 class NimSelection(Screen):
        def __init__(self, session):