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;
174 bool operator()(const std::string &a, const std::string &b) const
180 std::map<std::string,eRCDevice*,lstr> devices;
182 Signal1<void, const eRCKey&> keyEvent;
188 int islocked() { return locked; }
192 void setFile(int handle);
194 /* This is only relevant for "keyboard"-styled input devices,
195 i.e. not plain remote controls. It's up to the input device
196 driver to decide wheter an input device is a keyboard or
199 kmNone will ignore all Ascii Characters sent from the
200 keyboard/console driver, only give normal keycodes to the
203 kmAscii will filter out all keys which produce ascii characters,
204 and send them instead. Note that Modifiers like shift will still
205 be send. Control keys which produce escape codes are send using
208 kmAll will ignore all keycodes, and send everything as ascii,
209 including escape codes. Pretty much useless, since you should
210 lock the console and pass this as the console fd for making the
214 enum { kmNone, kmAscii, kmAll };
215 void setKeyboardMode(int mode) { keyboardMode = mode; }
216 int getKeyboardMode() { return keyboardMode; }
218 void keyPressed(const eRCKey &key)
220 /*emit*/ keyEvent(key);
223 void addDevice(const std::string &id, eRCDevice *dev);
224 void removeDevice(const std::string &id);
225 eRCDevice *getDevice(const std::string &id);
226 std::map<std::string,eRCDevice*,lstr> &getDevices();
228 static eRCInput *getInstance() { return instance; }