OIS  1.5
Object-oriented Input System
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OIS::Keyboard Class Referenceabstract

#include <OISKeyboard.h>

Inheritance diagram for OIS::Keyboard:
OIS::Object

Public Types

enum  TextTranslationMode { Off, Unicode, Ascii }
 TextTranslation Mode. More...
 
enum  Modifier {
  Shift = 0x0000001, Ctrl = 0x0000010, Alt = 0x0000100, CapsLock = 0x0001000,
  NumLock = 0x0010000
}
 Enum of bit position of modifer. More...
 

Public Member Functions

virtual ~Keyboard ()
 
virtual bool isKeyDown (KeyCode key) const =0
 
virtual void setEventCallback (KeyListener *keyListener)
 
KeyListenergetEventCallback () const
 
virtual void setTextTranslation (TextTranslationMode mode)
 
TextTranslationMode getTextTranslation () const
 
virtual const std::string & getAsString (KeyCode kc)=0
 
virtual OIS::KeyCode getAsKeyCode (std::string str)=0
 
bool isModifierDown (Modifier mod) const
 
virtual void copyKeyStates (char keys[256]) const =0
 
- Public Member Functions inherited from OIS::Object
virtual ~Object ()
 
Type type () const
 
const std::string & vendor () const
 
virtual bool buffered () const
 
InputManagergetCreator () const
 
virtual void setBuffered (bool buffered)=0
 
virtual void capture ()=0
 
virtual int getID () const
 
virtual InterfacequeryInterface (Interface::IType type)=0
 
virtual void _initialize ()=0
 

Protected Member Functions

 Keyboard (const std::string &vendor, bool buffered, int devID, InputManager *creator)
 
- Protected Member Functions inherited from OIS::Object
 Object (const std::string &vendor, Type iType, bool buffered, int devID, InputManager *creator)
 

Protected Attributes

unsigned int mModifiers
 Bit field that holds status of Alt, Ctrl, Shift. More...
 
KeyListenermListener
 Used for buffered/actionmapping callback. More...
 
TextTranslationMode mTextMode
 The current translation mode. More...
 
- Protected Attributes inherited from OIS::Object
std::string mVendor
 Vendor name if applicable/known. More...
 
Type mType
 Type of controller object. More...
 
bool mBuffered
 Buffered flag. More...
 
int mDevID
 Not fully implemented yet. More...
 
InputManagermCreator
 The creator who created this object. More...
 

Detailed Description

Keyboard base class. To be implemented by specific system (ie. DirectX Keyboard) This class is useful as you remain OS independent using this common interface.

Member Enumeration Documentation

◆ Modifier

Enum of bit position of modifer.

Enumerator
Shift 
Ctrl 
Alt 
CapsLock 
NumLock 

◆ TextTranslationMode

TextTranslation Mode.

Enumerator
Off 
Unicode 
Ascii 

Constructor & Destructor Documentation

◆ ~Keyboard()

virtual OIS::Keyboard::~Keyboard ( )
inlinevirtual

◆ Keyboard()

OIS::Keyboard::Keyboard ( const std::string &  vendor,
bool  buffered,
int  devID,
InputManager creator 
)
inlineprotected

Member Function Documentation

◆ copyKeyStates()

virtual void OIS::Keyboard::copyKeyStates ( char  keys[256]) const
pure virtual
Remarks
Copies the state of the keys into the sent buffer (in the form of 1 is down and 0 is up)

◆ getAsKeyCode()

virtual OIS::KeyCode OIS::Keyboard::getAsKeyCode ( std::string  str)
pure virtual
Remarks
Translates string to KeyCode representation. For example, "Enter" will be KC_ENTER - Locale specific of course.
Parameters
strstring to convert
Returns
The matching KeyCode

◆ getAsString()

virtual const std::string& OIS::Keyboard::getAsString ( KeyCode  kc)
pure virtual
Remarks
Translates KeyCode to string representation. For example, KC_ENTER will be "Enter" - Locale specific of course.
Parameters
kcKeyCode to convert
Returns
The string as determined from the current locale

◆ getEventCallback()

KeyListener* OIS::Keyboard::getEventCallback ( ) const
inline
Remarks
Returns currently set callback.. or 0

◆ getTextTranslation()

TextTranslationMode OIS::Keyboard::getTextTranslation ( ) const
inline
Remarks
Returns current translation mode

◆ isKeyDown()

virtual bool OIS::Keyboard::isKeyDown ( KeyCode  key) const
pure virtual
Remarks
Returns true if key is donwn
Parameters
keyA KeyCode to check

◆ isModifierDown()

bool Keyboard::isModifierDown ( Modifier  mod) const
Remarks
Check modifier status

◆ setEventCallback()

virtual void OIS::Keyboard::setEventCallback ( KeyListener keyListener)
inlinevirtual
Remarks
Register/unregister a Keyboard Listener - Only one allowed for simplicity. If broadcasting is neccessary, just broadcast from the callback you registered.
Parameters
keyListenerSend a pointer to a class derived from KeyListener or 0 to clear the callback

◆ setTextTranslation()

void Keyboard::setTextTranslation ( TextTranslationMode  mode)
virtual
Remarks
Enable extra processing to translate KC_*** to an actual text character based off of locale. Different managers may implement none or all. Check the translation mode after setting to be sure
Parameters
modeOff, Unicode, Ascii

Member Data Documentation

◆ mListener

KeyListener* OIS::Keyboard::mListener
protected

Used for buffered/actionmapping callback.

◆ mModifiers

unsigned int OIS::Keyboard::mModifiers
protected

Bit field that holds status of Alt, Ctrl, Shift.

◆ mTextMode

TextTranslationMode OIS::Keyboard::mTextMode
protected

The current translation mode.


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