Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
src
engine
Input
Input.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_INPUT
8
#define ENGINE_INPUT
9
10
namespace
Engine::Input {
11
15
enum
KeyCodes {
16
SPACE = 32
17
};
18
22
enum
MouseActions {
23
LEFT = 0,
24
MIDDLE = 1,
25
RIGHT = 2,
26
SCROLLUP = 3,
27
SCROLLDOWN = 4
28
};
29
30
enum
InputDevice {
31
KEYBOARD,
32
GAMEPAD,
33
MOUSE
34
};
35
39
struct
InputParams
{
40
char
keyCode = -1;
41
char
mouseButton = -1;
42
char
gamepadInput = -1;
43
};
44
56
class
Input
{
57
private
:
58
char
m_keyCode;
59
char
m_mouseButton;
60
char
m_gamepadInput;
61
62
float
m_isDown = 0;
63
bool
m_isPressed =
false
;
64
bool
m_isReleased =
false
;
65
66
public
:
67
68
float
currentStrength = 0;
69
79
Input
(
InputParams
params);
80
86
Input
() :
Input
((
InputParams
){}) {};
87
91
~Input
();
92
102
void
Update
();
103
109
bool
IsPressed
()
const
;
110
116
bool
IsReleased
()
const
;
117
123
bool
IsDown
()
const
;
124
130
float
Strength
()
const
;
131
149
char
GetInput
(InputDevice mode)
const
;
150
};
151
}
152
153
#endif
Engine::Input::Input
A class used to represent a single input in an InputManager.
Definition
Input.hpp:56
Engine::Input::Input::Strength
float Strength() const
Definition
Input.cpp:56
Engine::Input::Input::~Input
~Input()
Definition
Input.cpp:25
Engine::Input::Input::Input
Input()
Definition
Input.hpp:86
Engine::Input::Input::GetInput
char GetInput(InputDevice mode) const
Definition
Input.cpp:60
Engine::Input::Input::IsPressed
bool IsPressed() const
Checks if the input is just pressed.
Definition
Input.cpp:44
Engine::Input::Input::Update
void Update()
Updates the state of each possible input solution.
Definition
Input.cpp:35
Engine::Input::Input::IsDown
bool IsDown() const
Checks if the input is down.
Definition
Input.cpp:52
Engine::Input::Input::IsReleased
bool IsReleased() const
Checks if the input is just released.
Definition
Input.cpp:48
Engine::Input::InputParams
A struct used to hold the parameters of an input.
Definition
Input.hpp:39
Generated by
1.9.8