24 template<
typename Diagnostics>
141 template<
typename Diagnostics>
146 template<
typename Diagnostics>
149 this->isSpecial =
false;
150 this->isUnmake =
false;
151 this->isCtrlDown =
false;
152 this->isShiftDown =
false;
153 this->isCapsLockMode =
false;
154 this->isNumLockMode =
false;
155 this->pauseKeySequenceIndex = 0;
156 this->diagnostics = Diagnostics::defaultInstance();
159 template<
typename Diagnostics>
162 this->isSpecial =
false;
163 this->isUnmake =
false;
164 this->isCtrlDown =
false;
165 this->isShiftDown =
false;
166 this->isCapsLockMode =
false;
167 this->isNumLockMode =
false;
168 this->pauseKeySequenceIndex = 0;
169 this->diagnostics = &diagnostics;
172 template<
typename Diagnostics>
174 this->isSpecial =
false;
175 this->isUnmake =
false;
178 template<
typename Diagnostics>
183 this->isUnmake =
true;
189 this->isSpecial =
true;
194 if ((uint8_t)ps2Scan == pgm_read_byte(pauseKeySequence + this->pauseKeySequenceIndex)) {
195 ++this->pauseKeySequenceIndex;
196 if (this->pauseKeySequenceIndex <
sizeof(pauseKeySequence))
199 this->pauseKeySequenceIndex = 0;
200 this->isSpecial =
false;
201 this->isUnmake =
false;
208 this->isShiftDown = !this->isUnmake;
211 this->isCtrlDown = !this->isUnmake;
217 pauseKeySequenceIndex = 0;
222 this->isUnmake =
false;
223 this->isSpecial =
false;
229 this->isNumLockMode = !this->isNumLockMode;
232 this->isCapsLockMode = !this->isCapsLockMode;
236 char charTranslation = this->rawTranslate(ps2Scan);
237 if (charTranslation ==
'\0') {
240 else if (!this->isNumLockMode && isKeyAffectedByNumlock(ps2Scan, charTranslation)) {
243 else if (charTranslation >=
'a' && charTranslation <=
'z')
250 if (charTranslation >=
'a' && charTranslation <=
'z' && (this->isShiftDown != this->isCapsLockMode)) {
251 charTranslation = charTranslation -
'a' +
'A';
253 if (charTranslation >=
'a' && charTranslation <= 'z' && this->isCtrlDown) {
254 charTranslation = charTranslation -
'a' + 1;
257 else if (this->isShiftDown) {
258 switch (charTranslation) {
260 charTranslation =
'~';
263 charTranslation =
'!';
266 charTranslation =
'@';
269 charTranslation =
'#';
272 charTranslation =
'$';
275 charTranslation =
'%';
278 charTranslation =
'^';
281 charTranslation =
'&';
284 charTranslation =
'*';
287 charTranslation =
'(';
290 charTranslation =
')';
293 charTranslation =
'_';
296 charTranslation =
'+';
299 charTranslation =
'{';
302 charTranslation =
'}';
305 charTranslation =
':';
308 charTranslation =
'"';
311 charTranslation =
'<';
314 charTranslation =
'>';
317 charTranslation =
'?';
320 charTranslation =
'|';
325 return charTranslation;
328 template<
typename Diagnostics>
330 return ((uint8_t)ps2Scan >= 0x0d && ((uint8_t)ps2Scan - 0x0d) <
sizeof(ps2ToAsciiMap))
331 ? (char)pgm_read_byte(ps2ToAsciiMap + (uint8_t)ps2Scan - 0x0d)
335 template<
typename Diagnostics>
339 return rawTranslation ==
'.' || (rawTranslation >=
'0' && rawTranslation <=
'9');
char translatePs2Keycode(ps2::KeyboardOutput ps2Scan)
Processes the given scan code from the keyboard. It only gives you keydown events for keys that have ...
Definition: ps2_AnsiTranslator.hpp:179
Definition: ps2_AnsiTranslator.h:24
This class provides a translation from PS2 incoming scancodes to Ansi. Right now, the name "Ansi" is ...
Definition: ps2_AnsiTranslator.h:39
void reset()
Definition: ps2_AnsiTranslator.hpp:173
KeyboardOutput
Byte-codes sent back from the Ps2 keyboard to the host.
Definition: ps2_KeyboardOutput.h:31
AnsiTranslator()
Definition: ps2_AnsiTranslator.hpp:147
const char AnsiTranslator< Diagnostics >::ps2ToAsciiMap [] PROGMEM
Definition: ps2_AnsiTranslator.hpp:25