Brunot
Loading...
Searching...
No Matches
Input.h
Go to the documentation of this file.
1
15// ____ __ __ __
16// /\__ _\/\ \ /\ \/\ \
17// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
18// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
19// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
20// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
21// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
22
23
24#pragma once
25
26
27
28#include "System/opengl.h"
29#include "Logging.h"
31
32#include "Framework/Keys.h"
34#include "Framework/Mouse.h"
35
36#undef max
37#undef min
38
39namespace sys
40{
41class Editor;
42class Input;
43}
44
46
47namespace sys
48{
53class Input : public System
54{
55
56public:
58 : System("Input", Type::Input)
59 {
60 }
61
62 ~Input() override = default;
63
67 static auto getEnum() -> Type
68 {
69 return Type::Input;
70 }
71
72 auto clone() const -> std::unique_ptr<GameObject> override;
73
74protected:
75 auto systemShowMenu() -> void override;
76
77public:
78 auto onUpdate(float dt) -> void override;
79
80 auto endWindow() -> void override
81 {
82 } // for debug ImGUI
83 auto onRender() -> void override;
84 auto load(const Stream& stream) -> void override;
85 auto save(Stream& stream) const -> void override;
86
88 auto setEnabled(bool newState) -> void;
90 auto getEnabled() const -> bool;
91
93 auto setKeysEnabled(bool newState) -> void;
95 auto getKeysEnabled() const -> bool;
96
98 auto setControllerEnabled(bool newState) -> void;
100 auto getControllerEnabled() const -> bool;
101
103 auto setMouseEnabled(bool newState) -> void;
105 auto getMouseEnabled() const -> bool;
106
111 auto getMousePosition() const -> std::pair<float, float>;
112
117 auto getWorldMousePosition() const -> const Vector4D&;
118
124 static auto getNameOfInputtingDevice(int id) -> std::string;
125
130 [[nodiscard]] auto keys() -> Keys&
131 {
132 return k;
133 }
134
139 [[nodiscard]] auto controllers() -> Controllers&
140 {
141 return c;
142 }
143
148 [[nodiscard]] auto mouse() -> Mouse&
149 {
150 return m;
151 }
152
153
154private:
158
159};
160}
sys::Json Stream
Definition AudioObject.h:20
Class that detects whenever controllers are plugged in and broadcasts whenever any of them do an inpu...
Class that can interact with the keyboard.
Class that tracks mouse position and detects whenever a mouse button is pressed.
Class that detects whenever controllers are plugged in and broadcasts whenever any of them do an inpu...
Definition Controllers.h:38
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
Class that can interact with the keyboard.
Definition Keys.h:33
Class that tracks mouse position and detects whenever a mouse button is pressed.
Definition Mouse.h:36
Type
Definition System.h:20
@ Input
Definition System.h:24
System(const std::string &typeName, Type systemType)
Definition System.cpp:75
Definition Editor.h:47
System responsible for handling inputs and sending messages when they occur.
Definition Input.h:54
auto getMouseEnabled() const -> bool
Returns if Mouse input is enabled or not.
Definition Input.cpp:122
Mouse m
Definition Input.h:157
auto load(const Stream &stream) -> void override
Definition Input.cpp:85
auto getMousePosition() const -> std::pair< float, float >
Gets the current mouse position in screen coordinates.
Definition Input.cpp:137
Controllers c
Definition Input.h:156
auto setControllerEnabled(bool newState) -> void
Sets whether input from Controllers are accepted or not.
Definition Input.cpp:127
static auto getNameOfInputtingDevice(int id) -> std::string
Gets the name of a specific inputting device ID.
Definition Input.cpp:147
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Input.h:80
auto setKeysEnabled(bool newState) -> void
Sets whether input from Keys are accepted or not.
Definition Input.cpp:107
auto getKeysEnabled() const -> bool
Returns if keyboard input is enabled or not.
Definition Input.cpp:112
auto getEnabled() const -> bool
Returns true if any of the input methods are enabled. Otherwise, returns false.
Definition Input.cpp:102
static auto getEnum() -> Type
function required by all systems
Definition Input.h:67
Keys k
Definition Input.h:155
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Input.cpp:79
~Input() override=default
Input()
Definition Input.h:57
auto onUpdate(float dt) -> void override
called once every frame.
Definition Input.cpp:65
auto controllers() -> Controllers &
Definition Input.h:139
auto getControllerEnabled() const -> bool
Returns if Controller input is enabled or not.
Definition Input.cpp:132
auto setEnabled(bool newState) -> void
Sets the state of all three input methods (Keys, Controllers, Mouse) at once.
Definition Input.cpp:95
auto systemShowMenu() -> void override
Specific systems should override this function to show their specific menu for the system.
Definition Input.cpp:42
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Input.cpp:90
auto keys() -> Keys &
Definition Input.h:130
auto getWorldMousePosition() const -> const Vector4D &
Gets the current mouse position in world coordinates.
Definition Input.cpp:142
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Input.cpp:37
auto setMouseEnabled(bool newState) -> void
Sets whether input from Mouse are accepted or not.
Definition Input.cpp:117
auto mouse() -> Mouse &
Definition Input.h:148
the type of elements in a basic_json container
Definition GameObject.h:32
Definition KeyPressedMessage.h:25
Definition Vector4D.h:23