-
Notifications
You must be signed in to change notification settings - Fork 6
/
structs.rkt
568 lines (459 loc) · 11.1 KB
/
structs.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#lang racket
(require
ffi/unsafe
ffi/unsafe/define
ffi/cvector
ffi/unsafe/cvector)
(provide (all-defined-out))
(require "constants.rkt")
(define-cstruct _SDL_version
((major _sint8)
(minor _sint8)
(patch _uint8)))
; SDL_pixels.h
(define-cstruct _SDL_Color
((r _uint8)
(g _uint8)
(b _uint8)))
(define-cstruct _SDL_Palette
((ncolors _int)
(colors _SDL_Color-pointer)
(version _uint32)
(refcount _int)))
(define-cstruct _SDL_PixelFormat
([format _uint32]
[palette _SDL_Palette-pointer]
[BitsPerPixel _uint8]
[BytesPerPixel _uint8]
[padding (make-array-type _uint8 2)]
[Rmask _uint32]
[Gmask _uint32]
[Bmask _uint32]
[Amask _uint32]
[Rloss _uint8]
[Gloss _uint8]
[Bloss _uint8]
[Aloss _uint8]
[Rshift _uint8]
[Gshift _uint8]
[Bshift _uint8]
[Ashift _uint8]
[refcount _int]
[next _SDL_PixelFormat-pointer]))
; SDL_Rect.h
(define-cstruct _SDL_Point
([x _int]
[y _int]))
(define-cstruct _SDL_Rect
([x _int]
[y _int]
[w _int]
[h _int]))
;SDL_Surface.h
(define-cstruct _SDL_Surface
([flags _uint32]
[format _SDL_PixelFormat-pointer]
[w _int]
[h _int]
[pitch _int]
[pixels _pointer]
[userdata _pointer]
[locked _int]
[lock_data _pointer]
[clip_rect _SDL_Rect]
[map _pointer]
[refcount _int]))
;SDL_video.h
(define-cstruct _SDL_DisplayMode
((format _uint32)
(w _int)
(h _int)
(refresh_rate _int)
(driverdata _pointer)))
(define _SDL_Window _pointer)
(define _SDL_GLContext _pointer)
;SDL_audio.h
(define _SDL_AudioFormat _uint16)
(define _SDL_AudioCallback (_fun _pointer (_ptr io _uint8) _int -> _void))
(define AUDIO_S16LSB #x8010)
(define AUDIO_S16MSB #x9010)
(define AUDIO_S16 AUDIO_S16LSB)
(define AUDIO_S16SYS
(if (= SDL_BYTEORDER SDL_LIL_ENDIAN)
AUDIO_S16LSB
AUDIO_S16MSB))
(define SDL_AudioFilter _pointer)
(define SDL_AudioDeviceID _uint32)
(define-cstruct _SDL_AudioSpec
([freq _int]
[format _SDL_AudioFormat]
[channels _uint8]
[silence _uint8]
[samples _uint16]
[size _uint32]
[callback _SDL_AudioCallback]
[userdata _pointer]))
(define-cstruct _SDL_AudioCVT
([needed _int]
[src_format _SDL_AudioFormat]
[dst_format _SDL_AudioFormat]
[buf (_cpointer _uint8)]
[len _int]
[len_cvt _int]
[len_mult _int]
[len_ratio _double]
[filters (make-array-type SDL_AudioFilter 10)]
[filter_index _int]))
; SDL_keyboard.h
(define-cstruct _SDL_Keysym
([scancode SDL_Scancode]
[sym SDL_Keycode]
[mod _uint16]
[unicode _uint32]))
; SDL_mouse.h
(define _SDL_Cursor _pointer)
; SDL_Joystic.h
(define _SDL_Joystick _pointer)
(define SDL_JoystickID _int32)
(define-cstruct _SDL_JoystickGUID
([data (make-array-type _uint8 16)]))
; SDL_haptic.h
(define _SDL_Haptic _pointer)
(define-cstruct _SDL_HapticDirection
([type _uint8]
[dir (make-array-type _int32 3)]))
(define-cstruct _SDL_HapticConstant
([type _uint16]
[direction _SDL_HapticDirection]
[length _uint32]
[delay _uint16]
[button _uint16]
[interval _uint16]
[level _int16]
[attack_length _uint16]
[attack_level _uint16]
[fade_length _uint16]
[fade_level _uint16]))
(define-cstruct _SDL_HapticPeriodic
([type _uint16]
[direction _SDL_HapticDirection]
[length _uint32]
[delay _uint16]
[button _uint16]
[interval _uint16]
[period _uint16]
[magnitude _int16]
[offset _int16]
[phase _uint16]
[attack_length _uint16]
[attack_level _uint16]
[fade_length _uint16]
[fade_level _uint16]))
(define-cstruct _SDL_HapticCondition
([type _uint16]
[direction _SDL_HapticDirection]
[length _uint32]
[delay _uint16]
[button _uint16]
[interval _uint16]
[right_sat (make-array-type _uint16 3)]
[left_sat (make-array-type _uint16 3)]
[right_coeff (make-array-type _int16 3)]
[left_coeff (make-array-type _int16 3)]
[deadband (make-array-type _uint16 3)]
[center (make-array-type _int16 3)]))
(define-cstruct _SDL_HapticRamp
([type _uint16]
[direction _SDL_HapticDirection]
[length _uint32]
[delay _uint16]
[button _uint16]
[interval _uint16]
[start _int16]
[end _int16]
[attack_length _uint16]
[attack_level _uint16]
[fade_length _uint16]
[fade_level _uint16]))
(define-cstruct _SDL_HapticCustom
([type _uint16]
[direction _SDL_HapticDirection]
[length _uint32]
[delay _uint16]
[button _uint16]
[interval _uint16]
[channels _uint8]
[period _uint16]
[samples _uint16]
[data _uint16*]
[attack_length _uint16]
[attack_level _uint16]
[fade_length _uint16]
[fade_level _uint16]))
(define _SDL_HapticEffect
(_union
_uint16
_SDL_HapticConstant
_SDL_HapticPeriodic
_SDL_HapticCondition
_SDL_HapticRamp
_SDL_HapticCustom))
; SDL_gamecontroller.h
(define _SDL_GameController _pointer)
(define-cstruct _hat
([hat _int]
[hat_mask _int]))
(define-cstruct _SDL_GameControllerButtonBind
([bindType _SDL_GameControllerBindType]
[value
(make-union-type _int _int _hat)]))
; SDL_touch.h
(define SDL_TouchID _int64)
(define SDL_FingerID _int64)
(define-cstruct _SDL_Finger
([id SDL_FingerID]
[x _float]
[y _float]
[pressure _float]))
; SDL_gesture.h
(define SDL_GestureID _int64)
; SDL_Event.h
(define-cstruct _SDL_CommonEvent
([type _uint32]
[timestamp _uint32]))
(define-cstruct _SDL_WindowEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[event _uint8]
[padding1 _uint8]
[padding2 _uint8]
[padding3 _uint8]
[data1 _int32]
[data2 _int32]))
(define-cstruct _SDL_KeyboardEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[state _uint8]
[repeat _uint8]
[padding2 _uint8]
[padding3 _uint8]))
(define-cstruct _SDL_TextEditingEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[text _string]
[start _int32]
[length _int32]))
(define-cstruct _SDL_TextInputEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[text _string]))
(define-cstruct _SDL_MouseMotionEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[which _uint32]
[state _uint32]
[x _int32]
[y _int32]
[xrel _int32]
[yrel _int32]))
(define-cstruct _SDL_MouseButtonEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[which _uint32]
[button _uint8]
[state _uint8]
[padding1 _uint8]
[padding2 _uint8]
[x _int32]
[y _int32]))
(define-cstruct _SDL_MouseWheelEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[which _uint32]
[x _int32]
[y _int32]))
(define-cstruct _SDL_JoyAxisEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[axis _uint8]
[padding1 _uint8]
[padding2 _uint8]
[padding3 _uint8]
[value _int16]
[padding4 _uint16]))
(define-cstruct _SDL_JoyBallEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[ball _uint8]
[padding1 _uint8]
[padding2 _uint8]
[padding3 _uint8]
[xrel _int16]
[yrel _int16]))
(define-cstruct _SDL_JoyHatEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[hat _uint8]
[value _uint8]
[padding1 _uint8]
[padding2 _uint8]))
(define-cstruct _SDL_JoyButtonEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[button _uint8]
[state _uint8]
[padding1 _uint8]
[padding2 _uint8]))
(define-cstruct _SDL_JoyDeviceEvent
([type _uint32]
[timestamp _uint32]
[which _int32]))
(define-cstruct _SDL_ControllerAxisEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[axis _uint8]
[padding1 _uint8]
[padding2 _uint8]
[padding3 _uint8]
[value _int16]
[padding4 _uint16]))
(define-cstruct _SDL_ControllerButtonEvent
([type _uint32]
[timestamp _uint32]
[which SDL_JoystickID]
[button _uint8]
[state _uint8]
[padding1 _uint8]
[padding2 _uint8]))
(define-cstruct _SDL_ControllerDeviceEvent
([type _uint32]
[timestamp _uint32]
[which _int32]))
(define-cstruct _SDL_TouchFingerEvent
([type _uint32]
[timestamp _uint32]
[touchId SDL_TouchID]
[fingerId SDL_FingerID]
[x _float]
[y _float]
[dx _float]
[dy _float]
[pressure _float]))
(define-cstruct _SDL_MultiGestureEvent
([type _uint32]
[timestamp _uint32]
[touchId SDL_TouchID]
[dTheta _float]
[dDist _float]
[x _float]
[y _float]
[numFingers _uint16]
[padding _uint16]))
(define-cstruct _SDL_DollarGestureEvent
([type _uint32]
[timestamp _uint32]
[touchId SDL_TouchID]
[gestureId SDL_GestureID]
[numFingers _uint32]
[error _float]
[x _float]
[y _float]))
(define-cstruct _SDL_DropEvent
([type _uint32]
[timestamp _uint32]
[file _string]))
(define-cstruct _SDL_QuitEvent
([type _uint32]
[timestamp _uint32]))
(define-cstruct _SDL_OSEvent
([type _uint32]
[timestamp _uint32]))
(define-cstruct _SDL_UserEvent
([type _uint32]
[timestamp _uint32]
[windowID _uint32]
[code _int32]
[data1 _pointer]
[data2 _pointer]))
(define SDL_SysWMmsg _pointer)
(define-cstruct _SDL_SysWMEvent
([type _uint32]
[timestamp _uint32]
[msg SDL_SysWMmsg]))
(define _SDL_Event
(_union _uint32 ;type
_SDL_CommonEvent ;common
_SDL_WindowEvent ;window
_SDL_KeyboardEvent ;key
_SDL_TextEditingEvent ;edit
_SDL_TextInputEvent ;text
_SDL_MouseMotionEvent ;motion
_SDL_MouseButtonEvent ;button
_SDL_MouseWheelEvent ;wheel
_SDL_JoyAxisEvent ;jaxis
_SDL_JoyBallEvent ;jball
_SDL_JoyHatEvent ;jhat
_SDL_JoyButtonEvent ;jbutton
_SDL_JoyDeviceEvent ;jdevice
_SDL_ControllerAxisEvent ;caxis
_SDL_ControllerButtonEvent ;cbutton
_SDL_ControllerDeviceEvent ;cdevice
_SDL_QuitEvent ;quit
_SDL_UserEvent ;user
_SDL_SysWMEvent ;syswm
_SDL_TouchFingerEvent ;tfinger
_SDL_MultiGestureEvent ;mgesture
_SDL_DollarGestureEvent ;dgesture
_SDL_DropEvent ;drop
(make-array-type _uint8 56))) ;padding
(define-cpointer-type _SDL_Event*)
; SDL_stdinc.h
(define SDL_iconv_t _pointer)
; SDL_messagebox.h
(define-cstruct _SDL_MessageBoxButtonData
([flags _uint32]
[buttonid _int]
[text _string]))
(define-cstruct _SDL_MessageBoxColor
([r _uint8]
[g _uint8]
[b _uint8]))
(define-cstruct _SDL_MessageBoxColorScheme
([colors (make-array-type _SDL_MessageBoxColor SDL_MESSAGEBOX_COLOR_MAX)]))
(define-cstruct _SDL_MessageBoxData
([flags _uint32]
[window _SDL_Window]
[title _string]
[message _string]
[numbuttons _int]
[buttons _SDL_MessageBoxButtonData-pointer]
[colorScheme _SDL_MessageBoxColorScheme-pointer]))
; SDL_render.h
(define-cstruct _SDL_RendererInfo
([name _string]
[flags _uint32]
[num_texture_formats _uint32]
[texture_formats (make-array-type _uint32 16)]
[max_texture_width _int]
[max_texture_height _int]))
(define _SDL_Renderer _pointer)
(define _SDL_Texture _pointer)
; SDL_shape.h
(define _SDL_WindowShapeParams (_union _uint8 _SDL_Color))
(define-cstruct _SDL_WindowShapeMode
([mode _WindowShapeMode]
[parameters _SDL_WindowShapeParams]))
; SDL_timer.h
(define SDL_TimerID _int)