@kmamal/sdl 0.9.4 → 0.9.6-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -15
- package/binding.gyp +25 -5
- package/package.json +7 -4
- package/src/javascript/audio/audio-instance.js +9 -6
- package/src/javascript/cleanup.js +1 -1
- package/src/javascript/clipboard/index.js +2 -1
- package/src/javascript/controller/controller-instance.js +6 -0
- package/src/javascript/enums.js +1 -1
- package/src/javascript/events/index.js +302 -305
- package/src/javascript/index.js +1 -1
- package/src/javascript/joystick/joystick-instance.js +7 -0
- package/src/javascript/keyboard/index.js +3 -3
- package/src/javascript/keyboard/key-mapping.js +14 -6
- package/src/javascript/mouse/index.js +13 -12
- package/src/javascript/power/index.js +0 -2
- package/src/javascript/sensor/sensor-instance.js +1 -5
- package/src/javascript/video/window.js +17 -16
- package/src/native/audio.cpp +178 -0
- package/src/native/audio.h +21 -0
- package/src/native/clipboard.cpp +45 -0
- package/src/native/clipboard.h +13 -0
- package/src/native/cocoa-global.h +8 -0
- package/src/native/cocoa-global.mm +8 -0
- package/src/native/cocoa-window.h +9 -4
- package/src/native/cocoa-window.mm +6 -9
- package/src/native/controller.cpp +154 -0
- package/src/native/controller.h +17 -0
- package/src/native/enums.cpp +477 -0
- package/src/native/enums.h +67 -0
- package/src/native/events.cpp +339 -0
- package/src/native/events.h +15 -0
- package/src/native/global.cpp +187 -0
- package/src/native/global.h +15 -0
- package/src/native/joystick.cpp +388 -0
- package/src/native/joystick.h +22 -0
- package/src/native/keyboard.cpp +55 -0
- package/src/native/keyboard.h +18 -0
- package/src/native/module.cpp +98 -0
- package/src/native/mouse.cpp +186 -0
- package/src/native/mouse.h +21 -0
- package/src/native/power.cpp +18 -0
- package/src/native/power.h +12 -0
- package/src/native/sensor.cpp +117 -0
- package/src/native/sensor.h +15 -0
- package/src/native/video.cpp +90 -0
- package/src/native/video.h +12 -0
- package/src/native/window.cpp +755 -0
- package/src/native/window.h +29 -0
- package/src/types/index.d.ts +7 -4
- package/scripts/test.mjs +0 -12
- package/src/native/asprintf.c +0 -47
- package/src/native/asprintf.h +0 -37
- package/src/native/binding.cpp +0 -1680
- package/src/native/sdl-helpers.cpp +0 -2619
- package/src/native/sdl-helpers.h +0 -182
|
@@ -1,2619 +0,0 @@
|
|
|
1
|
-
#include "sdl-helpers.h"
|
|
2
|
-
#include <SDL.h>
|
|
3
|
-
#include <SDL_syswm.h>
|
|
4
|
-
#include <cstdio>
|
|
5
|
-
#include <cstdlib>
|
|
6
|
-
#include <cstring>
|
|
7
|
-
|
|
8
|
-
#if defined(_WIN32)
|
|
9
|
-
#include "asprintf.h"
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#if defined(__LINUX__)
|
|
14
|
-
#define GL_NativeWindow Window
|
|
15
|
-
struct GPU_NativeData {
|
|
16
|
-
Display *display;
|
|
17
|
-
Window window;
|
|
18
|
-
};
|
|
19
|
-
#define GPU_WINDOW_FLAG SDL_WINDOW_VULKAN
|
|
20
|
-
#elif defined(__WIN32__)
|
|
21
|
-
#define GL_NativeWindow HWND
|
|
22
|
-
struct GPU_NativeData {
|
|
23
|
-
HWND hwnd;
|
|
24
|
-
HINSTANCE hinstance;
|
|
25
|
-
};
|
|
26
|
-
#define GPU_WINDOW_FLAG 0
|
|
27
|
-
#elif defined(__MACOSX__)
|
|
28
|
-
#include "cocoa-window.h"
|
|
29
|
-
#define GL_NativeWindow CALayer *
|
|
30
|
-
struct GPU_NativeData {
|
|
31
|
-
CALayer *layer;
|
|
32
|
-
};
|
|
33
|
-
#define GPU_WINDOW_FLAG SDL_WINDOW_METAL
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#define RETURN_ERROR(...) do { \
|
|
38
|
-
char * error; \
|
|
39
|
-
int result = asprintf(&error, __VA_ARGS__); \
|
|
40
|
-
return result == -1 ? new ErrorMessage("asprintf failed", false) : new ErrorMessage(error); \
|
|
41
|
-
} while (0)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
static const char * no_error = nullptr;
|
|
45
|
-
|
|
46
|
-
static char * allocated_drop_file = nullptr ;
|
|
47
|
-
static char * allocated_clipboard = nullptr ;
|
|
48
|
-
static SDL_Cursor * allocated_cursor = nullptr;
|
|
49
|
-
|
|
50
|
-
struct AllocString {
|
|
51
|
-
char * buffer;
|
|
52
|
-
AllocString * next;
|
|
53
|
-
};
|
|
54
|
-
static AllocString * allocated_guid_strings = nullptr;
|
|
55
|
-
char * _allocateString (int size) {
|
|
56
|
-
AllocString * node = (AllocString*) malloc(sizeof(AllocString));
|
|
57
|
-
node->buffer = (char *) malloc(size);
|
|
58
|
-
AllocString * head = allocated_guid_strings;
|
|
59
|
-
allocated_guid_strings = node;
|
|
60
|
-
node->next = head;
|
|
61
|
-
return node->buffer;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static const Uint8 * keys;
|
|
65
|
-
static int num_keys;
|
|
66
|
-
|
|
67
|
-
static char text_input[32];
|
|
68
|
-
|
|
69
|
-
const static int SDL_JOYSTICK_AXIS_RANGE = SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN;
|
|
70
|
-
|
|
71
|
-
double _joystickMapAxis (int value) {
|
|
72
|
-
return (value - SDL_JOYSTICK_AXIS_MIN) / (SDL_JOYSTICK_AXIS_RANGE / 2.0) - 1;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
namespace SdlHelpers {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
#define MAKE_VAR(target, type, value) do { \
|
|
80
|
-
target.emplace<type>(value); \
|
|
81
|
-
} while (false)
|
|
82
|
-
|
|
83
|
-
#define MAKE_MAP(target) MAKE_VAR(target, 1, VariantMap())
|
|
84
|
-
|
|
85
|
-
static Variant var;
|
|
86
|
-
|
|
87
|
-
#define SET_PROP(object, prop, type, value) do { \
|
|
88
|
-
MAKE_VAR(var, type, value); \
|
|
89
|
-
std::get<VariantMap>(object).insert({ prop, var }); \
|
|
90
|
-
} while (false)
|
|
91
|
-
|
|
92
|
-
#define SET_NULL(object, prop) SET_PROP(object, prop, 0, std::monostate())
|
|
93
|
-
#define SET_MAP(object, prop, val) SET_PROP(object, prop, 1, std::get<VariantMap>(val))
|
|
94
|
-
#define SET_LIST(object, prop, val) SET_PROP(object, prop, 2, std::get<VariantList>(val))
|
|
95
|
-
#define SET_NUM(object, prop, val) SET_PROP(object, prop, 3, val)
|
|
96
|
-
#define SET_STRING(object, prop, val) SET_PROP(object, prop, 4, val)
|
|
97
|
-
#define SET_BOOL(object, prop, val) SET_PROP(object, prop, 5, val)
|
|
98
|
-
|
|
99
|
-
#define MAKE_LIST(target) MAKE_VAR(target, 2, VariantList())
|
|
100
|
-
|
|
101
|
-
#define APPEND(list, item) do { \
|
|
102
|
-
std::get<VariantList>(list).push_back(item); \
|
|
103
|
-
} while (false)
|
|
104
|
-
|
|
105
|
-
#define APPEND_VALUE(list, type, value) do { \
|
|
106
|
-
MAKE_VAR(var, type, value); \
|
|
107
|
-
APPEND(list, var); \
|
|
108
|
-
} while (false)
|
|
109
|
-
|
|
110
|
-
#define MAKE_NUM(target, value) MAKE_VAR(target, 3, value)
|
|
111
|
-
|
|
112
|
-
#define MAKE_STRING(target, value) MAKE_VAR(target, 4, value)
|
|
113
|
-
|
|
114
|
-
#define MAKE_BOOL(target, value) MAKE_VAR(target, 5, value)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
ErrorMessage::
|
|
118
|
-
ErrorMessage(const char * _message, bool _should_dispose)
|
|
119
|
-
: message(_message)
|
|
120
|
-
, should_dispose(_should_dispose)
|
|
121
|
-
{}
|
|
122
|
-
|
|
123
|
-
ErrorMessage::
|
|
124
|
-
~ErrorMessage()
|
|
125
|
-
{
|
|
126
|
-
if (!this->should_dispose) { return; }
|
|
127
|
-
free((void *) this->message);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
enum class EventFamily {
|
|
132
|
-
DISPLAY,
|
|
133
|
-
WINDOW,
|
|
134
|
-
KEYBOARD,
|
|
135
|
-
MOUSE,
|
|
136
|
-
TEXT,
|
|
137
|
-
DROP,
|
|
138
|
-
JOYSTICK_DEVICE,
|
|
139
|
-
JOYSTICK,
|
|
140
|
-
CONTROLLER,
|
|
141
|
-
SENSOR,
|
|
142
|
-
AUDIO_DEVICE,
|
|
143
|
-
CLIPBOARD,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
ErrorMessage *
|
|
147
|
-
enum_getEventFamilies (Variant & families)
|
|
148
|
-
{
|
|
149
|
-
MAKE_MAP(families);
|
|
150
|
-
|
|
151
|
-
SET_NUM(families, "display", (int) EventFamily::DISPLAY);
|
|
152
|
-
SET_NUM(families, "window", (int) EventFamily::WINDOW);
|
|
153
|
-
SET_NUM(families, "keyboard", (int) EventFamily::KEYBOARD);
|
|
154
|
-
SET_NUM(families, "mouse", (int) EventFamily::MOUSE);
|
|
155
|
-
SET_NUM(families, "text", (int) EventFamily::TEXT);
|
|
156
|
-
SET_NUM(families, "drop", (int) EventFamily::DROP);
|
|
157
|
-
SET_NUM(families, "joystickDevice", (int) EventFamily::JOYSTICK_DEVICE);
|
|
158
|
-
SET_NUM(families, "joystick", (int) EventFamily::JOYSTICK);
|
|
159
|
-
SET_NUM(families, "controller", (int) EventFamily::CONTROLLER);
|
|
160
|
-
SET_NUM(families, "audioDevice", (int) EventFamily::AUDIO_DEVICE);
|
|
161
|
-
SET_NUM(families, "clipboard", (int) EventFamily::CLIPBOARD);
|
|
162
|
-
|
|
163
|
-
return nullptr;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
enum class EventType {
|
|
168
|
-
QUIT,
|
|
169
|
-
DISPLAY_ADD,
|
|
170
|
-
DISPLAY_REMOVE,
|
|
171
|
-
DISPLAY_ORIENT,
|
|
172
|
-
SHOW,
|
|
173
|
-
HIDE,
|
|
174
|
-
EXPOSE,
|
|
175
|
-
MOVE,
|
|
176
|
-
RESIZE,
|
|
177
|
-
MINIMIZE,
|
|
178
|
-
MAXIMIZE,
|
|
179
|
-
RESTORE,
|
|
180
|
-
FOCUS,
|
|
181
|
-
BLUR,
|
|
182
|
-
HOVER,
|
|
183
|
-
LEAVE,
|
|
184
|
-
CLOSE,
|
|
185
|
-
DROP_BEGIN,
|
|
186
|
-
DROP_COMPLETE,
|
|
187
|
-
DROP_FILE,
|
|
188
|
-
DROP_TEXT,
|
|
189
|
-
KEY_DOWN,
|
|
190
|
-
KEY_UP,
|
|
191
|
-
TEXT_INPUT,
|
|
192
|
-
MOUSE_MOVE,
|
|
193
|
-
MOUSE_BUTTON_DOWN,
|
|
194
|
-
MOUSE_BUTTON_UP,
|
|
195
|
-
MOUSE_WHEEL,
|
|
196
|
-
DEVICE_ADD,
|
|
197
|
-
DEVICE_REMOVE,
|
|
198
|
-
AXIS_MOTION,
|
|
199
|
-
BALL_MOTION,
|
|
200
|
-
BUTTON_DOWN,
|
|
201
|
-
BUTTON_UP,
|
|
202
|
-
HAT_MOTION,
|
|
203
|
-
REMAP,
|
|
204
|
-
UPDATE,
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
ErrorMessage *
|
|
208
|
-
enum_getEventTypes (Variant & types)
|
|
209
|
-
{
|
|
210
|
-
MAKE_MAP(types);
|
|
211
|
-
|
|
212
|
-
SET_NUM(types, "quit", (int) EventType::QUIT);
|
|
213
|
-
SET_NUM(types, "displayAdd", (int) EventType::DISPLAY_ADD);
|
|
214
|
-
SET_NUM(types, "displayRemove", (int) EventType::DISPLAY_REMOVE);
|
|
215
|
-
SET_NUM(types, "displayOrient", (int) EventType::DISPLAY_ORIENT);
|
|
216
|
-
SET_NUM(types, "show", (int) EventType::SHOW);
|
|
217
|
-
SET_NUM(types, "hide", (int) EventType::HIDE);
|
|
218
|
-
SET_NUM(types, "expose", (int) EventType::EXPOSE);
|
|
219
|
-
SET_NUM(types, "move", (int) EventType::MOVE);
|
|
220
|
-
SET_NUM(types, "resize", (int) EventType::RESIZE);
|
|
221
|
-
SET_NUM(types, "minimize", (int) EventType::MINIMIZE);
|
|
222
|
-
SET_NUM(types, "maximize", (int) EventType::MAXIMIZE);
|
|
223
|
-
SET_NUM(types, "restore", (int) EventType::RESTORE);
|
|
224
|
-
SET_NUM(types, "focus", (int) EventType::FOCUS);
|
|
225
|
-
SET_NUM(types, "blur", (int) EventType::BLUR);
|
|
226
|
-
SET_NUM(types, "hover", (int) EventType::HOVER);
|
|
227
|
-
SET_NUM(types, "leave", (int) EventType::LEAVE);
|
|
228
|
-
SET_NUM(types, "close", (int) EventType::CLOSE);
|
|
229
|
-
SET_NUM(types, "dropBegin", (int) EventType::DROP_BEGIN);
|
|
230
|
-
SET_NUM(types, "dropComplete", (int) EventType::DROP_COMPLETE);
|
|
231
|
-
SET_NUM(types, "dropFile", (int) EventType::DROP_FILE);
|
|
232
|
-
SET_NUM(types, "dropText", (int) EventType::DROP_TEXT);
|
|
233
|
-
SET_NUM(types, "keyDown", (int) EventType::KEY_DOWN);
|
|
234
|
-
SET_NUM(types, "keyUp", (int) EventType::KEY_UP);
|
|
235
|
-
SET_NUM(types, "textInput", (int) EventType::TEXT_INPUT);
|
|
236
|
-
SET_NUM(types, "mouseMove", (int) EventType::MOUSE_MOVE);
|
|
237
|
-
SET_NUM(types, "mouseButtonDown", (int) EventType::MOUSE_BUTTON_DOWN);
|
|
238
|
-
SET_NUM(types, "mouseButtonUp", (int) EventType::MOUSE_BUTTON_UP);
|
|
239
|
-
SET_NUM(types, "mouseWheel", (int) EventType::MOUSE_WHEEL);
|
|
240
|
-
SET_NUM(types, "deviceAdd", (int) EventType::DEVICE_ADD);
|
|
241
|
-
SET_NUM(types, "deviceRemove", (int) EventType::DEVICE_REMOVE);
|
|
242
|
-
SET_NUM(types, "axisMotion", (int) EventType::AXIS_MOTION);
|
|
243
|
-
SET_NUM(types, "ballMotion", (int) EventType::BALL_MOTION);
|
|
244
|
-
SET_NUM(types, "buttonDown", (int) EventType::BUTTON_DOWN);
|
|
245
|
-
SET_NUM(types, "buttonUp", (int) EventType::BUTTON_UP);
|
|
246
|
-
SET_NUM(types, "hatMotion", (int) EventType::HAT_MOTION);
|
|
247
|
-
SET_NUM(types, "remap", (int) EventType::REMAP);
|
|
248
|
-
SET_NUM(types, "update", (int) EventType::UPDATE);
|
|
249
|
-
|
|
250
|
-
return nullptr;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
ErrorMessage *
|
|
255
|
-
enum_getPixelFormats (Variant & formats)
|
|
256
|
-
{
|
|
257
|
-
MAKE_MAP(formats);
|
|
258
|
-
|
|
259
|
-
SET_NUM(formats, "rgb332", SDL_PIXELFORMAT_RGB332);
|
|
260
|
-
SET_NUM(formats, "rgb444", SDL_PIXELFORMAT_RGB444);
|
|
261
|
-
SET_NUM(formats, "rgb555", SDL_PIXELFORMAT_RGB555);
|
|
262
|
-
SET_NUM(formats, "bgr555", SDL_PIXELFORMAT_BGR555);
|
|
263
|
-
SET_NUM(formats, "argb4444", SDL_PIXELFORMAT_ARGB4444);
|
|
264
|
-
SET_NUM(formats, "rgba4444", SDL_PIXELFORMAT_RGBA4444);
|
|
265
|
-
SET_NUM(formats, "abgr4444", SDL_PIXELFORMAT_ABGR4444);
|
|
266
|
-
SET_NUM(formats, "bgra4444", SDL_PIXELFORMAT_BGRA4444);
|
|
267
|
-
SET_NUM(formats, "argb1555", SDL_PIXELFORMAT_ARGB1555);
|
|
268
|
-
SET_NUM(formats, "rgba5551", SDL_PIXELFORMAT_RGBA5551);
|
|
269
|
-
SET_NUM(formats, "abgr1555", SDL_PIXELFORMAT_ABGR1555);
|
|
270
|
-
SET_NUM(formats, "bgra5551", SDL_PIXELFORMAT_BGRA5551);
|
|
271
|
-
SET_NUM(formats, "rgb565", SDL_PIXELFORMAT_RGB565);
|
|
272
|
-
SET_NUM(formats, "bgr565", SDL_PIXELFORMAT_BGR565);
|
|
273
|
-
SET_NUM(formats, "rgb24", SDL_PIXELFORMAT_RGB24);
|
|
274
|
-
SET_NUM(formats, "bgr24", SDL_PIXELFORMAT_BGR24);
|
|
275
|
-
SET_NUM(formats, "rgb888", SDL_PIXELFORMAT_RGB888);
|
|
276
|
-
SET_NUM(formats, "rgbx8888", SDL_PIXELFORMAT_RGBX8888);
|
|
277
|
-
SET_NUM(formats, "bgr888", SDL_PIXELFORMAT_BGR888);
|
|
278
|
-
SET_NUM(formats, "bgrx8888", SDL_PIXELFORMAT_BGRX8888);
|
|
279
|
-
SET_NUM(formats, "argb8888", SDL_PIXELFORMAT_ARGB8888);
|
|
280
|
-
SET_NUM(formats, "rgba8888", SDL_PIXELFORMAT_RGBA8888);
|
|
281
|
-
SET_NUM(formats, "abgr8888", SDL_PIXELFORMAT_ABGR8888);
|
|
282
|
-
SET_NUM(formats, "bgra8888", SDL_PIXELFORMAT_BGRA8888);
|
|
283
|
-
SET_NUM(formats, "argb2101010", SDL_PIXELFORMAT_ARGB2101010);
|
|
284
|
-
SET_NUM(formats, "rgba32", SDL_PIXELFORMAT_RGBA32);
|
|
285
|
-
SET_NUM(formats, "argb32", SDL_PIXELFORMAT_ARGB32);
|
|
286
|
-
SET_NUM(formats, "bgra32", SDL_PIXELFORMAT_BGRA32);
|
|
287
|
-
SET_NUM(formats, "abgr32", SDL_PIXELFORMAT_ABGR32);
|
|
288
|
-
SET_NUM(formats, "yv12", SDL_PIXELFORMAT_YV12);
|
|
289
|
-
SET_NUM(formats, "iyuv", SDL_PIXELFORMAT_IYUV);
|
|
290
|
-
SET_NUM(formats, "yuy2", SDL_PIXELFORMAT_YUY2);
|
|
291
|
-
SET_NUM(formats, "uyvy", SDL_PIXELFORMAT_UYVY);
|
|
292
|
-
SET_NUM(formats, "yvyu", SDL_PIXELFORMAT_YVYU);
|
|
293
|
-
SET_NUM(formats, "nv12", SDL_PIXELFORMAT_NV12);
|
|
294
|
-
SET_NUM(formats, "nv21", SDL_PIXELFORMAT_NV21);
|
|
295
|
-
|
|
296
|
-
return nullptr;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
ErrorMessage *
|
|
300
|
-
enum_getAudioFormats (Variant & formats)
|
|
301
|
-
{
|
|
302
|
-
MAKE_MAP(formats);
|
|
303
|
-
|
|
304
|
-
SET_NUM(formats, "s8", AUDIO_S8);
|
|
305
|
-
SET_NUM(formats, "u8", AUDIO_U8);
|
|
306
|
-
SET_NUM(formats, "s16lsb", AUDIO_S16LSB);
|
|
307
|
-
SET_NUM(formats, "s16msb", AUDIO_S16MSB);
|
|
308
|
-
SET_NUM(formats, "s16sys", AUDIO_S16SYS);
|
|
309
|
-
SET_NUM(formats, "s16", AUDIO_S16);
|
|
310
|
-
SET_NUM(formats, "u16lsb", AUDIO_U16LSB);
|
|
311
|
-
SET_NUM(formats, "u16msb", AUDIO_U16MSB);
|
|
312
|
-
SET_NUM(formats, "u16sys", AUDIO_U16SYS);
|
|
313
|
-
SET_NUM(formats, "u16", AUDIO_U16);
|
|
314
|
-
SET_NUM(formats, "s32lsb", AUDIO_S32LSB);
|
|
315
|
-
SET_NUM(formats, "s32msb", AUDIO_S32MSB);
|
|
316
|
-
SET_NUM(formats, "s32sys", AUDIO_S32SYS);
|
|
317
|
-
SET_NUM(formats, "s32", AUDIO_S32);
|
|
318
|
-
SET_NUM(formats, "f32lsb", AUDIO_F32LSB);
|
|
319
|
-
SET_NUM(formats, "f32msb", AUDIO_F32MSB);
|
|
320
|
-
SET_NUM(formats, "f32sys", AUDIO_F32SYS);
|
|
321
|
-
SET_NUM(formats, "f32", AUDIO_F32);
|
|
322
|
-
|
|
323
|
-
return nullptr;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
ErrorMessage *
|
|
327
|
-
enum_getScancodes (Variant & scancodes)
|
|
328
|
-
{
|
|
329
|
-
MAKE_MAP(scancodes);
|
|
330
|
-
|
|
331
|
-
SET_NUM(scancodes, "UNKNOWN", SDL_SCANCODE_UNKNOWN);
|
|
332
|
-
SET_NUM(scancodes, "A", SDL_SCANCODE_A);
|
|
333
|
-
SET_NUM(scancodes, "B", SDL_SCANCODE_B);
|
|
334
|
-
SET_NUM(scancodes, "C", SDL_SCANCODE_C);
|
|
335
|
-
SET_NUM(scancodes, "D", SDL_SCANCODE_D);
|
|
336
|
-
SET_NUM(scancodes, "E", SDL_SCANCODE_E);
|
|
337
|
-
SET_NUM(scancodes, "F", SDL_SCANCODE_F);
|
|
338
|
-
SET_NUM(scancodes, "G", SDL_SCANCODE_G);
|
|
339
|
-
SET_NUM(scancodes, "H", SDL_SCANCODE_H);
|
|
340
|
-
SET_NUM(scancodes, "I", SDL_SCANCODE_I);
|
|
341
|
-
SET_NUM(scancodes, "J", SDL_SCANCODE_J);
|
|
342
|
-
SET_NUM(scancodes, "K", SDL_SCANCODE_K);
|
|
343
|
-
SET_NUM(scancodes, "L", SDL_SCANCODE_L);
|
|
344
|
-
SET_NUM(scancodes, "M", SDL_SCANCODE_M);
|
|
345
|
-
SET_NUM(scancodes, "N", SDL_SCANCODE_N);
|
|
346
|
-
SET_NUM(scancodes, "O", SDL_SCANCODE_O);
|
|
347
|
-
SET_NUM(scancodes, "P", SDL_SCANCODE_P);
|
|
348
|
-
SET_NUM(scancodes, "Q", SDL_SCANCODE_Q);
|
|
349
|
-
SET_NUM(scancodes, "R", SDL_SCANCODE_R);
|
|
350
|
-
SET_NUM(scancodes, "S", SDL_SCANCODE_S);
|
|
351
|
-
SET_NUM(scancodes, "T", SDL_SCANCODE_T);
|
|
352
|
-
SET_NUM(scancodes, "U", SDL_SCANCODE_U);
|
|
353
|
-
SET_NUM(scancodes, "V", SDL_SCANCODE_V);
|
|
354
|
-
SET_NUM(scancodes, "W", SDL_SCANCODE_W);
|
|
355
|
-
SET_NUM(scancodes, "X", SDL_SCANCODE_X);
|
|
356
|
-
SET_NUM(scancodes, "Y", SDL_SCANCODE_Y);
|
|
357
|
-
SET_NUM(scancodes, "Z", SDL_SCANCODE_Z);
|
|
358
|
-
SET_NUM(scancodes, "1", SDL_SCANCODE_1);
|
|
359
|
-
SET_NUM(scancodes, "2", SDL_SCANCODE_2);
|
|
360
|
-
SET_NUM(scancodes, "3", SDL_SCANCODE_3);
|
|
361
|
-
SET_NUM(scancodes, "4", SDL_SCANCODE_4);
|
|
362
|
-
SET_NUM(scancodes, "5", SDL_SCANCODE_5);
|
|
363
|
-
SET_NUM(scancodes, "6", SDL_SCANCODE_6);
|
|
364
|
-
SET_NUM(scancodes, "7", SDL_SCANCODE_7);
|
|
365
|
-
SET_NUM(scancodes, "8", SDL_SCANCODE_8);
|
|
366
|
-
SET_NUM(scancodes, "9", SDL_SCANCODE_9);
|
|
367
|
-
SET_NUM(scancodes, "0", SDL_SCANCODE_0);
|
|
368
|
-
SET_NUM(scancodes, "RETURN", SDL_SCANCODE_RETURN);
|
|
369
|
-
SET_NUM(scancodes, "ESCAPE", SDL_SCANCODE_ESCAPE);
|
|
370
|
-
SET_NUM(scancodes, "BACKSPACE", SDL_SCANCODE_BACKSPACE);
|
|
371
|
-
SET_NUM(scancodes, "TAB", SDL_SCANCODE_TAB);
|
|
372
|
-
SET_NUM(scancodes, "SPACE", SDL_SCANCODE_SPACE);
|
|
373
|
-
SET_NUM(scancodes, "MINUS", SDL_SCANCODE_MINUS);
|
|
374
|
-
SET_NUM(scancodes, "EQUALS", SDL_SCANCODE_EQUALS);
|
|
375
|
-
SET_NUM(scancodes, "LEFTBRACKET", SDL_SCANCODE_LEFTBRACKET);
|
|
376
|
-
SET_NUM(scancodes, "RIGHTBRACKET", SDL_SCANCODE_RIGHTBRACKET);
|
|
377
|
-
SET_NUM(scancodes, "BACKSLASH", SDL_SCANCODE_BACKSLASH);
|
|
378
|
-
SET_NUM(scancodes, "NONUSHASH", SDL_SCANCODE_NONUSHASH);
|
|
379
|
-
SET_NUM(scancodes, "SEMICOLON", SDL_SCANCODE_SEMICOLON);
|
|
380
|
-
SET_NUM(scancodes, "APOSTROPHE", SDL_SCANCODE_APOSTROPHE);
|
|
381
|
-
SET_NUM(scancodes, "GRAVE", SDL_SCANCODE_GRAVE);
|
|
382
|
-
SET_NUM(scancodes, "COMMA", SDL_SCANCODE_COMMA);
|
|
383
|
-
SET_NUM(scancodes, "PERIOD", SDL_SCANCODE_PERIOD);
|
|
384
|
-
SET_NUM(scancodes, "SLASH", SDL_SCANCODE_SLASH);
|
|
385
|
-
SET_NUM(scancodes, "CAPSLOCK", SDL_SCANCODE_CAPSLOCK);
|
|
386
|
-
SET_NUM(scancodes, "F1", SDL_SCANCODE_F1);
|
|
387
|
-
SET_NUM(scancodes, "F2", SDL_SCANCODE_F2);
|
|
388
|
-
SET_NUM(scancodes, "F3", SDL_SCANCODE_F3);
|
|
389
|
-
SET_NUM(scancodes, "F4", SDL_SCANCODE_F4);
|
|
390
|
-
SET_NUM(scancodes, "F5", SDL_SCANCODE_F5);
|
|
391
|
-
SET_NUM(scancodes, "F6", SDL_SCANCODE_F6);
|
|
392
|
-
SET_NUM(scancodes, "F7", SDL_SCANCODE_F7);
|
|
393
|
-
SET_NUM(scancodes, "F8", SDL_SCANCODE_F8);
|
|
394
|
-
SET_NUM(scancodes, "F9", SDL_SCANCODE_F9);
|
|
395
|
-
SET_NUM(scancodes, "F10", SDL_SCANCODE_F10);
|
|
396
|
-
SET_NUM(scancodes, "F11", SDL_SCANCODE_F11);
|
|
397
|
-
SET_NUM(scancodes, "F12", SDL_SCANCODE_F12);
|
|
398
|
-
SET_NUM(scancodes, "PRINTSCREEN", SDL_SCANCODE_PRINTSCREEN);
|
|
399
|
-
SET_NUM(scancodes, "SCROLLLOCK", SDL_SCANCODE_SCROLLLOCK);
|
|
400
|
-
SET_NUM(scancodes, "PAUSE", SDL_SCANCODE_PAUSE);
|
|
401
|
-
SET_NUM(scancodes, "INSERT", SDL_SCANCODE_INSERT);
|
|
402
|
-
SET_NUM(scancodes, "HOME", SDL_SCANCODE_HOME);
|
|
403
|
-
SET_NUM(scancodes, "PAGEUP", SDL_SCANCODE_PAGEUP);
|
|
404
|
-
SET_NUM(scancodes, "DELETE", SDL_SCANCODE_DELETE);
|
|
405
|
-
SET_NUM(scancodes, "END", SDL_SCANCODE_END);
|
|
406
|
-
SET_NUM(scancodes, "PAGEDOWN", SDL_SCANCODE_PAGEDOWN);
|
|
407
|
-
SET_NUM(scancodes, "RIGHT", SDL_SCANCODE_RIGHT);
|
|
408
|
-
SET_NUM(scancodes, "LEFT", SDL_SCANCODE_LEFT);
|
|
409
|
-
SET_NUM(scancodes, "DOWN", SDL_SCANCODE_DOWN);
|
|
410
|
-
SET_NUM(scancodes, "UP", SDL_SCANCODE_UP);
|
|
411
|
-
SET_NUM(scancodes, "NUMLOCKCLEAR", SDL_SCANCODE_NUMLOCKCLEAR);
|
|
412
|
-
SET_NUM(scancodes, "KP_DIVIDE", SDL_SCANCODE_KP_DIVIDE);
|
|
413
|
-
SET_NUM(scancodes, "KP_MULTIPLY", SDL_SCANCODE_KP_MULTIPLY);
|
|
414
|
-
SET_NUM(scancodes, "KP_MINUS", SDL_SCANCODE_KP_MINUS);
|
|
415
|
-
SET_NUM(scancodes, "KP_PLUS", SDL_SCANCODE_KP_PLUS);
|
|
416
|
-
SET_NUM(scancodes, "KP_ENTER", SDL_SCANCODE_KP_ENTER);
|
|
417
|
-
SET_NUM(scancodes, "KP_1", SDL_SCANCODE_KP_1);
|
|
418
|
-
SET_NUM(scancodes, "KP_2", SDL_SCANCODE_KP_2);
|
|
419
|
-
SET_NUM(scancodes, "KP_3", SDL_SCANCODE_KP_3);
|
|
420
|
-
SET_NUM(scancodes, "KP_4", SDL_SCANCODE_KP_4);
|
|
421
|
-
SET_NUM(scancodes, "KP_5", SDL_SCANCODE_KP_5);
|
|
422
|
-
SET_NUM(scancodes, "KP_6", SDL_SCANCODE_KP_6);
|
|
423
|
-
SET_NUM(scancodes, "KP_7", SDL_SCANCODE_KP_7);
|
|
424
|
-
SET_NUM(scancodes, "KP_8", SDL_SCANCODE_KP_8);
|
|
425
|
-
SET_NUM(scancodes, "KP_9", SDL_SCANCODE_KP_9);
|
|
426
|
-
SET_NUM(scancodes, "KP_0", SDL_SCANCODE_KP_0);
|
|
427
|
-
SET_NUM(scancodes, "KP_PERIOD", SDL_SCANCODE_KP_PERIOD);
|
|
428
|
-
SET_NUM(scancodes, "NONUSBACKSLASH", SDL_SCANCODE_NONUSBACKSLASH);
|
|
429
|
-
SET_NUM(scancodes, "APPLICATION", SDL_SCANCODE_APPLICATION);
|
|
430
|
-
SET_NUM(scancodes, "POWER", SDL_SCANCODE_POWER);
|
|
431
|
-
SET_NUM(scancodes, "KP_EQUALS", SDL_SCANCODE_KP_EQUALS);
|
|
432
|
-
SET_NUM(scancodes, "F13", SDL_SCANCODE_F13);
|
|
433
|
-
SET_NUM(scancodes, "F14", SDL_SCANCODE_F14);
|
|
434
|
-
SET_NUM(scancodes, "F15", SDL_SCANCODE_F15);
|
|
435
|
-
SET_NUM(scancodes, "F16", SDL_SCANCODE_F16);
|
|
436
|
-
SET_NUM(scancodes, "F17", SDL_SCANCODE_F17);
|
|
437
|
-
SET_NUM(scancodes, "F18", SDL_SCANCODE_F18);
|
|
438
|
-
SET_NUM(scancodes, "F19", SDL_SCANCODE_F19);
|
|
439
|
-
SET_NUM(scancodes, "F20", SDL_SCANCODE_F20);
|
|
440
|
-
SET_NUM(scancodes, "F21", SDL_SCANCODE_F21);
|
|
441
|
-
SET_NUM(scancodes, "F22", SDL_SCANCODE_F22);
|
|
442
|
-
SET_NUM(scancodes, "F23", SDL_SCANCODE_F23);
|
|
443
|
-
SET_NUM(scancodes, "F24", SDL_SCANCODE_F24);
|
|
444
|
-
SET_NUM(scancodes, "EXECUTE", SDL_SCANCODE_EXECUTE);
|
|
445
|
-
SET_NUM(scancodes, "HELP", SDL_SCANCODE_HELP);
|
|
446
|
-
SET_NUM(scancodes, "MENU", SDL_SCANCODE_MENU);
|
|
447
|
-
SET_NUM(scancodes, "SELECT", SDL_SCANCODE_SELECT);
|
|
448
|
-
SET_NUM(scancodes, "STOP", SDL_SCANCODE_STOP);
|
|
449
|
-
SET_NUM(scancodes, "AGAIN", SDL_SCANCODE_AGAIN);
|
|
450
|
-
SET_NUM(scancodes, "UNDO", SDL_SCANCODE_UNDO);
|
|
451
|
-
SET_NUM(scancodes, "CUT", SDL_SCANCODE_CUT);
|
|
452
|
-
SET_NUM(scancodes, "COPY", SDL_SCANCODE_COPY);
|
|
453
|
-
SET_NUM(scancodes, "PASTE", SDL_SCANCODE_PASTE);
|
|
454
|
-
SET_NUM(scancodes, "FIND", SDL_SCANCODE_FIND);
|
|
455
|
-
SET_NUM(scancodes, "MUTE", SDL_SCANCODE_MUTE);
|
|
456
|
-
SET_NUM(scancodes, "VOLUMEUP", SDL_SCANCODE_VOLUMEUP);
|
|
457
|
-
SET_NUM(scancodes, "VOLUMEDOWN", SDL_SCANCODE_VOLUMEDOWN);
|
|
458
|
-
SET_NUM(scancodes, "KP_COMMA", SDL_SCANCODE_KP_COMMA);
|
|
459
|
-
SET_NUM(scancodes, "KP_EQUALSAS400", SDL_SCANCODE_KP_EQUALSAS400);
|
|
460
|
-
SET_NUM(scancodes, "INTERNATIONAL1", SDL_SCANCODE_INTERNATIONAL1);
|
|
461
|
-
SET_NUM(scancodes, "INTERNATIONAL2", SDL_SCANCODE_INTERNATIONAL2);
|
|
462
|
-
SET_NUM(scancodes, "INTERNATIONAL3", SDL_SCANCODE_INTERNATIONAL3);
|
|
463
|
-
SET_NUM(scancodes, "INTERNATIONAL4", SDL_SCANCODE_INTERNATIONAL4);
|
|
464
|
-
SET_NUM(scancodes, "INTERNATIONAL5", SDL_SCANCODE_INTERNATIONAL5);
|
|
465
|
-
SET_NUM(scancodes, "INTERNATIONAL6", SDL_SCANCODE_INTERNATIONAL6);
|
|
466
|
-
SET_NUM(scancodes, "INTERNATIONAL7", SDL_SCANCODE_INTERNATIONAL7);
|
|
467
|
-
SET_NUM(scancodes, "INTERNATIONAL8", SDL_SCANCODE_INTERNATIONAL8);
|
|
468
|
-
SET_NUM(scancodes, "INTERNATIONAL9", SDL_SCANCODE_INTERNATIONAL9);
|
|
469
|
-
SET_NUM(scancodes, "LANG1", SDL_SCANCODE_LANG1);
|
|
470
|
-
SET_NUM(scancodes, "LANG2", SDL_SCANCODE_LANG2);
|
|
471
|
-
SET_NUM(scancodes, "LANG3", SDL_SCANCODE_LANG3);
|
|
472
|
-
SET_NUM(scancodes, "LANG4", SDL_SCANCODE_LANG4);
|
|
473
|
-
SET_NUM(scancodes, "LANG5", SDL_SCANCODE_LANG5);
|
|
474
|
-
SET_NUM(scancodes, "LANG6", SDL_SCANCODE_LANG6);
|
|
475
|
-
SET_NUM(scancodes, "LANG7", SDL_SCANCODE_LANG7);
|
|
476
|
-
SET_NUM(scancodes, "LANG8", SDL_SCANCODE_LANG8);
|
|
477
|
-
SET_NUM(scancodes, "LANG9", SDL_SCANCODE_LANG9);
|
|
478
|
-
SET_NUM(scancodes, "ALTERASE", SDL_SCANCODE_ALTERASE);
|
|
479
|
-
SET_NUM(scancodes, "SYSREQ", SDL_SCANCODE_SYSREQ);
|
|
480
|
-
SET_NUM(scancodes, "CANCEL", SDL_SCANCODE_CANCEL);
|
|
481
|
-
SET_NUM(scancodes, "CLEAR", SDL_SCANCODE_CLEAR);
|
|
482
|
-
SET_NUM(scancodes, "PRIOR", SDL_SCANCODE_PRIOR);
|
|
483
|
-
SET_NUM(scancodes, "RETURN2", SDL_SCANCODE_RETURN2);
|
|
484
|
-
SET_NUM(scancodes, "SEPARATOR", SDL_SCANCODE_SEPARATOR);
|
|
485
|
-
SET_NUM(scancodes, "OUT", SDL_SCANCODE_OUT);
|
|
486
|
-
SET_NUM(scancodes, "OPER", SDL_SCANCODE_OPER);
|
|
487
|
-
SET_NUM(scancodes, "CLEARAGAIN", SDL_SCANCODE_CLEARAGAIN);
|
|
488
|
-
SET_NUM(scancodes, "CRSEL", SDL_SCANCODE_CRSEL);
|
|
489
|
-
SET_NUM(scancodes, "EXSEL", SDL_SCANCODE_EXSEL);
|
|
490
|
-
SET_NUM(scancodes, "KP_00", SDL_SCANCODE_KP_00);
|
|
491
|
-
SET_NUM(scancodes, "KP_000", SDL_SCANCODE_KP_000);
|
|
492
|
-
SET_NUM(scancodes, "THOUSANDSSEPARATOR", SDL_SCANCODE_THOUSANDSSEPARATOR);
|
|
493
|
-
SET_NUM(scancodes, "DECIMALSEPARATOR", SDL_SCANCODE_DECIMALSEPARATOR);
|
|
494
|
-
SET_NUM(scancodes, "CURRENCYUNIT", SDL_SCANCODE_CURRENCYUNIT);
|
|
495
|
-
SET_NUM(scancodes, "CURRENCYSUBUNIT", SDL_SCANCODE_CURRENCYSUBUNIT);
|
|
496
|
-
SET_NUM(scancodes, "KP_LEFTPAREN", SDL_SCANCODE_KP_LEFTPAREN);
|
|
497
|
-
SET_NUM(scancodes, "KP_RIGHTPAREN", SDL_SCANCODE_KP_RIGHTPAREN);
|
|
498
|
-
SET_NUM(scancodes, "KP_LEFTBRACE", SDL_SCANCODE_KP_LEFTBRACE);
|
|
499
|
-
SET_NUM(scancodes, "KP_RIGHTBRACE", SDL_SCANCODE_KP_RIGHTBRACE);
|
|
500
|
-
SET_NUM(scancodes, "KP_TAB", SDL_SCANCODE_KP_TAB);
|
|
501
|
-
SET_NUM(scancodes, "KP_BACKSPACE", SDL_SCANCODE_KP_BACKSPACE);
|
|
502
|
-
SET_NUM(scancodes, "KP_A", SDL_SCANCODE_KP_A);
|
|
503
|
-
SET_NUM(scancodes, "KP_B", SDL_SCANCODE_KP_B);
|
|
504
|
-
SET_NUM(scancodes, "KP_C", SDL_SCANCODE_KP_C);
|
|
505
|
-
SET_NUM(scancodes, "KP_D", SDL_SCANCODE_KP_D);
|
|
506
|
-
SET_NUM(scancodes, "KP_E", SDL_SCANCODE_KP_E);
|
|
507
|
-
SET_NUM(scancodes, "KP_F", SDL_SCANCODE_KP_F);
|
|
508
|
-
SET_NUM(scancodes, "KP_XOR", SDL_SCANCODE_KP_XOR);
|
|
509
|
-
SET_NUM(scancodes, "KP_POWER", SDL_SCANCODE_KP_POWER);
|
|
510
|
-
SET_NUM(scancodes, "KP_PERCENT", SDL_SCANCODE_KP_PERCENT);
|
|
511
|
-
SET_NUM(scancodes, "KP_LESS", SDL_SCANCODE_KP_LESS);
|
|
512
|
-
SET_NUM(scancodes, "KP_GREATER", SDL_SCANCODE_KP_GREATER);
|
|
513
|
-
SET_NUM(scancodes, "KP_AMPERSAND", SDL_SCANCODE_KP_AMPERSAND);
|
|
514
|
-
SET_NUM(scancodes, "KP_DBLAMPERSAND", SDL_SCANCODE_KP_DBLAMPERSAND);
|
|
515
|
-
SET_NUM(scancodes, "KP_VERTICALBAR", SDL_SCANCODE_KP_VERTICALBAR);
|
|
516
|
-
SET_NUM(scancodes, "KP_DBLVERTICALBAR", SDL_SCANCODE_KP_DBLVERTICALBAR);
|
|
517
|
-
SET_NUM(scancodes, "KP_COLON", SDL_SCANCODE_KP_COLON);
|
|
518
|
-
SET_NUM(scancodes, "KP_HASH", SDL_SCANCODE_KP_HASH);
|
|
519
|
-
SET_NUM(scancodes, "KP_SPACE", SDL_SCANCODE_KP_SPACE);
|
|
520
|
-
SET_NUM(scancodes, "KP_AT", SDL_SCANCODE_KP_AT);
|
|
521
|
-
SET_NUM(scancodes, "KP_EXCLAM", SDL_SCANCODE_KP_EXCLAM);
|
|
522
|
-
SET_NUM(scancodes, "KP_MEMSTORE", SDL_SCANCODE_KP_MEMSTORE);
|
|
523
|
-
SET_NUM(scancodes, "KP_MEMRECALL", SDL_SCANCODE_KP_MEMRECALL);
|
|
524
|
-
SET_NUM(scancodes, "KP_MEMCLEAR", SDL_SCANCODE_KP_MEMCLEAR);
|
|
525
|
-
SET_NUM(scancodes, "KP_MEMADD", SDL_SCANCODE_KP_MEMADD);
|
|
526
|
-
SET_NUM(scancodes, "KP_MEMSUBTRACT", SDL_SCANCODE_KP_MEMSUBTRACT);
|
|
527
|
-
SET_NUM(scancodes, "KP_MEMMULTIPLY", SDL_SCANCODE_KP_MEMMULTIPLY);
|
|
528
|
-
SET_NUM(scancodes, "KP_MEMDIVIDE", SDL_SCANCODE_KP_MEMDIVIDE);
|
|
529
|
-
SET_NUM(scancodes, "KP_PLUSMINUS", SDL_SCANCODE_KP_PLUSMINUS);
|
|
530
|
-
SET_NUM(scancodes, "KP_CLEAR", SDL_SCANCODE_KP_CLEAR);
|
|
531
|
-
SET_NUM(scancodes, "KP_CLEARENTRY", SDL_SCANCODE_KP_CLEARENTRY);
|
|
532
|
-
SET_NUM(scancodes, "KP_BINARY", SDL_SCANCODE_KP_BINARY);
|
|
533
|
-
SET_NUM(scancodes, "KP_OCTAL", SDL_SCANCODE_KP_OCTAL);
|
|
534
|
-
SET_NUM(scancodes, "KP_DECIMAL", SDL_SCANCODE_KP_DECIMAL);
|
|
535
|
-
SET_NUM(scancodes, "KP_HEXADECIMAL", SDL_SCANCODE_KP_HEXADECIMAL);
|
|
536
|
-
SET_NUM(scancodes, "LCTRL", SDL_SCANCODE_LCTRL);
|
|
537
|
-
SET_NUM(scancodes, "LSHIFT", SDL_SCANCODE_LSHIFT);
|
|
538
|
-
SET_NUM(scancodes, "LALT", SDL_SCANCODE_LALT);
|
|
539
|
-
SET_NUM(scancodes, "LGUI", SDL_SCANCODE_LGUI);
|
|
540
|
-
SET_NUM(scancodes, "RCTRL", SDL_SCANCODE_RCTRL);
|
|
541
|
-
SET_NUM(scancodes, "RSHIFT", SDL_SCANCODE_RSHIFT);
|
|
542
|
-
SET_NUM(scancodes, "RALT", SDL_SCANCODE_RALT);
|
|
543
|
-
SET_NUM(scancodes, "RGUI", SDL_SCANCODE_RGUI);
|
|
544
|
-
SET_NUM(scancodes, "MODE", SDL_SCANCODE_MODE);
|
|
545
|
-
SET_NUM(scancodes, "AUDIONEXT", SDL_SCANCODE_AUDIONEXT);
|
|
546
|
-
SET_NUM(scancodes, "AUDIOPREV", SDL_SCANCODE_AUDIOPREV);
|
|
547
|
-
SET_NUM(scancodes, "AUDIOSTOP", SDL_SCANCODE_AUDIOSTOP);
|
|
548
|
-
SET_NUM(scancodes, "AUDIOPLAY", SDL_SCANCODE_AUDIOPLAY);
|
|
549
|
-
SET_NUM(scancodes, "AUDIOMUTE", SDL_SCANCODE_AUDIOMUTE);
|
|
550
|
-
SET_NUM(scancodes, "MEDIASELECT", SDL_SCANCODE_MEDIASELECT);
|
|
551
|
-
SET_NUM(scancodes, "WWW", SDL_SCANCODE_WWW);
|
|
552
|
-
SET_NUM(scancodes, "MAIL", SDL_SCANCODE_MAIL);
|
|
553
|
-
SET_NUM(scancodes, "CALCULATOR", SDL_SCANCODE_CALCULATOR);
|
|
554
|
-
SET_NUM(scancodes, "COMPUTER", SDL_SCANCODE_COMPUTER);
|
|
555
|
-
SET_NUM(scancodes, "AC_SEARCH", SDL_SCANCODE_AC_SEARCH);
|
|
556
|
-
SET_NUM(scancodes, "AC_HOME", SDL_SCANCODE_AC_HOME);
|
|
557
|
-
SET_NUM(scancodes, "AC_BACK", SDL_SCANCODE_AC_BACK);
|
|
558
|
-
SET_NUM(scancodes, "AC_FORWARD", SDL_SCANCODE_AC_FORWARD);
|
|
559
|
-
SET_NUM(scancodes, "AC_STOP", SDL_SCANCODE_AC_STOP);
|
|
560
|
-
SET_NUM(scancodes, "AC_REFRESH", SDL_SCANCODE_AC_REFRESH);
|
|
561
|
-
SET_NUM(scancodes, "AC_BOOKMARKS", SDL_SCANCODE_AC_BOOKMARKS);
|
|
562
|
-
SET_NUM(scancodes, "BRIGHTNESSDOWN", SDL_SCANCODE_BRIGHTNESSDOWN);
|
|
563
|
-
SET_NUM(scancodes, "BRIGHTNESSUP", SDL_SCANCODE_BRIGHTNESSUP);
|
|
564
|
-
SET_NUM(scancodes, "DISPLAYSWITCH", SDL_SCANCODE_DISPLAYSWITCH);
|
|
565
|
-
SET_NUM(scancodes, "KBDILLUMTOGGLE", SDL_SCANCODE_KBDILLUMTOGGLE);
|
|
566
|
-
SET_NUM(scancodes, "KBDILLUMDOWN", SDL_SCANCODE_KBDILLUMDOWN);
|
|
567
|
-
SET_NUM(scancodes, "KBDILLUMUP", SDL_SCANCODE_KBDILLUMUP);
|
|
568
|
-
SET_NUM(scancodes, "EJECT", SDL_SCANCODE_EJECT);
|
|
569
|
-
SET_NUM(scancodes, "SLEEP", SDL_SCANCODE_SLEEP);
|
|
570
|
-
SET_NUM(scancodes, "APP1", SDL_SCANCODE_APP1);
|
|
571
|
-
SET_NUM(scancodes, "APP2", SDL_SCANCODE_APP2);
|
|
572
|
-
SET_NUM(scancodes, "AUDIOREWIND", SDL_SCANCODE_AUDIOREWIND);
|
|
573
|
-
SET_NUM(scancodes, "AUDIOFASTFORWARD", SDL_SCANCODE_AUDIOFASTFORWARD);
|
|
574
|
-
|
|
575
|
-
return nullptr;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
ErrorMessage *
|
|
579
|
-
enum_getMouseButtons (Variant & buttons)
|
|
580
|
-
{
|
|
581
|
-
MAKE_MAP(buttons);
|
|
582
|
-
|
|
583
|
-
SET_NUM(buttons, "LEFT", SDL_BUTTON_LEFT);
|
|
584
|
-
SET_NUM(buttons, "MIDDLE", SDL_BUTTON_MIDDLE);
|
|
585
|
-
SET_NUM(buttons, "RIGHT", SDL_BUTTON_RIGHT);
|
|
586
|
-
|
|
587
|
-
return nullptr;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
ErrorMessage *
|
|
591
|
-
enum_getCursors (Variant & cursors)
|
|
592
|
-
{
|
|
593
|
-
MAKE_MAP(cursors);
|
|
594
|
-
|
|
595
|
-
SET_NUM(cursors, "arrow", SDL_SYSTEM_CURSOR_ARROW);
|
|
596
|
-
SET_NUM(cursors, "ibeam", SDL_SYSTEM_CURSOR_IBEAM);
|
|
597
|
-
SET_NUM(cursors, "wait", SDL_SYSTEM_CURSOR_WAIT);
|
|
598
|
-
SET_NUM(cursors, "crosshair", SDL_SYSTEM_CURSOR_CROSSHAIR);
|
|
599
|
-
SET_NUM(cursors, "waitarrow", SDL_SYSTEM_CURSOR_WAITARROW);
|
|
600
|
-
SET_NUM(cursors, "sizenwse", SDL_SYSTEM_CURSOR_SIZENWSE);
|
|
601
|
-
SET_NUM(cursors, "sizenesw", SDL_SYSTEM_CURSOR_SIZENESW);
|
|
602
|
-
SET_NUM(cursors, "sizewe", SDL_SYSTEM_CURSOR_SIZEWE);
|
|
603
|
-
SET_NUM(cursors, "sizens", SDL_SYSTEM_CURSOR_SIZENS);
|
|
604
|
-
SET_NUM(cursors, "sizeall", SDL_SYSTEM_CURSOR_SIZEALL);
|
|
605
|
-
SET_NUM(cursors, "no", SDL_SYSTEM_CURSOR_NO);
|
|
606
|
-
SET_NUM(cursors, "hand", SDL_SYSTEM_CURSOR_HAND);
|
|
607
|
-
|
|
608
|
-
return nullptr;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
ErrorMessage *
|
|
612
|
-
enum_getHatPositions (Variant & positions)
|
|
613
|
-
{
|
|
614
|
-
MAKE_MAP(positions);
|
|
615
|
-
|
|
616
|
-
SET_NUM(positions, "centered", SDL_HAT_CENTERED);
|
|
617
|
-
SET_NUM(positions, "up", SDL_HAT_UP);
|
|
618
|
-
SET_NUM(positions, "right", SDL_HAT_RIGHT);
|
|
619
|
-
SET_NUM(positions, "down", SDL_HAT_DOWN);
|
|
620
|
-
SET_NUM(positions, "left", SDL_HAT_LEFT);
|
|
621
|
-
SET_NUM(positions, "rightup", SDL_HAT_RIGHTUP);
|
|
622
|
-
SET_NUM(positions, "rightdown", SDL_HAT_RIGHTDOWN);
|
|
623
|
-
SET_NUM(positions, "leftup", SDL_HAT_LEFTUP);
|
|
624
|
-
SET_NUM(positions, "leftdown", SDL_HAT_LEFTDOWN);
|
|
625
|
-
|
|
626
|
-
return nullptr;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
ErrorMessage *
|
|
630
|
-
enum_getPowerLevels (Variant & levels)
|
|
631
|
-
{
|
|
632
|
-
MAKE_MAP(levels);
|
|
633
|
-
|
|
634
|
-
SET_NUM(levels, "unknown", SDL_JOYSTICK_POWER_UNKNOWN);
|
|
635
|
-
SET_NUM(levels, "empty", SDL_JOYSTICK_POWER_EMPTY);
|
|
636
|
-
SET_NUM(levels, "low", SDL_JOYSTICK_POWER_LOW);
|
|
637
|
-
SET_NUM(levels, "medium", SDL_JOYSTICK_POWER_MEDIUM);
|
|
638
|
-
SET_NUM(levels, "full", SDL_JOYSTICK_POWER_FULL);
|
|
639
|
-
SET_NUM(levels, "wired", SDL_JOYSTICK_POWER_WIRED);
|
|
640
|
-
SET_NUM(levels, "max", SDL_JOYSTICK_POWER_MAX);
|
|
641
|
-
|
|
642
|
-
return nullptr;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
ErrorMessage *
|
|
646
|
-
enum_getJoystickTypes (Variant & types)
|
|
647
|
-
{
|
|
648
|
-
MAKE_MAP(types);
|
|
649
|
-
|
|
650
|
-
SET_NUM(types, "unknown", SDL_JOYSTICK_TYPE_UNKNOWN);
|
|
651
|
-
SET_NUM(types, "gamecontroller", SDL_JOYSTICK_TYPE_GAMECONTROLLER);
|
|
652
|
-
SET_NUM(types, "wheel", SDL_JOYSTICK_TYPE_WHEEL);
|
|
653
|
-
SET_NUM(types, "arcadestick", SDL_JOYSTICK_TYPE_ARCADE_STICK);
|
|
654
|
-
SET_NUM(types, "flightstick", SDL_JOYSTICK_TYPE_FLIGHT_STICK);
|
|
655
|
-
SET_NUM(types, "dancepad", SDL_JOYSTICK_TYPE_DANCE_PAD);
|
|
656
|
-
SET_NUM(types, "guitar", SDL_JOYSTICK_TYPE_GUITAR);
|
|
657
|
-
SET_NUM(types, "drumkit", SDL_JOYSTICK_TYPE_DRUM_KIT);
|
|
658
|
-
SET_NUM(types, "arcadepad", SDL_JOYSTICK_TYPE_ARCADE_PAD);
|
|
659
|
-
SET_NUM(types, "throttle", SDL_JOYSTICK_TYPE_THROTTLE);
|
|
660
|
-
|
|
661
|
-
return nullptr;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
ErrorMessage *
|
|
665
|
-
enum_getControllerAxes (Variant & axes)
|
|
666
|
-
{
|
|
667
|
-
MAKE_MAP(axes);
|
|
668
|
-
|
|
669
|
-
SET_NUM(axes, "leftStickX", SDL_CONTROLLER_AXIS_LEFTX);
|
|
670
|
-
SET_NUM(axes, "leftStickY", SDL_CONTROLLER_AXIS_LEFTY);
|
|
671
|
-
SET_NUM(axes, "rightStickX", SDL_CONTROLLER_AXIS_RIGHTX);
|
|
672
|
-
SET_NUM(axes, "rightStickY", SDL_CONTROLLER_AXIS_RIGHTY);
|
|
673
|
-
SET_NUM(axes, "leftTrigger", SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
|
674
|
-
SET_NUM(axes, "rightTrigger", SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
|
675
|
-
|
|
676
|
-
return nullptr;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
ErrorMessage *
|
|
680
|
-
enum_getControllerButtons (Variant & buttons)
|
|
681
|
-
{
|
|
682
|
-
MAKE_MAP(buttons);
|
|
683
|
-
|
|
684
|
-
SET_NUM(buttons, "dpadLeft", SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
|
685
|
-
SET_NUM(buttons, "dpadRight", SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
|
686
|
-
SET_NUM(buttons, "dpadUp", SDL_CONTROLLER_BUTTON_DPAD_UP);
|
|
687
|
-
SET_NUM(buttons, "dpadDown", SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
|
688
|
-
SET_NUM(buttons, "a", SDL_CONTROLLER_BUTTON_A);
|
|
689
|
-
SET_NUM(buttons, "b", SDL_CONTROLLER_BUTTON_B);
|
|
690
|
-
SET_NUM(buttons, "x", SDL_CONTROLLER_BUTTON_X);
|
|
691
|
-
SET_NUM(buttons, "y", SDL_CONTROLLER_BUTTON_Y);
|
|
692
|
-
SET_NUM(buttons, "guide", SDL_CONTROLLER_BUTTON_GUIDE);
|
|
693
|
-
SET_NUM(buttons, "back", SDL_CONTROLLER_BUTTON_BACK);
|
|
694
|
-
SET_NUM(buttons, "start", SDL_CONTROLLER_BUTTON_START);
|
|
695
|
-
SET_NUM(buttons, "leftStick", SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
|
696
|
-
SET_NUM(buttons, "rightStick", SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
|
697
|
-
SET_NUM(buttons, "leftShoulder", SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
|
698
|
-
SET_NUM(buttons, "rightShoulder", SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
|
699
|
-
SET_NUM(buttons, "paddle1", SDL_CONTROLLER_BUTTON_PADDLE1);
|
|
700
|
-
SET_NUM(buttons, "paddle2", SDL_CONTROLLER_BUTTON_PADDLE2);
|
|
701
|
-
SET_NUM(buttons, "paddle3", SDL_CONTROLLER_BUTTON_PADDLE3);
|
|
702
|
-
SET_NUM(buttons, "paddle4", SDL_CONTROLLER_BUTTON_PADDLE4);
|
|
703
|
-
|
|
704
|
-
return nullptr;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
ErrorMessage *
|
|
708
|
-
enum_getSensorTypes (Variant & types)
|
|
709
|
-
{
|
|
710
|
-
MAKE_MAP(types);
|
|
711
|
-
|
|
712
|
-
SET_NUM(types, "unknown", SDL_SENSOR_UNKNOWN);
|
|
713
|
-
SET_NUM(types, "accelerometer", SDL_SENSOR_ACCEL);
|
|
714
|
-
SET_NUM(types, "gyroscope", SDL_SENSOR_GYRO);
|
|
715
|
-
SET_NUM(types, "accelerometerLeft", SDL_SENSOR_ACCEL_L);
|
|
716
|
-
SET_NUM(types, "gyroscopeLeft", SDL_SENSOR_GYRO_L);
|
|
717
|
-
SET_NUM(types, "accelerometerRight", SDL_SENSOR_ACCEL_R);
|
|
718
|
-
SET_NUM(types, "gyroscopeRight", SDL_SENSOR_GYRO_R);
|
|
719
|
-
|
|
720
|
-
return nullptr;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
ErrorMessage *
|
|
724
|
-
enum_getPowerStates (Variant & states)
|
|
725
|
-
{
|
|
726
|
-
MAKE_MAP(states);
|
|
727
|
-
|
|
728
|
-
SET_NUM(states, "unknown", SDL_POWERSTATE_UNKNOWN);
|
|
729
|
-
SET_NUM(states, "noBattery", SDL_POWERSTATE_NO_BATTERY);
|
|
730
|
-
SET_NUM(states, "battery", SDL_POWERSTATE_ON_BATTERY);
|
|
731
|
-
SET_NUM(states, "charging", SDL_POWERSTATE_CHARGING);
|
|
732
|
-
SET_NUM(states, "charged", SDL_POWERSTATE_CHARGED);
|
|
733
|
-
|
|
734
|
-
return nullptr;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
ErrorMessage *
|
|
740
|
-
initialize (Variant & object)
|
|
741
|
-
{
|
|
742
|
-
// Hints
|
|
743
|
-
{
|
|
744
|
-
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
MAKE_MAP(object);
|
|
748
|
-
|
|
749
|
-
// Init
|
|
750
|
-
{
|
|
751
|
-
int subsystems = 0
|
|
752
|
-
| SDL_INIT_EVENTS
|
|
753
|
-
| SDL_INIT_JOYSTICK
|
|
754
|
-
| SDL_INIT_GAMECONTROLLER
|
|
755
|
-
| SDL_INIT_HAPTIC
|
|
756
|
-
| SDL_INIT_SENSOR;
|
|
757
|
-
if (SDL_Init(subsystems) != 0) {
|
|
758
|
-
RETURN_ERROR("SDL_Init() error: %s\n", SDL_GetError());
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// Version
|
|
763
|
-
{
|
|
764
|
-
Variant version, compile, runtime;
|
|
765
|
-
MAKE_MAP(version);
|
|
766
|
-
MAKE_MAP(compile);
|
|
767
|
-
MAKE_MAP(runtime);
|
|
768
|
-
|
|
769
|
-
SDL_version compile_version;
|
|
770
|
-
SDL_VERSION(&compile_version);
|
|
771
|
-
SET_NUM(compile, "major", compile_version.major);
|
|
772
|
-
SET_NUM(compile, "minor", compile_version.minor);
|
|
773
|
-
SET_NUM(compile, "patch", compile_version.patch);
|
|
774
|
-
SET_MAP(version, "compile", compile);
|
|
775
|
-
|
|
776
|
-
SDL_version runtime_version;
|
|
777
|
-
SDL_GetVersion(&runtime_version);
|
|
778
|
-
SET_NUM(runtime, "major", runtime_version.major);
|
|
779
|
-
SET_NUM(runtime, "minor", runtime_version.minor);
|
|
780
|
-
SET_NUM(runtime, "patch", runtime_version.patch);
|
|
781
|
-
SET_MAP(version, "runtime", runtime);
|
|
782
|
-
|
|
783
|
-
SET_MAP(object, "version", version);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
{
|
|
787
|
-
const char * platform_name = SDL_GetPlatform();
|
|
788
|
-
SET_STRING(object, "platform", platform_name);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
Variant drivers, video, audio;
|
|
792
|
-
MAKE_MAP(drivers);
|
|
793
|
-
MAKE_MAP(video);
|
|
794
|
-
MAKE_MAP(audio);
|
|
795
|
-
|
|
796
|
-
// Available Video Drivers
|
|
797
|
-
{
|
|
798
|
-
Variant list;
|
|
799
|
-
MAKE_LIST(list);
|
|
800
|
-
|
|
801
|
-
int num_drivers = SDL_GetNumVideoDrivers();
|
|
802
|
-
if (num_drivers < 0) {
|
|
803
|
-
RETURN_ERROR("SDL_GetNumVideoDrivers() error: %s\n", SDL_GetError());
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
const char * driver_name;
|
|
807
|
-
Variant name;
|
|
808
|
-
|
|
809
|
-
for (int i = 0; i < num_drivers; i ++) {
|
|
810
|
-
driver_name = SDL_GetVideoDriver(i);
|
|
811
|
-
if(driver_name == nullptr) {
|
|
812
|
-
RETURN_ERROR("SDL_GetVideoDriver(%d) error: %s\n", i, SDL_GetError());
|
|
813
|
-
}
|
|
814
|
-
MAKE_STRING(name, driver_name);
|
|
815
|
-
APPEND(list, name);
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
SET_LIST(video, "all", list);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
// Selected Video Driver
|
|
822
|
-
{
|
|
823
|
-
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) {
|
|
824
|
-
const char * driver_name = SDL_GetCurrentVideoDriver();
|
|
825
|
-
if(driver_name == nullptr) {
|
|
826
|
-
RETURN_ERROR("SDL_GetCurrentVideoDriver() error: %s\n", SDL_GetError());
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
SET_STRING(video, "current", driver_name);
|
|
830
|
-
} else {
|
|
831
|
-
SET_NULL(video, "current");
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
// Available Audio Drivers
|
|
836
|
-
{
|
|
837
|
-
int num_drivers = SDL_GetNumAudioDrivers();
|
|
838
|
-
if (num_drivers < 0) {
|
|
839
|
-
RETURN_ERROR("SDL_GetNumAudioDrivers() error: %s\n", SDL_GetError());
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
Variant list;
|
|
843
|
-
MAKE_LIST(list);
|
|
844
|
-
|
|
845
|
-
const char * driver_name;
|
|
846
|
-
Variant name;
|
|
847
|
-
|
|
848
|
-
for (int i = 0; i < num_drivers; i ++) {
|
|
849
|
-
driver_name = SDL_GetAudioDriver(i);
|
|
850
|
-
if(driver_name == nullptr) {
|
|
851
|
-
RETURN_ERROR("SDL_GetAudioDriver(%d) error: %s\n", i, SDL_GetError());
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
MAKE_STRING(name, driver_name);
|
|
855
|
-
APPEND(list, name);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
SET_LIST(audio, "all", list);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// Selected Audio Driver
|
|
862
|
-
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) {
|
|
863
|
-
const char * driver_name = SDL_GetCurrentAudioDriver();
|
|
864
|
-
if(driver_name == nullptr) {
|
|
865
|
-
RETURN_ERROR("SDL_GetCurrentAudioDriver() error: %s\n", SDL_GetError());
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
SET_STRING(audio, "current", driver_name);
|
|
869
|
-
} else {
|
|
870
|
-
SET_NULL(audio, "current");
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
SET_MAP(drivers, "video", video);
|
|
874
|
-
SET_MAP(drivers, "audio", audio);
|
|
875
|
-
SET_MAP(object, "drivers", drivers);
|
|
876
|
-
|
|
877
|
-
SDL_ClearError();
|
|
878
|
-
no_error = SDL_GetError();
|
|
879
|
-
|
|
880
|
-
keys = SDL_GetKeyboardState(&num_keys);
|
|
881
|
-
SDL_StartTextInput();
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
#if defined(__MACOSX__)
|
|
885
|
-
reenableInertialScrolling();
|
|
886
|
-
#endif
|
|
887
|
-
|
|
888
|
-
return nullptr;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
ErrorMessage *
|
|
893
|
-
_windowUpdateTexture(
|
|
894
|
-
SDL_Window * window,
|
|
895
|
-
SDL_Renderer * renderer,
|
|
896
|
-
int pixel_width, int pixel_height,
|
|
897
|
-
SDL_Texture ** texture_dst
|
|
898
|
-
) {
|
|
899
|
-
int window_id = SDL_GetWindowID(window);
|
|
900
|
-
|
|
901
|
-
int format = SDL_GetWindowPixelFormat(window);
|
|
902
|
-
SDL_Texture * texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STREAMING, pixel_width, pixel_height);
|
|
903
|
-
if (texture == nullptr) {
|
|
904
|
-
RETURN_ERROR("SDL_CreateTexture(%d) error: %s\n", window_id, SDL_GetError());
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
if (SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE)) {
|
|
908
|
-
RETURN_ERROR("SDL_SetTextureBlendMode(%d) error: %s\n", window_id, SDL_GetError());
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
SDL_Texture * old_texture = (SDL_Texture *) SDL_SetWindowData(window, "texture", texture);
|
|
912
|
-
if (old_texture != nullptr) { SDL_DestroyTexture(old_texture); }
|
|
913
|
-
|
|
914
|
-
if (texture_dst != nullptr) { *texture_dst = texture; }
|
|
915
|
-
|
|
916
|
-
return nullptr;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
ErrorMessage *
|
|
920
|
-
_windowUpdateRenderer(
|
|
921
|
-
SDL_Window * window,
|
|
922
|
-
bool * accelerated,
|
|
923
|
-
bool * vsync
|
|
924
|
-
) {
|
|
925
|
-
int window_id = SDL_GetWindowID(window);
|
|
926
|
-
|
|
927
|
-
SDL_Renderer * old_renderer = SDL_GetRenderer(window);
|
|
928
|
-
if (old_renderer != nullptr) { SDL_DestroyRenderer(old_renderer); }
|
|
929
|
-
|
|
930
|
-
int renderer_flags = 0
|
|
931
|
-
| (*accelerated ? SDL_RENDERER_ACCELERATED : SDL_RENDERER_SOFTWARE)
|
|
932
|
-
| (*accelerated && *vsync ? SDL_RENDERER_PRESENTVSYNC : 0);
|
|
933
|
-
|
|
934
|
-
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
|
935
|
-
if (renderer == nullptr) {
|
|
936
|
-
RETURN_ERROR("SDL_CreateRenderer(%d, %d) error: %s\n", window_id, renderer_flags, SDL_GetError());
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
SDL_RendererInfo info;
|
|
940
|
-
SDL_GetRendererInfo(renderer, &info);
|
|
941
|
-
|
|
942
|
-
*accelerated = info.flags & SDL_RENDERER_ACCELERATED;
|
|
943
|
-
*vsync = info.flags & SDL_RENDERER_PRESENTVSYNC;
|
|
944
|
-
|
|
945
|
-
int pixel_width, pixel_height;
|
|
946
|
-
SDL_GetWindowSizeInPixels(window, &pixel_width, &pixel_height);
|
|
947
|
-
|
|
948
|
-
ErrorMessage * error = _windowUpdateTexture(window, renderer, pixel_width, pixel_height, nullptr);
|
|
949
|
-
if (error != nullptr) { return error; }
|
|
950
|
-
|
|
951
|
-
return nullptr;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
ErrorMessage *
|
|
956
|
-
_controllerGetState (SDL_GameController * controller, Variant & object)
|
|
957
|
-
{
|
|
958
|
-
{
|
|
959
|
-
Variant axes;
|
|
960
|
-
MAKE_MAP(axes);
|
|
961
|
-
|
|
962
|
-
SET_NUM(axes, "leftStickX", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTX)));
|
|
963
|
-
SET_NUM(axes, "leftStickY", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTY)));
|
|
964
|
-
SET_NUM(axes, "rightStickX", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX)));
|
|
965
|
-
SET_NUM(axes, "rightStickY", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY)));
|
|
966
|
-
SET_NUM(axes, "leftTrigger", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERLEFT)));
|
|
967
|
-
SET_NUM(axes, "rightTrigger", _joystickMapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT)));
|
|
968
|
-
|
|
969
|
-
SET_MAP(object, "axes", axes);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
{
|
|
973
|
-
Variant buttons;
|
|
974
|
-
MAKE_MAP(buttons);
|
|
975
|
-
|
|
976
|
-
SET_BOOL(buttons, "dpadLeft", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT));
|
|
977
|
-
SET_BOOL(buttons, "dpadRight", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT));
|
|
978
|
-
SET_BOOL(buttons, "dpadUp", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP));
|
|
979
|
-
SET_BOOL(buttons, "dpadDown", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN));
|
|
980
|
-
SET_BOOL(buttons, "a", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_A));
|
|
981
|
-
SET_BOOL(buttons, "b", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_B));
|
|
982
|
-
SET_BOOL(buttons, "x", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_X));
|
|
983
|
-
SET_BOOL(buttons, "y", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_Y));
|
|
984
|
-
SET_BOOL(buttons, "guide", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_GUIDE));
|
|
985
|
-
SET_BOOL(buttons, "back", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_BACK));
|
|
986
|
-
SET_BOOL(buttons, "start", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_START));
|
|
987
|
-
SET_BOOL(buttons, "leftStick", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSTICK));
|
|
988
|
-
SET_BOOL(buttons, "rightStick", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSTICK));
|
|
989
|
-
SET_BOOL(buttons, "leftShoulder", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
|
|
990
|
-
SET_BOOL(buttons, "rightShoulder", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER));
|
|
991
|
-
SET_BOOL(buttons, "paddle1", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE1));
|
|
992
|
-
SET_BOOL(buttons, "paddle2", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE2));
|
|
993
|
-
SET_BOOL(buttons, "paddle3", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE3));
|
|
994
|
-
SET_BOOL(buttons, "paddle4", SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE4));
|
|
995
|
-
|
|
996
|
-
SET_MAP(object, "buttons", buttons);
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
return nullptr;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
ErrorMessage *
|
|
1004
|
-
packageEvent (const SDL_Event & event, Variant & object)
|
|
1005
|
-
{
|
|
1006
|
-
if (allocated_drop_file != nullptr) {
|
|
1007
|
-
SDL_free(allocated_drop_file);
|
|
1008
|
-
allocated_drop_file = nullptr;
|
|
1009
|
-
}
|
|
1010
|
-
if (allocated_clipboard != nullptr) {
|
|
1011
|
-
SDL_free(allocated_clipboard);
|
|
1012
|
-
allocated_clipboard = nullptr;
|
|
1013
|
-
}
|
|
1014
|
-
while (allocated_guid_strings != nullptr) {
|
|
1015
|
-
AllocString * tmp = allocated_guid_strings;
|
|
1016
|
-
allocated_guid_strings = allocated_guid_strings->next;
|
|
1017
|
-
free(tmp->buffer);
|
|
1018
|
-
free(tmp);
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
MAKE_MAP(object);
|
|
1022
|
-
|
|
1023
|
-
Variant value;
|
|
1024
|
-
switch (event.type) {
|
|
1025
|
-
case SDL_DISPLAYEVENT: {
|
|
1026
|
-
SET_NUM(object, "family", (int) EventFamily::DISPLAY);
|
|
1027
|
-
SET_NUM(object, "displayIndex", event.display.display);
|
|
1028
|
-
|
|
1029
|
-
switch (event.display.event) {
|
|
1030
|
-
case SDL_DISPLAYEVENT_CONNECTED: { SET_NUM(object, "type", (int) EventType::DISPLAY_ADD); break; }
|
|
1031
|
-
case SDL_DISPLAYEVENT_DISCONNECTED: { SET_NUM(object, "type", (int) EventType::DISPLAY_REMOVE); break; }
|
|
1032
|
-
case SDL_DISPLAYEVENT_ORIENTATION: { SET_NUM(object, "type", (int) EventType::DISPLAY_ORIENT); break; }
|
|
1033
|
-
}
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
case SDL_WINDOWEVENT: {
|
|
1038
|
-
SET_NUM(object, "family", (int) EventFamily::WINDOW);
|
|
1039
|
-
SET_NUM(object, "windowId", event.window.windowID);
|
|
1040
|
-
|
|
1041
|
-
switch (event.window.event) {
|
|
1042
|
-
case SDL_WINDOWEVENT_SHOWN: { SET_NUM(object, "type", (int) EventType::SHOW); break; }
|
|
1043
|
-
case SDL_WINDOWEVENT_HIDDEN: { SET_NUM(object, "type", (int) EventType::HIDE); break; }
|
|
1044
|
-
case SDL_WINDOWEVENT_EXPOSED: { SET_NUM(object, "type", (int) EventType::EXPOSE); break; }
|
|
1045
|
-
case SDL_WINDOWEVENT_MOVED: {
|
|
1046
|
-
SET_NUM(object, "type", (int) EventType::MOVE);
|
|
1047
|
-
SET_NUM(object, "x", event.window.data1);
|
|
1048
|
-
SET_NUM(object, "y", event.window.data2);
|
|
1049
|
-
break;
|
|
1050
|
-
}
|
|
1051
|
-
case SDL_WINDOWEVENT_SIZE_CHANGED: {
|
|
1052
|
-
SDL_Window * window = SDL_GetWindowFromID(event.window.windowID);
|
|
1053
|
-
if (window == nullptr) {
|
|
1054
|
-
RETURN_ERROR("SDL_CreateWindow() error: %s\n", SDL_GetError());
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
int pixel_width, pixel_height;
|
|
1058
|
-
SDL_GetWindowSizeInPixels(window, &pixel_width, &pixel_height);
|
|
1059
|
-
|
|
1060
|
-
SET_NUM(object, "type", (int) EventType::RESIZE);
|
|
1061
|
-
SET_NUM(object, "width", event.window.data1);
|
|
1062
|
-
SET_NUM(object, "height", event.window.data2);
|
|
1063
|
-
SET_NUM(object, "pixelWidth", pixel_width);
|
|
1064
|
-
SET_NUM(object, "pixelHeight", pixel_height);
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
case SDL_WINDOWEVENT_MINIMIZED: { SET_NUM(object, "type", (int) EventType::MINIMIZE); break; }
|
|
1068
|
-
case SDL_WINDOWEVENT_MAXIMIZED: { SET_NUM(object, "type", (int) EventType::MAXIMIZE); break; }
|
|
1069
|
-
case SDL_WINDOWEVENT_RESTORED: { SET_NUM(object, "type", (int) EventType::RESTORE); break; }
|
|
1070
|
-
case SDL_WINDOWEVENT_FOCUS_GAINED: { SET_NUM(object, "type", (int) EventType::FOCUS); break; }
|
|
1071
|
-
case SDL_WINDOWEVENT_FOCUS_LOST: { SET_NUM(object, "type", (int) EventType::BLUR); break; }
|
|
1072
|
-
case SDL_WINDOWEVENT_ENTER: { SET_NUM(object, "type", (int) EventType::HOVER); break; }
|
|
1073
|
-
case SDL_WINDOWEVENT_LEAVE: { SET_NUM(object, "type", (int) EventType::LEAVE); break; }
|
|
1074
|
-
case SDL_WINDOWEVENT_CLOSE: { SET_NUM(object, "type", (int) EventType::CLOSE); break; }
|
|
1075
|
-
}
|
|
1076
|
-
break;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
case SDL_DROPBEGIN:
|
|
1080
|
-
case SDL_DROPCOMPLETE: {
|
|
1081
|
-
SET_NUM(object, "family", (int) EventFamily::DROP);
|
|
1082
|
-
SET_NUM(object, "type", (int) (event.type == SDL_DROPBEGIN
|
|
1083
|
-
? EventType::DROP_BEGIN
|
|
1084
|
-
: EventType::DROP_COMPLETE));
|
|
1085
|
-
SET_NUM(object, "windowId", event.drop.windowID);
|
|
1086
|
-
break;
|
|
1087
|
-
}
|
|
1088
|
-
case SDL_DROPFILE:
|
|
1089
|
-
case SDL_DROPTEXT: {
|
|
1090
|
-
SET_NUM(object, "family", (int) EventFamily::DROP);
|
|
1091
|
-
bool is_file = event.type == SDL_DROPFILE;
|
|
1092
|
-
SET_NUM(object, "type", (int) (is_file
|
|
1093
|
-
? EventType::DROP_FILE
|
|
1094
|
-
: EventType::DROP_TEXT));
|
|
1095
|
-
SET_NUM(object, "windowId", event.drop.windowID);
|
|
1096
|
-
|
|
1097
|
-
allocated_drop_file = event.drop.file;
|
|
1098
|
-
SET_STRING(object, is_file ? "file" : "text", allocated_drop_file);
|
|
1099
|
-
break;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
case SDL_KEYDOWN:
|
|
1103
|
-
case SDL_KEYUP: {
|
|
1104
|
-
SET_NUM(object, "family", (int) EventFamily::KEYBOARD);
|
|
1105
|
-
SET_NUM(object, "type", (int) (event.type == SDL_KEYDOWN
|
|
1106
|
-
? EventType::KEY_DOWN
|
|
1107
|
-
: EventType::KEY_UP));
|
|
1108
|
-
SET_NUM(object, "windowId", event.key.windowID);
|
|
1109
|
-
|
|
1110
|
-
SDL_Keysym symbol = event.key.keysym;
|
|
1111
|
-
SET_NUM(object, "scancode", symbol.scancode);
|
|
1112
|
-
|
|
1113
|
-
const char * name = SDL_GetKeyName(symbol.sym);
|
|
1114
|
-
if (name[0] != '\0') {
|
|
1115
|
-
SET_STRING(object, "key", name);
|
|
1116
|
-
}
|
|
1117
|
-
else {
|
|
1118
|
-
SET_NULL(object, "key");
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
if (event.type == SDL_KEYDOWN) {
|
|
1122
|
-
SET_BOOL(object, "repeat", !!event.key.repeat);
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
SET_BOOL(object, "alt", !!(symbol.mod & KMOD_ALT));
|
|
1126
|
-
SET_BOOL(object, "ctrl", !!(symbol.mod & KMOD_CTRL));
|
|
1127
|
-
SET_BOOL(object, "shift", !!(symbol.mod & KMOD_SHIFT));
|
|
1128
|
-
SET_BOOL(object, "super", !!(symbol.mod & KMOD_GUI));
|
|
1129
|
-
SET_BOOL(object, "altgr", !!(symbol.mod & KMOD_MODE));
|
|
1130
|
-
SET_BOOL(object, "numlock", !!(symbol.mod & KMOD_NUM));
|
|
1131
|
-
SET_BOOL(object, "capslock", !!(symbol.mod & KMOD_CAPS));
|
|
1132
|
-
break;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
case SDL_TEXTINPUT: {
|
|
1136
|
-
SET_NUM(object, "family", (int) EventFamily::TEXT);
|
|
1137
|
-
SET_NUM(object, "type", (int) EventType::TEXT_INPUT);
|
|
1138
|
-
SET_NUM(object, "windowId", event.text.windowID);
|
|
1139
|
-
strcpy(text_input, event.text.text);
|
|
1140
|
-
SET_STRING(object, "text", text_input);
|
|
1141
|
-
break ;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
case SDL_MOUSEMOTION: {
|
|
1145
|
-
SET_NUM(object, "family", (int) EventFamily::MOUSE);
|
|
1146
|
-
SET_NUM(object, "type", (int) EventType::MOUSE_MOVE);
|
|
1147
|
-
SET_NUM(object, "windowId", event.motion.windowID);
|
|
1148
|
-
SET_BOOL(object, "touch", event.motion.which == SDL_TOUCH_MOUSEID);
|
|
1149
|
-
SET_NUM(object, "x", event.motion.x);
|
|
1150
|
-
SET_NUM(object, "y", event.motion.y);
|
|
1151
|
-
break;
|
|
1152
|
-
}
|
|
1153
|
-
case SDL_MOUSEBUTTONDOWN:
|
|
1154
|
-
case SDL_MOUSEBUTTONUP: {
|
|
1155
|
-
SET_NUM(object, "family", (int) EventFamily::MOUSE);
|
|
1156
|
-
SET_NUM(object, "type", (int) (event.type == SDL_MOUSEBUTTONDOWN
|
|
1157
|
-
? EventType::MOUSE_BUTTON_DOWN
|
|
1158
|
-
: EventType::MOUSE_BUTTON_UP));
|
|
1159
|
-
SET_NUM(object, "windowId", event.button.windowID);
|
|
1160
|
-
SET_BOOL(object, "touch", event.button.which == SDL_TOUCH_MOUSEID);
|
|
1161
|
-
SET_NUM(object, "button", event.button.button);
|
|
1162
|
-
SET_NUM(object, "x", event.button.x);
|
|
1163
|
-
SET_NUM(object, "y", event.button.y);
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
case SDL_MOUSEWHEEL: {
|
|
1167
|
-
SET_NUM(object, "family", (int) EventFamily::MOUSE);
|
|
1168
|
-
SET_NUM(object, "type", (int) EventType::MOUSE_WHEEL);
|
|
1169
|
-
SET_NUM(object, "windowId", event.wheel.windowID);
|
|
1170
|
-
SET_BOOL(object, "touch", event.wheel.which == SDL_TOUCH_MOUSEID);
|
|
1171
|
-
|
|
1172
|
-
int x, y;
|
|
1173
|
-
SDL_GetMouseState(&x, &y);
|
|
1174
|
-
SET_NUM(object, "x", x);
|
|
1175
|
-
SET_NUM(object, "y", y);
|
|
1176
|
-
|
|
1177
|
-
SET_NUM(object, "dx", event.wheel.x);
|
|
1178
|
-
SET_NUM(object, "dy", event.wheel.y);
|
|
1179
|
-
SET_BOOL(object, "flipped", event.wheel.direction);
|
|
1180
|
-
break;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
case SDL_JOYDEVICEADDED: {
|
|
1184
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK_DEVICE);
|
|
1185
|
-
SET_NUM(object, "type", (int) EventType::DEVICE_ADD);
|
|
1186
|
-
|
|
1187
|
-
Variant devices;
|
|
1188
|
-
ErrorMessage * error = joystick_getDevices(devices);
|
|
1189
|
-
if (error != nullptr) { return error; }
|
|
1190
|
-
SET_LIST(object, "devices", devices);
|
|
1191
|
-
break;
|
|
1192
|
-
}
|
|
1193
|
-
case SDL_JOYDEVICEREMOVED: {
|
|
1194
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK_DEVICE);
|
|
1195
|
-
SET_NUM(object, "type", (int) EventType::DEVICE_REMOVE);
|
|
1196
|
-
SET_NUM(object, "joystickId", event.jdevice.which);
|
|
1197
|
-
|
|
1198
|
-
Variant devices;
|
|
1199
|
-
ErrorMessage * error = joystick_getDevices(devices);
|
|
1200
|
-
if (error != nullptr) { return error; }
|
|
1201
|
-
SET_LIST(object, "devices", devices);
|
|
1202
|
-
break;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
case SDL_JOYAXISMOTION: {
|
|
1206
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK);
|
|
1207
|
-
SET_NUM(object, "type", (int) EventType::AXIS_MOTION);
|
|
1208
|
-
SET_NUM(object, "joystickId", event.jaxis.which);
|
|
1209
|
-
SET_NUM(object, "axis", event.jaxis.axis);
|
|
1210
|
-
SET_NUM(object, "value", _joystickMapAxis(event.jaxis.value));
|
|
1211
|
-
break ;
|
|
1212
|
-
}
|
|
1213
|
-
case SDL_JOYBALLMOTION: {
|
|
1214
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK);
|
|
1215
|
-
SET_NUM(object, "type", (int) EventType::BALL_MOTION);
|
|
1216
|
-
SET_NUM(object, "joystickId", event.jball.which);
|
|
1217
|
-
SET_NUM(object, "ball", event.jball.ball);
|
|
1218
|
-
SET_NUM(object, "x", event.jball.xrel);
|
|
1219
|
-
SET_NUM(object, "y", event.jball.yrel);
|
|
1220
|
-
break ;
|
|
1221
|
-
}
|
|
1222
|
-
case SDL_JOYBUTTONDOWN:
|
|
1223
|
-
case SDL_JOYBUTTONUP: {
|
|
1224
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK);
|
|
1225
|
-
SET_NUM(object, "type", (int) (event.type == SDL_JOYBUTTONDOWN
|
|
1226
|
-
? EventType::BUTTON_DOWN
|
|
1227
|
-
: EventType::BUTTON_UP));
|
|
1228
|
-
SET_NUM(object, "joystickId", event.jbutton.which);
|
|
1229
|
-
SET_NUM(object, "button", event.jbutton.button);
|
|
1230
|
-
break ;
|
|
1231
|
-
}
|
|
1232
|
-
case SDL_JOYHATMOTION: {
|
|
1233
|
-
SET_NUM(object, "family", (int) EventFamily::JOYSTICK);
|
|
1234
|
-
SET_NUM(object, "type", (int) EventType::HAT_MOTION);
|
|
1235
|
-
SET_NUM(object, "joystickId", event.jhat.which);
|
|
1236
|
-
SET_NUM(object, "hat", event.jhat.hat);
|
|
1237
|
-
SET_NUM(object, "value", event.jhat.value);
|
|
1238
|
-
break ;
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
case SDL_CONTROLLERDEVICEREMAPPED: {
|
|
1242
|
-
SET_NUM(object, "family", (int) EventFamily::CONTROLLER);
|
|
1243
|
-
SET_NUM(object, "type", (int) EventType::REMAP);
|
|
1244
|
-
SDL_JoystickID controllerId = event.cdevice.which;
|
|
1245
|
-
SET_NUM(object, "controllerId", controllerId);
|
|
1246
|
-
|
|
1247
|
-
SDL_GameController * controller = SDL_GameControllerFromInstanceID(controllerId);
|
|
1248
|
-
if (controller != nullptr) {
|
|
1249
|
-
ErrorMessage * error = _controllerGetState(controller, object);
|
|
1250
|
-
if (error != nullptr) { return error ; }
|
|
1251
|
-
}
|
|
1252
|
-
break;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
case SDL_CONTROLLERAXISMOTION: {
|
|
1256
|
-
SET_NUM(object, "family", (int) EventFamily::CONTROLLER);
|
|
1257
|
-
SET_NUM(object, "type", (int) EventType::AXIS_MOTION);
|
|
1258
|
-
SET_NUM(object, "controllerId", event.caxis.which);
|
|
1259
|
-
SET_NUM(object, "axis", event.caxis.axis);
|
|
1260
|
-
SET_NUM(object, "value", _joystickMapAxis(event.caxis.value));
|
|
1261
|
-
break;
|
|
1262
|
-
}
|
|
1263
|
-
case SDL_CONTROLLERBUTTONDOWN:
|
|
1264
|
-
case SDL_CONTROLLERBUTTONUP: {
|
|
1265
|
-
SET_NUM(object, "family", (int) EventFamily::CONTROLLER);
|
|
1266
|
-
SET_NUM(object, "type", (int) (event.type == SDL_CONTROLLERBUTTONDOWN
|
|
1267
|
-
? EventType::BUTTON_DOWN
|
|
1268
|
-
: EventType::BUTTON_UP));
|
|
1269
|
-
SET_NUM(object, "controllerId", event.cbutton.which);
|
|
1270
|
-
SET_NUM(object, "button", event.cbutton.button);
|
|
1271
|
-
break;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
case SDL_SENSORUPDATE: {
|
|
1275
|
-
SET_NUM(object, "family", (int) EventFamily::SENSOR);
|
|
1276
|
-
SET_NUM(object, "type", (int) EventType::UPDATE);
|
|
1277
|
-
SET_NUM(object, "sensorId", event.sensor.which);
|
|
1278
|
-
break;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
case SDL_AUDIODEVICEADDED: {
|
|
1282
|
-
SET_NUM(object, "family", (int) EventFamily::AUDIO_DEVICE);
|
|
1283
|
-
SET_NUM(object, "type", (int) EventType::DEVICE_ADD);
|
|
1284
|
-
bool is_capture = event.adevice.iscapture;
|
|
1285
|
-
SET_BOOL(object, "isRecorder", is_capture);
|
|
1286
|
-
|
|
1287
|
-
Variant devices;
|
|
1288
|
-
ErrorMessage * error = audio_getDevices(is_capture, devices);
|
|
1289
|
-
if (error != nullptr) { return error; }
|
|
1290
|
-
SET_LIST(object, "devices", devices);
|
|
1291
|
-
break;
|
|
1292
|
-
}
|
|
1293
|
-
case SDL_AUDIODEVICEREMOVED: {
|
|
1294
|
-
SET_NUM(object, "family", (int) EventFamily::AUDIO_DEVICE);
|
|
1295
|
-
SET_NUM(object, "type", (int) EventType::DEVICE_REMOVE);
|
|
1296
|
-
SET_NUM(object, "audioId", event.adevice.which);
|
|
1297
|
-
bool is_capture = event.adevice.iscapture;
|
|
1298
|
-
SET_BOOL(object, "isRecorder", is_capture);
|
|
1299
|
-
|
|
1300
|
-
Variant devices;
|
|
1301
|
-
ErrorMessage * error = audio_getDevices(is_capture, devices);
|
|
1302
|
-
if (error != nullptr) { return error; }
|
|
1303
|
-
SET_LIST(object, "devices", devices);
|
|
1304
|
-
break;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
case SDL_CLIPBOARDUPDATE: {
|
|
1308
|
-
SET_NUM(object, "family", (int) EventFamily::CLIPBOARD);
|
|
1309
|
-
SET_NUM(object, "type", (int) EventType::UPDATE);
|
|
1310
|
-
break;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
// case SDL_FINGERUP:
|
|
1314
|
-
// case SDL_FINGERDOWN: {
|
|
1315
|
-
// SET_STRING(object, "type", event.type == SDL_FINGERUP
|
|
1316
|
-
// ? "fingerUp"
|
|
1317
|
-
// : "fingerDown");
|
|
1318
|
-
// SET_NUM(object, "touch_id", event.tfinger.touchId);
|
|
1319
|
-
// SET_NUM(object, "finger_id", event.tfinger.fingerId);
|
|
1320
|
-
// SET_NUM(object, "pressure", event.tfinger.pressure);
|
|
1321
|
-
// SET_NUM(object, "x", event.tfinger.x);
|
|
1322
|
-
// SET_NUM(object, "y", event.tfinger.y);
|
|
1323
|
-
// break;
|
|
1324
|
-
// }
|
|
1325
|
-
// case SDL_FINGERMOTION: {
|
|
1326
|
-
// SET_STRING(object, "type", "fingerMotion");
|
|
1327
|
-
// SET_NUM(object, "touch_id", event.tfinger.touchId);
|
|
1328
|
-
// SET_NUM(object, "finger_id", event.tfinger.fingerId);
|
|
1329
|
-
// SET_NUM(object, "pressure", event.tfinger.pressure);
|
|
1330
|
-
// SET_NUM(object, "x", event.tfinger.x);
|
|
1331
|
-
// SET_NUM(object, "y", event.tfinger.y);
|
|
1332
|
-
// SET_NUM(object, "dx", event.tfinger.dx);
|
|
1333
|
-
// SET_NUM(object, "dy", event.tfinger.dy);
|
|
1334
|
-
// break;
|
|
1335
|
-
// }
|
|
1336
|
-
}
|
|
1337
|
-
return nullptr;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
ErrorMessage *
|
|
1341
|
-
events_poll (Variant & object)
|
|
1342
|
-
{
|
|
1343
|
-
SDL_Event event;
|
|
1344
|
-
bool got_event = SDL_PollEvent(&event);
|
|
1345
|
-
|
|
1346
|
-
if (!got_event) { return nullptr; }
|
|
1347
|
-
|
|
1348
|
-
ErrorMessage * error = packageEvent(event, object);
|
|
1349
|
-
if (error != nullptr) { return error; }
|
|
1350
|
-
|
|
1351
|
-
return nullptr;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
ErrorMessage *
|
|
1355
|
-
events_wait (int timeout, Variant & object)
|
|
1356
|
-
{
|
|
1357
|
-
SDL_Event event;
|
|
1358
|
-
|
|
1359
|
-
bool got_event = SDL_WaitEventTimeout(&event, timeout);
|
|
1360
|
-
SDL_ClearError();
|
|
1361
|
-
|
|
1362
|
-
if (!got_event) { return nullptr; }
|
|
1363
|
-
|
|
1364
|
-
ErrorMessage * error = packageEvent(event, object);
|
|
1365
|
-
if (error != nullptr) { return error; }
|
|
1366
|
-
|
|
1367
|
-
return nullptr;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
ErrorMessage *
|
|
1372
|
-
video_getDisplays(Variant & list)
|
|
1373
|
-
{
|
|
1374
|
-
int num_displays = SDL_GetNumVideoDisplays();
|
|
1375
|
-
if (num_displays < 0) {
|
|
1376
|
-
RETURN_ERROR("SDL_GetNumVideoDisplays() error: %s\n", SDL_GetError());
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
const char * name;
|
|
1380
|
-
SDL_Rect rect;
|
|
1381
|
-
SDL_DisplayMode mode;
|
|
1382
|
-
float ddpi;
|
|
1383
|
-
float hdpi;
|
|
1384
|
-
float vdpi;
|
|
1385
|
-
|
|
1386
|
-
MAKE_LIST(list);
|
|
1387
|
-
|
|
1388
|
-
for (int i = 0; i < num_displays; i++) {
|
|
1389
|
-
Variant display;
|
|
1390
|
-
MAKE_MAP(display);
|
|
1391
|
-
|
|
1392
|
-
name = SDL_GetDisplayName(i);
|
|
1393
|
-
if(name == nullptr) {
|
|
1394
|
-
RETURN_ERROR("SDL_GetDisplayName(%d) error: %s\n", i, SDL_GetError());
|
|
1395
|
-
}
|
|
1396
|
-
SET_STRING(display, "name", name);
|
|
1397
|
-
|
|
1398
|
-
if (SDL_GetCurrentDisplayMode(i, &mode) != 0) {
|
|
1399
|
-
RETURN_ERROR("SDL_GetCurrentDisplayMode(%d) error: %s\n", i, SDL_GetError());
|
|
1400
|
-
}
|
|
1401
|
-
SET_NUM(display, "format", mode.format);
|
|
1402
|
-
SET_NUM(display, "frequency", mode.refresh_rate);
|
|
1403
|
-
|
|
1404
|
-
{
|
|
1405
|
-
Variant geometry;
|
|
1406
|
-
MAKE_MAP(geometry);
|
|
1407
|
-
|
|
1408
|
-
if(SDL_GetDisplayBounds(i, &rect) != 0) {
|
|
1409
|
-
RETURN_ERROR("SDL_GetDisplayBounds(%d) error: %s\n", i, SDL_GetError());
|
|
1410
|
-
}
|
|
1411
|
-
SET_NUM(geometry, "x", rect.x);
|
|
1412
|
-
SET_NUM(geometry, "y", rect.y);
|
|
1413
|
-
SET_NUM(geometry, "width", rect.w);
|
|
1414
|
-
SET_NUM(geometry, "height", rect.h);
|
|
1415
|
-
|
|
1416
|
-
SET_MAP(display, "geometry", geometry);
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
{
|
|
1420
|
-
Variant usable;
|
|
1421
|
-
MAKE_MAP(usable);
|
|
1422
|
-
|
|
1423
|
-
if(SDL_GetDisplayUsableBounds(i, &rect) != 0) {
|
|
1424
|
-
RETURN_ERROR("SDL_GetDisplayUsableBounds(%d) error: %s\n", i, SDL_GetError());
|
|
1425
|
-
}
|
|
1426
|
-
SET_NUM(usable, "x", rect.x);
|
|
1427
|
-
SET_NUM(usable, "y", rect.y);
|
|
1428
|
-
SET_NUM(usable, "width", rect.w);
|
|
1429
|
-
SET_NUM(usable, "height", rect.h);
|
|
1430
|
-
|
|
1431
|
-
SET_MAP(display, "usable", usable);
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
{
|
|
1435
|
-
Variant dpi;
|
|
1436
|
-
MAKE_MAP(dpi);
|
|
1437
|
-
|
|
1438
|
-
if (SDL_GetDisplayDPI(i, &ddpi, &hdpi, &vdpi) != 0) {
|
|
1439
|
-
RETURN_ERROR("SDL_GetDisplayDPI(%d) error: %s\n", i, SDL_GetError());
|
|
1440
|
-
}
|
|
1441
|
-
SET_NUM(dpi, "diagonal", ddpi);
|
|
1442
|
-
SET_NUM(dpi, "horizontal", hdpi);
|
|
1443
|
-
SET_NUM(dpi, "vertical", vdpi);
|
|
1444
|
-
|
|
1445
|
-
SET_MAP(display, "dpi", dpi);
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
APPEND(list, display);
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
return nullptr;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
ErrorMessage *
|
|
1456
|
-
window_create (
|
|
1457
|
-
const char * title, int display,
|
|
1458
|
-
int ** x, int ** y, int ** width, int ** height,
|
|
1459
|
-
int * pixel_width, int * pixel_height,
|
|
1460
|
-
bool visible,
|
|
1461
|
-
bool * fullscreen,
|
|
1462
|
-
bool * resizable,
|
|
1463
|
-
bool * borderless,
|
|
1464
|
-
bool * always_on_top,
|
|
1465
|
-
bool * accelerated,
|
|
1466
|
-
bool * vsync,
|
|
1467
|
-
bool opengl,
|
|
1468
|
-
bool webgpu,
|
|
1469
|
-
bool * skip_taskbar,
|
|
1470
|
-
bool * popup_menu,
|
|
1471
|
-
bool * tooltip,
|
|
1472
|
-
bool * utility,
|
|
1473
|
-
int * window_id, void ** native_pointer, int * native_size
|
|
1474
|
-
) {
|
|
1475
|
-
if (*x == nullptr) {
|
|
1476
|
-
*x = (int *) malloc(sizeof(int));
|
|
1477
|
-
**x = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
|
|
1478
|
-
}
|
|
1479
|
-
if (*y == nullptr) {
|
|
1480
|
-
*y = (int *) malloc(sizeof(int));
|
|
1481
|
-
**y = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
|
|
1482
|
-
}
|
|
1483
|
-
if (*width == nullptr) {
|
|
1484
|
-
*width = (int *) malloc(sizeof(int));
|
|
1485
|
-
**width = 640;
|
|
1486
|
-
}
|
|
1487
|
-
if (*height == nullptr) {
|
|
1488
|
-
*height = (int *) malloc(sizeof(int));
|
|
1489
|
-
**height = 480;
|
|
1490
|
-
}
|
|
1491
|
-
int desired_flags = 0
|
|
1492
|
-
| SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI
|
|
1493
|
-
| (*fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)
|
|
1494
|
-
| (*resizable ? SDL_WINDOW_RESIZABLE : 0)
|
|
1495
|
-
| (*borderless ? SDL_WINDOW_BORDERLESS : 0)
|
|
1496
|
-
| (*always_on_top ? SDL_WINDOW_ALWAYS_ON_TOP : 0)
|
|
1497
|
-
| (opengl ? SDL_WINDOW_OPENGL : 0)
|
|
1498
|
-
| (webgpu ? GPU_WINDOW_FLAG : 0)
|
|
1499
|
-
| (*skip_taskbar ? SDL_WINDOW_SKIP_TASKBAR : 0)
|
|
1500
|
-
| (*popup_menu ? SDL_WINDOW_POPUP_MENU : 0)
|
|
1501
|
-
| (*tooltip ? SDL_WINDOW_TOOLTIP : 0)
|
|
1502
|
-
| (*utility ? SDL_WINDOW_UTILITY : 0)
|
|
1503
|
-
;
|
|
1504
|
-
|
|
1505
|
-
SDL_Window * window = SDL_CreateWindow(title, **x, **y, **width, **height, desired_flags);
|
|
1506
|
-
if (window == nullptr) {
|
|
1507
|
-
RETURN_ERROR("SDL_CreateWindow() error: %s\n", SDL_GetError());
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
*window_id = SDL_GetWindowID(window);
|
|
1511
|
-
if (*window_id == 0) {
|
|
1512
|
-
RETURN_ERROR("SDL_GetWindowID() error: %s\n", SDL_GetError());
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
int actual_flags = SDL_GetWindowFlags(window);
|
|
1516
|
-
*fullscreen = actual_flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
1517
|
-
*resizable = actual_flags & SDL_WINDOW_RESIZABLE;
|
|
1518
|
-
*borderless = actual_flags & SDL_WINDOW_BORDERLESS;
|
|
1519
|
-
*always_on_top = actual_flags & SDL_WINDOW_ALWAYS_ON_TOP;
|
|
1520
|
-
*skip_taskbar = actual_flags & SDL_WINDOW_SKIP_TASKBAR;
|
|
1521
|
-
*popup_menu = actual_flags & SDL_WINDOW_POPUP_MENU;
|
|
1522
|
-
*tooltip = actual_flags & SDL_WINDOW_TOOLTIP;
|
|
1523
|
-
*utility = actual_flags & SDL_WINDOW_UTILITY;
|
|
1524
|
-
|
|
1525
|
-
SDL_GetWindowPosition(window, *x, *y);
|
|
1526
|
-
SDL_GetWindowSizeInPixels(window, pixel_width, pixel_height);
|
|
1527
|
-
|
|
1528
|
-
if (opengl || webgpu) {
|
|
1529
|
-
SDL_SysWMinfo info;
|
|
1530
|
-
SDL_VERSION(&(info.version));
|
|
1531
|
-
bool got_info = SDL_GetWindowWMInfo(window, &info);
|
|
1532
|
-
if (!got_info) {
|
|
1533
|
-
RETURN_ERROR("SDL_GetWindowWMInfo(%d) error: %s\n", *window_id, SDL_GetError());
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
if (opengl) {
|
|
1537
|
-
int size = sizeof(GL_NativeWindow);
|
|
1538
|
-
GL_NativeWindow *pointer = (GL_NativeWindow *) malloc(size);
|
|
1539
|
-
#if defined(__LINUX__)
|
|
1540
|
-
*pointer = info.info.x11.window;
|
|
1541
|
-
#elif defined(__WIN32__)
|
|
1542
|
-
*pointer = info.info.win.window;
|
|
1543
|
-
#elif defined(__MACOSX__)
|
|
1544
|
-
*pointer = getCocoaGlView(info.info.cocoa.window);
|
|
1545
|
-
#endif
|
|
1546
|
-
|
|
1547
|
-
*native_pointer = pointer;
|
|
1548
|
-
*native_size = size;
|
|
1549
|
-
} else if (webgpu) {
|
|
1550
|
-
int size = sizeof(GPU_NativeData);
|
|
1551
|
-
GPU_NativeData *pointer = (GPU_NativeData *) malloc(size);
|
|
1552
|
-
|
|
1553
|
-
#if defined(__LINUX__)
|
|
1554
|
-
pointer->display = info.info.x11.display;
|
|
1555
|
-
pointer->window = info.info.x11.window;
|
|
1556
|
-
#elif defined(__WIN32__)
|
|
1557
|
-
pointer->hwnd = info.info.win.window;
|
|
1558
|
-
pointer->hinstance = info.info.win.hinstance;
|
|
1559
|
-
#elif defined(__MACOSX__)
|
|
1560
|
-
pointer->layer = getCocoaGpuView(info.info.cocoa.window);
|
|
1561
|
-
#endif
|
|
1562
|
-
|
|
1563
|
-
*native_pointer = pointer;
|
|
1564
|
-
*native_size = size;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
else {
|
|
1568
|
-
ErrorMessage * error = _windowUpdateRenderer(window, accelerated, vsync);
|
|
1569
|
-
if (error != nullptr) { return error; }
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
if (visible) { SDL_ShowWindow(window); }
|
|
1573
|
-
|
|
1574
|
-
return nullptr;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
ErrorMessage *
|
|
1578
|
-
window_setTitle (int window_id, const char * title)
|
|
1579
|
-
{
|
|
1580
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1581
|
-
if (window == nullptr) {
|
|
1582
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
SDL_SetWindowTitle(window, title);
|
|
1586
|
-
|
|
1587
|
-
return nullptr;
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
ErrorMessage *
|
|
1591
|
-
window_setPosition (int window_id, int x, int y)
|
|
1592
|
-
{
|
|
1593
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1594
|
-
if (window == nullptr) {
|
|
1595
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
SDL_SetWindowPosition(window, x, y);
|
|
1599
|
-
|
|
1600
|
-
return nullptr;
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
ErrorMessage *
|
|
1604
|
-
window_setSize (int window_id, int width, int height, int * pixel_width, int * pixel_height)
|
|
1605
|
-
{
|
|
1606
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1607
|
-
if (window == nullptr) {
|
|
1608
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
SDL_SetWindowSize(window, width, height);
|
|
1612
|
-
|
|
1613
|
-
SDL_GetWindowSizeInPixels(window, pixel_width, pixel_height);
|
|
1614
|
-
|
|
1615
|
-
return nullptr;
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
ErrorMessage *
|
|
1619
|
-
window_setFullscreen (int window_id, bool * fullscreen)
|
|
1620
|
-
{
|
|
1621
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1622
|
-
if (window == nullptr) {
|
|
1623
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
if (SDL_SetWindowFullscreen(window, *fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) != 0) {
|
|
1627
|
-
RETURN_ERROR("SDL_SetWindowFullscreen(%d, %d) error: %s\n", window_id, *fullscreen, SDL_GetError());
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
int actual_flags = SDL_GetWindowFlags(window);
|
|
1631
|
-
*fullscreen = actual_flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
1632
|
-
|
|
1633
|
-
return nullptr;
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
ErrorMessage *
|
|
1637
|
-
window_setResizable (int window_id, bool * resizable)
|
|
1638
|
-
{
|
|
1639
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1640
|
-
if (window == nullptr) {
|
|
1641
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
SDL_SetWindowResizable(window, *resizable ? SDL_TRUE : SDL_FALSE);
|
|
1645
|
-
|
|
1646
|
-
int actual_flags = SDL_GetWindowFlags(window);
|
|
1647
|
-
*resizable = actual_flags & SDL_WINDOW_RESIZABLE;
|
|
1648
|
-
|
|
1649
|
-
return nullptr;
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
ErrorMessage *
|
|
1653
|
-
window_setBorderless (int window_id, bool * borderless)
|
|
1654
|
-
{
|
|
1655
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1656
|
-
if (window == nullptr) {
|
|
1657
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
SDL_SetWindowBordered(window, *borderless ? SDL_FALSE : SDL_TRUE);
|
|
1661
|
-
|
|
1662
|
-
int actual_flags = SDL_GetWindowFlags(window);
|
|
1663
|
-
*borderless = actual_flags & SDL_WINDOW_BORDERLESS;
|
|
1664
|
-
|
|
1665
|
-
return nullptr;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
ErrorMessage *
|
|
1669
|
-
window_setAcceleratedAndVsync (int window_id, bool * accelerated, bool * vsync)
|
|
1670
|
-
{
|
|
1671
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1672
|
-
if (window == nullptr) {
|
|
1673
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
ErrorMessage * error = _windowUpdateRenderer(window, accelerated, vsync);
|
|
1677
|
-
if (error != nullptr) { return error; }
|
|
1678
|
-
|
|
1679
|
-
return nullptr;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
ErrorMessage *
|
|
1683
|
-
window_focus (int window_id)
|
|
1684
|
-
{
|
|
1685
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1686
|
-
if (window == nullptr) {
|
|
1687
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
SDL_RaiseWindow(window);
|
|
1691
|
-
|
|
1692
|
-
return nullptr;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
ErrorMessage *
|
|
1696
|
-
window_show (int window_id)
|
|
1697
|
-
{
|
|
1698
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1699
|
-
if (window == nullptr) {
|
|
1700
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
SDL_ShowWindow(window);
|
|
1704
|
-
|
|
1705
|
-
return nullptr;
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
ErrorMessage *
|
|
1709
|
-
window_hide (int window_id)
|
|
1710
|
-
{
|
|
1711
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1712
|
-
if (window == nullptr) {
|
|
1713
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
SDL_HideWindow(window);
|
|
1717
|
-
|
|
1718
|
-
return nullptr;
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
ErrorMessage *
|
|
1722
|
-
window_maximize (int window_id)
|
|
1723
|
-
{
|
|
1724
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1725
|
-
if (window == nullptr) {
|
|
1726
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
SDL_MaximizeWindow(window);
|
|
1730
|
-
|
|
1731
|
-
return nullptr;
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
ErrorMessage *
|
|
1735
|
-
window_minimize (int window_id)
|
|
1736
|
-
{
|
|
1737
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1738
|
-
if (window == nullptr) {
|
|
1739
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
SDL_MinimizeWindow(window);
|
|
1743
|
-
|
|
1744
|
-
return nullptr;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
ErrorMessage *
|
|
1748
|
-
window_restore (int window_id)
|
|
1749
|
-
{
|
|
1750
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1751
|
-
if (window == nullptr) {
|
|
1752
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
SDL_RestoreWindow(window);
|
|
1756
|
-
|
|
1757
|
-
return nullptr;
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
ErrorMessage *
|
|
1761
|
-
window_render (
|
|
1762
|
-
int window_id,
|
|
1763
|
-
int w, int h, int stride,
|
|
1764
|
-
unsigned int format,
|
|
1765
|
-
void * pixels
|
|
1766
|
-
) {
|
|
1767
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1768
|
-
if (window == nullptr) {
|
|
1769
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
|
-
SDL_Renderer * renderer = SDL_GetRenderer(window);
|
|
1773
|
-
if (renderer == nullptr) {
|
|
1774
|
-
RETURN_ERROR("SDL_GetRenderer(%d) error: %s\n", window_id, SDL_GetError());
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
SDL_Texture * texture = (SDL_Texture *) SDL_GetWindowData(window, "texture");
|
|
1778
|
-
if (texture == nullptr) {
|
|
1779
|
-
RETURN_ERROR("SDL_GetWindowData(%d) error: %s\n", window_id, SDL_GetError());
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
unsigned int texture_format;
|
|
1783
|
-
int texture_width, texture_height;
|
|
1784
|
-
if (SDL_QueryTexture(texture, &texture_format, nullptr, &texture_width, &texture_height)) {
|
|
1785
|
-
RETURN_ERROR("SDL_QueryTexture(%d) error: %s\n", window_id, SDL_GetError());
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
int pixel_width, pixel_height;
|
|
1789
|
-
SDL_GetWindowSizeInPixels(window, &pixel_width, &pixel_height);
|
|
1790
|
-
|
|
1791
|
-
if (pixel_width != texture_width || pixel_height != texture_height) {
|
|
1792
|
-
ErrorMessage * error = _windowUpdateTexture(window, renderer, pixel_width, pixel_height, &texture);
|
|
1793
|
-
if (error != nullptr) { return error; }
|
|
1794
|
-
texture_width = pixel_width;
|
|
1795
|
-
texture_height = pixel_height;
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
SDL_Surface * src_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), stride, format);
|
|
1799
|
-
if (src_surface == nullptr) {
|
|
1800
|
-
RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d, %d, %d) error: %s\n", window_id, w, h, stride, format, SDL_GetError());
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
if (SDL_SetSurfaceBlendMode(src_surface, SDL_BLENDMODE_NONE) != 0) {
|
|
1804
|
-
RETURN_ERROR("SDL_SetSurfaceBlendMode(%d) error: %s\n", window_id, SDL_GetError());
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
void *texture_pixels;
|
|
1808
|
-
int texture_stride;
|
|
1809
|
-
SDL_LockTexture(texture, nullptr, &texture_pixels, &texture_stride);
|
|
1810
|
-
|
|
1811
|
-
SDL_Surface * dst_surface = SDL_CreateRGBSurfaceWithFormatFrom(texture_pixels, texture_width, texture_height, SDL_BITSPERPIXEL(texture_format), texture_stride, texture_format);
|
|
1812
|
-
if (dst_surface == nullptr) {
|
|
1813
|
-
RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d, %d, %d) error: %s\n", window_id, texture_width, texture_height, texture_stride, texture_format, SDL_GetError());
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
if (SDL_BlitScaled(src_surface, NULL, dst_surface, NULL) != 0) {
|
|
1817
|
-
RETURN_ERROR("SDL_BlitSurface(%d) error: %s\n", window_id, SDL_GetError());
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
SDL_UnlockTexture(texture);
|
|
1821
|
-
|
|
1822
|
-
if (SDL_RenderCopy(renderer, texture, nullptr, nullptr) != 0) {
|
|
1823
|
-
RETURN_ERROR("SDL_RenderCopy(%d) error: %s\n", window_id, SDL_GetError());
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
SDL_RenderPresent(renderer);
|
|
1827
|
-
|
|
1828
|
-
SDL_FreeSurface(src_surface);
|
|
1829
|
-
SDL_FreeSurface(dst_surface);
|
|
1830
|
-
|
|
1831
|
-
return nullptr;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
ErrorMessage *
|
|
1835
|
-
window_setIcon (
|
|
1836
|
-
int window_id,
|
|
1837
|
-
int w, int h, int stride,
|
|
1838
|
-
unsigned int format,
|
|
1839
|
-
void * pixels
|
|
1840
|
-
) {
|
|
1841
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1842
|
-
if (window == nullptr) {
|
|
1843
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), stride, format);
|
|
1847
|
-
if (surface == nullptr) {
|
|
1848
|
-
RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d, %d) error: %s\n", window_id, w, h, format, SDL_GetError());
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
SDL_SetWindowIcon(window, surface);
|
|
1852
|
-
|
|
1853
|
-
SDL_FreeSurface(surface);
|
|
1854
|
-
|
|
1855
|
-
return nullptr;
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
ErrorMessage *
|
|
1859
|
-
window_flash (int window_id, int type)
|
|
1860
|
-
{
|
|
1861
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1862
|
-
if (window == nullptr) {
|
|
1863
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
SDL_FlashOperation op;
|
|
1867
|
-
switch (type) {
|
|
1868
|
-
case 2: op = SDL_FLASH_UNTIL_FOCUSED; break;
|
|
1869
|
-
case 1: op = SDL_FLASH_BRIEFLY; break;
|
|
1870
|
-
default: op = SDL_FLASH_CANCEL; break;
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
if (SDL_FlashWindow(window, op) != 0) {
|
|
1874
|
-
RETURN_ERROR("SDL_FlashWindow(%d, %d) error: %s\n", window_id, type, SDL_GetError());
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
return nullptr;
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
ErrorMessage *
|
|
1881
|
-
window_destroy (int window_id)
|
|
1882
|
-
{
|
|
1883
|
-
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
1884
|
-
if (window == nullptr) {
|
|
1885
|
-
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
SDL_Renderer * renderer = SDL_GetRenderer(window);
|
|
1889
|
-
if (renderer != nullptr) {
|
|
1890
|
-
SDL_Texture * texture = (SDL_Texture *) SDL_GetWindowData(window, "texture");
|
|
1891
|
-
|
|
1892
|
-
SDL_DestroyTexture(texture);
|
|
1893
|
-
SDL_DestroyRenderer(renderer);
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
SDL_DestroyWindow(window);
|
|
1897
|
-
|
|
1898
|
-
return nullptr;
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
ErrorMessage *
|
|
1903
|
-
keyboard_getKey (int scancode, const char ** key)
|
|
1904
|
-
{
|
|
1905
|
-
int keycode = SDL_GetKeyFromScancode((SDL_Scancode) scancode);
|
|
1906
|
-
*key = SDL_GetKeyName(keycode);
|
|
1907
|
-
return nullptr;
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
ErrorMessage *
|
|
1911
|
-
keyboard_getScancode (const char * key, int * scancode)
|
|
1912
|
-
{
|
|
1913
|
-
int keycode = SDL_GetKeyFromName(key);
|
|
1914
|
-
*scancode = keycode == SDLK_UNKNOWN ? 0 : SDL_GetScancodeFromKey((SDL_Keycode) keycode);
|
|
1915
|
-
return nullptr;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
ErrorMessage *
|
|
1919
|
-
keyboard_getState (Variant & list)
|
|
1920
|
-
{
|
|
1921
|
-
MAKE_LIST(list);
|
|
1922
|
-
|
|
1923
|
-
Variant key;
|
|
1924
|
-
for (int i = 0 ; i < num_keys; i++) {
|
|
1925
|
-
MAKE_BOOL(key, keys[i]);
|
|
1926
|
-
APPEND(list, key);
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
return nullptr;
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
ErrorMessage *
|
|
1934
|
-
mouse_getButton (int button, int * state)
|
|
1935
|
-
{
|
|
1936
|
-
int buttons = SDL_GetMouseState(nullptr, nullptr);
|
|
1937
|
-
*state = buttons & SDL_BUTTON(button);
|
|
1938
|
-
|
|
1939
|
-
return nullptr;
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
ErrorMessage *
|
|
1943
|
-
mouse_getPosition (Variant & position)
|
|
1944
|
-
{
|
|
1945
|
-
MAKE_MAP(position);
|
|
1946
|
-
|
|
1947
|
-
int x, y;
|
|
1948
|
-
SDL_GetGlobalMouseState(&x, &y);
|
|
1949
|
-
|
|
1950
|
-
SET_NUM(position, "x", x);
|
|
1951
|
-
SET_NUM(position, "y", y);
|
|
1952
|
-
|
|
1953
|
-
return nullptr;
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
ErrorMessage *
|
|
1957
|
-
mouse_setPosition (int x, int y)
|
|
1958
|
-
{
|
|
1959
|
-
if (SDL_WarpMouseGlobal(x, y) != 0) {
|
|
1960
|
-
RETURN_ERROR("SDL_WarpMouseGlobal(%d, %d) error: %s\n", x, y, SDL_GetError());
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
return nullptr;
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
ErrorMessage *
|
|
1967
|
-
mouse_capture (bool capture)
|
|
1968
|
-
{
|
|
1969
|
-
SDL_CaptureMouse(capture ? SDL_TRUE : SDL_FALSE);
|
|
1970
|
-
|
|
1971
|
-
return nullptr;
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
ErrorMessage *
|
|
1975
|
-
mouse_setCursor (int cursor_id)
|
|
1976
|
-
{
|
|
1977
|
-
if (allocated_cursor != nullptr) {
|
|
1978
|
-
SDL_FreeCursor(allocated_cursor);
|
|
1979
|
-
allocated_cursor = nullptr;
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
allocated_cursor = SDL_CreateSystemCursor((SDL_SystemCursor) cursor_id);
|
|
1983
|
-
if (allocated_cursor == nullptr) {
|
|
1984
|
-
RETURN_ERROR("SDL_CreateSystemCursor(%d) error: %s\n", cursor_id, SDL_GetError());
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
SDL_SetCursor(allocated_cursor);
|
|
1988
|
-
|
|
1989
|
-
return nullptr;
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
ErrorMessage *
|
|
1993
|
-
mouse_setCursorImage (
|
|
1994
|
-
int w, int h, int stride,
|
|
1995
|
-
unsigned int format,
|
|
1996
|
-
void * pixels,
|
|
1997
|
-
int x, int y
|
|
1998
|
-
) {
|
|
1999
|
-
SDL_Surface* surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), stride, format);
|
|
2000
|
-
if (surface == nullptr) {
|
|
2001
|
-
RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d) error: %s\n", w, h, format, SDL_GetError());
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
allocated_cursor = SDL_CreateColorCursor(surface, x, y);
|
|
2005
|
-
if (allocated_cursor == nullptr) {
|
|
2006
|
-
RETURN_ERROR("SDL_CreateColorCursor(%d, %d) error: %s\n", x, y, SDL_GetError());
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
SDL_FreeSurface(surface);
|
|
2010
|
-
|
|
2011
|
-
SDL_SetCursor(allocated_cursor);
|
|
2012
|
-
|
|
2013
|
-
return nullptr;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
ErrorMessage *
|
|
2017
|
-
mouse_showCursor (bool show)
|
|
2018
|
-
{
|
|
2019
|
-
SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE);
|
|
2020
|
-
|
|
2021
|
-
return nullptr;
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
ErrorMessage *
|
|
2026
|
-
joystick_getDevices(Variant & list)
|
|
2027
|
-
{
|
|
2028
|
-
int num_devices = SDL_NumJoysticks();
|
|
2029
|
-
if (num_devices < 0) {
|
|
2030
|
-
RETURN_ERROR("SDL_NumJoysticks() error: %s\n", SDL_GetError());
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
MAKE_LIST(list);
|
|
2034
|
-
|
|
2035
|
-
for (int i = 0; i < num_devices; i++) {
|
|
2036
|
-
Variant device;
|
|
2037
|
-
MAKE_MAP(device);
|
|
2038
|
-
|
|
2039
|
-
SET_NUM(device, "_index", i);
|
|
2040
|
-
|
|
2041
|
-
int id = SDL_JoystickGetDeviceInstanceID(i);
|
|
2042
|
-
SET_NUM(device, "id", id);
|
|
2043
|
-
|
|
2044
|
-
int type = SDL_JoystickGetDeviceType(i);
|
|
2045
|
-
SET_NUM(device, "type", type);
|
|
2046
|
-
|
|
2047
|
-
const char * name = SDL_JoystickNameForIndex(i);
|
|
2048
|
-
if (name == nullptr) {
|
|
2049
|
-
RETURN_ERROR("SDL_JoystickNameForIndex(%d) error: %s\n", i, SDL_GetError());
|
|
2050
|
-
}
|
|
2051
|
-
SET_STRING(device, "name", name);
|
|
2052
|
-
|
|
2053
|
-
const char * path = SDL_JoystickPathForIndex(i);
|
|
2054
|
-
if (path == nullptr) {
|
|
2055
|
-
RETURN_ERROR("SDL_JoystickPathForIndex(%d) error: %s\n", i, SDL_GetError());
|
|
2056
|
-
}
|
|
2057
|
-
SET_STRING(device, "path", path);
|
|
2058
|
-
|
|
2059
|
-
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(i);
|
|
2060
|
-
char * guid_string = _allocateString(33);
|
|
2061
|
-
SDL_JoystickGetGUIDString(guid, guid_string, 33);
|
|
2062
|
-
SET_STRING(device, "guid", guid_string);
|
|
2063
|
-
|
|
2064
|
-
int vendor = SDL_JoystickGetDeviceVendor(i);
|
|
2065
|
-
SET_NUM(device, "vendor", vendor);
|
|
2066
|
-
|
|
2067
|
-
int product = SDL_JoystickGetDeviceProduct(i);
|
|
2068
|
-
SET_NUM(device, "product", product);
|
|
2069
|
-
|
|
2070
|
-
int version = SDL_JoystickGetDeviceProductVersion(i);
|
|
2071
|
-
SET_NUM(device, "version", version);
|
|
2072
|
-
|
|
2073
|
-
int player = SDL_JoystickGetDevicePlayerIndex(i);
|
|
2074
|
-
SET_NUM(device, "player", player);
|
|
2075
|
-
|
|
2076
|
-
bool is_controller = SDL_IsGameController(i);
|
|
2077
|
-
SET_BOOL(device, "isController", is_controller);
|
|
2078
|
-
if (is_controller) {
|
|
2079
|
-
const char * mapping = SDL_GameControllerMappingForDeviceIndex(i);
|
|
2080
|
-
if (mapping != nullptr) {
|
|
2081
|
-
SET_STRING(device, "mapping", mapping);
|
|
2082
|
-
} else {
|
|
2083
|
-
SET_NULL(device, "mapping");
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
APPEND(list, device);
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
return nullptr;
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
ErrorMessage *
|
|
2094
|
-
joystick_open (int index, Variant & object)
|
|
2095
|
-
{
|
|
2096
|
-
SDL_Joystick * joystick = SDL_JoystickOpen(index);
|
|
2097
|
-
if (joystick == nullptr) {
|
|
2098
|
-
RETURN_ERROR("SDL_JoystickOpen(%d) error: %s\n", index, SDL_GetError());
|
|
2099
|
-
}
|
|
2100
|
-
|
|
2101
|
-
MAKE_MAP(object);
|
|
2102
|
-
|
|
2103
|
-
{
|
|
2104
|
-
SDL_JoystickID joystick_id = SDL_JoystickInstanceID(joystick);
|
|
2105
|
-
if (joystick_id < 0) {
|
|
2106
|
-
RETURN_ERROR("SDL_JoystickInstanceID(%d) error: %s\n", index, SDL_GetError());
|
|
2107
|
-
}
|
|
2108
|
-
SET_NUM(object, "id", joystick_id);
|
|
2109
|
-
|
|
2110
|
-
SET_NUM(object, "firmwareVersion", SDL_JoystickGetFirmwareVersion(joystick));
|
|
2111
|
-
|
|
2112
|
-
const char * serial = SDL_JoystickGetSerial(joystick);
|
|
2113
|
-
if (serial != nullptr) {
|
|
2114
|
-
SET_STRING(object, "serialNumber", serial);
|
|
2115
|
-
} else {
|
|
2116
|
-
SET_NULL(object, "serialNumber");
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
SET_BOOL(object, "hasLed", SDL_JoystickHasLED(joystick));
|
|
2120
|
-
SET_BOOL(object, "hasRumble", SDL_JoystickHasRumble(joystick));
|
|
2121
|
-
SET_BOOL(object, "hasRumbleTriggers", SDL_JoystickHasRumbleTriggers(joystick));
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
{
|
|
2125
|
-
int num_axes = SDL_JoystickNumAxes(joystick);
|
|
2126
|
-
if (num_axes < 0) {
|
|
2127
|
-
RETURN_ERROR("SDL_JoystickNumAxes(%d) error: %s\n", index, SDL_GetError());
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
Variant axes;
|
|
2131
|
-
MAKE_LIST(axes);
|
|
2132
|
-
|
|
2133
|
-
for (int i = 0; i < num_axes; i++) {
|
|
2134
|
-
Sint16 value = SDL_JoystickGetAxis(joystick, i);
|
|
2135
|
-
|
|
2136
|
-
Variant axis;
|
|
2137
|
-
MAKE_NUM(axis, _joystickMapAxis(value));
|
|
2138
|
-
APPEND(axes, axis);
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
SET_LIST(object, "axes", axes);
|
|
2142
|
-
}
|
|
2143
|
-
|
|
2144
|
-
{
|
|
2145
|
-
int num_balls = SDL_JoystickNumBalls(joystick);
|
|
2146
|
-
if (num_balls < 0) {
|
|
2147
|
-
RETURN_ERROR("SDL_JoystickNumBalls(%d) error: %s\n", index, SDL_GetError());
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
Variant balls;
|
|
2151
|
-
MAKE_LIST(balls);
|
|
2152
|
-
|
|
2153
|
-
for (int i = 0; i < num_balls; i++) {
|
|
2154
|
-
int dx, dy;
|
|
2155
|
-
if (SDL_JoystickGetBall(joystick, i, &dx, &dy) != 0) {
|
|
2156
|
-
RETURN_ERROR("SDL_JoystickGetBall(%d, %d) error: %s\n", index, i, SDL_GetError());
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
Variant ball;
|
|
2160
|
-
MAKE_MAP(ball);
|
|
2161
|
-
SET_NUM(ball, "x", dx);
|
|
2162
|
-
SET_NUM(ball, "y", dy);
|
|
2163
|
-
APPEND(balls, ball);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
SET_LIST(object, "balls", balls);
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
{
|
|
2170
|
-
int num_buttons = SDL_JoystickNumButtons(joystick);
|
|
2171
|
-
if (num_buttons < 0) {
|
|
2172
|
-
RETURN_ERROR("SDL_JoystickNumButtons(%d) error: %s\n", index, SDL_GetError());
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
Variant buttons;
|
|
2176
|
-
MAKE_LIST(buttons);
|
|
2177
|
-
|
|
2178
|
-
for (int i = 0; i < num_buttons; i++) {
|
|
2179
|
-
int pressed = SDL_JoystickGetButton(joystick, i);
|
|
2180
|
-
|
|
2181
|
-
Variant button;
|
|
2182
|
-
MAKE_BOOL(button, pressed);
|
|
2183
|
-
APPEND(buttons, button);
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
SET_LIST(object, "buttons", buttons);
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
{
|
|
2190
|
-
int num_hats = SDL_JoystickNumHats(joystick);
|
|
2191
|
-
if (num_hats < 0) {
|
|
2192
|
-
RETURN_ERROR("SDL_JoystickNumHats(%d) error: %s\n", index, SDL_GetError());
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
Variant hats;
|
|
2196
|
-
MAKE_LIST(hats);
|
|
2197
|
-
|
|
2198
|
-
for (int i = 0; i < num_hats; i++) {
|
|
2199
|
-
int position = SDL_JoystickGetHat(joystick, i);
|
|
2200
|
-
|
|
2201
|
-
Variant hat;
|
|
2202
|
-
MAKE_NUM(hat, position);
|
|
2203
|
-
APPEND(hats, hat);
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
SET_LIST(object, "hats", hats);
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
return nullptr;
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
ErrorMessage *
|
|
2213
|
-
joystick_close (int joystick_id)
|
|
2214
|
-
{
|
|
2215
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2216
|
-
if (joystick == nullptr) {
|
|
2217
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
SDL_JoystickClose(joystick);
|
|
2221
|
-
|
|
2222
|
-
return nullptr;
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
ErrorMessage *
|
|
2226
|
-
joystick_getPower (int joystick_id, int * power)
|
|
2227
|
-
{
|
|
2228
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2229
|
-
if (joystick == nullptr) {
|
|
2230
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
*power = SDL_JoystickCurrentPowerLevel(joystick);
|
|
2234
|
-
|
|
2235
|
-
return nullptr;
|
|
2236
|
-
}
|
|
2237
|
-
|
|
2238
|
-
ErrorMessage *
|
|
2239
|
-
joystick_rumble (
|
|
2240
|
-
int joystick_id,
|
|
2241
|
-
double low_freq_rumble,
|
|
2242
|
-
double high_freq_rumble,
|
|
2243
|
-
int duration
|
|
2244
|
-
) {
|
|
2245
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2246
|
-
if (joystick == nullptr) {
|
|
2247
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
if (SDL_JoystickRumble(joystick, low_freq_rumble * 0xFFFF, high_freq_rumble * 0xFFFF, duration) == -1) {
|
|
2251
|
-
RETURN_ERROR("SDL_JoystickRumble(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
return nullptr;
|
|
2255
|
-
}
|
|
2256
|
-
|
|
2257
|
-
ErrorMessage *
|
|
2258
|
-
joystick_setLed (int joystick_id, double red, double green, double blue)
|
|
2259
|
-
{
|
|
2260
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2261
|
-
if (joystick == nullptr) {
|
|
2262
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2263
|
-
}
|
|
2264
|
-
|
|
2265
|
-
if (SDL_JoystickSetLED(joystick, red * 0xFF, green * 0xFF, blue * 0xFF) == -1) {
|
|
2266
|
-
RETURN_ERROR("SDL_JoystickSetLED(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
return nullptr;
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
|
-
ErrorMessage *
|
|
2273
|
-
joystick_setPlayer (int joystick_id, int player)
|
|
2274
|
-
{
|
|
2275
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2276
|
-
if (joystick == nullptr) {
|
|
2277
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
SDL_JoystickSetPlayerIndex(joystick, player);
|
|
2281
|
-
|
|
2282
|
-
return nullptr;
|
|
2283
|
-
}
|
|
2284
|
-
|
|
2285
|
-
ErrorMessage *
|
|
2286
|
-
joystick_rumbleTriggers (
|
|
2287
|
-
int joystick_id,
|
|
2288
|
-
double left_rumble,
|
|
2289
|
-
double right_rumble,
|
|
2290
|
-
int duration
|
|
2291
|
-
) {
|
|
2292
|
-
SDL_Joystick * joystick = SDL_JoystickFromInstanceID(joystick_id);
|
|
2293
|
-
if (joystick == nullptr) {
|
|
2294
|
-
RETURN_ERROR("SDL_JoystickFromInstanceID(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
if (SDL_JoystickRumbleTriggers(joystick, left_rumble * 0xFFFF, right_rumble * 0xFFFF, duration) == -1) {
|
|
2298
|
-
RETURN_ERROR("SDL_JoystickRumbleTriggers(%d) error: %s\n", joystick_id, SDL_GetError());
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
return nullptr;
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
ErrorMessage *
|
|
2305
|
-
controller_open (int index, Variant & object)
|
|
2306
|
-
{
|
|
2307
|
-
SDL_GameController * controller = SDL_GameControllerOpen(index);
|
|
2308
|
-
if (controller == nullptr) {
|
|
2309
|
-
RETURN_ERROR("SDL_GameControllerOpen(%d) error: %s\n", index, SDL_GetError());
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
MAKE_MAP(object);
|
|
2313
|
-
|
|
2314
|
-
{
|
|
2315
|
-
SDL_Joystick * joystick = SDL_GameControllerGetJoystick(controller);
|
|
2316
|
-
if (joystick == nullptr) {
|
|
2317
|
-
RETURN_ERROR("SDL_GameControllerGetJoystick(%d) error: %s\n", index, SDL_GetError());
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
SDL_JoystickID joystick_id = SDL_JoystickInstanceID(joystick);
|
|
2321
|
-
if (joystick_id < 0) {
|
|
2322
|
-
RETURN_ERROR("SDL_JoystickInstanceID(%d) error: %s\n", index, SDL_GetError());
|
|
2323
|
-
}
|
|
2324
|
-
SET_NUM(object, "id", joystick_id);
|
|
2325
|
-
|
|
2326
|
-
SET_NUM(object, "firmwareVersion", SDL_JoystickGetFirmwareVersion(joystick));
|
|
2327
|
-
|
|
2328
|
-
const char * serial = SDL_JoystickGetSerial(joystick);
|
|
2329
|
-
if (serial != nullptr) {
|
|
2330
|
-
SET_STRING(object, "serialNumber", serial);
|
|
2331
|
-
} else {
|
|
2332
|
-
SET_NULL(object, "serialNumber");
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
SET_BOOL(object, "hasLed", SDL_JoystickHasLED(joystick));
|
|
2336
|
-
SET_BOOL(object, "hasRumble", SDL_JoystickHasRumble(joystick));
|
|
2337
|
-
SET_BOOL(object, "hasRumbleTriggers", SDL_JoystickHasRumbleTriggers(joystick));
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
ErrorMessage * error = _controllerGetState(controller, object);
|
|
2341
|
-
if (error != nullptr) { return error; }
|
|
2342
|
-
|
|
2343
|
-
return nullptr;
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
ErrorMessage *
|
|
2347
|
-
controller_close (int controller_id)
|
|
2348
|
-
{
|
|
2349
|
-
SDL_GameController * controller = SDL_GameControllerFromInstanceID(controller_id);
|
|
2350
|
-
if (controller == nullptr) {
|
|
2351
|
-
RETURN_ERROR("SDL_GameControllerFromInstanceID(%d) error: %s\n", controller_id, SDL_GetError());
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
SDL_GameControllerClose(controller);
|
|
2355
|
-
|
|
2356
|
-
return nullptr;
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
ErrorMessage *
|
|
2360
|
-
controller_addMappings (char ** mappings, int length)
|
|
2361
|
-
{
|
|
2362
|
-
for (int i = 0; i < length; i++) {
|
|
2363
|
-
if (SDL_GameControllerAddMapping(mappings[i]) == -1) {
|
|
2364
|
-
RETURN_ERROR("SDL_GameControllerAddMapping(%s) error: %s\n", mappings[i], SDL_GetError());
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
return nullptr;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
ErrorMessage *
|
|
2372
|
-
sensor_getDevices (Variant & list)
|
|
2373
|
-
{
|
|
2374
|
-
int num_devices = SDL_NumSensors();
|
|
2375
|
-
if (num_devices < 0) {
|
|
2376
|
-
RETURN_ERROR("SDL_NumSensors() error: %s\n", SDL_GetError());
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
MAKE_LIST(list);
|
|
2380
|
-
|
|
2381
|
-
for (int i = 0; i < num_devices; i++) {
|
|
2382
|
-
Variant device;
|
|
2383
|
-
MAKE_MAP(device);
|
|
2384
|
-
|
|
2385
|
-
SET_NUM(device, "_index", i);
|
|
2386
|
-
|
|
2387
|
-
int id = SDL_SensorGetDeviceInstanceID(i);
|
|
2388
|
-
SET_NUM(device, "id", id);
|
|
2389
|
-
|
|
2390
|
-
int type = SDL_SensorGetDeviceType(i);
|
|
2391
|
-
SET_NUM(device, "type", type);
|
|
2392
|
-
|
|
2393
|
-
const char * name = SDL_SensorGetDeviceName(i);
|
|
2394
|
-
if (name == nullptr) {
|
|
2395
|
-
RETURN_ERROR("SDL_SensorGetDeviceName(%d) error: %s\n", i, SDL_GetError());
|
|
2396
|
-
}
|
|
2397
|
-
SET_STRING(device, "name", name);
|
|
2398
|
-
|
|
2399
|
-
APPEND(list, device);
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
return nullptr;
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
|
-
ErrorMessage *
|
|
2406
|
-
sensor_open (int index)
|
|
2407
|
-
{
|
|
2408
|
-
SDL_Sensor * sensor = SDL_SensorOpen(index);
|
|
2409
|
-
if (sensor == nullptr) {
|
|
2410
|
-
RETURN_ERROR("SDL_SensorOpen(%d) error: %s\n", index, SDL_GetError());
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
return nullptr;
|
|
2414
|
-
}
|
|
2415
|
-
|
|
2416
|
-
ErrorMessage *
|
|
2417
|
-
sensor_close (int sensor_id)
|
|
2418
|
-
{
|
|
2419
|
-
SDL_Sensor * sensor = SDL_SensorFromInstanceID(sensor_id);
|
|
2420
|
-
if (sensor == nullptr) {
|
|
2421
|
-
RETURN_ERROR("SDL_SensorFromInstanceID(%d) error: %s\n", sensor_id, SDL_GetError());
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
SDL_SensorClose(sensor);
|
|
2425
|
-
|
|
2426
|
-
return nullptr;
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
ErrorMessage *
|
|
2430
|
-
sensor_getData (int sensor_id, Variant & object)
|
|
2431
|
-
{
|
|
2432
|
-
SDL_Sensor * sensor = SDL_SensorFromInstanceID(sensor_id);
|
|
2433
|
-
if (sensor == nullptr) {
|
|
2434
|
-
RETURN_ERROR("SDL_SensorFromInstanceID(%d) error: %s\n", sensor_id, SDL_GetError());
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
Uint64 timestamp;
|
|
2438
|
-
float data[3];
|
|
2439
|
-
if (SDL_SensorGetDataWithTimestamp(sensor, ×tamp, data, 3) == -1) {
|
|
2440
|
-
RETURN_ERROR("SDL_SensorGetDataWithTimestamp(%d) error: %s\n", sensor_id, SDL_GetError());
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
MAKE_MAP(object);
|
|
2444
|
-
SET_NUM(object, "timestamp", timestamp);
|
|
2445
|
-
SET_NUM(object, "x", data[0]);
|
|
2446
|
-
SET_NUM(object, "y", data[1]);
|
|
2447
|
-
SET_NUM(object, "z", data[2]);
|
|
2448
|
-
|
|
2449
|
-
return nullptr;
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
ErrorMessage *
|
|
2455
|
-
audio_getDevices(bool capture, Variant & list)
|
|
2456
|
-
{
|
|
2457
|
-
MAKE_LIST(list);
|
|
2458
|
-
|
|
2459
|
-
int num_devices = SDL_GetNumAudioDevices(capture ? 1 : 0);
|
|
2460
|
-
if (num_devices == -1) {
|
|
2461
|
-
const char * error = SDL_GetError();
|
|
2462
|
-
if (error != no_error) {
|
|
2463
|
-
RETURN_ERROR("SDL_GetNumAudioDevices(%d) error: %s\n", capture, error);
|
|
2464
|
-
}
|
|
2465
|
-
return nullptr;
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
for (int i = 0; i < num_devices; i++) {
|
|
2469
|
-
Variant device;
|
|
2470
|
-
MAKE_MAP(device);
|
|
2471
|
-
|
|
2472
|
-
SET_BOOL(device, "isRecorder", capture);
|
|
2473
|
-
|
|
2474
|
-
const char * name = SDL_GetAudioDeviceName(i, capture);
|
|
2475
|
-
if (name == nullptr) {
|
|
2476
|
-
RETURN_ERROR("SDL_GetAudioDeviceName(%d, %d) error: %s\n", i, capture, SDL_GetError());
|
|
2477
|
-
}
|
|
2478
|
-
SET_STRING(device, "name", name);
|
|
2479
|
-
|
|
2480
|
-
APPEND(list, device);
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
return nullptr;
|
|
2484
|
-
}
|
|
2485
|
-
|
|
2486
|
-
ErrorMessage *
|
|
2487
|
-
audio_openDevice (
|
|
2488
|
-
const char * name, bool capture,
|
|
2489
|
-
int freq, int format, int channels, int samples,
|
|
2490
|
-
int * audio_id
|
|
2491
|
-
) {
|
|
2492
|
-
SDL_AudioSpec desired;
|
|
2493
|
-
SDL_memset(&desired, 0, sizeof(desired));
|
|
2494
|
-
desired.freq = freq;
|
|
2495
|
-
desired.format = format;
|
|
2496
|
-
desired.channels = channels;
|
|
2497
|
-
desired.samples = samples;
|
|
2498
|
-
|
|
2499
|
-
SDL_AudioDeviceID audio_device = SDL_OpenAudioDevice(name, capture ? 1 : 0, &desired, nullptr, 0);
|
|
2500
|
-
if (audio_device == 0) {
|
|
2501
|
-
RETURN_ERROR("SDL_OpenAudioDevice() error: %s\n", SDL_GetError());
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
*audio_id = audio_device;
|
|
2505
|
-
|
|
2506
|
-
return nullptr;
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
ErrorMessage *
|
|
2510
|
-
audio_close (int audio_id)
|
|
2511
|
-
{
|
|
2512
|
-
SDL_PauseAudioDevice(audio_id, 1);
|
|
2513
|
-
SDL_CloseAudioDevice(audio_id);
|
|
2514
|
-
|
|
2515
|
-
return nullptr;
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
ErrorMessage *
|
|
2519
|
-
audio_play (int audio_id, bool play)
|
|
2520
|
-
{
|
|
2521
|
-
SDL_PauseAudioDevice(audio_id, play ? 0 : 1);
|
|
2522
|
-
|
|
2523
|
-
return nullptr;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
ErrorMessage *
|
|
2527
|
-
audio_getQueueSize (int audio_id, unsigned int * size)
|
|
2528
|
-
{
|
|
2529
|
-
*size = SDL_GetQueuedAudioSize(audio_id);
|
|
2530
|
-
|
|
2531
|
-
return nullptr;
|
|
2532
|
-
}
|
|
2533
|
-
|
|
2534
|
-
ErrorMessage *
|
|
2535
|
-
audio_clearQueue (int audio_id)
|
|
2536
|
-
{
|
|
2537
|
-
SDL_ClearQueuedAudio(audio_id);
|
|
2538
|
-
|
|
2539
|
-
return nullptr;
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
ErrorMessage *
|
|
2543
|
-
audio_enqueue (int audio_id, void * src, int size)
|
|
2544
|
-
{
|
|
2545
|
-
if (SDL_QueueAudio(audio_id, src, size) != 0) {
|
|
2546
|
-
RETURN_ERROR("SDL_QueueAudio() error: %s\n", SDL_GetError());
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
return nullptr;
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
ErrorMessage *
|
|
2553
|
-
audio_dequeue (int audio_id, void * dst, int size, int * num)
|
|
2554
|
-
{
|
|
2555
|
-
*num = SDL_DequeueAudio(audio_id, dst, size);
|
|
2556
|
-
|
|
2557
|
-
return nullptr;
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
ErrorMessage *
|
|
2562
|
-
clipboard_getText (const char ** text)
|
|
2563
|
-
{
|
|
2564
|
-
if (!SDL_HasClipboardText()) {
|
|
2565
|
-
return nullptr;
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
if (allocated_clipboard) {
|
|
2569
|
-
SDL_free(allocated_clipboard);
|
|
2570
|
-
allocated_clipboard = nullptr;
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
allocated_clipboard = SDL_GetClipboardText();
|
|
2574
|
-
if (!allocated_clipboard) {
|
|
2575
|
-
RETURN_ERROR("SDL_GetClipboardText(NULL) error: %s\n", SDL_GetError());
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
*text = allocated_clipboard;
|
|
2579
|
-
|
|
2580
|
-
return nullptr;
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
|
-
ErrorMessage *
|
|
2584
|
-
clipboard_setText (const char * text)
|
|
2585
|
-
{
|
|
2586
|
-
if (SDL_SetClipboardText(text) != 0) {
|
|
2587
|
-
RETURN_ERROR("SDL_SetClipboardText() error: %s\n", SDL_GetError());
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
return nullptr;
|
|
2591
|
-
}
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
ErrorMessage *
|
|
2595
|
-
power_getInfo (Variant & info)
|
|
2596
|
-
{
|
|
2597
|
-
int seconds, percent;
|
|
2598
|
-
SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
|
|
2599
|
-
|
|
2600
|
-
MAKE_MAP(info);
|
|
2601
|
-
|
|
2602
|
-
SET_NUM(info, "state", (int) state);
|
|
2603
|
-
SET_NUM(info, "seconds", seconds);
|
|
2604
|
-
SET_NUM(info, "percent", percent);
|
|
2605
|
-
|
|
2606
|
-
return nullptr;
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
ErrorMessage *
|
|
2611
|
-
cleanup ()
|
|
2612
|
-
{
|
|
2613
|
-
SDL_Quit();
|
|
2614
|
-
|
|
2615
|
-
return nullptr;
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
} // namespace
|