4 // The generic remote controller.
7 #include "pirkeynames.h"
12 // We'll define a maximum number of repetitions, regardless of how long the
13 // user presses the button. (This is just in case we miss the point at which
14 // he stops pressing it...) 500 should be plenty.
15 #define MAX_REPEAT_COUNT 500
17 typedef std::deque<bool> CommandSequence;
19 // As I've learned more about IR protocols, the concept of what a specific
20 // key is gets more and more complex. To deal with this, I'm going to allow
21 // a key to have more than one command sequence associated with it. (I need
22 // up to three codes for Sony keys, and as many as four to define an
23 // individual Pioneer key.)
27 CommandSequence firstCode;
28 CommandSequence secondCode;
29 CommandSequence thirdCode;
30 CommandSequence fourthCode;
33 // I'll go ahead and use associative arrays to build up lists of keycodes.
34 typedef std::map<int, PIRKeyBits> KeycodeCollection;
37 // Right now, the only reason for this object to inherit from QObject is
38 // so it can participate in Qt-style threading. Note that it has no
39 // event loop, and no access to the GUI, so don't go trying to communicate
40 // with the user here...
41 class PIRProtocol: public QObject
57 // A special addKey used for Sony's SIRC protocol:
60 unsigned int addressData,
62 unsigned int commandData);
66 unsigned int secondaryAddressData,
67 unsigned int primaryAddressData,
68 unsigned int commandData);
72 unsigned int addressData,
73 unsigned int commandData);
77 unsigned int addressData,
78 unsigned int commandData);
82 unsigned int firstAddress,
83 unsigned int firstCommand,
84 unsigned int secondAddress,
85 unsigned int secondCommand);
90 unsigned int addressData,
91 unsigned int commandData);
96 unsigned int addressData,
97 unsigned int commandData);
99 void setCarrierFrequency(
105 void setMinimumRepetitions(
106 unsigned int minrep);
117 virtual void startSendingCommand(
118 unsigned int threadableID,
119 PIRKeyName command) = 0;
123 const char *errString);
126 bool isCommandSupported(
129 void clearRepeatFlag();
130 bool checkRepeatFlag();
132 unsigned int carrierFrequency;
133 unsigned int dutyCycle;
136 CommandSequence &bits,
140 KeycodeCollection keycodes;
142 // A sleep function for all protocols:
143 void sleepUntilRepeat(
144 int commandDuration);
146 // The "gap" parameter from LIRC. If the commands are "variable-length",
147 // this indicates the amount of time between the last pulse of one
148 // command and the first pulse of the next. If "constant-length", it is
149 // the time between the _first_ pulse of one command and the first pulse
152 bool isConstantLength;
155 // More administrative data wrapped around the actual command:
156 CommandSequence preData;
157 CommandSequence postData;
159 // Some remotes require a minimum number of repetitions:
160 // Note: thinking about removing this -- don't know if it is needed
161 int minimumRepetitions;
166 #endif // PIRPROTOCOL_H