docs
Loading...
Searching...
No Matches
GamepadEvent.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5#pragma once
7#include <Ultralight/String.h>
8
9namespace ultralight {
10
11///
12/// Event representing a change in gamepad connection state.
13///
14/// @see Renderer::FireGamepadEvent
15///
17 public:
18 ///
19 /// The various GamepadEvent types.
20 ///
21 enum Type {
22 ///
23 /// This event type should be fired when a gamepad is connected.
24 ///
25 /// @note You will need to previously declare the gamepad, its index, and details about
26 /// its axis and button layout via Renderer::SetGamepadDetails prior to calling
27 /// Renderer::FireGamepadEvent.
28 ///
30
31 ///
32 /// This event type should be fired when a gamepad is disconnected.
33 ///
35 };
36
37 ///
38 /// The type of this GamepadEvent
39 ///
41
42 ///
43 /// The index of the gamepad, this should match the value previously set in
44 /// Renderer::SetGamepadDetails.
45 ///
46 uint32_t index;
47};
48
49///
50/// Event representing a change in gamepad axis state (eg, pressing a stick in a certain direction).
51///
52/// @see Renderer::FireGamepadAxisEvent
53///
55 public:
56 ///
57 /// The index of the gamepad, this should match the value previously set in
58 /// Renderer::SetGamepadDetails.
59 ///
60 uint32_t index;
61
62 ///
63 /// The index of the axis whose value has changed.
64 ///
65 /// This value should be in the range previously set in Renderer::SetGamepadDetails.
66 ///
67 uint32_t axis_index;
68
69 ///
70 /// The new value of the axis.
71 ///
72 /// This value should be normalized to the range [-1.0, 1.0].
73 ///
74 double value;
75};
76
77///
78/// Event representing a change in gamepad button state (eg, pressing a button on a gamepad).
79///
80/// @see Renderer::FireGamepadButtonEvent
81///
83 public:
84 ///
85 /// The index of the gamepad, this should match the value previously set in
86 /// Renderer::SetGamepadDetails.
87 ///
88 uint32_t index;
89
90 ///
91 /// The index of the button whose value has changed.
92 ///
93 /// This value should be in the range previously set in Renderer::SetGamepadDetails.
94 ///
95 uint32_t button_index;
96
97 ///
98 /// The new value of the button.
99 ///
100 /// This value should be normalized to the range [0.0, 1.0] (0.0 = not pressed,
101 /// 1.0 = fully pressed). Any value greater than 0.0 is considered "pressed".
102 ///
103 double value;
104};
105
106} // namespace ultralight
#define UExport
Definition Exports.h:22
Event representing a change in gamepad axis state (eg, pressing a stick in a certain direction).
Definition GamepadEvent.h:54
uint32_t axis_index
The index of the axis whose value has changed.
Definition GamepadEvent.h:67
uint32_t index
The index of the gamepad, this should match the value previously set in Renderer::SetGamepadDetails.
Definition GamepadEvent.h:60
double value
The new value of the axis.
Definition GamepadEvent.h:74
Event representing a change in gamepad button state (eg, pressing a button on a gamepad).
Definition GamepadEvent.h:82
uint32_t index
The index of the gamepad, this should match the value previously set in Renderer::SetGamepadDetails.
Definition GamepadEvent.h:88
uint32_t button_index
The index of the button whose value has changed.
Definition GamepadEvent.h:95
double value
The new value of the button.
Definition GamepadEvent.h:103
Event representing a change in gamepad connection state.
Definition GamepadEvent.h:16
Type
The various GamepadEvent types.
Definition GamepadEvent.h:21
@ kType_GamepadDisconnected
This event type should be fired when a gamepad is disconnected.
Definition GamepadEvent.h:34
@ kType_GamepadConnected
This event type should be fired when a gamepad is connected.
Definition GamepadEvent.h:29
uint32_t index
The index of the gamepad, this should match the value previously set in Renderer::SetGamepadDetails.
Definition GamepadEvent.h:46
Type type
The type of this GamepadEvent.
Definition GamepadEvent.h:40
Root namespace for every public Ultralight type, function, and enumeration.