Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Keyboard Class Referenceabstract

#include <Keyboard.h>

Inherits SubsystemInterface.

Inherited by DirectInputKeyboard.

Public Types

enum  { MAX_KEY_STATES = 3 }
 

Public Member Functions

 Keyboard (void)
 
virtual ~Keyboard (void)
 
virtual void init (void)
 
virtual void reset (void)
 Reset keyboard system.
 
virtual void update (void)
 
virtual Bool getCapsState (void)=0
 get state of caps lock key, return TRUE if down
 
virtual void createStreamMessages (void)
 
Bool isShift ()
 
Bool isCtrl ()
 
Bool isAlt ()
 
Int getModifierFlags ()
 
void resetKeys (void)
 reset the state of the keys
 
KeyboardIOgetFirstKey (void)
 get first key ready for processing
 
void setKeyStatusData (UnsignedByte key, KeyboardIO::StatusType data)
 set key status
 
WideChar translateKey (WideChar keyCode)
 translte key code to printable UNICODE char
 
WideChar getPrintableKey (UnsignedByte key, Int state)
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Types

enum  { NUM_KEYS = 256 }
 
enum  { KEY_NAMES_COUNT = 256 }
 

Protected Member Functions

virtual void getKey (KeyboardIO *key)=0
 
void initKeyNames (void)
 initialize the key names table
 
void updateKeys (void)
 update the state of our key data
 
Bool checkKeyRepeat (void)
 check for repeating keys
 
UnsignedByte getKeyStatusData (UnsignedByte key)
 get key status
 
Bool getKeyStateBit (UnsignedByte key, Int bit)
 get key state bit
 
UnsignedInt getKeySequenceData (UnsignedByte key)
 get key sequence
 
void setKeyStateData (UnsignedByte key, UnsignedByte data)
 get key state
 

Protected Attributes

UnsignedShort m_modifiers
 
UnsignedByte m_shift2Key
 
KeyboardIO m_keys [NUM_KEYS]
 the keys
 
KeyboardIO m_keyStatus [NUM_KEYS]
 the key status flags
 
struct { 
 
   WideChar   stdKey 
 
   WideChar   shifted 
 
   WideChar   shifted2 
 
m_keyNames [KEY_NAMES_COUNT
 
UnsignedInt m_inputFrame
 frame input was gathered on
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Detailed Description

Keyboard singleton to interface with the keyboard

Definition at line 87 of file Keyboard.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_KEY_STATES 

Definition at line 121 of file Keyboard.h.

◆ anonymous enum

anonymous enum
protected
Enumerator
KEY_NAMES_COUNT 

Definition at line 154 of file Keyboard.h.

◆ anonymous enum

anonymous enum
protected
Enumerator
NUM_KEYS 

Definition at line 150 of file Keyboard.h.

Constructor & Destructor Documentation

◆ Keyboard()

Keyboard::Keyboard ( void )

Definition at line 687 of file Keyboard.cpp.

◆ ~Keyboard()

Keyboard::~Keyboard ( void )
virtual

Definition at line 702 of file Keyboard.cpp.

Member Function Documentation

◆ checkKeyRepeat()

Bool Keyboard::checkKeyRepeat ( void )
protected

check for repeating keys

check key repeat sequences, TRUE is returned if repeat is occurring

Todo
we shouldn't think about repeating any keys while we don't have the focus

Definition at line 199 of file Keyboard.cpp.

◆ createStreamMessages()

void Keyboard::createStreamMessages ( void )
virtual

given state of device, create messages and put them on the stream for the raw state.

Given the state of the device, create messages from the input and place them on the message stream

Definition at line 50 of file Keyboard.cpp.

◆ getCapsState()

virtual Bool Keyboard::getCapsState ( void )
pure virtual

get state of caps lock key, return TRUE if down

Implemented in DirectInputKeyboard.

◆ getFirstKey()

KeyboardIO * Keyboard::getFirstKey ( void )

get first key ready for processing

get the first key in our current state of the keyboard

Definition at line 763 of file Keyboard.cpp.

◆ getKey()

virtual void Keyboard::getKey ( KeyboardIO * key)
protectedpure virtual

get the key data for a single key, KEY_NONE should be returned when no key data is available to get anymore, you must implement this for your device

Implemented in DirectInputKeyboard.

◆ getKeySequenceData()

UnsignedInt Keyboard::getKeySequenceData ( UnsignedByte key)
protected

get key sequence

return the sequence data for the given key

Definition at line 787 of file Keyboard.cpp.

◆ getKeyStateBit()

Bool Keyboard::getKeyStateBit ( UnsignedByte key,
Int bit )
protected

get key state bit

Get the key state data as a Bool for the specified key

Definition at line 779 of file Keyboard.cpp.

◆ getKeyStatusData()

UnsignedByte Keyboard::getKeyStatusData ( UnsignedByte key)
protected

get key status

return the key status for the specified key

Definition at line 771 of file Keyboard.cpp.

◆ getModifierFlags()

Int Keyboard::getModifierFlags ( )
inline

Definition at line 112 of file Keyboard.h.

◆ getPrintableKey()

WideChar Keyboard::getPrintableKey ( UnsignedByte key,
Int state )

Definition at line 976 of file Keyboard.cpp.

◆ init()

void Keyboard::init ( void )
virtual

initialize the keyboard, only extend this functionality, do not replace

Initialzie the keyboard

Implements SubsystemInterface.

Reimplemented in DirectInputKeyboard.

Definition at line 710 of file Keyboard.cpp.

◆ initKeyNames()

void Keyboard::initKeyNames ( void )
protected

initialize the key names table

Initialize the keyboard key-names array

Definition at line 255 of file Keyboard.cpp.

◆ isAlt()

Bool Keyboard::isAlt ( )

returns true if any shift state is pressed

Definition at line 966 of file Keyboard.cpp.

◆ isCtrl()

Bool Keyboard::isCtrl ( )

returns true if any control state is pressed

Definition at line 954 of file Keyboard.cpp.

◆ isShift()

Bool Keyboard::isShift ( )

returns true if any shift state is pressed

Definition at line 942 of file Keyboard.cpp.

◆ reset()

void Keyboard::reset ( void )
virtual

Reset keyboard system.

Reset keyboard system

Implements SubsystemInterface.

Reimplemented in DirectInputKeyboard.

Definition at line 724 of file Keyboard.cpp.

◆ resetKeys()

void Keyboard::resetKeys ( void )

reset the state of the keys

Reset the state data for the keys, we likely want to do this when we once again gain focus to our app from something like an alt tab

Definition at line 747 of file Keyboard.cpp.

◆ setKeyStateData()

void Keyboard::setKeyStateData ( UnsignedByte key,
UnsignedByte data )
protected

get key state

set the key state data

Definition at line 803 of file Keyboard.cpp.

◆ setKeyStatusData()

void Keyboard::setKeyStatusData ( UnsignedByte key,
KeyboardIO::StatusType data )

set key status

set the key status data

Definition at line 795 of file Keyboard.cpp.

◆ translateKey()

WideChar Keyboard::translateKey ( WideChar keyCode)

translte key code to printable UNICODE char

This routine must be called with every character to properly monitor the shift state. Takes a keycode as input, and returns the UNICODE char representing the character.

Definition at line 814 of file Keyboard.cpp.

◆ update()

void Keyboard::update ( void )
virtual

gather current state of all keys, extend this functionality, do not replace

Called once per frame to gather key data input

Implements SubsystemInterface.

Reimplemented in DirectInputKeyboard.

Definition at line 732 of file Keyboard.cpp.

◆ updateKeys()

void Keyboard::updateKeys ( void )
protected

update the state of our key data

update all our key state data

Todo
– if we don't have focus, we could destroy all the keys retrieved here so that we don't process anything

Definition at line 101 of file Keyboard.cpp.

Member Data Documentation

◆ m_inputFrame

UnsignedInt Keyboard::m_inputFrame
protected

frame input was gathered on

Definition at line 163 of file Keyboard.h.

◆ [struct]

struct { ... } Keyboard::m_keyNames[ KEY_NAMES_COUNT ]

◆ m_keys

KeyboardIO Keyboard::m_keys[NUM_KEYS]
protected

the keys

Definition at line 151 of file Keyboard.h.

◆ m_keyStatus

KeyboardIO Keyboard::m_keyStatus[NUM_KEYS]
protected

the key status flags

Definition at line 152 of file Keyboard.h.

◆ m_modifiers

UnsignedShort Keyboard::m_modifiers
protected

Definition at line 137 of file Keyboard.h.

◆ m_shift2Key

UnsignedByte Keyboard::m_shift2Key
protected

Definition at line 148 of file Keyboard.h.

◆ shifted

WideChar Keyboard::shifted

Definition at line 159 of file Keyboard.h.

◆ shifted2

WideChar Keyboard::shifted2

Definition at line 160 of file Keyboard.h.

◆ stdKey

WideChar Keyboard::stdKey

Definition at line 158 of file Keyboard.h.


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