Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Mouse.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef ENGINE_MOUSE
8#define ENGINE_MOUSE
9
10#include "Input.hpp"
11#include "../Utils.hpp"
12
13#include <vector>
14#include <emscripten/html5.h>
15
16namespace Engine::Input {
17
24 class Mouse {
25 private:
26
27 Vec2f m_position = {0, 0};
28
29 Mouse();
30
31 std::vector<Input*> m_listeners;
32
33 static bool mouseMove_emscripten(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
34
35 static bool mouseDown_emscripten(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
36
37 static bool mouseUp_emscripten(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData);
38
39 static bool mouseScroll_emscripten(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData);
40
41 public:
42
46 static Mouse& GetInstance();
47
53 void AddListener(Input* input);
54
60 void RemoveListener(Input* input);
61
69 };
70}
71
72#endif
A class used to represent a single input in an InputManager.
Definition Input.hpp:56
Singleton class used to handle mouse input.
Definition Mouse.hpp:24
void RemoveListener(Input *input)
Definition Mouse.cpp:85
void AddListener(Input *input)
Definition Mouse.cpp:81
static Mouse & GetInstance()
Returns the singleton instance.
Definition Mouse.cpp:89
Vec2f GetPosition()
Returns the position of the mouse.
Definition Mouse.cpp:94
A 2D vector struct with overloaded operators.
Definition Utils.hpp:38