40 #ifndef _inputmouse_cpp
41 #define _inputmouse_cpp
43 #include "Input/mouse.h"
44 #include "Graphics/viewport.h"
45 #include "Graphics/gamewindow.h"
46 #include "exception.h"
53 #include "../src/video/SDL_sysvideo.h"
60 CurrentViewport(NULL),
69 this->MulticlickTimer->
Reset();
74 delete MulticlickTimer;
77 void Mouse::UpdateImpl(
const MetaCodeContainer& DeltaCodes, MetaCodeContainer& GeneratedCodes)
84 SDL_Window* Focus = SDL_GetMouseFocus();
85 Vector2 OldPosition = this->Position;
87 for(
Whole X = 0 ; X < DeltaCodes.size() ; ++X )
89 const MetaCode& CurrCode = DeltaCodes[X];
102 else this->MulticlickTimer->
Reset();
105 if( this->MulticlickCode.
GetCode() != MCICode )
108 this->MulticlickCode.
SetCode(MCICode);
113 this->MulticlickTimer->
Start();
116 else if( Input::MOUSEWHEELVERTICAL == ICode )
120 else if( Input::MOUSEWHEELHORIZONTAL == ICode )
127 if( Input::MOUSEABSOLUTEVERTICAL == ICode )
131 else if( Input::MOUSEABSOLUTEHORIZONTAL == ICode )
156 this->CurrentViewport = VP;
161 this->CurrentViewport = NULL;
165 this->Delta = this->Position - OldPosition;
169 GeneratedCodes.push_back(MulticlickCode);
172 this->Sequences.
Update(DeltaCodes,GeneratedCodes);
177 for( ConstMetaCodeIterator MCIt = Sequence.begin() ; MCIt != Sequence.end() ; ++MCIt )
179 if( !MCIt->IsMouseEvent() )
186 for(
UInt32 Index = 0 ; Index < this->Buttons.size() ; ++Index )
195 return (Input::MOUSEBUTTON_1 <= Code && Input::MOUSEBUTTON_2 >= Code);
215 {
return this->CurrentViewport; }
218 {
return ( this->CurrentViewport ? this->CurrentViewport->
GetParentWindow() : NULL ); }
221 {
return this->Position; }
224 {
return this->Position.
X; }
227 {
return this->Position.
Y; }
230 {
return ( this->CurrentViewport ? this->Position -
Vector2( this->CurrentViewport->
GetLeft(),this->CurrentViewport->
GetTop() ) :
Vector2(0,0) ); }
239 {
return this->Delta; }
242 {
return this->Delta.
X; }
245 {
return this->Delta.
Y; }
248 {
return std::numeric_limits<UInt16>::max(); }
251 {
return this->Buttons.at( Button - 1 ); }
257 {
return this->VerticalWheelState; }
260 {
return this->HorizontalWheelState; }
266 { SDL_ShowCursor(Visible); }
269 {
return 0 != SDL_ShowCursor(-1); }
272 {
return 0 == SDL_SetRelativeMouseMode( (Enable?SDL_TRUE:SDL_FALSE) ); }
275 {
return SDL_GetRelativeMouseMode(); }