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