nv-sgl 0.6.0__cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. include/tevclient.h +393 -0
  2. nv_sgl-0.6.0.dist-info/LICENSE +29 -0
  3. nv_sgl-0.6.0.dist-info/METADATA +21 -0
  4. nv_sgl-0.6.0.dist-info/RECORD +133 -0
  5. nv_sgl-0.6.0.dist-info/WHEEL +6 -0
  6. nv_sgl-0.6.0.dist-info/top_level.txt +1 -0
  7. sgl/__init__.py +15 -0
  8. sgl/__init__.pyi +6738 -0
  9. sgl/include/sgl/app/app.h +113 -0
  10. sgl/include/sgl/core/bitmap.h +302 -0
  11. sgl/include/sgl/core/crypto.h +89 -0
  12. sgl/include/sgl/core/data_type.h +46 -0
  13. sgl/include/sgl/core/dds_file.h +103 -0
  14. sgl/include/sgl/core/enum.h +201 -0
  15. sgl/include/sgl/core/error.h +161 -0
  16. sgl/include/sgl/core/file_stream.h +77 -0
  17. sgl/include/sgl/core/file_system_watcher.h +141 -0
  18. sgl/include/sgl/core/format.h +36 -0
  19. sgl/include/sgl/core/fwd.h +90 -0
  20. sgl/include/sgl/core/hash.h +45 -0
  21. sgl/include/sgl/core/input.h +522 -0
  22. sgl/include/sgl/core/logger.h +214 -0
  23. sgl/include/sgl/core/macros.h +184 -0
  24. sgl/include/sgl/core/maths.h +45 -0
  25. sgl/include/sgl/core/memory_mapped_file.h +112 -0
  26. sgl/include/sgl/core/memory_mapped_file_stream.h +32 -0
  27. sgl/include/sgl/core/memory_stream.h +74 -0
  28. sgl/include/sgl/core/object.h +683 -0
  29. sgl/include/sgl/core/platform.h +239 -0
  30. sgl/include/sgl/core/plugin.h +331 -0
  31. sgl/include/sgl/core/resolver.h +39 -0
  32. sgl/include/sgl/core/short_vector.h +141 -0
  33. sgl/include/sgl/core/static_vector.h +111 -0
  34. sgl/include/sgl/core/stream.h +54 -0
  35. sgl/include/sgl/core/string.h +276 -0
  36. sgl/include/sgl/core/struct.h +360 -0
  37. sgl/include/sgl/core/thread.h +28 -0
  38. sgl/include/sgl/core/timer.h +52 -0
  39. sgl/include/sgl/core/traits.h +15 -0
  40. sgl/include/sgl/core/type_utils.h +19 -0
  41. sgl/include/sgl/core/window.h +177 -0
  42. sgl/include/sgl/device/agility_sdk.h +24 -0
  43. sgl/include/sgl/device/blit.h +88 -0
  44. sgl/include/sgl/device/buffer_cursor.h +162 -0
  45. sgl/include/sgl/device/command.h +539 -0
  46. sgl/include/sgl/device/cuda_api.h +766 -0
  47. sgl/include/sgl/device/cuda_interop.h +39 -0
  48. sgl/include/sgl/device/cuda_utils.h +107 -0
  49. sgl/include/sgl/device/cursor_utils.h +129 -0
  50. sgl/include/sgl/device/device.h +668 -0
  51. sgl/include/sgl/device/device_resource.h +37 -0
  52. sgl/include/sgl/device/fence.h +91 -0
  53. sgl/include/sgl/device/formats.h +330 -0
  54. sgl/include/sgl/device/framebuffer.h +85 -0
  55. sgl/include/sgl/device/fwd.h +164 -0
  56. sgl/include/sgl/device/helpers.h +20 -0
  57. sgl/include/sgl/device/hot_reload.h +75 -0
  58. sgl/include/sgl/device/input_layout.h +74 -0
  59. sgl/include/sgl/device/kernel.h +69 -0
  60. sgl/include/sgl/device/memory_heap.h +155 -0
  61. sgl/include/sgl/device/native_formats.h +342 -0
  62. sgl/include/sgl/device/native_handle.h +73 -0
  63. sgl/include/sgl/device/native_handle_traits.h +65 -0
  64. sgl/include/sgl/device/pipeline.h +138 -0
  65. sgl/include/sgl/device/print.h +45 -0
  66. sgl/include/sgl/device/python/cursor_utils.h +853 -0
  67. sgl/include/sgl/device/query.h +52 -0
  68. sgl/include/sgl/device/raytracing.h +84 -0
  69. sgl/include/sgl/device/reflection.h +1254 -0
  70. sgl/include/sgl/device/resource.h +705 -0
  71. sgl/include/sgl/device/sampler.h +57 -0
  72. sgl/include/sgl/device/shader.h +516 -0
  73. sgl/include/sgl/device/shader_cursor.h +85 -0
  74. sgl/include/sgl/device/shader_object.h +94 -0
  75. sgl/include/sgl/device/shader_offset.h +67 -0
  76. sgl/include/sgl/device/shared_handle.h +12 -0
  77. sgl/include/sgl/device/slang_utils.h +54 -0
  78. sgl/include/sgl/device/swapchain.h +74 -0
  79. sgl/include/sgl/device/types.h +782 -0
  80. sgl/include/sgl/math/colorspace.h +56 -0
  81. sgl/include/sgl/math/constants.h +7 -0
  82. sgl/include/sgl/math/float16.h +146 -0
  83. sgl/include/sgl/math/matrix.h +6 -0
  84. sgl/include/sgl/math/matrix_math.h +746 -0
  85. sgl/include/sgl/math/matrix_types.h +207 -0
  86. sgl/include/sgl/math/python/primitivetype.h +33 -0
  87. sgl/include/sgl/math/quaternion.h +6 -0
  88. sgl/include/sgl/math/quaternion_math.h +484 -0
  89. sgl/include/sgl/math/quaternion_types.h +83 -0
  90. sgl/include/sgl/math/ray.h +47 -0
  91. sgl/include/sgl/math/scalar_math.h +249 -0
  92. sgl/include/sgl/math/scalar_types.h +107 -0
  93. sgl/include/sgl/math/vector.h +6 -0
  94. sgl/include/sgl/math/vector_math.h +1796 -0
  95. sgl/include/sgl/math/vector_types.h +336 -0
  96. sgl/include/sgl/python/nanobind.h +489 -0
  97. sgl/include/sgl/python/py_doc.h +11600 -0
  98. sgl/include/sgl/python/sgl_ext_pch.h +8 -0
  99. sgl/include/sgl/sgl.h +21 -0
  100. sgl/include/sgl/sgl_pch.h +6 -0
  101. sgl/include/sgl/stl/bit.h +377 -0
  102. sgl/include/sgl/tests/testing.h +54 -0
  103. sgl/include/sgl/ui/fwd.h +34 -0
  104. sgl/include/sgl/ui/imgui_config.h +43 -0
  105. sgl/include/sgl/ui/ui.h +71 -0
  106. sgl/include/sgl/ui/widgets.h +918 -0
  107. sgl/include/sgl/utils/python/slangpy.h +366 -0
  108. sgl/include/sgl/utils/renderdoc.h +50 -0
  109. sgl/include/sgl/utils/slangpy.h +153 -0
  110. sgl/include/sgl/utils/tev.h +93 -0
  111. sgl/include/sgl/utils/texture_loader.h +106 -0
  112. sgl/libgfx.so +0 -0
  113. sgl/libsgl.so +0 -0
  114. sgl/libslang-glslang.so +0 -0
  115. sgl/libslang.so +0 -0
  116. sgl/libtevclient.a +0 -0
  117. sgl/math/__init__.pyi +5083 -0
  118. sgl/platform/__init__.pyi +102 -0
  119. sgl/renderdoc/__init__.pyi +51 -0
  120. sgl/sgl_ext.cpython-313-x86_64-linux-gnu.so +0 -0
  121. sgl/shaders/sgl/device/blit.slang +93 -0
  122. sgl/shaders/sgl/device/nvapi.slang +5 -0
  123. sgl/shaders/sgl/device/nvapi.slangh +7 -0
  124. sgl/shaders/sgl/device/print.slang +445 -0
  125. sgl/shaders/sgl/math/constants.slang +4 -0
  126. sgl/shaders/sgl/math/ray.slang +29 -0
  127. sgl/shaders/sgl/ui/imgui.slang +49 -0
  128. sgl/slangpy/__init__.pyi +268 -0
  129. sgl/tev/__init__.pyi +108 -0
  130. sgl/thread/__init__.pyi +4 -0
  131. sgl/ui/__init__.pyi +1118 -0
  132. share/cmake/tevclient/tevclient-config-release.cmake +19 -0
  133. share/cmake/tevclient/tevclient-config.cmake +103 -0
@@ -0,0 +1,45 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include <utility>
6
+ #include <functional>
7
+
8
+ namespace sgl {
9
+
10
+ inline size_t hash_combine(size_t hash1, size_t hash2)
11
+ {
12
+ return hash2 ^ (hash1 + 0x9e3779b9 + (hash2 << 6) + (hash2 >> 2));
13
+ }
14
+
15
+ template<typename T>
16
+ size_t hash(const T& t)
17
+ {
18
+ return std::hash<T>()(t);
19
+ }
20
+
21
+ template<typename T1, typename T2, typename... Rest>
22
+ size_t hash(const T1& t1, const T2& t2, const Rest&... rest)
23
+ {
24
+ size_t result = hash_combine(hash(t1), hash(t2));
25
+ ((result = hash_combine(result, hash(rest))), ...);
26
+ return result;
27
+ }
28
+
29
+ template<typename T1, typename T2>
30
+ size_t hash(const std::pair<T1, T2>& t)
31
+ {
32
+ return hash_combine(hash(t.first), hash(t.second));
33
+ }
34
+
35
+ template<typename T>
36
+ struct hasher {
37
+ size_t operator()(const T& t) const { return hash(t); }
38
+ };
39
+
40
+ template<typename T>
41
+ struct comparator {
42
+ size_t operator()(const T& t1, const T& t2) const { return t1 == t2; }
43
+ };
44
+
45
+ } // namespace sgl
@@ -0,0 +1,522 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include "sgl/core/macros.h"
6
+ #include "sgl/core/enum.h"
7
+ #include "sgl/math/vector_types.h"
8
+
9
+ #include <string>
10
+
11
+ namespace sgl {
12
+
13
+ /// Mouse cursor modes.
14
+ enum class CursorMode : uint32_t {
15
+ /// The cursor is visible and behaves normally.
16
+ normal,
17
+ /// The cursor is hidden when over the window.
18
+ hidden,
19
+ /// The cursor is hidden and locked to the window.
20
+ disabled,
21
+ };
22
+
23
+ SGL_ENUM_INFO(
24
+ CursorMode,
25
+ {
26
+ {CursorMode::normal, "normal"},
27
+ {CursorMode::hidden, "hidden"},
28
+ {CursorMode::disabled, "disabled"},
29
+ }
30
+ );
31
+ SGL_ENUM_REGISTER(CursorMode);
32
+
33
+ /// Mouse buttons.
34
+ enum class MouseButton : uint32_t {
35
+ left,
36
+ middle,
37
+ right,
38
+ unknown,
39
+ };
40
+
41
+ SGL_ENUM_INFO(
42
+ MouseButton,
43
+ {
44
+ {MouseButton::left, "left"},
45
+ {MouseButton::middle, "middle"},
46
+ {MouseButton::right, "right"},
47
+ {MouseButton::unknown, "unknown"},
48
+ }
49
+ );
50
+ SGL_ENUM_REGISTER(MouseButton);
51
+
52
+ /// Keyboard modifier flags.
53
+ enum class KeyModifierFlags : uint32_t {
54
+ none = 0,
55
+ shift = 1,
56
+ ctrl = 2,
57
+ alt = 4,
58
+ };
59
+
60
+ SGL_ENUM_CLASS_OPERATORS(KeyModifierFlags);
61
+ SGL_ENUM_INFO(
62
+ KeyModifierFlags,
63
+ {
64
+ {KeyModifierFlags::none, "none"},
65
+ {KeyModifierFlags::shift, "shift"},
66
+ {KeyModifierFlags::ctrl, "ctrl"},
67
+ {KeyModifierFlags::alt, "alt"},
68
+ }
69
+ );
70
+ SGL_ENUM_REGISTER(KeyModifierFlags);
71
+
72
+ /// Keyboard modifiers.
73
+ enum class KeyModifier : uint32_t {
74
+ shift = (uint32_t)KeyModifierFlags::shift,
75
+ ctrl = (uint32_t)KeyModifierFlags::ctrl,
76
+ alt = (uint32_t)KeyModifierFlags::alt
77
+ };
78
+
79
+ SGL_ENUM_INFO(
80
+ KeyModifier,
81
+ {
82
+ {KeyModifier::shift, "shift"},
83
+ {KeyModifier::ctrl, "ctrl"},
84
+ {KeyModifier::alt, "alt"},
85
+ }
86
+ );
87
+ SGL_ENUM_REGISTER(KeyModifier);
88
+
89
+ /// Keyboard key codes.
90
+ enum class KeyCode : uint32_t {
91
+ // Key codes 0..255 are reserved for ASCII codes.
92
+ space = ' ',
93
+ apostrophe = '\'',
94
+ comma = ',',
95
+ minus = '-',
96
+ period = '.',
97
+ slash = '/',
98
+ key0 = '0',
99
+ key1 = '1',
100
+ key2 = '2',
101
+ key3 = '3',
102
+ key4 = '4',
103
+ key5 = '5',
104
+ key6 = '6',
105
+ key7 = '7',
106
+ key8 = '8',
107
+ key9 = '9',
108
+ semicolon = ';',
109
+ equal = '=',
110
+ a = 'A',
111
+ b = 'B',
112
+ c = 'C',
113
+ d = 'D',
114
+ e = 'E',
115
+ f = 'F',
116
+ g = 'G',
117
+ h = 'H',
118
+ i = 'I',
119
+ j = 'J',
120
+ k = 'K',
121
+ l = 'L',
122
+ m = 'M',
123
+ n = 'N',
124
+ o = 'O',
125
+ p = 'P',
126
+ q = 'Q',
127
+ r = 'R',
128
+ s = 'S',
129
+ t = 'T',
130
+ u = 'U',
131
+ v = 'V',
132
+ w = 'W',
133
+ x = 'X',
134
+ y = 'Y',
135
+ z = 'Z',
136
+ left_bracket = '[',
137
+ backslash = '\\',
138
+ right_bracket = ']',
139
+ grave_accent = '`',
140
+
141
+ // Special keys start at key code 256.
142
+ escape = 256,
143
+ tab,
144
+ enter,
145
+ backspace,
146
+ insert,
147
+ delete_,
148
+ right,
149
+ left,
150
+ down,
151
+ up,
152
+ page_up,
153
+ page_down,
154
+ home,
155
+ end,
156
+ caps_lock,
157
+ scroll_lock,
158
+ num_lock,
159
+ print_screen,
160
+ pause,
161
+ f1,
162
+ f2,
163
+ f3,
164
+ f4,
165
+ f5,
166
+ f6,
167
+ f7,
168
+ f8,
169
+ f9,
170
+ f10,
171
+ f11,
172
+ f12,
173
+ keypad0,
174
+ keypad1,
175
+ keypad2,
176
+ keypad3,
177
+ keypad4,
178
+ keypad5,
179
+ keypad6,
180
+ keypad7,
181
+ keypad8,
182
+ keypad9,
183
+ keypad_del,
184
+ keypad_divide,
185
+ keypad_multiply,
186
+ keypad_subtract,
187
+ keypad_add,
188
+ keypad_enter,
189
+ keypad_equal,
190
+ left_shift,
191
+ left_control,
192
+ left_alt,
193
+ left_super,
194
+ right_shift,
195
+ right_control,
196
+ right_alt,
197
+ right_super,
198
+ menu,
199
+ unknown,
200
+ };
201
+
202
+ SGL_ENUM_INFO(
203
+ KeyCode,
204
+ {
205
+ {KeyCode::space, "space"},
206
+ {KeyCode::apostrophe, "apostrophe"},
207
+ {KeyCode::comma, "comma"},
208
+ {KeyCode::minus, "minus"},
209
+ {KeyCode::period, "period"},
210
+ {KeyCode::slash, "slash"},
211
+ {KeyCode::key0, "key0"},
212
+ {KeyCode::key1, "key1"},
213
+ {KeyCode::key2, "key2"},
214
+ {KeyCode::key3, "key3"},
215
+ {KeyCode::key4, "key4"},
216
+ {KeyCode::key5, "key5"},
217
+ {KeyCode::key6, "key6"},
218
+ {KeyCode::key7, "key7"},
219
+ {KeyCode::key8, "key8"},
220
+ {KeyCode::key9, "key9"},
221
+ {KeyCode::semicolon, "semicolon"},
222
+ {KeyCode::equal, "equal"},
223
+ {KeyCode::a, "a"},
224
+ {KeyCode::b, "b"},
225
+ {KeyCode::c, "c"},
226
+ {KeyCode::d, "d"},
227
+ {KeyCode::e, "e"},
228
+ {KeyCode::f, "f"},
229
+ {KeyCode::g, "g"},
230
+ {KeyCode::h, "h"},
231
+ {KeyCode::i, "i"},
232
+ {KeyCode::j, "j"},
233
+ {KeyCode::k, "k"},
234
+ {KeyCode::l, "l"},
235
+ {KeyCode::m, "m"},
236
+ {KeyCode::n, "n"},
237
+ {KeyCode::o, "o"},
238
+ {KeyCode::p, "p"},
239
+ {KeyCode::q, "q"},
240
+ {KeyCode::r, "r"},
241
+ {KeyCode::s, "s"},
242
+ {KeyCode::t, "t"},
243
+ {KeyCode::u, "u"},
244
+ {KeyCode::v, "v"},
245
+ {KeyCode::w, "w"},
246
+ {KeyCode::x, "x"},
247
+ {KeyCode::y, "y"},
248
+ {KeyCode::z, "z"},
249
+ {KeyCode::left_bracket, "left_bracket"},
250
+ {KeyCode::backslash, "backslash"},
251
+ {KeyCode::right_bracket, "right_bracket"},
252
+ {KeyCode::grave_accent, "grave_accent"},
253
+ {KeyCode::escape, "escape"},
254
+ {KeyCode::tab, "tab"},
255
+ {KeyCode::enter, "enter"},
256
+ {KeyCode::backspace, "backspace"},
257
+ {KeyCode::insert, "insert"},
258
+ {KeyCode::delete_, "delete"},
259
+ {KeyCode::right, "right"},
260
+ {KeyCode::left, "left"},
261
+ {KeyCode::down, "down"},
262
+ {KeyCode::up, "up"},
263
+ {KeyCode::page_up, "page_up"},
264
+ {KeyCode::page_down, "page_down"},
265
+ {KeyCode::home, "home"},
266
+ {KeyCode::end, "end"},
267
+ {KeyCode::caps_lock, "caps_lock"},
268
+ {KeyCode::scroll_lock, "scroll_lock"},
269
+ {KeyCode::num_lock, "num_lock"},
270
+ {KeyCode::print_screen, "print_screen"},
271
+ {KeyCode::pause, "pause"},
272
+ {KeyCode::f1, "f1"},
273
+ {KeyCode::f2, "f2"},
274
+ {KeyCode::f3, "f3"},
275
+ {KeyCode::f4, "f4"},
276
+ {KeyCode::f5, "f5"},
277
+ {KeyCode::f6, "f6"},
278
+ {KeyCode::f7, "f7"},
279
+ {KeyCode::f8, "f8"},
280
+ {KeyCode::f9, "f9"},
281
+ {KeyCode::f10, "f10"},
282
+ {KeyCode::f11, "f11"},
283
+ {KeyCode::f12, "f12"},
284
+ {KeyCode::keypad0, "keypad0"},
285
+ {KeyCode::keypad1, "keypad1"},
286
+ {KeyCode::keypad2, "keypad2"},
287
+ {KeyCode::keypad3, "keypad3"},
288
+ {KeyCode::keypad4, "keypad4"},
289
+ {KeyCode::keypad5, "keypad5"},
290
+ {KeyCode::keypad6, "keypad6"},
291
+ {KeyCode::keypad7, "keypad7"},
292
+ {KeyCode::keypad8, "keypad8"},
293
+ {KeyCode::keypad9, "keypad9"},
294
+ {KeyCode::keypad_del, "keypad_del"},
295
+ {KeyCode::keypad_divide, "keypad_divide"},
296
+ {KeyCode::keypad_multiply, "keypad_multiply"},
297
+ {KeyCode::keypad_subtract, "keypad_subtract"},
298
+ {KeyCode::keypad_add, "keypad_add"},
299
+ {KeyCode::keypad_enter, "keypad_enter"},
300
+ {KeyCode::keypad_equal, "keypad_equal"},
301
+ {KeyCode::left_shift, "left_shift"},
302
+ {KeyCode::left_control, "left_control"},
303
+ {KeyCode::left_alt, "left_alt"},
304
+ {KeyCode::left_super, "left_super"},
305
+ {KeyCode::right_shift, "right_shift"},
306
+ {KeyCode::right_control, "right_control"},
307
+ {KeyCode::right_alt, "right_alt"},
308
+ {KeyCode::right_super, "right_super"},
309
+ {KeyCode::menu, "menu"},
310
+ {KeyCode::unknown, "unknown"},
311
+ }
312
+ );
313
+ SGL_ENUM_REGISTER(KeyCode);
314
+
315
+ /// Keyboard event types.
316
+ enum class KeyboardEventType {
317
+ /// Key was pressed.
318
+ key_press,
319
+ /// Key was released.
320
+ key_release,
321
+ /// Key is repeatedly down.
322
+ key_repeat,
323
+ /// Character input.
324
+ input
325
+ };
326
+
327
+ SGL_ENUM_INFO(
328
+ KeyboardEventType,
329
+ {
330
+ {KeyboardEventType::key_press, "key_press"},
331
+ {KeyboardEventType::key_release, "key_release"},
332
+ {KeyboardEventType::key_repeat, "key_repeat"},
333
+ {KeyboardEventType::input, "input"},
334
+ }
335
+ );
336
+ SGL_ENUM_REGISTER(KeyboardEventType);
337
+
338
+ /// Keyboard event.
339
+ struct SGL_API KeyboardEvent {
340
+ /// The event type.
341
+ KeyboardEventType type;
342
+ /// The key that was pressed/released/repeated.
343
+ KeyCode key{KeyCode::unknown};
344
+ /// UTF-32 codepoint for input events.
345
+ uint32_t codepoint{0};
346
+ /// Keyboard modifier flags.
347
+ KeyModifierFlags mods{0};
348
+
349
+ /// Returns true if this event is a key press event.
350
+ bool is_key_press() const { return type == KeyboardEventType::key_press; }
351
+ /// Returns true if this event is a key release event.
352
+ bool is_key_release() const { return type == KeyboardEventType::key_release; }
353
+ /// Returns true if this event is a key repeat event.
354
+ bool is_key_repeat() const { return type == KeyboardEventType::key_repeat; }
355
+ /// Returns true if this event is an input event.
356
+ bool is_input() const { return type == KeyboardEventType::input; }
357
+
358
+ /// Returns true if the specified modifier is set.
359
+ bool has_modifier(KeyModifier mod) const { return is_set(mods, (KeyModifierFlags)mod); }
360
+
361
+ std::string to_string() const;
362
+ };
363
+
364
+ /// Mouse event types.
365
+ enum class MouseEventType {
366
+ /// Mouse button was pressed.
367
+ button_down,
368
+ /// Mouse button was released.
369
+ button_up,
370
+ /// Mouse cursor position changed.
371
+ move,
372
+ /// Mouse wheel was scrolled.
373
+ scroll
374
+ };
375
+
376
+ SGL_ENUM_INFO(
377
+ MouseEventType,
378
+ {
379
+ {MouseEventType::button_down, "button_down"},
380
+ {MouseEventType::button_up, "button_up"},
381
+ {MouseEventType::move, "move"},
382
+ {MouseEventType::scroll, "scroll"},
383
+ }
384
+ );
385
+ SGL_ENUM_REGISTER(MouseEventType);
386
+
387
+ /// Mouse event.
388
+ struct SGL_API MouseEvent {
389
+ /// The event type.
390
+ MouseEventType type;
391
+ /// The mouse position.
392
+ float2 pos{0.f, 0.f};
393
+ /// The scroll offset.
394
+ float2 scroll{0.f, 0.f};
395
+ /// The mouse button that was pressed/released.
396
+ MouseButton button{MouseButton::unknown};
397
+ /// Keyboard modifier flags.
398
+ KeyModifierFlags mods{0};
399
+
400
+ /// Returns true if this event is a mouse button down event.
401
+ bool is_button_down() const { return type == MouseEventType::button_down; }
402
+ /// Returns true if this event is a mouse button up event.
403
+ bool is_button_up() const { return type == MouseEventType::button_up; }
404
+ /// Returns true if this event is a mouse move event.
405
+ bool is_move() const { return type == MouseEventType::move; }
406
+ /// Returns true if this event is a mouse scroll event.
407
+ bool is_scroll() const { return type == MouseEventType::scroll; }
408
+
409
+ /// Returns true if the specified modifier is set.
410
+ bool has_modifier(KeyModifier mod) const { return is_set(mods, (KeyModifierFlags)mod); }
411
+
412
+ std::string to_string() const;
413
+ };
414
+
415
+ /// Gamepad event types.
416
+ enum class GamepadEventType {
417
+ /// Gamepad button was pressed.
418
+ button_down,
419
+ /// Gamepad button was released.
420
+ button_up,
421
+ /// Gamepad was connected.
422
+ connect,
423
+ /// Gamepad was disconnected.
424
+ disconnect,
425
+ };
426
+
427
+ SGL_ENUM_INFO(
428
+ GamepadEventType,
429
+ {
430
+ {GamepadEventType::button_down, "button_down"},
431
+ {GamepadEventType::button_up, "button_up"},
432
+ {GamepadEventType::connect, "connect"},
433
+ {GamepadEventType::disconnect, "disconnect"},
434
+ }
435
+ );
436
+ SGL_ENUM_REGISTER(GamepadEventType);
437
+
438
+ /// Gamepad buttons.
439
+ enum class GamepadButton : uint32_t {
440
+ a,
441
+ b,
442
+ x,
443
+ y,
444
+ left_bumper,
445
+ right_bumper,
446
+ back,
447
+ start,
448
+ guide,
449
+ left_thumb,
450
+ right_thumb,
451
+ up,
452
+ right,
453
+ down,
454
+ left,
455
+ };
456
+
457
+ SGL_ENUM_INFO(
458
+ GamepadButton,
459
+ {
460
+ {GamepadButton::a, "a"},
461
+ {GamepadButton::b, "b"},
462
+ {GamepadButton::x, "x"},
463
+ {GamepadButton::y, "y"},
464
+ {GamepadButton::left_bumper, "left_bumper"},
465
+ {GamepadButton::right_bumper, "right_bumper"},
466
+ {GamepadButton::back, "back"},
467
+ {GamepadButton::start, "start"},
468
+ {GamepadButton::guide, "guide"},
469
+ {GamepadButton::left_thumb, "left_thumb"},
470
+ {GamepadButton::right_thumb, "right_thumb"},
471
+ {GamepadButton::up, "up"},
472
+ {GamepadButton::right, "right"},
473
+ {GamepadButton::down, "down"},
474
+ {GamepadButton::left, "left"},
475
+ }
476
+ );
477
+ SGL_ENUM_REGISTER(GamepadButton);
478
+
479
+ /// Gamepad event.
480
+ struct SGL_API GamepadEvent {
481
+ /// The event type.
482
+ GamepadEventType type;
483
+ /// The gamepad button that was pressed/released.
484
+ GamepadButton button;
485
+
486
+ /// Returns true if this event is a gamepad button down event.
487
+ bool is_button_down() const { return type == GamepadEventType::button_down; }
488
+ /// Returns true if this event is a gamepad button up event.
489
+ bool is_button_up() const { return type == GamepadEventType::button_up; }
490
+ /// Returns true if this event is a gamepad connect event.
491
+ bool is_connect() const { return type == GamepadEventType::connect; }
492
+ /// Returns true if this event is a gamepad disconnect event.
493
+ bool is_disconnect() const { return type == GamepadEventType::disconnect; }
494
+
495
+ std::string to_string() const;
496
+ };
497
+
498
+ /// Gamepad state.
499
+ struct SGL_API GamepadState {
500
+ /// X-axis of the left analog stick.
501
+ float left_x;
502
+ /// Y-axis of the left analog stick.
503
+ float left_y;
504
+ /// X-axis of the right analog stick.
505
+ float right_x;
506
+ /// Y-axis of the right analog stick.
507
+ float right_y;
508
+ /// Value of the left analog trigger.
509
+ float left_trigger;
510
+ /// Value of the right analog trigger.
511
+ float right_trigger;
512
+
513
+ /// Bitfield of gamepad buttons (see \ref GamepadButton).
514
+ uint32_t buttons;
515
+
516
+ /// Returns true if the specified button is down.
517
+ bool is_button_down(GamepadButton button) const { return buttons & (1 << uint32_t(button)); }
518
+
519
+ std::string to_string() const;
520
+ };
521
+
522
+ } // namespace sgl