40 #ifndef _inputcontroller_cpp
41 #define _inputcontroller_cpp
43 #include "Input/controller.h"
45 #include "exception.h"
55 SDL_Joystick* InternalController = (SDL_Joystick*)InternalControl;
56 this->Axes.resize( SDL_JoystickNumAxes(InternalController), 0 );
57 this->Trackballs.resize( SDL_JoystickNumBalls(InternalController),
Vector2(0,0) );
58 this->Buttons.resize( SDL_JoystickNumButtons(InternalController),
Input::BUTTON_UP );
59 this->Hats.resize( SDL_JoystickNumHats(InternalController), Input::CONTROLLERHAT_CENTERED );
61 this->DeviceName = SDL_JoystickName(InternalController);
71 for(
Whole X = 0 ; X < DeltaCodes.size() ; ++X )
73 const MetaCode& CurrCode = DeltaCodes[X];
78 else if(CurrCode.
GetCode() >= Input::CONTROLLERBALL_FIRST && CurrCode.
GetCode() <= Input::CONTROLLERBALL_LAST)
80 if( Input::CONTROLLERBALL_1_HORIZONTAL == CurrCode.
GetCode() ){
82 }
else if( Input::CONTROLLERBALL_1_VERTICAL == CurrCode.
GetCode() ){
84 }
else if( Input::CONTROLLERBALL_2_HORIZONTAL == CurrCode.
GetCode() ){
86 }
else if( Input::CONTROLLERBALL_2_VERTICAL == CurrCode.
GetCode() ){
95 else if(CurrCode.
GetCode() >= Input::CONTROLLERHAT_FIRST && CurrCode.
GetCode() <= Input::CONTROLLERHAT_LAST)
97 this->Hats.at( CurrCode.
GetCode() - Input::CONTROLLERHAT_FIRST ) = static_cast<Input::HatState>(CurrCode.
GetMetaValue());
100 this->Sequences.
Update(DeltaCodes,GeneratedCodes);
105 for( ConstMetaCodeIterator MCIt = Sequence.begin() ; MCIt != Sequence.end() ; ++MCIt )
107 if( !MCIt->IsControllerEvent() )
108 { MEZZ_EXCEPTION(
Exception::PARAMETERS_EXCEPTION,
"Non-Controller MetaCode detected when attempting to insert an Input Sequence into Controller input device.") }
114 for(
UInt32 Index = 0 ; Index < this->Buttons.size() ; ++Index )
125 {
return this->Index; }
128 {
return this->DeviceName; }
131 {
return this->Axes.size(); }
134 {
return this->Trackballs.size(); }
137 {
return this->Hats.size(); }
143 {
return this->Axes.at( Axis - 1 ); }
146 {
return this->Trackballs.at( Trackball - 1 ); }
155 {
return this->Hats.at( Hat - 1 ); }
162 if( Input::CONTROLLERBALL_1_HORIZONTAL == Trackball ){
163 return this->Trackballs.at(0).X;
164 }
else if( Input::CONTROLLERBALL_1_VERTICAL == Trackball ){
165 return this->Trackballs.at(0).Y;
166 }
else if( Input::CONTROLLERBALL_2_HORIZONTAL == Trackball ){
167 return this->Trackballs.at(1).X;
168 }
else if( Input::CONTROLLERBALL_2_VERTICAL == Trackball ){
169 return this->Trackballs.at(1).Y;
176 {
return this->Buttons.at( Button - 1 ); }
182 {
return this->Hats.at( Hat - Input::CONTROLLERHAT_FIRST ); }