CommonLibSSE (Parapets fork)
ButtonEvent.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/I/IDEvent.h"
5 #include "RE/I/InputEvent.h"
6 #include "RE/V/VRWandEvent.h"
7 
8 namespace RE
9 {
10 #ifndef SKYRIMVR
11  class ButtonEvent : public IDEvent
12 #else
13  class ButtonEvent : public VRWandEvent
14 #endif
15  {
16  public:
17  inline static constexpr auto RTTI = RTTI_ButtonEvent;
18 
19  ~ButtonEvent() override; // 00
20 
21  void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration)
22  {
23  Init(a_device, a_id, a_value, a_duration, ""sv);
24  }
25 
26  void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration, const BSFixedString& a_userEvent)
27  {
28  value = a_value;
29  heldDownSecs = a_duration;
30  device = a_device;
31  idCode = a_id;
32  userEvent = a_userEvent;
33 #ifdef SKYRIMVR
34  unkVR28 = -1;
35 #endif
36  }
37 
38 #ifdef SKYRIMVR
39  void Init(INPUT_DEVICE a_device, std::int32_t a_arg2, std::int32_t a_id, float a_value, float a_duration)
40  {
41  Init(a_device, a_arg2, a_id, a_value, a_duration, ""sv);
42  }
43 
44  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)
45  {
46  value = a_value;
47  heldDownSecs = a_duration;
48  device = a_device;
49  idCode = a_id;
50  userEvent = a_userEvent;
51  unkVR28 = a_arg2;
52  }
53 #endif
54 
55  [[nodiscard]] constexpr float Value() const noexcept
56  {
57  return value;
58  }
59  [[nodiscard]] constexpr float HeldDuration() const noexcept { return heldDownSecs; }
60  [[nodiscard]] constexpr bool IsPressed() const noexcept { return Value() > 0.0F; }
61  [[nodiscard]] constexpr bool IsRepeating() const noexcept { return HeldDuration() > 0.0F; }
62  [[nodiscard]] constexpr bool IsDown() const noexcept { return IsPressed() && (HeldDuration() == 0.0F); }
63  [[nodiscard]] constexpr bool IsHeld() const noexcept { return IsPressed() && IsRepeating(); }
64  [[nodiscard]] constexpr bool IsUp() const noexcept { return (Value() == 0.0F) && IsRepeating(); }
65 
66  // members
67  float value; // 28
68  float heldDownSecs; // 2C
69  };
70 #ifndef SKYRIMVR
71  static_assert(sizeof(ButtonEvent) == 0x30);
72 #else
73  static_assert(sizeof(ButtonEvent) == 0x38);
74 #endif
75 }
Definition: ButtonEvent.h:15
static constexpr auto RTTI
Definition: ButtonEvent.h:17
constexpr float Value() const noexcept
Definition: ButtonEvent.h:55
float heldDownSecs
Definition: ButtonEvent.h:68
void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration)
Definition: ButtonEvent.h:21
constexpr bool IsRepeating() const noexcept
Definition: ButtonEvent.h:61
float value
Definition: ButtonEvent.h:67
constexpr bool IsHeld() const noexcept
Definition: ButtonEvent.h:63
constexpr bool IsDown() const noexcept
Definition: ButtonEvent.h:62
void Init(INPUT_DEVICE a_device, std::int32_t a_id, float a_value, float a_duration, const BSFixedString &a_userEvent)
Definition: ButtonEvent.h:26
~ButtonEvent() override
constexpr bool IsPressed() const noexcept
Definition: ButtonEvent.h:60
constexpr float HeldDuration() const noexcept
Definition: ButtonEvent.h:59
constexpr bool IsUp() const noexcept
Definition: ButtonEvent.h:64
Definition: IDEvent.h:9
std::uint32_t idCode
Definition: IDEvent.h:23
BSFixedString userEvent
Definition: IDEvent.h:22
stl::enumeration< INPUT_DEVICE, std::uint32_t > device
Definition: InputEvent.h:45
Definition: VRWandEvent.h:8
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_ButtonEvent
Definition: Offsets_RTTI.h:3693
INPUT_DEVICES::INPUT_DEVICE INPUT_DEVICE
Definition: InputDevices.h:26
detail::BSFixedString< char > BSFixedString
Definition: BSFixedString.h:147
INPUT_DEVICE
Definition: InputDevices.h:8