Spinning Topp Logo BlackTopp Studios
inc
metacode.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _inputmetacode_cpp
41 #define _inputmetacode_cpp
42 
43 #include "entresol.h" //only used for logging
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 // Includes
47 ///////////////////////////////////////
48 
49 #include "exception.h"
50 #include "Input/metacode.h"
51 #include "stringtool.h"
52 #include "serialization.h"
53 #include "unicode.h"
54 
55 #include <assert.h>
56 #include <limits>
57 #include <ostream>
58 #include <cstring>
59 #include <memory>
60 
61 #include "SDL.h"
62 
63 using namespace std;
64 
65 namespace Mezzanine
66 {
67  namespace Input
68  {
69  ///////////////////////////////////////////////////////////////////////////////
70  // Creation and Deletion Methods
71 
72  MetaCode::MetaCode() :
73  MetaValue(0),
74  DeviceIndex(std::numeric_limits<Int32>::max()),
75  Code(Input::KEY_UNKNOWN)
76  { }
77 
78  MetaCode::MetaCode(const MetaCode& Other) :
79  MetaValue(Other.MetaValue),
80  DeviceIndex(Other.DeviceIndex),
81  Code(Other.Code)
82  { }
83 
84  MetaCode::MetaCode(const Int32 Value, const Input::InputCode NewCode) :
85  MetaValue(Value),
86  DeviceIndex(std::numeric_limits<Int32>::max()),
87  Code(NewCode)
88  { }
89 
90  MetaCode::MetaCode(const Int32 Value, const Input::InputCode NewCode, const Int32 Index) :
91  MetaValue(Value),
92  DeviceIndex(Index),
93  Code(NewCode)
94  { }
95 
97  { }
98 
100  {
101  MetaCodeContainer Ret;
102  switch(Raw.type)
103  {
104  case SDL_KEYDOWN:
105  {
107  break;
108  }
109  case SDL_KEYUP:
110  {
112  break;
113  }
114  case SDL_MOUSEBUTTONDOWN:
115  {
117  break;
118  }
119  case SDL_MOUSEBUTTONUP:
120  {
122  break;
123  }
124  case SDL_JOYBUTTONDOWN:
125  {
126  Ret.push_back( MetaCode(Input::BUTTON_PRESSING,GetInputCodeFromSDL_JOYSTICK(Raw),Raw.jbutton.which) );
127  break;
128  }
129  case SDL_JOYBUTTONUP:
130  {
131  Ret.push_back( MetaCode(Input::BUTTON_LIFTING,GetInputCodeFromSDL_JOYSTICK(Raw),Raw.jbutton.which) );
132  break;
133  }
134  case SDL_MOUSEMOTION:
135  {
136  Ret.push_back( MetaCode(Raw.motion.x,Input::MOUSEABSOLUTEHORIZONTAL) );
137  Ret.push_back( MetaCode(Raw.motion.y,Input::MOUSEABSOLUTEVERTICAL) );
138 
139  if( Raw.motion.xrel != 0 ) {
140  Ret.push_back( MetaCode(Raw.motion.xrel,Input::MOUSEHORIZONTAL) );
141  }
142  if( Raw.motion.yrel != 0 ) {
143  Ret.push_back( MetaCode(Raw.motion.yrel,Input::MOUSEVERTICAL) );
144  }
145  break;
146  }
147  case SDL_JOYBALLMOTION:
148  {
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) );
152  }
153  if( Raw.jball.xrel != 0 ) {
154  Ret.push_back( MetaCode(Raw.jball.xrel,Input::CONTROLLERBALL_1_HORIZONTAL,Raw.jball.which) );
155  }
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) );
159  }
160  if( Raw.jball.xrel != 0 ) {
161  Ret.push_back( MetaCode(Raw.jball.xrel,Input::CONTROLLERBALL_2_HORIZONTAL,Raw.jball.which) );
162  }
163  }else{
164  MEZZ_EXCEPTION(ExceptionBase::NOT_IMPLEMENTED_EXCEPTION,"More then 2 trackballs is currently not supported. Perhaps we should expand our enum.");
165  }
166  break;
167  }
168  case SDL_JOYHATMOTION:
169  {
170  Ret.push_back( MetaCode(Raw.jhat.value,MetaCode::GetControllerHatCode(Raw.jhat.hat + 1),Raw.jhat.which) );
171  break;
172  }
173  case SDL_JOYAXISMOTION:
174  {
175  Ret.push_back( MetaCode(Raw.jaxis.value,MetaCode::GetControllerAxisCode(Raw.jaxis.axis + 1),Raw.jaxis.which) );
176  break;
177  }
178  case SDL_TEXTINPUT:
179  {
180  Integer Position = 0;
181  Integer BytesAdvance = 0;
182  while( Raw.text.text[Position] != '\0' )
183  {
184  Int32 GlyphID = Unicode::GetIntFromCharacter(BytesAdvance,&(Raw.text.text[Position]));
185  if( GlyphID < 0 ) {
186  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Non-UTF8 encoded text generated from TextInput event.");
187  }
188  Ret.push_back( MetaCode(GlyphID,Input::OSTEXTINPUT) );
189  Position += BytesAdvance;
190  }
191  break;
192  }
193  default:
194  {
195  // Create a safe but gibberish default
196  Ret.push_back( MetaCode(Input::BUTTON_UP,Input::KEY_FIRST) );
197  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Unknown User Input Inserted into Metacode");
198  break;
199  }
200  }
201  return Ret;
202  }
203 
204  ///////////////////////////////////////////////////////////////////////////////
205  // Dirty Hacks
206 
207  //This function assumes the RawEvent is a valid SDL Keyevent
209  {
210  //This Whole thing will only work with SDL Keyboard events. If we switch out event subsystems this is one of those that must change it.
211  Input::InputCode To;
212 
213  assert( sizeof(To)==sizeof(Raw.key.keysym.sym) );
214  memcpy( &To, &(Raw.key.keysym.scancode), sizeof(Raw.key.keysym.scancode));
215 
216  return To;
217  }
218 
220  {
221  switch (Raw.button.button )
222  {
223  case SDL_BUTTON_LEFT: return Input::MOUSEBUTTON_1;
224  case SDL_BUTTON_RIGHT: return Input::MOUSEBUTTON_2;
225  case SDL_BUTTON_MIDDLE: return Input::MOUSEBUTTON_3;
226  case SDL_BUTTON_X1: return Input::MOUSEBUTTON_4;
227  case SDL_BUTTON_X2: return Input::MOUSEBUTTON_5;
228  }
229  return Input::KEY_UNKNOWN;
230  }
231 
233  { return GetControllerButtonCode(Raw.jbutton.button); }
234 
235  ///////////////////////////////////////////////////////////////////////////////
236  // Gets and Sets
237 
239  { this->Code = NewCode; }
240 
241  void MetaCode::SetCode(const Int32 NewCode)
242  { this->Code = (Input::InputCode)NewCode; }
243 
245  { return this->Code; }
246 
247  void MetaCode::SetMetaValue(const Int32 Value)
248  { this->MetaValue = Value; }
249 
251  { return this->MetaValue; }
252 
253  void MetaCode::SetDeviceIndex(const Int32 Index)
254  { this->DeviceIndex = Index; }
255 
257  { return DeviceIndex; }
258 
260  {
261  this->Code = Input::KEY_UNKNOWN;
262  this->MetaValue = 0;
263  this->DeviceIndex = numeric_limits<Int32>::max();
264  }
265 
266  ///////////////////////////////////////////////////////////////////////////////
267  // Conversion and Casting Functions
268 
270  {
271  if( Input::BUTTON_LIFTING <= this->MetaValue && Input::BUTTON_DOWN >= this->MetaValue) {
272  return (Input::ButtonState) this->MetaValue;
273  }else{
274  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Invalid ButtonState in MetaValue");
275  }
276  }
277 
279  {
280  if( Input::DIRECTIONALMOTION_DOWNRIGHT <= this->MetaValue && Input::DIRECTIONALMOTION_UPLEFT >= this->MetaValue) {
282  }else{
283  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Invalid DirectionalMotionState in MetaValue");
284  }
285  }
286 
288  {
289  Input::InputCode Answer = (Input::InputCode)(ButtonNumber + (UInt16)Input::MOUSEBUTTON);
290  if ( Input::MOUSEBUTTON_FIRST > Answer && Input::MOUSEBUTTON_LAST < Answer)
291  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Unsupported mouse Button."); }
292  return Answer;
293  }
294 
296  {
299  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Unsupported Controller Button."); }
300  return Answer;
301  }
302 
304  {
307  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Unsupported Controller Axis."); }
308  return Answer;
309  }
310 
312  {
313  Input::InputCode Answer = (Input::InputCode)(HatNumber + (UInt16)Input::CONTROLLERHAT);
314  if ( Input::CONTROLLERHAT_FIRST > Answer && Input::CONTROLLERHAT_LAST < Answer)
315  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Unsupported Controller Hat."); }
316  return Answer;
317  }
318 
319  ///////////////////////////////////////////////////////////////////////////////
320  // Utility Checks
321 
323  { return (Input::KEY_FIRST <= this->Code && Input::KEY_LAST >= this->Code); }
324 
326  { return (Input::MOUSEBUTTON_FIRST <= this->Code && Input::MOUSEBUTTON_LAST >= this->Code); }
327 
329  { return (Input::CONTROLLERBUTTON_FIRST <= this->Code && Input::CONTROLLERBUTTON_LAST >= this->Code); }
330 
332  { return (this->IsKeyboardButton() || this->IsMouseButton() || this->IsControllerButton()); }
333 
335  { return this->IsKeyboardButton(); }
336 
338  { return (Input::MOUSE_FIRST <= this->Code && Input::MOUSE_LAST >= this->Code) || this->IsMouseMultiClickEvent(); }
339 
341  { return (Input::MOUSEMOTION_FIRST <= this->Code && Input::MOUSEMOTION_LAST && this->Code); }
342 
344  { return (Input::COMPOUNDINPUT_MOUSEMULTICLICKFIRST <= this->Code && Input::COMPOUNDINPUT_MOUSEMULTICLICKLAST >= this->Code); }
345 
347  { return (Input::MULTITOUCH_FIRST <= this->Code && Input::MULTITOUCH_LAST >= this->Code); }
348 
350  { return (Input::CONTROLLER_FIRST <= this->Code && Input::CONTROLLER_LAST >= this->Code); }
351 
353  { return (Input::CONTROLLERAXIS_FIRST <= this->Code && Input::CONTROLLERAXIS_LAST >= this->Code); }
354 
356  { return (Input::CONTROLLERHAT_FIRST <= this->Code && Input::CONTROLLERHAT_LAST >= this->Code); }
357 
359  { return (Input::INPUTEVENT_FIRST <= this->Code && Input::INPUTEVENT_LAST >= this->Code); }
360 
362  { return (Input::KEY_LALT == this->Code || Input::KEY_RALT == this->Code); }
363 
365  { return (Input::KEY_LCTRL == this->Code || Input::KEY_RCTRL == this->Code); }
366 
368  { return (Input::KEY_LSHIFT == this->Code || Input::KEY_RSHIFT == this->Code); }
369 
371  { return (Input::KEY_LSUPER == this->Code || Input::KEY_RSUPER == this->Code); }
372 
374  { return ( this->IsDeviceButton() ); }
375 
377  {
378  if( this->IsKeyboardEvent() ) return Input::DEVICE_KEYBOARD;
379  else if( this->IsMouseEvent() ) return Input::DEVICE_MOUSE;
380  else if( this->IsMultitouchEvent() ) return Input::DEVICE_MULTITOUCH;
381  else if( this->IsControllerEvent() ) return Input::DEVICE_CONTROLLER;
382  else return Input::DEVICE_UNKNOWN;
383  }
384 
385  ///////////////////////////////////////////////////////////////////////////////
386  // Operators
387 
389  {
390  this->Code = Other.Code;
391  this->MetaValue = Other.MetaValue;
392  this->DeviceIndex = Other.DeviceIndex;
393  return *this;
394  }
395 
396  Boole MetaCode::operator==(const MetaCode& Other) const
397  {
398  return (this->Code == Other.Code &&
399  this->MetaValue == Other.MetaValue &&
400  this->DeviceIndex == Other.DeviceIndex);
401  }
402 
403  Boole MetaCode::operator!=(const MetaCode& Other) const
404  {
405  return (this->Code != Other.Code ||
406  this->MetaValue != Other.MetaValue ||
407  this->DeviceIndex != Other.DeviceIndex);
408  }
409 
410  Boole MetaCode::operator<(const MetaCode& Other) const
411  { return (this->Code < Other.Code); }
412 
413  Boole MetaCode::operator>(const MetaCode& Other) const
414  { return (this->Code > Other.Code); }
415 
416  void MetaCode::ProtoSerialize(XML::Node& CurrentRoot) const
417  {
418  XML::Node SelfNode = CurrentRoot.AppendChild( MetaCode::GetSerializableName() );
419 
420  if( SelfNode.AppendAttribute("Version").SetValue("1") &&
421  SelfNode.AppendAttribute("MetaValue").SetValue( this->MetaValue ) &&
422  SelfNode.AppendAttribute("DeviceIndex").SetValue( this->DeviceIndex ) &&
423  SelfNode.AppendAttribute("Code").SetValue( this->Code ) )
424  {
425  return;
426  }else{
427  SerializeError("Create XML Attribute Values",MetaCode::GetSerializableName(),true);
428  }
429  }
430 
432  {
433  XML::Attribute CurrAttrib;
434 
435  if( String(OneNode.Name()) == MetaCode::GetSerializableName() ) {
436  if(OneNode.GetAttribute("Version").AsInt() == 1) {
437  CurrAttrib = OneNode.GetAttribute("MetaValue");
438  if( !CurrAttrib.Empty() )
439  this->MetaValue = CurrAttrib.AsInt();
440 
441  CurrAttrib = OneNode.GetAttribute("DeviceIndex");
442  if( !CurrAttrib.Empty() )
443  this->DeviceIndex = CurrAttrib.AsInt();
444 
445  CurrAttrib = OneNode.GetAttribute("Code");
446  if( !CurrAttrib.Empty() )
447  this->Code = static_cast<Input::InputCode>( CurrAttrib.AsUint() );
448  }else{
449  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + MetaCode::GetSerializableName() + ": Not Version 1.");
450  }
451  }else{
452  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,MetaCode::GetSerializableName() + " was not found in the provided XML node, which was expected.");
453  }
454  }
455 
457  { return "MetaCode"; }
458  }//Input
459 }//Mezzanine
460 
461 std::ostream& operator << (std::ostream& stream, const Mezzanine::Input::MetaCode& x)
462 {
463  //stream << "<MetaCode Version=\"1\" MetaValue=\"" << x.GetMetaValue() << "\"" << " Code=\"" << x.GetCode() << "\" />";
464  Mezzanine::Serialize(stream,x);
465  return stream;
466 }
467 
468 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::Input::MetaCode& x)
469  { return Mezzanine::DeSerialize(stream, x); }
470 
472 {
473  x.ProtoDeSerialize(OneNode);
474  return OneNode;
475 }
476 
477 #endif
DirectionalMotionState
An Optional listing of values that can be used in a metacode Indicate spin, digital or binary travel ...
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
Definition: interpolator.h:433
int32_t Int32
An 32-bit integer.
Definition: datatypes.h:124
This contains simple tools for indexing with UTF8 characters swiftly.
This is the lowest mouse button value, all mice values will be larger of equal to this...
InputCode
The InputCode enum defines all the posible types of inputs.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
The last Multi Touch event.
static Input::InputCode GetMouseButtonCode(const UInt16 ButtonNumber)
Accepts a int and returns the InputCode for the Corresponding Mouse button.
Definition: metacode.cpp:287
Boole IsControllerEvent() const
Does this MetaCode Represent a state of a Controller Event.
Definition: metacode.cpp:349
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
static Input::InputCode GetInputCodeFromSDL_MOUSE(const RawEvent &Raw)
Converts an internal mouse input event into a Mezzanine mouse InputCode.
Definition: metacode.cpp:219
void SetCode(const Input::InputCode NewCode)
This Sets The InputCode.
Definition: metacode.cpp:238
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Input::InputCode Code
The code indicating what type of input this is.
Definition: metacode.h:111
Int32 DeviceIndex
The device index if this is input from a controller. For keyboards and mice this is the max value if ...
Definition: metacode.h:108
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
Definition: metacode.cpp:416
void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
Definition: metacode.cpp:431
Boole IsAltKey() const
Is this a left or right Alt key.
Definition: metacode.cpp:361
The last MouseEvent Code, all Mouse events will be less than this.
Boole IsInputEvent() const
Does this MetaCode Represent some other (non-keyboard and non-mouse button).
Definition: metacode.cpp:358
Int32 GetDeviceIndex() const
Gets the currently set device index.
Definition: metacode.cpp:256
The Last Controller axis event, all joystick axis event will be lower or equal to this...
The Last mouse button event, all mouse button event will be lower or equal to this.
Thrown when the requested identity could not be found.
Definition: exception.h:94
static Input::InputCode GetInputCodeFromSDL_KEY(const RawEvent &Raw)
Converts an internal keyboard input event into a Mezzanine keyboard InputCode.
Definition: metacode.cpp:208
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
Thrown when we just have not coded a thing yet, but we knew what the API should look like...
Definition: exception.h:117
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.
Definition: datatypes.h:154
static Input::InputCode GetControllerAxisCode(const UInt16 AxisNumber)
Accepts a int and returns the InputCode for the Corresponding Controller Axis.
Definition: metacode.cpp:303
Most Commonly Right click.
STL namespace.
Int32 MetaValue
The relevant value for the type of input this is, if applicable.
Definition: metacode.h:105
The Last Controller button event, all Controller button event will be lower or equal to this...
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
Boole IsPollable() const
Is this metacode a pollable event.
Definition: metacode.cpp:373
Boole IsMultitouchEvent() const
Does this MetaCode Represent a state of a multitouch device.
Definition: metacode.cpp:346
void SetNullValues()
Sets all the values of this MetaCode to Null values.
Definition: metacode.cpp:259
Boole IsControllerHatEvent() const
Does this MetaCode Represent a hat position on a controller.
Definition: metacode.cpp:355
String GetSerializableName() const
Get the name of the the XML tag this class will leave behind as its instances are serialized...
Definition: metacode.cpp:456
SDL_Event RawEvent
This is an internal datatype use to communicate with the User input Subsystem.
Definition: datatypes.h:219
This is the lowest Controller button value, all joystickbutton values will be larger of equal to this...
This implements the exception hiearchy for Mezzanine.
Int32 GetMetaValue() const
This Returns the MetaValue.
Definition: metacode.cpp:250
The interface for serialization.
Boole IsKeyboardButton() const
Does this MetaCode Represent a state of a keyboard key.
Definition: metacode.cpp:322
Boole IsControllerButton() const
Does this MetaCode Represent a state of a Controller button.
Definition: metacode.cpp:328
MetaCode & operator=(const MetaCode &Other)
Assignment operator.
Definition: metacode.cpp:388
bool SetValue(const Char8 *rhs)
Set the value of this.
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
Boole operator>(const MetaCode &Other) const
Compares two MetaCode's to see if this is greater.
Definition: metacode.cpp:413
static Input::InputCode GetControllerHatCode(const UInt16 HatNumber)
Accepts a int and returns the InputCode for the Corresponding Controller Hat.
Definition: metacode.cpp:311
Boole operator<(const MetaCode &Other) const
Compares two MetaCode's to see if this is less.
Definition: metacode.cpp:410
This is the generic Some stickbutton button code. You can add the number of the jpystick button to th...
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
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. ...
static MetaCodeContainer CreateMetaCodes(const RawEvent &Raw)
Internal creation method.
Definition: metacode.cpp:99
Boole IsKeyboardEvent() const
Does this MetaCode Represent a state of a keyboard Event.
Definition: metacode.cpp:334
bool Empty() const
Is this storing anything at all?
Boole operator==(const MetaCode &Other) const
Compares two MetaCode's for equality.
Definition: metacode.cpp:396
This is the generic Controller axis code. You can add the number of the Controller axis to this and y...
Most commonly left click.
void SetDeviceIndex(const Int32 Index)
Sets the device index if applicable.
Definition: metacode.cpp:253
Boole IsShiftKey() const
Is this a left or right Shift key.
Definition: metacode.cpp:367
Boole operator!=(const MetaCode &Other) const
Compares two MetaCode's for inequality.
Definition: metacode.cpp:403
The last Keyboard InputCode, all Keys values will be less than this, and all Events will be larger th...
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
Input::DirectionalMotionState GetMetaValueAsDirectionalMotionState() const
Get the MetaValue as a Input::DirectionalMotionState.
Definition: metacode.cpp:278
This is the generic Some mouse button code. You can add the number of the mouse button to this and yo...
Input::InputCode GetCode() const
This Returns the Inputcode.
Definition: metacode.cpp:244
~MetaCode()
Class destructor.
Definition: metacode.cpp:96
This is the lowest Controller axis value, all jpystick values will be larger of equal to this...
InputDevice
An enum listing containing the different kind of input devices, useful for some query functions...
Thrown when parameters are checked at runtime and found invalid.
Definition: exception.h:108
Most commonly middle click.
This Determines the kind of user input.
Definition: metacode.h:93
Boole IsCtrlKey() const
Is this a left or right Ctrl key.
Definition: metacode.cpp:364
static Input::InputCode GetControllerButtonCode(const UInt16 ButtonNumber)
Accepts a int and returns the InputCode for the Corresponding Controller button.
Definition: metacode.cpp:295
Int32 GetIntFromCharacter(Int32 &BytesUsed, const char *CurrentCharacter)
Get a number suitable for using in an index from a character string.
Definition: unicode.cpp:86
The last Controller Input Code, all Controller events will be less than this.
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
std::vector< Input::MetaCode > MetaCodeContainer
Convenience datatype for storage of MetaCodes.
Definition: metacode.h:97
void SetMetaValue(const Int32 Value)
This Sets The MetaValue.
Definition: metacode.cpp:247
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
ButtonState
An Optional listing of value that can be used in a metacode to represent the information of a button ...
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
Definition: interpolator.h:448
Boole IsDeviceButton() const
Does this MetaCode Represent a state of any button on an input device.
Definition: metacode.cpp:331
Boole IsSuperKey() const
Is this a left or right Super key (Windows logo key, Apple logo key, etc...).
Definition: metacode.cpp:370
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
Boole IsMouseMultiClickEvent() const
Does this MetaCode Represent multiple clicks of a mouse button.
Definition: metacode.cpp:343
MetaCode()
Default constructor.
Definition: metacode.cpp:72
The last Input Code, all event codes will be less than this.
static Input::InputCode GetInputCodeFromSDL_JOYSTICK(const RawEvent &Raw)
Converts an internal controller input event into a Mezzanine controller InputCode.
Definition: metacode.cpp:232
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.
Input::InputDevice GetDeviceType() const
Gets the device-type this MetaCode is representing.
Definition: metacode.cpp:376
Input::ButtonState GetMetaValueAsButtonState() const
Get the MetaValue as a Input::ButtonState.
Definition: metacode.cpp:269
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Boole IsMouseMotionEvent() const
Does this MetaCode Represent movement of the mouse or mouse wheel.
Definition: metacode.cpp:340
Boole IsMouseEvent() const
Does this MetaCode Represent a state of a mouse Event.
Definition: metacode.cpp:337
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Boole IsMouseButton() const
Does this MetaCode Represent a state of a Mouse button.
Definition: metacode.cpp:325
Boole IsControllerAxisEvent() const
Does this MetaCode Represent an axis position on a controller.
Definition: metacode.cpp:352