Ps2KeyboardHost  1.0.1
Allows you to read from one or more PS2-style keyboards on an Arduino.
ps2_AnsiTranslator.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Steve Benz <s8878992@hotmail.com>
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 USA
18 */
19 #pragma once
20 
21 #include "ps2_KeyboardLeds.h"
22 #include "ps2_KeyboardOutput.h"
23 
24 namespace ps2 {
38  template <typename Diagnostics = NullDiagnostics>
40  {
41  public:
43  AnsiTranslator(Diagnostics &diagnostics);
44  void reset();
45 
54 
58  inline bool isCtrlKeyDown() const { return this->isCtrlDown; }
59 
63  inline bool isShiftKeyDown() const { return this->isShiftDown; }
64 
69  inline void setCapsLock(bool newCapsLockValue) { this->isCapsLockMode = newCapsLockValue; }
70 
72  inline bool getCapsLock() const { return this->isCapsLockMode; }
73 
78  inline void setNumLock(bool newNumLockValue) { this->isNumLockMode = newNumLockValue; }
79 
81  inline bool getNumLock() const { return this->isNumLockMode; }
82 
83  private:
84  char rawTranslate(KeyboardOutput ps2Key);
85  bool isKeyAffectedByNumlock(KeyboardOutput ps2Key, char rawTranslation);
86 
87  static const char ps2ToAsciiMap[] PROGMEM;
88  static const byte pauseKeySequence[] PROGMEM;
89 
90  bool isSpecial;
91  bool isUnmake;
92  bool isCtrlDown;
93  bool isShiftDown;
94  bool isCapsLockMode;
95  bool isNumLockMode;
96  int pauseKeySequenceIndex;
97  Diagnostics *diagnostics;
98  };
99 }
100 
101 #include "ps2_AnsiTranslator.hpp"
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
bool isCtrlKeyDown() const
Gets the state of the Ctrl key.
Definition: ps2_AnsiTranslator.h:58
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
bool getCapsLock() const
Gets the state of the caps lock mode.
Definition: ps2_AnsiTranslator.h:72
void setCapsLock(bool newCapsLockValue)
Sets the state of the caps lock mode.
Definition: ps2_AnsiTranslator.h:69
void setNumLock(bool newNumLockValue)
Sets the state of the num lock mode.
Definition: ps2_AnsiTranslator.h:78
bool isShiftKeyDown() const
Gets the state of the Shift key.
Definition: ps2_AnsiTranslator.h:63
AnsiTranslator()
Definition: ps2_AnsiTranslator.hpp:147
bool getNumLock() const
Gets the state of the num lock mode.
Definition: ps2_AnsiTranslator.h:81