Plasma Engine  2.0
Loading...
Searching...
No Matches
MouseKeyboard.h
1#pragma once
2
3#include <Core/Input/InputDevice.h>
4#include <Foundation/Math/Vec2.h>
5
8{
9 enum Enum
10 {
17
18 Default = NoClip,
19 };
20};
21
25class PL_CORE_DLL plInputDeviceMouseKeyboard : public plInputDevice
26{
27 PL_ADD_DYNAMIC_REFLECTION(plInputDeviceMouseKeyboard, plInputDevice);
28
29public:
30 plInputDeviceMouseKeyboard() { m_vMouseScale.Set(1.0f); }
31
33 virtual void SetShowMouseCursor(bool bShow) = 0;
34
36 virtual bool GetShowMouseCursor() const = 0;
37
45
48
50 virtual void SetMouseSpeed(const plVec2& vScale) { m_vMouseScale = vScale; }
51
53 plVec2 GetMouseSpeed() const { return m_vMouseScale; }
54
56 static plInt32 GetWindowNumberMouseIsOver() { return s_iMouseIsOverWindowNumber; }
57
59 bool IsFocused() { return m_bIsFocused; }
60
61protected:
62 virtual void UpdateInputSlotValues() override;
63
64 plTime m_DoubleClickTime = plTime::MakeFromMilliseconds(500);
65 static plInt32 s_iMouseIsOverWindowNumber;
66
67private:
68 plVec2 m_vMouseScale;
69
70 bool m_bIsFocused = true;
71
72 plTime m_LastMouseClick[3];
73 bool m_bMouseDown[3] = {false, false, false};
74};
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.
This is the base class for all input devices that handle mouse and keyboard input.
Definition MouseKeyboard.h:26
virtual void SetShowMouseCursor(bool bShow)=0
Shows or hides the mouse cursor inside the application window.
virtual plMouseCursorClipMode::Enum GetClipMouseCursor() const =0
Returns whether the mouse is confined to the application window or not.
plVec2 GetMouseSpeed() const
Returns the scaling factor that is applied on all (relative) mouse input.
Definition MouseKeyboard.h:53
virtual void SetMouseSpeed(const plVec2 &vScale)
Sets the scaling factor that is applied on all (relative) mouse input.
Definition MouseKeyboard.h:50
static plInt32 GetWindowNumberMouseIsOver()
Returns the number of the plWindow over which the mouse moved last.
Definition MouseKeyboard.h:56
virtual void SetClipMouseCursor(plMouseCursorClipMode::Enum mode)=0
Will trap the mouse inside the application window. Should usually be enabled, to prevent accidental t...
virtual bool GetShowMouseCursor() const =0
Returns whether the mouse cursor is shown.
bool IsFocused()
Returns if the associated plWindow has focus.
Definition MouseKeyboard.h:59
Specifies how to restrict movement of the Operating System mouse.
Definition MouseKeyboard.h:8
Enum
Definition MouseKeyboard.h:10
@ ClipToWindow
Definition MouseKeyboard.h:12
@ NoClip
The mouse can move unrestricted and leave the application window.
Definition MouseKeyboard.h:11
@ ClipToWindowImmediate
The mouse gets restricted to the window area as soon as possible.
Definition MouseKeyboard.h:14
@ ClipToPosition
Definition MouseKeyboard.h:15
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE static constexpr plTime MakeFromMilliseconds(double fMilliseconds)
Creates an instance of plTime that was initialized from milliseconds.
Definition Time.h:26