Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Mezzanine::Input::MetaCode Class Reference

This Determines the kind of user input. More...

#include <metacode.h>

Public Types

typedef MetaCodeContainer::const_iterator ConstMetaCodeIterator
 Const Iterator type for convenient MetaCode storage.
 
typedef std::vector< Input::MetaCodeMetaCodeContainer
 Convenience datatype for storage of MetaCodes.
 
typedef MetaCodeContainer::iterator MetaCodeIterator
 Iterator type for convenient MetaCode storage.
 

Public Member Functions

 MetaCode ()
 Default constructor. More...
 
 MetaCode (const MetaCode &Other)
 Copy constructor. More...
 
 MetaCode (const Int32 Value, const Input::InputCode NewCode)
 Descriptive Constructor. More...
 
 MetaCode (const Int32 Value, const Input::InputCode NewCode, const Int32 Index)
 Descriptive Constructor. More...
 
 MetaCode (const RawEvent &Raw)
 The Heavy Lifting Constructor. More...
 
 ~MetaCode ()
 Class destructor.
 
Input::InputCode GetCode () const
 This Returns the Inputcode. More...
 
Int32 GetDeviceIndex () const
 Gets the currently set device index. More...
 
Input::InputDevice GetDeviceType () const
 Gets the device-type this MetaCode is representing. More...
 
Int32 GetMetaValue () const
 This Returns the MetaValue. More...
 
Input::ButtonState GetMetaValueAsButtonState () const
 Get the MetaValue as a Input::ButtonState. More...
 
Input::DirectionalMotionState GetMetaValueAsDirectionalMotionState () const
 Get the MetaValue as a Input::DirectionalMotionState. More...
 
String GetSerializableName () const
 Get the name of the the XML tag this class will leave behind as its instances are serialized. More...
 
Boole IsAltKey () const
 Is this a left or right Alt key. More...
 
Boole IsControllerAxisEvent () const
 Does this MetaCode Represent an axis position on a controller. More...
 
Boole IsControllerButton () const
 Does this MetaCode Represent a state of a Controller button. More...
 
Boole IsControllerEvent () const
 Does this MetaCode Represent a state of a Controller Event. More...
 
Boole IsControllerHatEvent () const
 Does this MetaCode Represent a hat position on a controller. More...
 
Boole IsCtrlKey () const
 Is this a left or right Ctrl key. More...
 
Boole IsDeviceButton () const
 Does this MetaCode Represent a state of any button on an input device. More...
 
Boole IsInputEvent () const
 Does this MetaCode Represent some other (non-keyboard and non-mouse button). More...
 
Boole IsKeyboardButton () const
 Does this MetaCode Represent a state of a keyboard key. More...
 
Boole IsKeyboardEvent () const
 Does this MetaCode Represent a state of a keyboard Event. More...
 
Boole IsMouseButton () const
 Does this MetaCode Represent a state of a Mouse button. More...
 
Boole IsMouseEvent () const
 Does this MetaCode Represent a state of a mouse Event. More...
 
Boole IsMouseMotionEvent () const
 Does this MetaCode Represent movement of the mouse or mouse wheel. More...
 
Boole IsMouseMultiClickEvent () const
 Does this MetaCode Represent multiple clicks of a mouse button. More...
 
Boole IsMultitouchEvent () const
 Does this MetaCode Represent a state of a multitouch device. More...
 
Boole IsPollable () const
 Is this metacode a pollable event. More...
 
Boole IsShiftKey () const
 Is this a left or right Shift key. More...
 
Boole IsSuperKey () const
 Is this a left or right Super key (Windows logo key, Apple logo key, etc...). More...
 
Boole operator!= (const MetaCode &Other) const
 Compares two MetaCode's for inequality. More...
 
Boole operator< (const MetaCode &Other) const
 Compares two MetaCode's to see if this is less. More...
 
MetaCodeoperator= (const MetaCode &Other)
 Assignment operator. More...
 
Boole operator== (const MetaCode &Other) const
 Compares two MetaCode's for equality. More...
 
Boole operator> (const MetaCode &Other) const
 Compares two MetaCode's to see if this is greater. More...
 
void ProtoDeSerialize (const XML::Node &OneNode)
 Take the data stored in an XML and overwrite this instance of this object with it. More...
 
void ProtoSerialize (XML::Node &CurrentRoot) const
 Convert this class to an XML::Node ready for serialization. More...
 
void SetCode (const Input::InputCode NewCode)
 This Sets The InputCode. More...
 
void SetCode (const Int32 NewCode)
 This Sets The InputCode using an Int32. More...
 
void SetDeviceIndex (const Int32 Index)
 Sets the device index if applicable. More...
 
void SetMetaValue (const Int32 Value)
 This Sets The MetaValue. More...
 
void SetNullValues ()
 Sets all the values of this MetaCode to Null values.
 

Static Public Member Functions

static MetaCodeContainer CreateMetaCodes (const RawEvent &Raw)
 Internal creation method. More...
 
static Input::InputCode GetControllerAxisCode (const UInt16 AxisNumber)
 Accepts a int and returns the InputCode for the Corresponding Controller Axis. More...
 
static Input::InputCode GetControllerButtonCode (const UInt16 ButtonNumber)
 Accepts a int and returns the InputCode for the Corresponding Controller button. More...
 
static Input::InputCode GetControllerHatCode (const UInt16 HatNumber)
 Accepts a int and returns the InputCode for the Corresponding Controller Hat. More...
 
static Input::InputCode GetMouseButtonCode (const UInt16 ButtonNumber)
 Accepts a int and returns the InputCode for the Corresponding Mouse button. More...
 

Static Protected Member Functions

static Input::InputCode GetInputCodeFromSDL_JOYSTICK (const RawEvent &Raw)
 Converts an internal controller input event into a Mezzanine controller InputCode. More...
 
static Input::InputCode GetInputCodeFromSDL_KEY (const RawEvent &Raw)
 Converts an internal keyboard input event into a Mezzanine keyboard InputCode. More...
 
static Input::InputCode GetInputCodeFromSDL_MOUSE (const RawEvent &Raw)
 Converts an internal mouse input event into a Mezzanine mouse InputCode. More...
 

Protected Attributes

Input::InputCode Code
 The code indicating what type of input this is. More...
 
Int32 DeviceIndex
 The device index if this is input from a controller. For keyboards and mice this is the max value if a Int32. More...
 
Int32 MetaValue
 The relevant value for the type of input this is, if applicable. More...
 

Detailed Description

This Determines the kind of user input.

A Metacode contains the data that is passed around with an input event. It stores one type of button press or analog representation (Mouse move, joystick tilt, wheel spin, etc...). If it is an analog representation it will also store how far or how it is pushed, pressed, rotated, or whatever. Several of these can be used in combination to represent button combinations, or complex input combinations (like portions of fighter game moves).

Definition at line 93 of file metacode.h.

Constructor & Destructor Documentation

Mezzanine::Input::MetaCode::MetaCode ( )

Default constructor.

Remarks
This sets nothing on the MetaCode and leaves it completely unassigned. Accessing a data member could cause problems.

Definition at line 72 of file metacode.cpp.

Mezzanine::Input::MetaCode::MetaCode ( const MetaCode Other)

Copy constructor.

Parameters
OtherThe other MetaCode to copy from.

Definition at line 78 of file metacode.cpp.

Mezzanine::Input::MetaCode::MetaCode ( const Int32  Value,
const Input::InputCode  NewCode 
)

Descriptive Constructor.

Parameters
ValueHow much is something moving, tilting, rotating or whatever.
NewCodeWhich key or which type of input was pressed.

Definition at line 84 of file metacode.cpp.

Mezzanine::Input::MetaCode::MetaCode ( const Int32  Value,
const Input::InputCode  NewCode,
const Int32  Index 
)

Descriptive Constructor.

Parameters
ValueHow much is something moving, tilting, rotating or whatever.
NewCodeWhich key or which type of input was pressed.
IndexThe index of the device this metacode is describing.

Definition at line 90 of file metacode.cpp.

Mezzanine::Input::MetaCode::MetaCode ( const RawEvent Raw)

The Heavy Lifting Constructor.

This contructor accepts a RawEvent from the input event subsystem internal to the engine. This converts all the required information from the lower level format and store what is needed in the event that is created. This is used heavily by engine internals.
This constructor expects to receive a type of RawEvent that can be converted into exactly one kind of Metacode. Depending on the User input subsystem, this could be all RawEvents, or even just some RawEvents.

Exceptions
RawEvent which creates Multiple Metacodes inserted into Metacode- Thrown when passed a certain (system dependant) incorrect type of RawEvent.
Unknown User Input Inserted into Metacode- Thrown when receiving either a corrupt, improperly handle, or unsupported RawEvent.
Warning
We recomend against using this Constructor, because the binary format of RawEvent could change if the input event SubSystem Changes. In that event you would have to recompile your application to get it working with a new version of Mezzanine. Using this function in Game code removes any gaurantees of Game Code Portability.

Member Function Documentation

MetaCode::MetaCodeContainer Mezzanine::Input::MetaCode::CreateMetaCodes ( const RawEvent Raw)
static

Internal creation method.

Remarks
This method accepts a RawEvent from the input event subsystem internal to the engine. This converts all the required information from the lower level format and store what is needed in the event that is created. This is used heavily by engine internals.
This constructor expects to receive a type of RawEvent that can be converted into one or more kinds of Metacode.
Warning
We recomend against using this Constructor, because the binary format of RawEvent could change if the input event SubSystem Changes. In that event you would have to recompile your application to get it working with a new version of Mezzanine. Using this function in Game code removes any gaurantees of Game Code Portability.
Exceptions
RawEvent which creates Multiple Metacodes inserted into Metacode- Thrown when passed a certain (system dependant) incorrect type of RawEvent.
Unknown User Input Inserted into Metacode- Thrown when receiving either a corrupt, improperly handle, or unsupported RawEvent.
Parameters
RawThe internal event to be converted into one or more MetaCodes.
Returns
Returns a container of the created MetaCodes.

Definition at line 99 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetCode ( ) const

This Returns the Inputcode.

This Value can be use to determine what keyboard button has been pressed, or what specific kind of Joystick or mouse event has occurred. This value can be set with SetCode .

Returns
This returns the input code for this MetaCode.

Definition at line 244 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetControllerAxisCode ( const UInt16  AxisNumber)
static

Accepts a int and returns the InputCode for the Corresponding Controller Axis.

Parameters
AxisNumberThe number of the axis you want the code for.
Returns
When passed 0 this returns Input::CONTROLLERAXIS, otherwise this returns Input::CONTROLLERAXIS_X where X is the number that was passed in.

Definition at line 303 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetControllerButtonCode ( const UInt16  ButtonNumber)
static

Accepts a int and returns the InputCode for the Corresponding Controller button.

Parameters
ButtonerNumberThe number of the button you want the code for.
Returns
When passed 0 this returns Input::CONTROLLERBUTTON, otherwise this returns Input::CONTROLLERBUTTON_X where X is the number that was passed in.

Definition at line 295 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetControllerHatCode ( const UInt16  HatNumber)
static

Accepts a int and returns the InputCode for the Corresponding Controller Hat.

Parameters
HatNumberThe index of the hat you want the code for.
Returns
When passed 0 this returns Input::CONTROLLERHAT, otherwise this returns Input::CONTROLLERHAT_X where X is the number that was passed in.

Definition at line 311 of file metacode.cpp.

Int32 Mezzanine::Input::MetaCode::GetDeviceIndex ( ) const

Gets the currently set device index.

Remarks
If no device is set or applicable, this will return the max value for a Int32 (-1).
Returns
Returns a Int32 that is the for the device this metacode applies to.

Definition at line 256 of file metacode.cpp.

Input::InputDevice Mezzanine::Input::MetaCode::GetDeviceType ( ) const

Gets the device-type this MetaCode is representing.

Returns
Returns an Input::InputDevice value for the device this MetaCode is representing.

Definition at line 376 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetInputCodeFromSDL_JOYSTICK ( const RawEvent Raw)
staticprotected

Converts an internal controller input event into a Mezzanine controller InputCode.

Parameters
RawThe internal event to be converted into a controller InputCode.
Returns
Returns the converted Mezzanine InputCode.

Definition at line 232 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetInputCodeFromSDL_KEY ( const RawEvent Raw)
staticprotected

Converts an internal keyboard input event into a Mezzanine keyboard InputCode.

Parameters
RawThe internal event to be converted into a keyboard InputCode.
Returns
Returns the converted Mezzanine InputCode.

Definition at line 208 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetInputCodeFromSDL_MOUSE ( const RawEvent Raw)
staticprotected

Converts an internal mouse input event into a Mezzanine mouse InputCode.

Parameters
RawThe internal event to be converted into a mouse InputCode.
Returns
Returns the converted Mezzanine InputCode.

Definition at line 219 of file metacode.cpp.

Int32 Mezzanine::Input::MetaCode::GetMetaValue ( ) const

This Returns the MetaValue.

The MetaValue can be use to determine how far something is tilted, pushed, rotated, or other analog value. This value can be set with SetMetaValue .

Returns
This returns the input code for this MetaCode. This could return any number inside a range (depending on hardware and configuration) to represent how tilted a joystick or how much a mouse moved.

Definition at line 250 of file metacode.cpp.

Input::ButtonState Mezzanine::Input::MetaCode::GetMetaValueAsButtonState ( ) const

Get the MetaValue as a Input::ButtonState.

Returns
This returns the appropriate button state or throws an Mezzanine::Exception if an invalid button state is stored in the MetaValue.
Exceptions
Thisthrows a Mezzanine::Exception if the MetaValue is less than BUTTON_LIFTING or greater than BUTTON_DOWN.

Definition at line 269 of file metacode.cpp.

Input::DirectionalMotionState Mezzanine::Input::MetaCode::GetMetaValueAsDirectionalMotionState ( ) const

Get the MetaValue as a Input::DirectionalMotionState.

Returns
This returns the appropriate MouseWheel state or throws an Mezzanine::Exception if an invalid state is stored in the MetaValue
Exceptions
Thisthrows a Mezzanine::Exception if the MetaValue is less than MOUSEWHEEL_DOWN or greater than MOUSEWHEEL_UP.

Definition at line 278 of file metacode.cpp.

Input::InputCode Mezzanine::Input::MetaCode::GetMouseButtonCode ( const UInt16  ButtonNumber)
static

Accepts a int and returns the InputCode for the Corresponding Mouse button.

Parameters
ButtonerNumberThe number of the button you want the code for.
Returns
When passed 0 this returns Input::MOUSEBUTTON, otherwise this returns Input::MOUSEBUTTON_X where X is the number that was passed in.

Definition at line 287 of file metacode.cpp.

String Mezzanine::Input::MetaCode::GetSerializableName ( ) const

Get the name of the the XML tag this class will leave behind as its instances are serialized.

Returns
A string containing "Vector3".

Definition at line 456 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsAltKey ( ) const

Is this a left or right Alt key.

Returns
This returns a Boole which will be true if this is a left or right Alt key.

Definition at line 361 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsControllerAxisEvent ( ) const

Does this MetaCode Represent an axis position on a controller.

Returns
This returns a Boole which will be true if this is between CONTROLLERAXIS_FIRST and CONTROLLERAXIS_LAST.

Definition at line 352 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsControllerButton ( ) const

Does this MetaCode Represent a state of a Controller button.

Returns
This returns a Boole which will be true if this is a CONTROLLERBUTTON_X event.

Definition at line 328 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsControllerEvent ( ) const

Does this MetaCode Represent a state of a Controller Event.

Returns
This returns a Boole which will be true if this is between CONTROLLER_FIRST and CONTROLLER_LAST.

Definition at line 349 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsControllerHatEvent ( ) const

Does this MetaCode Represent a hat position on a controller.

Returns
This returns a Boole which will be true if this is between CONTROLLERHAT_FIRST and CONTROLLERHAT_LAST.

Definition at line 355 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsCtrlKey ( ) const

Is this a left or right Ctrl key.

Returns
This returns a Boole which will be true if this is a left or right Ctrl key.

Definition at line 364 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsDeviceButton ( ) const

Does this MetaCode Represent a state of any button on an input device.

Returns
This returns a Boole which will be true if this is event pertains to any button on any input device.

Definition at line 331 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsInputEvent ( ) const

Does this MetaCode Represent some other (non-keyboard and non-mouse button).

Returns
This returns a Boole which will be true if this is between INPUTEVENT_FIRST and INPUTEVENT_LAST.

Definition at line 358 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsKeyboardButton ( ) const

Does this MetaCode Represent a state of a keyboard key.

Returns
This returns a Boole which will be true if this is a keyboard event.

Definition at line 322 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsKeyboardEvent ( ) const

Does this MetaCode Represent a state of a keyboard Event.

Returns
This returns a Boole which will be true if this is between KEY_FIRST and KEY_LAST.

Definition at line 334 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsMouseButton ( ) const

Does this MetaCode Represent a state of a Mouse button.

Returns
This returns a Boole which will be true if this is a MOUSEBUTTON_X event.

Definition at line 325 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsMouseEvent ( ) const

Does this MetaCode Represent a state of a mouse Event.

Returns
This returns a Boole which will be true if this is between MOUSE_FIRST and MOUSE_LAST.

Definition at line 337 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsMouseMotionEvent ( ) const

Does this MetaCode Represent movement of the mouse or mouse wheel.

Returns
This returns a Boole which will be true if this is between MOUSEMOTION_FIRST and MOUSEMOTION_LAST.

Definition at line 340 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsMouseMultiClickEvent ( ) const

Does this MetaCode Represent multiple clicks of a mouse button.

Returns
This returns a Boole which will be true if this is between the first mouse multiclick input code and the last mouse multiclick input code.

Definition at line 343 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsMultitouchEvent ( ) const

Does this MetaCode Represent a state of a multitouch device.

Returns
This returns a Boole which will be true if this is between the MULTITOUCH_FIRST and MULTITOUCH_LAST.

Definition at line 346 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsPollable ( ) const

Is this metacode a pollable event.

Returns
if this metacode stores a device button then this is a pollable event.

Definition at line 373 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsShiftKey ( ) const

Is this a left or right Shift key.

Returns
This returns a Boole which will be true if this is a left or right Shift key.

Definition at line 367 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::IsSuperKey ( ) const

Is this a left or right Super key (Windows logo key, Apple logo key, etc...).

Returns
This returns a Boole which will be true if this is a left or right Super key.

Definition at line 370 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::operator!= ( const MetaCode Other) const

Compares two MetaCode's for inequality.

Parameters
OtherThe other MetaCode to compare with.
Returns
Returns true if the two MetaCode's are not equal, false otherwise.

Definition at line 403 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::operator< ( const MetaCode Other) const

Compares two MetaCode's to see if this is less.

Note
This only compares the InputCode contained in both MetaCode's.
Parameters
OtherThe other MetaCode to compare with.
Returns
Returns true if this MetaCode is less then the MetaCode being compared, false otherwise.

Definition at line 410 of file metacode.cpp.

MetaCode & Mezzanine::Input::MetaCode::operator= ( const MetaCode Other)

Assignment operator.

Parameters
OtherThe other MetaCode to assign to this.
Returns
Returns a reference to this.

Definition at line 388 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::operator== ( const MetaCode Other) const

Compares two MetaCode's for equality.

Parameters
OtherThe other MetaCode to compare with.
Returns
Returns true if the two MetaCode's are equal, false otherwise.

Definition at line 396 of file metacode.cpp.

Boole Mezzanine::Input::MetaCode::operator> ( const MetaCode Other) const

Compares two MetaCode's to see if this is greater.

Note
This only compares the InputCode contained in both MetaCode's.
Parameters
OtherThe other MetaCode to compare with.
Returns
Returns true if this MetaCode is greater then the MetaCode being compared, false otherwise.

Definition at line 413 of file metacode.cpp.

void Mezzanine::Input::MetaCode::ProtoDeSerialize ( const XML::Node OneNode)

Take the data stored in an XML and overwrite this instance of this object with it.

Parameters
OneNodeand XML::Node containing the data.

Definition at line 431 of file metacode.cpp.

void Mezzanine::Input::MetaCode::ProtoSerialize ( XML::Node CurrentRoot) const

Convert this class to an XML::Node ready for serialization.

Parameters
CurrentRootThe point in the XML hierarchy that all this vector3 should be appended to.

Definition at line 416 of file metacode.cpp.

void Mezzanine::Input::MetaCode::SetCode ( const Input::InputCode  NewCode)

This Sets The InputCode.

See GetCode to see exactly what the Code is. This will Set the code stored in this MetaCode. This value can be retrieved with GetCode .

Parameters
NewCodeThe value you want the stored code to become.

Definition at line 238 of file metacode.cpp.

void Mezzanine::Input::MetaCode::SetCode ( const Int32  NewCode)

This Sets The InputCode using an Int32.

Warning
This will cast an Int32 into an InputCode. Be careful, it is possible to put impossible or ridiculous values, in with this. For example Accidentally stuffing in the result of MOUSEBUTTON + 22 looks like it would give you MOUSEBUTTON_22. But that Doesn't exist, at the time of this writing you would get MOUSEABSOLUTEVERTICAL. Be careful, or skip this alltogether and use one of the provided functions that do the math for you like.
Parameters
NewCodeThe value you want the stored code to become.

Definition at line 241 of file metacode.cpp.

void Mezzanine::Input::MetaCode::SetDeviceIndex ( const Int32  Index)

Sets the device index if applicable.

Parameters
IndexThe index of the device this metacode applies to.

Definition at line 253 of file metacode.cpp.

void Mezzanine::Input::MetaCode::SetMetaValue ( const Int32  Value)

This Sets The MetaValue.

See GetMetaValue to see exactly what the MetaValue is. This will set the MetaValue stored in this MetaCode. This value can be retrieved with GetMetaValue .

Parameters
ValueThe value you want the stored MetaValue to become. No bounds checking will be done. You can supply a completely invalid value if you choose to.

Definition at line 247 of file metacode.cpp.

Member Data Documentation

Input::InputCode Mezzanine::Input::MetaCode::Code
protected

The code indicating what type of input this is.

Definition at line 111 of file metacode.h.

Int32 Mezzanine::Input::MetaCode::DeviceIndex
protected

The device index if this is input from a controller. For keyboards and mice this is the max value if a Int32.

Definition at line 108 of file metacode.h.

Int32 Mezzanine::Input::MetaCode::MetaValue
protected

The relevant value for the type of input this is, if applicable.

Definition at line 105 of file metacode.h.


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