sdl2_impl 0.1.0
Vendor SDL2 2.32 : IGraphic2Module / IAudioModule
Loading...
Searching...
No Matches
SdlMouse.hpp
Go to the documentation of this file.
1
11#ifndef SDLMOUSE_HPP_
12#define SDLMOUSE_HPP_
13
14//Sdl
15#include <SDL.h>
16
17//Interface
18#include "IMouse.hpp"
19
20#include <unordered_map>
21
22class SdlWindow;
23
24class SdlMouse : public graphic::IMouse {
25
26 public:
27 SdlMouse(SdlWindow &window) : _window(window) {}
28 ~SdlMouse() override = default;
29
30 //definis dans SdlWindow.hpp, une fois SdlWindow complete
31 bool isButtonPressed(Buttons key) const override;
32 bool isButtonReleased(Buttons key) const override;
33 bool isButtonDown(Buttons key) const override;
34 bool isButtonUp(Buttons key) const override;
35
36 //relative a la fenetre, comme raylib et sfml : le contrat l'impose,
37 //sinon aucun test de survol ecrit dessus ne serait portable
38 Vector2f getPosition() const override;
39 void setPosition(Vector2f position) override;
40
41 float GetMouseWheelMove() const override;
42
43 private:
44 SdlWindow &_window;
45
46 const std::unordered_map<Buttons, uint8_t> _buttons = {
47 { Buttons::BUTTON_LEFT, SDL_BUTTON_LEFT },
48 { Buttons::BUTTON_RIGHT, SDL_BUTTON_RIGHT },
49 { Buttons::BUTTON_MIDDLE, SDL_BUTTON_MIDDLE },
50 { Buttons::EXTRA_BUTTON_1, SDL_BUTTON_X1 },
51 { Buttons::EXTRA_BUTTON_2, SDL_BUTTON_X2 },
52 };
53};
54
57#endif /* !SDLMOUSE_HPP_ */
Definition SdlMouse.hpp:24
~SdlMouse() override=default
SdlMouse(SdlWindow &window)
Definition SdlMouse.hpp:27
Une fenetre SDL et son renderer, implemente IWindow2.
Definition SdlWindow.hpp:50
bool isButtonPressed(Buttons key) const override
Definition SdlWindow.hpp:470
void setPosition(Vector2f position) override
Definition SdlWindow.hpp:489
bool isButtonDown(Buttons key) const override
Definition SdlWindow.hpp:484
float GetMouseWheelMove() const override
Definition SdlWindow.hpp:494
bool isButtonReleased(Buttons key) const override
Definition SdlWindow.hpp:477
bool isButtonUp(Buttons key) const override
Definition SdlWindow.hpp:485
Vector2f getPosition() const override
Definition SdlWindow.hpp:487