Ps2KeyboardHost  1.0.1
Allows you to read from one or more PS2-style keyboards on an Arduino.
ps2::AnsiTranslator< Diagnostics > Class Template Reference

This class provides a translation from PS2 incoming scancodes to Ansi. Right now, the name "Ansi" is aspirational, as the implementation given here only works for English keyboards. More...

#include <ps2_AnsiTranslator.h>

Public Member Functions

 AnsiTranslator ()
 
 AnsiTranslator (Diagnostics &diagnostics)
 
void reset ()
 
char translatePs2Keycode (ps2::KeyboardOutput ps2Scan)
 Processes the given scan code from the keyboard. It only gives you keydown events for keys that have an ansi translation (e.g. the "g" key has an effect, the "Home" key does not.) More...
 
bool isCtrlKeyDown () const
 Gets the state of the Ctrl key. More...
 
bool isShiftKeyDown () const
 Gets the state of the Shift key. More...
 
void setCapsLock (bool newCapsLockValue)
 Sets the state of the caps lock mode. More...
 
bool getCapsLock () const
 Gets the state of the caps lock mode. More...
 
void setNumLock (bool newNumLockValue)
 Sets the state of the num lock mode. More...
 
bool getNumLock () const
 Gets the state of the num lock mode. More...
 

Detailed Description

template<typename Diagnostics = NullDiagnostics>
class ps2::AnsiTranslator< Diagnostics >

This class provides a translation from PS2 incoming scancodes to Ansi. Right now, the name "Ansi" is aspirational, as the implementation given here only works for English keyboards.

This will translate shift keys, caps lock, num lock and the ctrl key. E.g. if the user types "Ctrl+G", translatePs2Keycode will return Ascii 7. If the caps lock key has been pressed before and the user types "g", it will return 'G'. If the user types shift+H under these circumstances, it will return 'h'.

Template Parameters
DiagnosticsA sink for debugging information.

Constructor & Destructor Documentation

◆ AnsiTranslator() [1/2]

template<typename Diagnostics >
ps2::AnsiTranslator< Diagnostics >::AnsiTranslator ( )

◆ AnsiTranslator() [2/2]

template<typename Diagnostics >
ps2::AnsiTranslator< Diagnostics >::AnsiTranslator ( Diagnostics &  diagnostics)

Member Function Documentation

◆ getCapsLock()

template<typename Diagnostics = NullDiagnostics>
bool ps2::AnsiTranslator< Diagnostics >::getCapsLock ( ) const
inline

Gets the state of the caps lock mode.

◆ getNumLock()

template<typename Diagnostics = NullDiagnostics>
bool ps2::AnsiTranslator< Diagnostics >::getNumLock ( ) const
inline

Gets the state of the num lock mode.

◆ isCtrlKeyDown()

template<typename Diagnostics = NullDiagnostics>
bool ps2::AnsiTranslator< Diagnostics >::isCtrlKeyDown ( ) const
inline

Gets the state of the Ctrl key.

Returns
True if the key was pressed down as of the last call to translatePs2Keycode.

◆ isShiftKeyDown()

template<typename Diagnostics = NullDiagnostics>
bool ps2::AnsiTranslator< Diagnostics >::isShiftKeyDown ( ) const
inline

Gets the state of the Shift key.

Returns
True if the key was pressed down as of the last call to translatePs2Keycode.

◆ reset()

template<typename Diagnostics >
void ps2::AnsiTranslator< Diagnostics >::reset ( )

◆ setCapsLock()

template<typename Diagnostics = NullDiagnostics>
void ps2::AnsiTranslator< Diagnostics >::setCapsLock ( bool  newCapsLockValue)
inline

Sets the state of the caps lock mode.

Note that this has no effect on the PS2 keyboard or the PS2 keyboard LED. It just effects how keypresses are translated.

◆ setNumLock()

template<typename Diagnostics = NullDiagnostics>
void ps2::AnsiTranslator< Diagnostics >::setNumLock ( bool  newNumLockValue)
inline

Sets the state of the num lock mode.

Note that this has no effect on the PS2 keyboard or the PS2 keyboard LED. It just effects how keypresses are translated.

◆ translatePs2Keycode()

template<typename Diagnostics >
char ps2::AnsiTranslator< Diagnostics >::translatePs2Keycode ( ps2::KeyboardOutput  ps2Scan)

Processes the given scan code from the keyboard. It only gives you keydown events for keys that have an ansi translation (e.g. the "g" key has an effect, the "Home" key does not.)

Returns
If it indicates a new, ansi character has been pressed, it will return the ansi value, otherwise it will return a nul character ('\0').

The documentation for this class was generated from the following files: