CommonLibSSE NG
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
8namespace RE
9{
10 class ButtonEvent : public IDEvent
11 {
12 public:
13 inline static constexpr auto RTTI = RTTI_ButtonEvent;
14 inline static constexpr auto VTABLE = VTABLE_ButtonEvent;
15
16 ~ButtonEvent() override; // 00
17
18 [[nodiscard]] constexpr float Value() const noexcept { return value; }
19 [[nodiscard]] constexpr float HeldDuration() const noexcept { return heldDownSecs; }
20 [[nodiscard]] constexpr bool IsPressed() const noexcept { return Value() > 0.0F; }
21 [[nodiscard]] constexpr bool IsRepeating() const noexcept { return HeldDuration() > 0.0F; }
22 [[nodiscard]] constexpr bool IsDown() const noexcept { return IsPressed() && (HeldDuration() == 0.0F); }
23 [[nodiscard]] constexpr bool IsHeld() const noexcept { return IsPressed() && IsRepeating(); }
24 [[nodiscard]] constexpr bool IsUp() const noexcept { return (Value() == 0.0F) && IsRepeating(); }
25
26 // members
27 float value; // 28
28 float heldDownSecs; // 2C
29
30 static ButtonEvent* Create(INPUT_DEVICE a_inputDevice, const BSFixedString& a_userEvent, uint32_t a_idCode, float a_value, float a_heldDownSecs)
31 {
32 auto buttonEvent = malloc<ButtonEvent>(sizeof(ButtonEvent));
33 std::memset(reinterpret_cast<void*>(buttonEvent), 0, sizeof(ButtonEvent));
34 if (buttonEvent) {
35 stl::emplace_vtable<ButtonEvent>(buttonEvent);
36 buttonEvent->device = a_inputDevice;
37 buttonEvent->eventType = INPUT_EVENT_TYPE::kButton;
38 buttonEvent->next = nullptr;
39 buttonEvent->userEvent = a_userEvent;
40 buttonEvent->idCode = a_idCode;
41 buttonEvent->value = a_value;
42 buttonEvent->heldDownSecs = a_heldDownSecs;
43 }
44 return buttonEvent;
45 }
46 };
47 static_assert(sizeof(ButtonEvent) == 0x30);
48}
Definition ButtonEvent.h:11
static constexpr auto RTTI
Definition ButtonEvent.h:13
constexpr float Value() const noexcept
Definition ButtonEvent.h:18
float heldDownSecs
Definition ButtonEvent.h:28
static ButtonEvent * Create(INPUT_DEVICE a_inputDevice, const BSFixedString &a_userEvent, uint32_t a_idCode, float a_value, float a_heldDownSecs)
Definition ButtonEvent.h:30
constexpr bool IsRepeating() const noexcept
Definition ButtonEvent.h:21
static constexpr auto VTABLE
Definition ButtonEvent.h:14
float value
Definition ButtonEvent.h:27
constexpr bool IsHeld() const noexcept
Definition ButtonEvent.h:23
constexpr bool IsDown() const noexcept
Definition ButtonEvent.h:22
~ButtonEvent() override
constexpr bool IsPressed() const noexcept
Definition ButtonEvent.h:20
constexpr float HeldDuration() const noexcept
Definition ButtonEvent.h:19
constexpr bool IsUp() const noexcept
Definition ButtonEvent.h:24
Definition IDEvent.h:9
Definition AbsorbEffect.h:6
constexpr REL::VariantID RTTI_ButtonEvent(687042, 394891, 0x1f0b280)
constexpr std::array< REL::VariantID, 1 > VTABLE_ButtonEvent
Definition Offsets_VTABLE.h:2351
INPUT_DEVICE
Definition InputDevices.h:8