Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Keyboard.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_KEYBOARD
8#define ENGINE_KEYBOARD
9
10#include <vector>
11#include <emscripten/html5.h>
12
13#include "Input.hpp"
14
15
16namespace Engine::Input {
17
24 class Keyboard {
25 private:
26
27 std::vector<Input*> m_listeners;
28
29 Keyboard();
30
31 static bool keyDown_emscripten(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData);
32
33 static bool keyUp_emscripten(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData);
34
35 public:
36
40 static Keyboard& GetInstance();
41
45 void AddListener(Input* input);
46
50 void RemoveListener(Input* input);
51 };
52};
53
54#endif
A class used to represent a single input in an InputManager.
Definition Input.hpp:56
Singleton class used to handle keyboard input.
Definition Keyboard.hpp:24
void AddListener(Input *input)
Adds an input listener to the keyboard.
Definition Keyboard.cpp:54
void RemoveListener(Input *input)
Removes an input listener.
Definition Keyboard.cpp:58
static Keyboard & GetInstance()
Returns the singleton instance.
Definition Keyboard.cpp:49