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.
57 * Receives codes from one or more remote controls.
59 class eRCDriver: public Object
62 std::list<eRCDevice*> listeners;
67 * \brief Constructs a driver.
69 * \param input The RCInput to bind this driver to.
71 eRCDriver(eRCInput *input);
73 * \brief Get pointer to key-consumer.
75 eRCInput *getInput() const { return input; }
77 * \brief Adds a code lister
79 void addCodeListener(eRCDevice *dev)
81 listeners.push_back(dev);
83 void removeCodeListener(eRCDevice *dev)
85 listeners.remove(dev);
89 void enable(int en) { enabled=en; }
92 class eRCShortDriver: public eRCDriver
99 eRCShortDriver(const char *filename);
103 class eRCInputEventDriver: public eRCDriver
108 void keyPressed(int);
110 std::string getDeviceName();
111 eRCInputEventDriver(const char *filename);
112 ~eRCInputEventDriver();
121 eRCKey(eRCDevice *producer, int code, int flags):
122 producer(producer), code(code), flags(flags)
131 bool operator<(const eRCKey &r) const
133 if (r.producer == producer)
141 } else if (r.code < code)
145 } else if (r.producer < producer)
159 void set(int delay, int repeat);
160 int rdelay, // keypress delay after first keypress to begin of repeat (in ms)
161 rrate; // repeat rate (in ms)
164 class eRCInput: public Object
168 static eRCInput *instance;
173 bool operator()(const std::string &a, const std::string &b) const
179 std::map<std::string,eRCDevice*,lstr> devices;
181 Signal1<void, const eRCKey&> keyEvent;
187 int islocked() { return locked; }
191 void setFile(int handle);
193 void keyPressed(const eRCKey &key)
195 /*emit*/ keyEvent(key);
198 void addDevice(const std::string &id, eRCDevice *dev);
199 void removeDevice(const std::string &id);
200 eRCDevice *getDevice(const std::string &id);
201 std::map<std::string,eRCDevice*,lstr> &getDevices();
203 static eRCInput *getInstance() { return instance; }