@@ -8,8 +8,7 @@ namespace Util {
88
99// init all static members
1010SDL_Event Input::s_Event = SDL_Event();
11-
12- glm::vec2 Input::s_CursorPosition = glm::vec2(0 .0F );
11+ Util::PTSDPosition Input::s_CursorPosition = Util::PTSDPosition(0 .0F , 0 .0F );
1312glm::vec2 Input::s_ScrollDistance = glm::vec2(-1 .0F , -1 .0F );
1413
1514std::unordered_map<Keycode, std::pair<bool , bool >> Input::s_KeyState = {
@@ -78,12 +77,7 @@ void Input::UpdateKeyState(const SDL_Event *event) {
7877void Input::Update () {
7978 int x, y;
8079 SDL_GetMouseState (&x, &y);
81- s_CursorPosition.x = static_cast <float >(x);
82- s_CursorPosition.y = static_cast <float >(y);
83-
84- s_CursorPosition.x -= static_cast <float >(PTSD_Config::WINDOW_WIDTH) / 2 ;
85- s_CursorPosition.y = -(s_CursorPosition.y -
86- static_cast <float >(PTSD_Config::WINDOW_HEIGHT) / 2 );
80+ s_CursorPosition = Util::PTSDPosition::FromSDL (x, y);
8781
8882 s_Scroll = s_MouseMoving = false ;
8983
@@ -116,13 +110,13 @@ void Input::Update() {
116110 }
117111}
118112
119- glm::vec2 Input::GetCursorPosition () {
113+ Util::PTSDPosition Input::GetCursorPosition () {
120114 return s_CursorPosition;
121115}
122116
123- void Input::SetCursorPosition (const glm::vec2 &pos ) {
124- SDL_WarpMouseInWindow ( nullptr , static_cast < int >(pos. x ),
125- static_cast < int >(pos. y ) );
117+ void Input::SetCursorPosition (const Util::PTSDPosition &ptsdPos ) {
118+ auto sdlPos = ptsdPos. ToSDLPosition ();
119+ SDL_WarpMouseInWindow ( nullptr , sdlPos. x , sdlPos. y );
126120}
127121
128122} // namespace Util
0 commit comments