7 #include <lib/base/ebase.h>
8 #include <libsig_comp.h>
16 * \brief A remote control.
18 * Handles one remote control. Gets codes from a \ref eRCDriver. Produces events in \ref eRCInput.
20 class eRCDevice: public Object
28 * \brief Constructs a new remote control.
30 * \param id The identifier of the RC, for use in settings.
31 * \param input The \ref eRCDriver where this remote gets its codes from.
33 eRCDevice(std::string id, eRCDriver *input);
36 * \brief Handles a device specific code.
38 * Generates events in \ref eRCInput. code is highly device- and driver dependant.
39 * For Example, it might be 16bit codes with one bit make/break or special codes
42 virtual void handleCode(int code)=0;
44 * \brief Get user readable description.
45 * \result The description.
47 virtual const char *getDescription() const=0;
48 const std::string getIdentifier() const { return id; }
50 * \brief Get a description for a specific key.
51 * \param key The key to get the description for.
52 * \result User readable description of given key.
54 virtual const char *getKeyDescription(const eRCKey &key) const=0;
56 * \brief Get a dbox2-compatible keycode.
58 * THIS IS DEPRECATED! DON'T USE IT UNLESS YOU NEED IT!
59 * \param key The key to get the compatible code for.
60 * \result The dbox2-compatible code. (new RC as defined in enum).
62 virtual int getKeyCompatibleCode(const eRCKey &key) const;
66 * Receives codes from one or more remote controls.
68 class eRCDriver: public Object
71 std::list<eRCDevice*> listeners;
76 * \brief Constructs a driver.
78 * \param input The RCInput to bind this driver to.
80 eRCDriver(eRCInput *input);
82 * \brief Get pointer to key-consumer.
84 eRCInput *getInput() const { return input; }
86 * \brief Adds a code lister
88 void addCodeListener(eRCDevice *dev)
90 listeners.push_back(dev);
92 void removeCodeListener(eRCDevice *dev)
94 listeners.remove(dev);
98 void enable(int en) { enabled=en; }
101 class eRCShortDriver: public eRCDriver
106 void keyPressed(int);
108 eRCShortDriver(const char *filename);
112 class eRCInputEventDriver: public eRCDriver
117 void keyPressed(int);
119 std::string getDeviceName();
120 eRCInputEventDriver(const char *filename);
121 ~eRCInputEventDriver();
130 eRCKey(eRCDevice *producer, int code, int flags):
131 producer(producer), code(code), flags(flags)
140 bool operator<(const eRCKey &r) const
142 if (r.producer == producer)
150 } else if (r.code < code)
154 } else if (r.producer < producer)
168 void set(int delay, int repeat);
169 int rdelay, // keypress delay after first keypress to begin of repeat (in ms)
170 rrate; // repeat rate (in ms)
173 class eRCInput: public Object
177 static eRCInput *instance;
182 bool operator()(const std::string &a, const std::string &b) const
188 std::map<std::string,eRCDevice*,lstr> devices;
190 Signal1<void, const eRCKey&> keyEvent;
193 RC_0=0, RC_1=0x1, RC_2=0x2, RC_3=0x3, RC_4=0x4, RC_5=0x5, RC_6=0x6, RC_7=0x7,
195 RC_RIGHT=10, RC_LEFT=11, RC_UP=12, RC_DOWN=13, RC_OK=14, RC_MUTE=15,
196 RC_STANDBY=16, RC_GREEN=17, RC_YELLOW=18, RC_RED=19, RC_BLUE=20, RC_PLUS=21, RC_MINUS=22,
197 RC_HELP=23, RC_DBOX=24,
198 RC_UP_LEFT=27, RC_UP_RIGHT=28, RC_DOWN_LEFT=29, RC_DOWN_RIGHT=30, RC_HOME=31
205 int islocked() { return locked; }
209 void setFile(int handle);
211 void keyPressed(const eRCKey &key)
213 /*emit*/ keyEvent(key);
216 void addDevice(const std::string &id, eRCDevice *dev);
217 void removeDevice(const std::string &id);
218 eRCDevice *getDevice(const std::string &id);
219 std::map<std::string,eRCDevice*,lstr> &getDevices();
221 static eRCInput *getInstance() { return instance; }