Plasma Engine  2.0
Loading...
Searching...
No Matches
VirtualThumbStick.h
1#pragma once
2
3#include <Core/Input/InputDevice.h>
4#include <Core/Input/InputManager.h>
5#include <Foundation/Math/Vec2.h>
6
14class PL_CORE_DLL plVirtualThumbStick final : public plInputDevice
15{
16 PL_ADD_DYNAMIC_REFLECTION(plVirtualThumbStick, plInputDevice);
17
18public:
21
24
26 struct Input
27 {
28 enum Enum
29 {
32 Custom
33 };
34 };
35
52
55 {
56 enum Enum
57 {
59 ActivationPoint
60 };
61 };
62
76 void SetInputArea(const plVec2& vLowerLeft, const plVec2& vUpperRight, float fThumbstickRadius, float fPriority,
77 CenterMode::Enum center = CenterMode::ActivationPoint);
78
80 void GetInputArea(plVec2& out_vLowerLeft, plVec2& out_vUpperRight);
81
86 void SetTriggerInputSlot(Input::Enum input, const plInputActionConfig* pCustomConfig = nullptr);
87
92 void SetThumbstickOutput(Output::Enum output, plStringView sOutputLeft = {}, plStringView sOutputRight = {}, plStringView sOutputUp = {}, plStringView sOutputDown = {});
93
95 void SetAreaFocusMode(plInputActionConfig::OnEnterArea onEnter, plInputActionConfig::OnLeaveArea onLeave);
96
98 void SetEnabled(bool bEnabled) { m_bEnabled = bEnabled; }
99
101 bool IsEnabled() const { return m_bEnabled; }
102
104 bool IsActive() const { return m_bIsActive; }
105
106protected:
107 void UpdateActionMapping();
108
109 plVec2 m_vLowerLeft;
110 plVec2 m_vUpperRight;
111 float m_fRadius;
112
113 plInputActionConfig m_ActionConfig;
114 plStringView m_sOutputLeft;
115 plStringView m_sOutputRight;
116 plStringView m_sOutputUp;
117 plStringView m_sOutputDown;
118
119 bool m_bEnabled;
120 bool m_bConfigChanged;
121 bool m_bIsActive;
122 plString m_sName;
123 plVec2 m_vCenter;
124 CenterMode::Enum m_CenterMode;
125
126 static plInt32 s_iThumbsticks;
127
128private:
129 virtual void InitializeDevice() override {}
130 virtual void UpdateInputSlotValues() override;
131 virtual void RegisterInputSlots() override;
132};
The base class for all input device types.
Definition InputDevice.h:41
virtual void UpdateInputSlotValues()=0
Override this, if you need to query the state of the hardware to update the input slots.
virtual void RegisterInputSlots()=0
Override this to register all the input slots that this device exposes.
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A Virtual Thumb-stick is an input device that transforms certain types of input (mouse / touch) into ...
Definition VirtualThumbStick.h:15
bool IsEnabled() const
Returns whether the thumb-stick is currently enabled.
Definition VirtualThumbStick.h:101
virtual void InitializeDevice() override
Override this if you need to do device specific initialization before the first use.
Definition VirtualThumbStick.h:129
void SetEnabled(bool bEnabled)
Allows to enable or disable the entire thumb-stick temporarily.
Definition VirtualThumbStick.h:98
bool IsActive() const
Returns whether the thumb-stick is currently active (ie. triggered) and generates output.
Definition VirtualThumbStick.h:104
A struct that defines how to register an input action.
Definition InputManager.h:10
OnEnterArea
For Input Areas: Describes what happens when any trigger slot is already active will the input slots ...
Definition InputManager.h:70
OnLeaveArea
For Input Areas: Describes what happens when an action is currently triggered, but the input slots us...
Definition InputManager.h:62
Defines whether the thumb-stick center position is locked or relative to where the user started touch...
Definition VirtualThumbStick.h:55
Enum
Definition VirtualThumbStick.h:57
@ InputArea
The center of the thumb-stick is always at the center of the input area.
Definition VirtualThumbStick.h:58
This enum allows to select either some default input mapping or to select 'Custom'.
Definition VirtualThumbStick.h:27
Enum
Definition VirtualThumbStick.h:29
@ Touchpoint
The Virtual Thumb-stick will be triggered by touch input events.
Definition VirtualThumbStick.h:30
@ MousePosition
The Virtual Thumb-stick will be triggered by mouse input.
Definition VirtualThumbStick.h:31
Specifies which type of output the thumb-stick shall generate.
Definition VirtualThumbStick.h:38
Enum
Definition VirtualThumbStick.h:40
@ Controller2_LeftStick
The Thumb-stick acts like the left stick of controller 2.
Definition VirtualThumbStick.h:45
@ Controller0_RightStick
The Thumb-stick acts like the right stick of controller 0.
Definition VirtualThumbStick.h:42
@ Controller3_LeftStick
The Thumb-stick acts like the left stick of controller 3.
Definition VirtualThumbStick.h:47
@ Controller1_LeftStick
The Thumb-stick acts like the left stick of controller 1.
Definition VirtualThumbStick.h:43
@ Controller0_LeftStick
The Thumb-stick acts like the left stick of controller 0.
Definition VirtualThumbStick.h:41
@ Controller3_RightStick
The Thumb-stick acts like the right stick of controller 3.
Definition VirtualThumbStick.h:48
@ Controller2_RightStick
The Thumb-stick acts like the right stick of controller 2.
Definition VirtualThumbStick.h:46
@ Controller1_RightStick
The Thumb-stick acts like the right stick of controller 1.
Definition VirtualThumbStick.h:44