| @@ -30,11 +30,12 @@ static class InputData | |||||
| public: | public: | ||||
| InputData() | InputData() | ||||
| { | |||||
| mouse.x = mouse.y = -1; | |||||
| } | |||||
| : mouse(-1, -1), | |||||
| buttons(0, 0, 0) | |||||
| { } | |||||
| Int2 mouse; | Int2 mouse; | ||||
| Int3 buttons; | |||||
| } | } | ||||
| inputdata; | inputdata; | ||||
| @@ -74,3 +75,18 @@ Int2 Input::GetMousePos() | |||||
| return data->mouse; | return data->mouse; | ||||
| } | } | ||||
| void Input::SetMouseButton(int index) | |||||
| { | |||||
| data->buttons[index] = 1; | |||||
| } | |||||
| void Input::UnsetMouseButton(int index) | |||||
| { | |||||
| data->buttons[index] = 0; | |||||
| } | |||||
| Int3 Input::GetMouseButtons() | |||||
| { | |||||
| return data->buttons; | |||||
| } | |||||
| @@ -24,6 +24,9 @@ public: | |||||
| static Float2 GetAxis(int axis); | static Float2 GetAxis(int axis); | ||||
| static void SetMousePos(Int2 coord); | static void SetMousePos(Int2 coord); | ||||
| static Int2 GetMousePos(); | static Int2 GetMousePos(); | ||||
| static void SetMouseButton(int index); | |||||
| static void UnsetMouseButton(int index); | |||||
| static Int3 GetMouseButtons(); | |||||
| }; | }; | ||||
| #endif // __DH_INPUT_H__ | #endif // __DH_INPUT_H__ | ||||
| @@ -65,6 +65,10 @@ void SdlInput::TickGame(float deltams) | |||||
| else if (event.type == SDL_KEYDOWN) | else if (event.type == SDL_KEYDOWN) | ||||
| Input::KeyPressed(event.key.keysym.sym, deltams); | Input::KeyPressed(event.key.keysym.sym, deltams); | ||||
| #endif | #endif | ||||
| else if (event.type == SDL_MOUSEBUTTONDOWN) | |||||
| Input::SetMouseButton(event.button.button - 1); | |||||
| else if (event.type == SDL_MOUSEBUTTONUP) | |||||
| Input::UnsetMouseButton(event.button.button - 1); | |||||
| } | } | ||||
| /* Send the whole keyboard state to the input system */ | /* Send the whole keyboard state to the input system */ | ||||