40 #ifndef _EVENTUSERINPUT_CPP
41 #define _EVENTUSERINPUT_CPP
52 #include "eventuserinput.h"
55 #include "stringtool.h"
70 EventUserInput::EventUserInput()
74 { this->push_back(Code_); }
76 EventUserInput::EventUserInput(
const vector<Input::MetaCode>& Code_)
79 EventUserInput::~EventUserInput()
83 {
return this->at(Index); }
85 size_t EventUserInput::GetMetaCodeCount()
86 {
return this->size(); }
90 this->push_back(Code_);
97 return this->AddCode(CurrentMetaCode);
103 return this->AddCode(CurrentMetaCode);
106 void EventUserInput::AddCodes(
const vector<Input::MetaCode>& Codes)
108 for(
unsigned int c=0; Codes.size()>c ; c++)
109 { this->push_back(Codes.at(c)); }
114 vector<Input::MetaCode>::iterator iter;
116 for(iter=this->begin(); this->end()!=iter ; iter++)
125 void EventUserInput::EraseCode(
const unsigned int& Index)
126 { this->erase(this->begin()+Index); }
129 {
return UserInput; }
135 vector<Input::MetaCode> EventUserInput::AddCodesFromSDLMouseMotion(
const RawEvent& RawEvent_)
137 vector<Input::MetaCode> Results;
139 Results.push_back(this->AddCode(RawEvent_.motion.x, Input::MOUSEABSOLUTEHORIZONTAL));
140 Results.push_back(this->AddCode(RawEvent_.motion.y, Input::MOUSEABSOLUTEVERTICAL));
142 if(0 != RawEvent_.motion.xrel)
143 { Results.push_back(this->AddCode(RawEvent_.motion.xrel, Input::MOUSEHORIZONTAL));}
145 if(0 != RawEvent_.motion.yrel)
146 { Results.push_back(this->AddCode(RawEvent_.motion.yrel, Input::MOUSEVERTICAL));}
150 vector<Input::MetaCode> EventUserInput::AddCodesFromSDLJoyStickMotion(
const RawEvent& RawEvent_)
152 vector<Input::MetaCode> Results;
154 Results.push_back(this->AddCode(RawEvent_.jaxis.value, Input::MetaCode::GetControllerAxisCode(RawEvent_.jaxis.axis+1), RawEvent_.jaxis.which));
159 vector<Input::MetaCode> EventUserInput::AddCodeFromSDLJoyStickHat(
const RawEvent& RawEvent_)
161 vector<Input::MetaCode> Results;
164 if( Input::CONTROLLERHAT_FIRST > Hat || Input::CONTROLLERHAT_LAST < Hat )
166 MEZZ_EXCEPTION(ExceptionBase::NOT_IMPLEMENTED_EXCEPTION,
"Unsupported Controller Hat Event");
169 Results.push_back(this->AddCode( RawEvent_.jhat.value, Hat, RawEvent_.jhat.which ));
173 vector<Input::MetaCode> EventUserInput::AddCodeFromSDLJoyStickBall(
const RawEvent& RawEvent_)
175 vector<Input::MetaCode> Results;
177 if( 0 == RawEvent_.jball.ball )
179 if( RawEvent_.jball.yrel != 0 )
180 { Results.push_back(this->AddCode(RawEvent_.jball.yrel, Input::CONTROLLERBALL_1_VERTICAL, RawEvent_.jball.which)); }
181 if( RawEvent_.jball.xrel != 0 )
182 { Results.push_back(this->AddCode(RawEvent_.jball.xrel, Input::CONTROLLERBALL_1_HORIZONTAL, RawEvent_.jball.which)); }
183 }
else if( 1 == RawEvent_.jball.ball ){
184 if( RawEvent_.jball.yrel != 0 )
185 { Results.push_back(this->AddCode(RawEvent_.jball.yrel, Input::CONTROLLERBALL_2_VERTICAL, RawEvent_.jball.which)); }
186 if( RawEvent_.jball.xrel != 0 )
187 { Results.push_back(this->AddCode(RawEvent_.jball.xrel, Input::CONTROLLERBALL_2_HORIZONTAL, RawEvent_.jball.which)); }
189 MEZZ_EXCEPTION(ExceptionBase::NOT_IMPLEMENTED_EXCEPTION,
"More then 2 trackballs is currently not supported. Perhaps we should expand our enum.");
201 stream <<
"<EventUserInput Version=\"1\">";
202 for (vector<Mezzanine::Input::MetaCode>::const_iterator Iter = Ev.begin(); Iter!=Ev.end(); ++Iter)
206 stream <<
"</EventUserInput>";
216 Doc->GetFirstChild() >> Ev;
String GetOneTag(std::istream &stream)
Gets the first tag out of the Stream and returns it as a String.
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
Document * PreParseClassFromSingleTag(const String &NameSpace, const String &ClassName, const String &OneTag)
Perform a basic series of checks for extracting meaning from a single xml tag.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
A simple reference counting pointer.
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.
Node GetNextSibling() const
Attempt to retrieve the next sibling of this Node.
uint16_t UInt16
An 16-bit unsigned integer.
EventType
A listing of values that can be used to identify Events.
A light-weight handle for manipulating nodes in DOM tree.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
Thrown when the identity string wasn't valid at all.
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.
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.