sfml_impl 0.1.0
Vendor SFML 3.0.2 : IGraphic2Module / IAudioModule
Loading...
Searching...
No Matches
SfmlMouse.hpp
Go to the documentation of this file.
1
11#ifndef SFMLMOUSE_HPP_
12#define SFMLMOUSE_HPP_
13
14//Sfml
15#include <SFML/Window.hpp>
16
17//Interface
18#include "IMouse.hpp"
19
20#include <unordered_map>
21
22class SfmlWindow;
23
29class SfmlMouse : public graphic::IMouse {
30
31 public:
32 SfmlMouse(SfmlWindow &window) : _window(window) {}
33
34 ~SfmlMouse() override = default;
35
36 bool isButtonPressed(Buttons key) const override;
37 bool isButtonReleased(Buttons key) const override;
38 bool isButtonDown(Buttons key) const override;
39 bool isButtonUp(Buttons key) const override;
40
41 // window-relative, like raylib - the contract mandates it, otherwise
42 // no hit-test written against it would be portable
43 Vector2f getPosition() const override;
44 void setPosition(Vector2f position) override;
45
46 float GetMouseWheelMove() const override;
47
48 private:
49 SfmlWindow &_window;
50
51 const std::unordered_map<Buttons, sf::Mouse::Button> _buttons = {
52 { Buttons::BUTTON_LEFT, sf::Mouse::Button::Left },
53 { Buttons::BUTTON_RIGHT, sf::Mouse::Button::Right },
54 { Buttons::BUTTON_MIDDLE, sf::Mouse::Button::Middle },
55
56 { Buttons::EXTRA_BUTTON_1, sf::Mouse::Button::Extra1 },
57 { Buttons::EXTRA_BUTTON_2, sf::Mouse::Button::Extra2 },
58 };
59};
60
63#endif /* !SFMLMOUSE_HPP_ */
Maps the contract's buttons to sfml buttons, and reads the state the window accumulated while popping...
Definition SfmlMouse.hpp:29
~SfmlMouse() override=default
SfmlMouse(SfmlWindow &window)
Definition SfmlMouse.hpp:32
Sfml Window class - implements IWindow2 only, sfml has no 3D.
Definition SfmlWindow.hpp:46
bool isButtonPressed(Buttons key) const override
Definition SfmlWindow.hpp:297
float GetMouseWheelMove() const override
Definition SfmlWindow.hpp:326
bool isButtonDown(Buttons key) const override
Definition SfmlWindow.hpp:311
bool isButtonUp(Buttons key) const override
Definition SfmlWindow.hpp:312
bool isButtonReleased(Buttons key) const override
Definition SfmlWindow.hpp:304
void setPosition(Vector2f position) override
Definition SfmlWindow.hpp:319
Vector2f getPosition() const override
Definition SfmlWindow.hpp:314