MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected 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 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 UInt16 &Index)
 Descriptive Constructor. More...
 
 MetaCode (const RawEvent &RawEvent_)
 The Heavy Lifting Constructor. More...
 
Input::InputCode GetCode () const
 This Returns the Inputcode. More...
 
UInt16 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...
 
bool IsAltKey () const
 Is this a left or right Alt key. More...
 
bool IsControllerAxisEvent () const
 Does this MetaCode Represent an axis position on a controller. More...
 
bool IsControllerButton () const
 Does this MetaCode Represent a state of a Controller button. More...
 
bool IsControllerEvent () const
 Does this MetaCode Represent a state of a Controller Event. More...
 
bool IsControllerHatEvent () const
 Does this MetaCode Represent a hat position on a controller. More...
 
bool IsCtrlKey () const
 Is this a left or right Ctrl key. More...
 
bool IsDeviceButton () const
 Does this MetaCode Represent a state of any button on an input device. More...
 
bool IsInputEvent () const
 Does this MetaCode Represent some other (non-keyboard and non-mouse button). More...
 
bool IsKeyboardButton () const
 Does this MetaCode Represent a state of a keyboard key. More...
 
bool IsKeyboardEvent () const
 Does this MetaCode Represent a state of a keyboard Event. More...
 
bool IsMouseButton () const
 Does this MetaCode Represent a state of a Mouse button. More...
 
bool IsMouseEvent () const
 Does this MetaCode Represent a state of a mouse Event. More...
 
bool IsMouseMotionEvent () const
 Does this MetaCode Represent movement of the mouse or mouse wheel. More...
 
bool IsMouseMultiClickEvent () const
 Does this MetaCode Represent multiple clicks of a mouse button. More...
 
bool IsMultitouchEvent () const
 Does this MetaCode Represent a state of a multitouch device. More...
 
bool IsPollable () const
 Is this metacode a pollable event. More...
 
bool IsShiftKey () const
 Is this a left or right Shift key. More...
 
bool IsSuperKey () const
 Is this a left or right Super key (Windows logo key, Apple logo key, etc...). More...
 
bool operator!= (const MetaCode &Other) const
 Compares two MetaCode's for inequality. More...
 
bool operator< (const MetaCode &Other) const
 Compares two MetaCode's to see if this is less. More...
 
MetaCodeoperator= (const MetaCode &Other)
 Assignment operator. More...
 
bool operator== (const MetaCode &Other) const
 Compares two MetaCode's for equality. More...
 
bool 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...
 
String SerializableName () const
 Get the name of the the XML tag this class will leave behind as its instances are serialized. 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 UInt16 &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 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 GetMouseButtonCode (const UInt16 ButtonNumber)
 Accepts a int and returns the InputCode for the Corresponding Mouse button. More...
 

Protected Member Functions

void Construct (const RawEvent &RawEvent_)
 
void Construct (const Int32 &Value, const Input::InputCode &NewCode)
 

Static Protected Member Functions

static Input::InputCode GetInputCodeFromSDL_JOYSTICK (const RawEvent &RawEvent_)
 
static Input::InputCode GetInputCodeFromSDL_KEY (const RawEvent &RawEvent_)
 
static Input::InputCode GetInputCodeFromSDL_MOUSE (const RawEvent &RawEvent_)
 

Protected Attributes

Input::InputCode Code
 
UInt16 DeviceIndex
 
Int32 MetaValue
 

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.

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

Definition at line 71 of file metacode.cpp.

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

Copy constructor.

This sets all values in the MetaCode, leaving it in completely ready state.

Parameters
OtherThe other MetaCode to copy from.

Definition at line 74 of file metacode.cpp.

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

Descriptive Constructor.

This sets all values in the MetaCode, leaving it in completely ready state. This is the ideal constructor for simulating user input.

Parameters
ValueHow much is something moving, tilting, rotating or whatever. For buttons a positive value is pushed, and a negative value is becoming unpressed, and 0 is unpressed.
NewCodeWhich key or which type of input was pressed. Sqeaky, thinks this has partial unicode support.

Definition at line 77 of file metacode.cpp.

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

Descriptive Constructor.

This sets all values in the MetaCode, leaving it in completely ready state. This is the ideal constructor for simulating user input.

Parameters
ValueHow much is something moving, tilting, rotating or whatever. For buttons a positive value is pushed, and a negative value is becoming unpressed, and 0 is unpressed.
NewCodeWhich key or which type of input was pressed. Sqeaky, thinks this has partial unicode support.
IndexThe index of the device this metacode is describing.

Definition at line 82 of file metacode.cpp.

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

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.

Definition at line 88 of file metacode.cpp.

Member Function Documentation

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 175 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 button you want the code for.
Returns
When passed 0 this returns Input::JOYSTICKAXIS, otherwise this returns Input::CONTROLLERAXIS_X where X is the number that was passed in.

Definition at line 235 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::JOYSTICKBUTTON, otherwise this returns Input::CONTROLLERBUTTON_X where X is the number that was passed in.

Definition at line 227 of file metacode.cpp.

UInt16 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 UInt16 (-1).
Returns
Returns a UInt16 that is the for the device this metacode applies to.

Definition at line 187 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 300 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 181 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 199 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 209 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 219 of file metacode.cpp.

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

Is this a left or right Alt key.

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

Definition at line 285 of file metacode.cpp.

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

Does this MetaCode Represent an axis position on a controller.

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

Definition at line 276 of file metacode.cpp.

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

Does this MetaCode Represent a state of a Controller button.

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

Definition at line 252 of file metacode.cpp.

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

Does this MetaCode Represent a state of a Controller Event.

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

Definition at line 273 of file metacode.cpp.

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

Does this MetaCode Represent a hat position on a controller.

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

Definition at line 279 of file metacode.cpp.

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

Is this a left or right Ctrl key.

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

Definition at line 288 of file metacode.cpp.

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

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

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

Definition at line 255 of file metacode.cpp.

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

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

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

Definition at line 282 of file metacode.cpp.

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

Does this MetaCode Represent a state of a keyboard key.

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

Definition at line 246 of file metacode.cpp.

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

Does this MetaCode Represent a state of a keyboard Event.

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

Definition at line 258 of file metacode.cpp.

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

Does this MetaCode Represent a state of a Mouse button.

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

Definition at line 249 of file metacode.cpp.

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

Does this MetaCode Represent a state of a mouse Event.

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

Definition at line 261 of file metacode.cpp.

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

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

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

Definition at line 264 of file metacode.cpp.

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

Does this MetaCode Represent multiple clicks of a mouse button.

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

Definition at line 267 of file metacode.cpp.

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

Does this MetaCode Represent a state of a multitouch device.

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

Definition at line 270 of file metacode.cpp.

bool 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 297 of file metacode.cpp.

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

Is this a left or right Shift key.

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

Definition at line 291 of file metacode.cpp.

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

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

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

Definition at line 294 of file metacode.cpp.

bool 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 327 of file metacode.cpp.

bool 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 334 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 312 of file metacode.cpp.

bool 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 320 of file metacode.cpp.

bool 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 339 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 367 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 345 of file metacode.cpp.

String Mezzanine::Input::MetaCode::SerializableName ( ) 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 383 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 169 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 172 of file metacode.cpp.

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

Sets the device index if applicable.

Parameters
IndexThe index of the device this metacode applies to.

Definition at line 184 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 178 of file metacode.cpp.


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