40 #ifndef _inputmetacode_cpp
41 #define _inputmetacode_cpp
49 #include "exception.h"
50 #include "Input/metacode.h"
51 #include "stringtool.h"
71 MetaCode::MetaCode() : MetaValue(0), DeviceIndex( numeric_limits<
UInt16>::max() ), Code(Input::
KEY_UNKNOWN)
79 this->Construct(Value, NewCode);
84 this->Construct(Value, NewCode);
90 this->Construct(RawEvent_);
93 void MetaCode::Construct(
const RawEvent& RawEvent_)
95 switch(RawEvent_.type)
103 case SDL_MOUSEBUTTONDOWN:
106 case SDL_MOUSEBUTTONUP:
109 case SDL_JOYBUTTONDOWN:
112 case SDL_JOYBUTTONUP:
117 case SDL_JOYBALLMOTION:
case SDL_JOYHATMOTION:
118 case SDL_JOYAXISMOTION:
case SDL_MOUSEMOTION:
145 assert(
sizeof(To)==
sizeof(RawEvent_.key.keysym.sym) );
146 memcpy( &To, &(RawEvent_.key.keysym.scancode),
sizeof(RawEvent_.key.keysym.scancode));
153 switch (RawEvent_.button.button )
158 case SDL_BUTTON_X1:
return Input::MOUSEBUTTON_4;
159 case SDL_BUTTON_X2:
return Input::MOUSEBUTTON_5;
170 { this->Code = NewCode; }
176 {
return this->Code; }
179 { this->MetaValue = Value; }
182 {
return this->MetaValue; }
185 { this->DeviceIndex = Index; }
188 {
return DeviceIndex; }
194 this->DeviceIndex = numeric_limits<UInt32>::max();
201 if( Input::BUTTON_LIFTING <= this->MetaValue &&
Input::BUTTON_DOWN >= this->MetaValue)
247 {
return (Input::KEY_FIRST <= this->Code &&
Input::KEY_LAST >= this->Code); }
265 {
return (Input::MOUSEMOTION_FIRST <= this->Code && Input::MOUSEMOTION_LAST && this->Code); }
268 {
return (Input::COMPOUNDINPUT_MOUSEMULTICLICKFIRST <= this->Code && Input::COMPOUNDINPUT_MOUSEMULTICLICKLAST >= this->Code); }
280 {
return (Input::CONTROLLERHAT_FIRST <= this->Code && Input::CONTROLLERHAT_LAST >= this->Code); }
289 {
return (Input::KEY_LCTRL == this->Code || Input::KEY_RCTRL == this->Code); }
292 {
return (Input::KEY_LSHIFT == this->Code || Input::KEY_RSHIFT == this->Code); }
306 else return Input::DEVICE_UNKNOWN;
314 this->Code = Other.Code;
315 this->MetaValue = Other.MetaValue;
316 this->DeviceIndex = Other.DeviceIndex;
322 return (this->Code == Other.Code &&
323 this->MetaValue == Other.MetaValue &&
324 this->DeviceIndex == Other.DeviceIndex);
329 return (this->Code != Other.Code ||
330 this->MetaValue != Other.MetaValue ||
331 this->DeviceIndex != Other.DeviceIndex);
336 return (this->Code < Other.Code);
341 return (this->Code > Other.Code);
354 if( VersionAttr && MetaValue_ && Code_ )
384 {
return String(
"MetaCode"); }