CommonLibVR
Loading...
Searching...
No Matches
ButtonEvent.h
Go to the documentation of this file.
1#pragma once
2
4#include "RE/I/IDEvent.h"
5#include "RE/I/InputEvent.h"
7#include "RE/V/VRWandEvent.h"
8
9namespace RE
10{
11#ifndef SKYRIMVR
12 class ButtonEvent : public IDEvent
13#else
14 class ButtonEvent : public VRWandEvent
15#endif
16 {
17 public:
18 inline static constexpr auto RTTI = RTTI_ButtonEvent;
19 inline static constexpr auto VTABLE = VTABLE_ButtonEvent;
20
21 ~ButtonEvent() override; // 00
22
23 void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration)
24 {
25 Init(a_device, a_id, a_value, a_duration, ""sv);
26 }
27
28 void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration, const BSFixedString& a_userEvent)
29 {
30 value = a_value;
31 heldDownSecs = a_duration;
32 device = a_device;
33 idCode = a_id;
34 userEvent = a_userEvent;
35#ifdef SKYRIMVR
36 unkVR28 = -1;
37#endif
38 }
39
40#ifdef SKYRIMVR
41 void Init(INPUT_DEVICE a_device, std::int32_t a_arg2, std::int32_t a_id, float a_value, float a_duration)
42 {
43 Init(a_device, a_arg2, a_id, a_value, a_duration, ""sv);
44 }
45
46 void Init(INPUT_DEVICE a_device, std::int32_t a_arg2, std::int32_t a_id, float a_value, float a_duration, const BSFixedString& a_userEvent)
47 {
48 value = a_value;
49 heldDownSecs = a_duration;
50 device = a_device;
51 idCode = a_id;
52 userEvent = a_userEvent;
53 unkVR28 = a_arg2;
54 }
55#endif
56
57 [[nodiscard]] constexpr float Value() const noexcept
58 {
59 return value;
60 }
61 [[nodiscard]] constexpr float HeldDuration() const noexcept { return heldDownSecs; }
62 [[nodiscard]] constexpr bool IsPressed() const noexcept { return Value() > 0.0F; }
63 [[nodiscard]] constexpr bool IsRepeating() const noexcept { return HeldDuration() > 0.0F; }
64 [[nodiscard]] constexpr bool IsDown() const noexcept { return IsPressed() && (HeldDuration() == 0.0F); }
65 [[nodiscard]] constexpr bool IsHeld() const noexcept { return IsPressed() && IsRepeating(); }
66 [[nodiscard]] constexpr bool IsUp() const noexcept { return (Value() == 0.0F) && IsRepeating(); }
67
68 // members
69 float value; // 28
70 float heldDownSecs; // 2C
71
72 static ButtonEvent* Create(INPUT_DEVICE a_inputDevice, const BSFixedString& a_userEvent, uint32_t a_idCode, float a_value, float a_heldDownSecs)
73 {
74 auto buttonEvent = malloc<ButtonEvent>(sizeof(ButtonEvent));
75 std::memset((void*)buttonEvent, 0, sizeof(ButtonEvent));
76 if (buttonEvent) {
77 stl::emplace_vtable<ButtonEvent>(buttonEvent);
78 buttonEvent->device = a_inputDevice;
79 buttonEvent->eventType = INPUT_EVENT_TYPE::kButton;
80 buttonEvent->next = nullptr;
81 buttonEvent->userEvent = a_userEvent;
82 buttonEvent->idCode = a_idCode;
83 buttonEvent->value = a_value;
84 buttonEvent->heldDownSecs = a_heldDownSecs;
85 }
86 return buttonEvent;
87 }
88
89 private:
91 };
92#ifndef SKYRIMVR
93 static_assert(sizeof(ButtonEvent) == 0x30);
94#else
95 static_assert(sizeof(ButtonEvent) == 0x38);
96#endif
97}
#define KEEP_FOR_RE()
Definition PCH.h:517
Definition ButtonEvent.h:16
static constexpr auto RTTI
Definition ButtonEvent.h:18
constexpr float Value() const noexcept
Definition ButtonEvent.h:57
float heldDownSecs
Definition ButtonEvent.h:70
void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration)
Definition ButtonEvent.h:23
static ButtonEvent * Create(INPUT_DEVICE a_inputDevice, const BSFixedString &a_userEvent, uint32_t a_idCode, float a_value, float a_heldDownSecs)
Definition ButtonEvent.h:72
constexpr bool IsRepeating() const noexcept
Definition ButtonEvent.h:63
static constexpr auto VTABLE
Definition ButtonEvent.h:19
float value
Definition ButtonEvent.h:69
constexpr bool IsHeld() const noexcept
Definition ButtonEvent.h:65
constexpr bool IsDown() const noexcept
Definition ButtonEvent.h:64
void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration, const BSFixedString &a_userEvent)
Definition ButtonEvent.h:28
~ButtonEvent() override
constexpr bool IsPressed() const noexcept
Definition ButtonEvent.h:62
constexpr float HeldDuration() const noexcept
Definition ButtonEvent.h:61
constexpr bool IsUp() const noexcept
Definition ButtonEvent.h:66
Definition IDEvent.h:9
std::uint32_t idCode
Definition IDEvent.h:24
BSFixedString userEvent
Definition IDEvent.h:23
REX::EnumSet< INPUT_DEVICE, std::uint32_t > device
Definition InputEvent.h:54
Definition VRWandEvent.h:8
Definition AbsorbEffect.h:6
constexpr REL::ID RTTI_ButtonEvent(static_cast< std::uint64_t >(687042))
INPUT_DEVICES::INPUT_DEVICE INPUT_DEVICE
Definition InputDevices.h:27
constexpr std::array< REL::ID, 1 > VTABLE_ButtonEvent
Definition Offsets_VTABLE.h:10619
detail::BSFixedString< char > BSFixedString
Definition BSFixedString.h:239
INPUT_DEVICE
Definition InputDevices.h:8