40 #ifndef _inputmetacode_cpp
41 #define _inputmetacode_cpp
50 #include "Input/metacode.h"
51 #include "stringtool.h"
72 MetaCode::MetaCode() :
74 DeviceIndex(
std::numeric_limits<
Int32>::max()),
79 MetaValue(Other.MetaValue),
80 DeviceIndex(Other.DeviceIndex),
86 DeviceIndex(
std::numeric_limits<
Int32>::max()),
114 case SDL_MOUSEBUTTONDOWN:
119 case SDL_MOUSEBUTTONUP:
124 case SDL_JOYBUTTONDOWN:
129 case SDL_JOYBUTTONUP:
134 case SDL_MOUSEMOTION:
136 Ret.push_back(
MetaCode(Raw.motion.x,Input::MOUSEABSOLUTEHORIZONTAL) );
137 Ret.push_back(
MetaCode(Raw.motion.y,Input::MOUSEABSOLUTEVERTICAL) );
139 if( Raw.motion.xrel != 0 ) {
140 Ret.push_back(
MetaCode(Raw.motion.xrel,Input::MOUSEHORIZONTAL) );
142 if( Raw.motion.yrel != 0 ) {
143 Ret.push_back(
MetaCode(Raw.motion.yrel,Input::MOUSEVERTICAL) );
147 case SDL_JOYBALLMOTION:
149 if( 0 == Raw.jball.ball ) {
150 if( Raw.jball.yrel != 0 ) {
151 Ret.push_back(
MetaCode(Raw.jball.yrel,Input::CONTROLLERBALL_1_VERTICAL,Raw.jball.which) );
153 if( Raw.jball.xrel != 0 ) {
154 Ret.push_back(
MetaCode(Raw.jball.xrel,Input::CONTROLLERBALL_1_HORIZONTAL,Raw.jball.which) );
156 }
else if( 1 == Raw.jball.ball ) {
157 if( Raw.jball.yrel != 0 ) {
158 Ret.push_back(
MetaCode(Raw.jball.yrel,Input::CONTROLLERBALL_2_VERTICAL,Raw.jball.which) );
160 if( Raw.jball.xrel != 0 ) {
161 Ret.push_back(
MetaCode(Raw.jball.xrel,Input::CONTROLLERBALL_2_HORIZONTAL,Raw.jball.which) );
168 case SDL_JOYHATMOTION:
173 case SDL_JOYAXISMOTION:
182 while( Raw.text.text[Position] !=
'\0' )
188 Ret.push_back(
MetaCode(GlyphID,Input::OSTEXTINPUT) );
189 Position += BytesAdvance;
213 assert(
sizeof(To)==
sizeof(Raw.key.keysym.sym) );
214 memcpy( &To, &(Raw.key.keysym.scancode),
sizeof(Raw.key.keysym.scancode));
221 switch (Raw.button.button )
226 case SDL_BUTTON_X1:
return Input::MOUSEBUTTON_4;
227 case SDL_BUTTON_X2:
return Input::MOUSEBUTTON_5;
239 { this->
Code = NewCode; }
245 {
return this->
Code; }
314 if ( Input::CONTROLLERHAT_FIRST > Answer && Input::CONTROLLERHAT_LAST < Answer)
341 {
return (Input::MOUSEMOTION_FIRST <= this->
Code && Input::MOUSEMOTION_LAST && this->
Code); }
344 {
return (Input::COMPOUNDINPUT_MOUSEMULTICLICKFIRST <= this->
Code && Input::COMPOUNDINPUT_MOUSEMULTICLICKLAST >= this->
Code); }
356 {
return (Input::CONTROLLERHAT_FIRST <= this->
Code && Input::CONTROLLERHAT_LAST >= this->
Code); }
365 {
return (Input::KEY_LCTRL == this->
Code || Input::KEY_RCTRL == this->
Code); }
368 {
return (Input::KEY_LSHIFT == this->
Code || Input::KEY_RSHIFT == this->
Code); }
379 else if( this->
IsMouseEvent() )
return Input::DEVICE_MOUSE;
382 else return Input::DEVICE_UNKNOWN;
411 {
return (this->
Code < Other.
Code); }
414 {
return (this->
Code > Other.
Code); }
438 if( !CurrAttrib.
Empty() )
442 if( !CurrAttrib.
Empty() )
446 if( !CurrAttrib.
Empty() )
447 this->
Code = static_cast<Input::InputCode>( CurrAttrib.
AsUint() );
457 {
return "MetaCode"; }
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
int32_t Int32
An 32-bit integer.
This contains simple tools for indexing with UTF8 characters swiftly.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
bool Boole
Generally acts a single bit, true or false.
Thrown when the requested identity could not be found.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Thrown when we just have not coded a thing yet, but we knew what the API should look like...
std::ostream & Serialize(std::ostream &Stream, const T &Converted, const String &Indent=String(""))
Convert any class that supports serialization or has a serializer to a string of chars in a stream...
int Integer
A datatype used to represent any integer close to.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
SDL_Event RawEvent
This is an internal datatype use to communicate with the User input Subsystem.
This implements the exception hiearchy for Mezzanine.
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
uint16_t UInt16
An 16-bit unsigned integer.
A light-weight handle for manipulating nodes in DOM tree.
unsigned int AsUint(unsigned int def=0) const
Attempts to convert the value of the attribute to an unsigned int and returns the results...
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
bool Empty() const
Is this storing anything at all?
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
Thrown when parameters are checked at runtime and found invalid.
Int32 GetIntFromCharacter(Int32 &BytesUsed, const char *CurrentCharacter)
Get a number suitable for using in an index from a character string.
The bulk of the engine components go in this namspace.
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.