+
Remote Control
+
+The joy of zapping!
+
+There are several ways to control the operation of VDR. The builtin methods
+are using the PC keyboard, a homebuilt RCU unit or the LIRC interface.
+Of course there may be many more ways you might think of to implement a
+remote control, so a plugin can use the cRemote class to do that.
+
+The simplest method for a plugin to issue commands to VDR is to call the
+static function cRemote::Put(eKeys Key), as in
+
+
+
+In this case the plugin must do the mapping of whatever incoming signal or code
+it processes to the eKeys values itself. This makes sense if the incoming
+codes are well known and won't ever change.
+
+In cases where the incoming codes are not known, or not all available keys may
+be supported by the actual remote control in use, you may want to derive your
+own remote control class from cRemote, as in
+
+
+#include <vdr/remote.h>
+#include <vdr/thread.h>
+
+class cMyRemote : public cRemote, private cThread {
+private:
+ virtual void Action(void);
+public:
+ cMyRemote(const char *Name);
+ virtual bool Initialize(void);
+ };
+
|
+
+Note that deriving from cThread is not required for a remote control
+class to work, but typically you may want to have a separate thread running that
+collects the input and delivers it to the cRemote base class.
+
+You should create your derived remote control object in the
+Start() function of your plugin.
+Note that the object has to be created on the heap (using new),
+and you shall not delete it at any point (it will be deleted automatically
+when the program ends).
+
+The constructor of your remote control class should look like this
+
+
+cMyRemote::cMyRemote(const char *Name)
+:cRemote(Name)
+{
+ Start();
+}
+
|
+
+The Name is important in order for the cRemote base class
+to be able to distinguish the codes for the various remote controls.
+When creating your cMyRemote object you should use the value returned
+by the Name() member function of the plugin class, which returns the
+plugin's name. Calling Start() will start the thread that collects
+the incoming data (by calling your Action() function).
+In case you need to do any other setup steps, like opening a file or initializing
+member variables, you should do so before calling Start().
+
+VDR will handle everything necessary to learn the key mappings of your remote
+control. In order to do so, it will first call the virtual function Initialize(),
+in which you should take all necessary steps to make sure your remote control
+can be accessed. This may, for instance, include trying various communications
+protocols. Initialize(), if implemented, shall only return after it has
+made sure data can be received from the remote control. Before calling this
+function, VDR will prompt the user on the OSD to press any key on the remote control.
+As soon as your derived cRemote class has detected useful incoming data,
+Initialize() should return true. If any fatal error occurs, false
+should be returned.
+
+If your remote control class needs some setup data that shall be
+readily available next time VDR starts (without having to go through the initialization
+procedure again) it can use the cRemote member functions
+
+
+void PutSetup(const char *Setup);
+const char *GetSetup(void);
+
|
+
+to store and retrieve a character string containing whatever data is needed.
+Note that the Initialize() function will only be called if there are
+no key mappings known for this remote control. Once the key mappings have been
+learned, Initialize() will never be called again.
+
+The cRemote class assumes that any incoming remote control code can be
+expressed as a character string. So whatever data your remote control provides
+needs to be given to the base class by calling
+
+
+Put(const char *Code, bool Repeat = false, bool Release = false);
+
|
+
+where Code is the string representation of the remote control's
+incoming data. Repeat and Release are boolean flags that
+indicate whether this is a repeated keypress, or the key has been released.
+Since a common case for remote control data is to be given as a numerical
+value, there is another Put() function available for your convenience,
+which takes a 64 bit unsigned integer value instead of a character string:
+
+
+Put(uint64 Code, bool Repeat = false, bool Release = false);
+
|
+
+The other parameters have the same meaning as in the first version of this function.
+ |