Plasma Engine  2.0
Loading...
Searching...
No Matches
InputDevice.h
1#pragma once
2
3#include <Core/CoreDLL.h>
4#include <Core/Input/Declarations.h>
5#include <Foundation/Containers/Map.h>
6#include <Foundation/Reflection/Reflection.h>
7#include <Foundation/Strings/String.h>
8#include <Foundation/Time/Time.h>
9#include <Foundation/Utilities/EnumerableClass.h>
10
40class PL_CORE_DLL plInputDevice : public plEnumerable<plInputDevice, plReflectedClass>
41{
42 PL_DECLARE_ENUMERABLE_CLASS_WITH_BASE(plInputDevice, plReflectedClass);
43 PL_ADD_DYNAMIC_REFLECTION(plInputDevice, plReflectedClass);
44
45public:
48
50 float GetInputSlotState(plStringView sSlot) const;
51
55 bool HasDeviceBeenUsedLastFrame() const;
56
57private:
58 friend class plInputManager;
59
68 plUInt32 RetrieveLastCharacter();
69
71 static void UpdateAllHardwareStates(plTime tTimeDifference);
72
74 static void UpdateAllDevices();
75
77 static void ResetAllDevices();
78
80 static plUInt32 RetrieveLastCharacterFromAllDevices();
81
82protected:
84 static void RegisterInputSlot(plStringView sName, plStringView sDefaultDisplayName, plBitflags<plInputSlotFlags> SlotFlags); // [tested]
85
99
102 plUInt32 m_uiLastCharacter; // [tested]
103
105 virtual void InitializeDevice() = 0;
106
114 virtual void UpdateInputSlotValues() = 0;
115
118 virtual void ResetInputSlotValues(){}; // [tested]
119
124 virtual void RegisterInputSlots() = 0; // [tested]
125
128 virtual void UpdateHardwareState(plTime tTimeDifference) {}
129
130private:
132 void Initialize();
133 bool m_bInitialized = false;
134 bool m_bGeneratedInputRecently = false;
135};
Base class to add the ability to another class to enumerate all active instance of it,...
Definition EnumerableClass.h:28
The base class for all input device types.
Definition InputDevice.h:41
virtual void UpdateHardwareState(plTime tTimeDifference)
This function is called once after plInputManager::Update with the same time delta value....
Definition InputDevice.h:128
plMap< plString, float > m_InputSlotValues
Stores all the values for all input slots that this device handles.
Definition InputDevice.h:98
plUInt32 m_uiLastCharacter
If this input device type handles character input, it should write the last typed character into this...
Definition InputDevice.h:102
virtual void ResetInputSlotValues()
Override this, if you need to reset certain input slot values to zero, after the plInputManager is fi...
Definition InputDevice.h:118
virtual void UpdateInputSlotValues()=0
Override this, if you need to query the state of the hardware to update the input slots.
virtual void InitializeDevice()=0
Override this if you need to do device specific initialization before the first use.
virtual void RegisterInputSlots()=0
Override this to register all the input slots that this device exposes.
The central class to set up and query the state of all input.
Definition InputManager.h:91
Definition Map.h:408
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12