-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.rkt
4218 lines (3153 loc) · 135 KB
/
main.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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#lang racket/base
(require
(for-syntax racket/base)
(for-syntax racket/format)
(for-syntax racket/syntax)
ffi/unsafe
ffi/unsafe/define
(submod racket/performance-hint begin-encourage-inline)
(rename-in racket/contract
[-> contract/->])
sdl2/private/lib-path)
(provide
(except-out
(all-defined-out)
sdl2-lib
define-sdl2
define-sdl2-vararg))
(define sdl2-lib (ffi-lib (lib-path) '("0" #f)))
(define-ffi-definer define-sdl2 sdl2-lib)
(define-cpointer-type _uint8*)
(define-cpointer-type _int8*)
(define-cpointer-type _uint16*)
(define-cpointer-type _int16*)
(define-cpointer-type _uint32*)
(define-cpointer-type _int32*)
(define-cpointer-type _uint*)
(define-cpointer-type _int*)
(define-cpointer-type _size*)
(define-cpointer-type _float*)
(define-syntax (define-sdl2-vararg stx)
(syntax-case stx ()
[(_ name (arg-types ...) ret-type)
(with-syntax*
([name-str (~a (syntax->datum #'name))]
[arglist
(map
(lambda (arg)
(gensym (syntax->datum arg)))
(syntax->list #'(arg-types ...)))]
[full-arglist (append (syntax->list #'arglist) 'args)]
[final-call (append '(apply fun) (syntax->list #'arglist) '(args))])
#'(define name
(let ([interfaces (make-hash)])
(lambda full-arglist
(define itypes
(append (list arg-types ...)
(map (lambda (x)
(cond
[(and (integer? x) (exact? x)) _int]
[(and (number? x) (real? x)) _double*]
[(string? x) _string]
[(bytes? x) _bytes]
[(symbol? x) _symbol]
[else
(error
"don't know how to deal with ~e" x)]))
args)))
(let ([fun (hash-ref
interfaces itypes
(lambda ()
(let ([i (get-ffi-obj
name-str sdl2-lib
(_cprocedure itypes ret-type))])
(hash-set! interfaces itypes i)
i)))])
final-call)))))]))
;; SDL_stdinc.h
(define SDL_arraysize array-length)
(define SDL_TABLESIZE SDL_arraysize)
(define-syntax-rule (SDL_STRINGIFY_ARG arg)
(~a arg))
(define (SDL_FOURCC A B C D)
(let ([a (if (char? A) (char->integer A) A)]
[b (if (char? B) (char->integer B) B)]
[c (if (char? C) (char->integer C) C)]
[d (if (char? D) (char->integer D) D)])
(bitwise-ior
(bitwise-and #xffffffff (arithmetic-shift (bitwise-and #xff a) 0))
(bitwise-and #xffffffff (arithmetic-shift (bitwise-and #xff b) 8))
(bitwise-and #xffffffff (arithmetic-shift (bitwise-and #xff c) 16))
(bitwise-and #xffffffff (arithmetic-shift (bitwise-and #xff d) 24)))))
(define SDL_FALSE 0)
(define SDL_TRUE 1)
(define _SDL_bool _int)
(define SDL_MAX_SINT8 #x7F)
(define SDL_MIN_SINT8 (bitwise-not #x7F))
(define SDL_MAX_UINT8 #xFF)
(define SDL_MIN_UINT8 #x00)
(define SDL_MAX_SINT16 #x7FFF)
(define SDL_MIN_SINT16 (bitwise-not #x7FFF))
(define SDL_MAX_UINT16 #xFFFF)
(define SDL_MIN_UINT16 #x0000)
(define SDL_MAX_SINT32 #x7FFFFFFF)
(define SDL_MIN_SINT32 (bitwise-not #x7FFFFFFF))
(define SDL_MAX_UINT32 #xFFFFFFFF)
(define SDL_MIN_UINT32 #x00000000)
(define SDL_MAX_SINT64 #x7FFFFFFFFFFFFFFF)
(define SDL_MIN_SINT64 (bitwise-not #x7FFFFFFFFFFFFFFF))
(define SDL_MAX_UINT64 #xFFFFFFFFFFFFFFFF)
(define SDL_MIN_UINT64 #x0000000000000000)
(define-sdl2 SDL_malloc (_fun _size -> _pointer))
(define-sdl2 SDL_calloc (_fun _size _size -> _pointer))
(define-sdl2 SDL_realloc (_fun _pointer _size -> _pointer))
(define-sdl2 SDL_free (_fun _pointer -> _void))
(define SDL_stack_alloc SDL_malloc)
(define SDL_stack_free SDL_free)
(define _SDL_malloc_func (_fun _size -> _pointer))
(define _SDL_calloc_func (_fun _size _size -> _pointer))
(define _SDL_realloc_func (_fun _pointer _size -> _pointer))
(define _SDL_free_func (_fun _pointer -> _void))
(define-sdl2 SDL_GetMemoryFunctions
(_fun _SDL_malloc_func _SDL_calloc_func _SDL_realloc_func _SDL_free_func -> _void)
#:make-fail make-not-available)
(define-sdl2 SDL_SetMemoryFunctions
(_fun _SDL_malloc_func _SDL_calloc_func _SDL_realloc_func _SDL_free_func -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_GetNumAllocations (_fun -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_getenv (_fun _string -> _string))
(define-sdl2 SDL_setenv (_fun _string _string _int -> _int))
(define-sdl2 SDL_qsort (_fun _pointer _size _size (_fun _pointer _pointer -> _int) -> _void))
(define-sdl2 SDL_abs (_fun _int -> _int))
(define-syntax-rule (SDL_min x y)
(if (< x y) x y))
(define-syntax-rule (SDL_max x y)
(if (> x y) x y))
(define-sdl2 SDL_isdigit (_fun _int -> _int))
(define-sdl2 SDL_isspace (_fun _int -> _int))
(define-sdl2 SDL_toupper (_fun _int -> _int))
(define-sdl2 SDL_tolower (_fun _int -> _int))
(define-sdl2 SDL_memset (_fun _pointer _int _size -> _pointer))
(define-sdl2 SDL_memcpy (_fun _pointer _pointer _size -> _pointer))
(define-sdl2 SDL_memmove (_fun _pointer _pointer _size -> _pointer))
(define-sdl2 SDL_memcmp (_fun _pointer _pointer _size -> _int))
(define-sdl2 SDL_wcsdup (_fun _string/ucs-4 -> _string/ucs-4)
#:make-fail make-not-available)
(define-sdl2 SDL_wcslen (_fun _string/ucs-4 -> _size))
(define-sdl2 SDL_wcslcpy (_fun _string/ucs-4 _string/ucs-4 _size -> _size))
(define-sdl2 SDL_wcslcat (_fun _string/ucs-4 _string/ucs-4 _size -> _size))
(define-sdl2 SDL_wcscmp (_fun _string/ucs-4 _string/ucs-4 -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_strlen (_fun _string -> _size))
(define-sdl2 SDL_strlcpy (_fun _string _string _size -> _size))
(define-sdl2 SDL_utf8strlcpy (_fun _string _string _size -> _size))
(define-sdl2 SDL_strlcat (_fun _string _string _size -> _size))
(define-sdl2 SDL_strdup (_fun _string -> _string))
(define-sdl2 SDL_strrev (_fun _string -> _string))
(define-sdl2 SDL_strupr (_fun _string -> _string))
(define-sdl2 SDL_strlwr (_fun _string -> _string))
(define-sdl2 SDL_strchr (_fun _string _int -> _string))
(define-sdl2 SDL_strrchr (_fun _string _int -> _string))
(define-sdl2 SDL_strstr (_fun _string _string -> _string))
(define-sdl2 SDL_utf8strlen (_fun _string -> _size)
#:make-fail make-not-available)
(define-sdl2 SDL_itoa (_fun _int _string _int -> _string))
(define-sdl2 SDL_uitoa (_fun _uint _string _int -> _string))
(define-sdl2 SDL_ltoa (_fun _long _string _int -> _string))
(define-sdl2 SDL_ultoa (_fun _ulong _string _int -> _string))
(define-sdl2 SDL_lltoa (_fun _sint64 _string _int -> _string))
(define-sdl2 SDL_ulltoa (_fun _uint64 _string _int -> _string))
(define-sdl2 SDL_atoi (_fun _string -> _int))
(define-sdl2 SDL_atof (_fun _string -> _double))
(define-sdl2 SDL_strtol (_fun _string (_ptr i _string) _int -> _long))
(define-sdl2 SDL_strtoul (_fun _string (_ptr i _string) _int -> _ulong))
(define-sdl2 SDL_strtoll (_fun _string (_ptr i _string) _int -> _sint64))
(define-sdl2 SDL_strtoull (_fun _string (_ptr i _string) _int -> _uint64))
(define-sdl2 SDL_strtod (_fun _string (_ptr i _string) -> _double))
(define-sdl2 SDL_strcmp (_fun _string _string -> _int))
(define-sdl2 SDL_strncmp (_fun _string _string _size -> _int))
(define-sdl2 SDL_strcasecmp (_fun _string _string -> _int))
(define-sdl2 SDL_strncasecmp (_fun _string _string _size -> _int))
(define-sdl2 SDL_acos (_fun _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_acosf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_asin (_fun _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_asinf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_atan (_fun _double -> _double))
(define-sdl2 SDL_atanf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_atan2 (_fun _double _double -> _double))
(define-sdl2 SDL_atan2f (_fun _float _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_ceil (_fun _double -> _double))
(define-sdl2 SDL_ceilf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_copysign (_fun _double _double -> _double))
(define-sdl2 SDL_copysignf (_fun _float _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_cos (_fun _double -> _double))
(define-sdl2 SDL_cosf (_fun _float -> _float))
(define-sdl2 SDL_exp (_fun _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_expf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_fabs (_fun _double -> _double))
(define-sdl2 SDL_fabsf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_floor (_fun _double -> _double))
(define-sdl2 SDL_floorf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_fmod (_fun _double _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_fmodf (_fun _float _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_log (_fun _double -> _double))
(define-sdl2 SDL_logf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_log10 (_fun _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_log10f (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_pow (_fun _double _double -> _double))
(define-sdl2 SDL_powf (_fun _float _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_scalbn (_fun _double _int -> _double))
(define-sdl2 SDL_scalbnf (_fun _float _int -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_sin (_fun _double -> _double))
(define-sdl2 SDL_sinf (_fun _float -> _float))
(define-sdl2 SDL_sqrt (_fun _double -> _double))
(define-sdl2 SDL_sqrtf (_fun _float -> _float)
#:make-fail make-not-available)
(define-sdl2 SDL_tan (_fun _double -> _double)
#:make-fail make-not-available)
(define-sdl2 SDL_tanf (_fun _float -> _float)
#:make-fail make-not-available)
(define SDL_ICONV_ERROR (cast -1 _intptr _size))
(define SDL_ICONV_E2BIG (cast -2 _intptr _size))
(define SDL_ICONV_EILSEQ (cast -3 _intptr _size))
(define SDL_ICONV_EINVAL (cast -4 _intptr _size))
(define-cpointer-type _SDL_iconv_t*)
(define-sdl2 SDL_iconv_open (_fun _string _string -> _SDL_iconv_t*))
(define-sdl2 SDL_iconv_close (_fun _SDL_iconv_t* -> _int))
(define-sdl2 SDL_iconv (_fun _SDL_iconv_t* (_ptr i _string) _size* (_ptr o _string) _size* -> _size))
(define-sdl2 SDL_iconv_string (_fun _string _string _string _size -> _string))
(define (SDL_iconv_utf8_locale S)
(SDL_iconv_string "" "UTF-8" S (+ (SDL_strlen S) 1)))
(define (SDL_iconv_utf8_ucs2 S)
(cast
(SDL_iconv_string "UCS-2-INTERNAL" "UTF-8" S (+ (SDL_strlen S) 1))
_string
_uint16*/null))
(define (SDL_iconv_utf8_ucs4 S)
(cast
(SDL_iconv_string "UCS-4-INTERNAL" "UTF-8" S (+ (SDL_strlen S) 1))
_string
_uint32*/null))
(define (SDL_memcpy4 dst src dwords)
(SDL_memcpy dst src (* dwords 4)))
;; SDL_assert.h
(define _SDL_AssertState
(_enum
'(SDL_ASSERTION_RETRY
SDL_ASSERTION_BREAK
SDL_ASSERTION_ABORT
SDL_ASSERTION_IGNORE
SDL_ASSERTION_ALWAYS_IGNORE)))
(define-cstruct _SDL_AssertData
([always_ignore _int]
[trigger_count _uint]
[condition _string]
[filename _string]
[linenum _int]
[function _string]
[next _pointer]))
(define _SDL_AssertData* _SDL_AssertData-pointer)
(define-sdl2 SDL_ReportAssertion (_fun _SDL_AssertData* _string _string _int -> _SDL_AssertState))
(define _SDL_AssertionHandler (_fun _SDL_AssertData* _pointer -> _SDL_AssertState))
(define-sdl2 SDL_SetAssertionHandler (_fun _SDL_AssertionHandler _pointer -> _void))
(define-sdl2 SDL_GetDefaultAssertionHandler (_fun -> _SDL_AssertionHandler)
#:make-fail make-not-available)
(define-sdl2 SDL_GetAssertionHandler (_fun (_ptr o _pointer) -> _SDL_AssertionHandler)
#:make-fail make-not-available)
(define-sdl2 SDL_GetAssertionReport (_fun -> _SDL_AssertData*))
(define-sdl2 SDL_ResetAssertionReport (_fun -> _void))
;; SDL_atomic.h
(define _SDL_SpinLock _int)
(define _SDL_SpinLock* _int*)
(define-sdl2 SDL_AtomicTryLock (_fun _SDL_SpinLock* -> _SDL_bool))
(define-sdl2 SDL_AtomicLock (_fun _SDL_SpinLock* -> _void))
(define-sdl2 SDL_AtomicUnlock (_fun _SDL_SpinLock* -> _void))
(define (SDL_CompilerBarrier)
(define tmp (cast (malloc (ctype-sizeof _int)) _pointer _int*))
(ptr-set! tmp _int 0)
(SDL_AtomicLock tmp)
(SDL_AtomicUnlock tmp))
(define SDL_MemoryBarrierRelease SDL_CompilerBarrier)
(define SDL_MemoryBarrierAcquire SDL_CompilerBarrier)
(define-cstruct _SDL_atomic_t
([value _int]))
(define _SDL_atomic_t* _SDL_atomic_t-pointer)
(define-sdl2 SDL_AtomicCAS (_fun _SDL_atomic_t* _int _int -> _SDL_bool))
(define-sdl2 SDL_AtomicGet (_fun _SDL_atomic_t* -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_AtomicAdd (_fun _SDL_atomic_t* _int -> _int)
#:make-fail make-not-available)
(define (SDL_AtomicIncRef a) (SDL_AtomicAdd a 1))
(define (SDL_AtomicDecRef a) (= 1 (SDL_AtomicAdd a -1)))
(define-sdl2 SDL_AtomicCASPtr (_fun (_ptr io _pointer) _pointer _pointer -> _SDL_bool))
(define-sdl2 SDL_AtomicSetPtr (_fun (_ptr io _pointer) _pointer -> _pointer)
#:make-fail make-not-available)
(define-sdl2 SDL_AtomicGetPtr (_fun (_ptr i _pointer) -> _pointer)
#:make-fail make-not-available)
;; SDL_rwops.h
(define SDL_RWOPS_UNKNOWN 0)
(define SDL_RWOPS_WINFILE 1)
(define SDL_RWOPS_STDFILE 2)
(define SDL_RWOPS_JNIFILE 3)
(define SDL_RWOPS_MEMORY 4)
(define SDL_RWOPS_MEMORY_RO 5)
(define-cstruct _SDL_RWops
([size (_fun _pointer -> _sint64)]
[seek (_fun _pointer _sint64 _int -> _sint64)]
[read (_fun _pointer _pointer _size _size -> _size)]
[write (_fun _pointer _pointer _size _size -> _size)]
[close (_fun _pointer -> _int)]
[type _uint32]
;; XXX be on the safe side and occupy maximum space for the hidden union
[hidden-ptr1 _pointer]
[hidden-ptr2 _pointer]
[hidden-ptr3 _pointer]
[hidden-ptr4 _pointer]
[hidden-ptr5 _pointer]
[hidden-ptr6 _pointer]
[hidden-ptr7 _pointer]
[hidden-ptr8 _pointer]
[hidden-ptr9 _pointer]))
(define _SDL_RWops* _SDL_RWops-pointer)
(define _SDL_RWops*/null _SDL_RWops-pointer/null)
(define-sdl2 SDL_RWFromFile (_fun _string _string -> _SDL_RWops*/null))
(define-sdl2 SDL_RWFromFP (_fun _pointer _SDL_bool -> _SDL_RWops*/null))
(define-sdl2 SDL_RWFromMem (_fun _pointer _int -> _SDL_RWops*/null))
(define-sdl2 SDL_RWFromConstMem (_fun _pointer _int -> _SDL_RWops*/null))
(define-sdl2 SDL_AllocRW (_fun -> _SDL_RWops*/null))
(define-sdl2 SDL_FreeRW (_fun _SDL_RWops* -> _void))
(define RW_SEEK_SET 0)
(define RW_SEEK_CUR 1)
(define RW_SEEK_END 2)
(define (SDL_RWsize ctx) ((SDL_RWops-size ctx) ctx))
(define (SDL_RWseek ctx offset whence) ((SDL_RWops-seek ctx) ctx offset whence))
(define (SDL_RWtell ctx) ((SDL_RWops-seek ctx) 0 RW_SEEK_CUR))
(define (SDL_RWread ctx ptr size n) ((SDL_RWops-read ctx) ctx ptr size n))
(define (SDL_RWwrite ctx ptr size n) ((SDL_RWops-write ctx) ctx ptr size n))
(define (SDL_RWclose ctx) ((SDL_RWops-close ctx) ctx))
(define-sdl2 SDL_LoadFile_RW (_fun _SDL_RWops* _size _int -> _pointer)
#:make-fail make-not-available)
(define (SDL_LoadFile file datasize)
(SDL_LoadFile_RW
(SDL_RWFromFile file "rb")
datasize 1))
(define-sdl2 SDL_ReadU8 (_fun _SDL_RWops* -> _uint8 ))
(define-sdl2 SDL_ReadLE16 (_fun _SDL_RWops* -> _uint16))
(define-sdl2 SDL_ReadBE16 (_fun _SDL_RWops* -> _uint16))
(define-sdl2 SDL_ReadLE32 (_fun _SDL_RWops* -> _uint32))
(define-sdl2 SDL_ReadBE32 (_fun _SDL_RWops* -> _uint32))
(define-sdl2 SDL_ReadLE64 (_fun _SDL_RWops* -> _uint64))
(define-sdl2 SDL_ReadBE64 (_fun _SDL_RWops* -> _uint64))
(define-sdl2 SDL_WriteU8 (_fun _SDL_RWops* _uint8 -> _size))
(define-sdl2 SDL_WriteLE16 (_fun _SDL_RWops* _uint16 -> _size))
(define-sdl2 SDL_WriteBE16 (_fun _SDL_RWops* _uint16 -> _size))
(define-sdl2 SDL_WriteLE32 (_fun _SDL_RWops* _uint32 -> _size))
(define-sdl2 SDL_WriteBE32 (_fun _SDL_RWops* _uint32 -> _size))
(define-sdl2 SDL_WriteLE64 (_fun _SDL_RWops* _uint64 -> _size))
(define-sdl2 SDL_WriteBE64 (_fun _SDL_RWops* _uint64 -> _size))
;; SDL_audio.h
(define _SDL_AudioFormat _uint16)
(define SDL_AUDIO_MASK_BITSIZE #xFF)
(define SDL_AUDIO_MASK_DATATYPE (arithmetic-shift 1 8))
(define SDL_AUDIO_MASK_ENDIAN (arithmetic-shift 1 12))
(define SDL_AUDIO_MASK_SIGNED (arithmetic-shift 1 15))
(define (SDL_AUDIO_BITSIZE x) (bitwise-and x SDL_AUDIO_MASK_BITSIZE))
(define (SDL_AUDIO_ISFLOAT x) (bitwise-and x SDL_AUDIO_MASK_DATATYPE))
(define (SDL_AUDIO_ISBIGENDIAN x) (bitwise-and x SDL_AUDIO_MASK_ENDIAN))
(define (SDL_AUDIO_ISSIGNED x) (bitwise-and x SDL_AUDIO_MASK_SIGNED))
(define (SDL_AUDIO_ISINT x) (bitwise-not (SDL_AUDIO_ISFLOAT x)))
(define (SDL_AUDIO_ISLITTLEENDIAN x) (bitwise-not (SDL_AUDIO_ISBIGENDIAN x)))
(define (SDL_AUDIO_ISUNSIGNED x) (bitwise-not (SDL_AUDIO_ISSIGNED x)))
(define AUDIO_U8 #x0008)
(define AUDIO_S8 #x8008)
(define AUDIO_U16LSB #x0010)
(define AUDIO_S16LSB #x8010)
(define AUDIO_U16MSB #x1010)
(define AUDIO_S16MSB #x9010)
(define AUDIO_U16 AUDIO_U16LSB)
(define AUDIO_S16 AUDIO_S16LSB)
(define AUDIO_S32LSB #x8020)
(define AUDIO_S32MSB #x9020)
(define AUDIO_S32 AUDIO_S32LSB)
(define AUDIO_F32LSB #x8120)
(define AUDIO_F32MSB #x9120)
(define AUDIO_F32 AUDIO_F32LSB)
(define AUDIO_U16SYS (if (system-big-endian?) AUDIO_U16MSB AUDIO_U16LSB))
(define AUDIO_S16SYS (if (system-big-endian?) AUDIO_S16MSB AUDIO_U16LSB))
(define AUDIO_S32SYS (if (system-big-endian?) AUDIO_S32MSB AUDIO_U16LSB))
(define AUDIO_F32SYS (if (system-big-endian?) AUDIO_F32MSB AUDIO_U16LSB))
(define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE #x00000001)
(define SDL_AUDIO_ALLOW_FORMAT_CHANGE #x00000002)
(define SDL_AUDIO_ALLOW_CHANNELS_CHANGE #x00000004)
(define SDL_AUDIO_ALLOW_SAMPLES_CHANGE #x00000008)
(define SDL_AUDIO_ALLOW_ANY_CHANGE (bitwise-ior
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE
SDL_AUDIO_ALLOW_FORMAT_CHANGE
SDL_AUDIO_ALLOW_CHANNELS_CHANGE
SDL_AUDIO_ALLOW_SAMPLES_CHANGE))
(define _SDL_AudioCallback (_fun _pointer _uint8* _int -> _void))
(define-cstruct _SDL_AudioSpec
([freq _int]
[format _SDL_AudioFormat]
[channels _uint8]
[silence _uint8]
[samples _uint16]
[padding _uint16]
[size _uint32]
[callback _SDL_AudioCallback]
[userdata _pointer]))
(define _SDL_AudioSpec* _SDL_AudioSpec-pointer)
(define _SDL_AudioSpec*/null _SDL_AudioSpec-pointer/null)
(define _SDL_AudioFilter (_fun _pointer _SDL_AudioFormat -> _void))
(define SDL_AUDIOCVT_MAX_FILTERS 9)
(define-cstruct _SDL_AudioCVT
([needed _int]
[src_format _SDL_AudioFormat]
[dst_format _SDL_AudioFormat]
[rate_incr _double]
[buf _uint8*]
[len _int]
[len_cvt _int]
[len_mult _int]
[len_ratio _double]
[filters (_array _SDL_AudioFilter (+ SDL_AUDIOCVT_MAX_FILTERS 1))]
[filter_index _int])
#:alignment 1)
(define _SDL_AudioCVT* _SDL_AudioCVT-pointer)
(define-sdl2 SDL_GetNumAudioDrivers (_fun -> _int))
(define-sdl2 SDL_GetAudioDriver (_fun _int -> _string))
(define-sdl2 SDL_AudioInit (_fun _string -> _int))
(define-sdl2 SDL_AudioQuit (_fun -> _void))
(define-sdl2 SDL_GetCurrentAudioDriver (_fun -> _string))
(define-sdl2 SDL_OpenAudio (_fun _SDL_AudioSpec* _SDL_AudioSpec*/null -> _int))
(define _SDL_AudioDeviceID _uint32)
(define-sdl2 SDL_GetNumAudioDevices (_fun _int -> _int))
(define-sdl2 SDL_GetAudioDeviceName (_fun _int _int -> _string))
(define-sdl2 SDL_OpenAudioDevice
(_fun _string _int _SDL_AudioSpec* _SDL_AudioSpec* _int -> _SDL_AudioDeviceID))
(define _SDL_AudioStatus
(_enum
'(SDL_AUDIO_STOPPED = 0
SDL_AUDIO_PLAYING
SDL_AUDIO_PAUSED)))
(define-sdl2 SDL_GetAudioStatus (_fun -> _SDL_AudioStatus))
(define-sdl2 SDL_GetAudioDeviceStatus (_fun _SDL_AudioDeviceID -> _SDL_AudioStatus))
(define-sdl2 SDL_PauseAudio (_fun _int -> _void))
(define-sdl2 SDL_PauseAudioDevice (_fun _SDL_AudioDeviceID _int -> _void))
(define-sdl2 SDL_LoadWAV_RW
(_fun _SDL_RWops* _int _SDL_AudioSpec* (_ptr o _uint8*) _uint32* -> _SDL_AudioSpec*/null))
(define (SDL_LoadWAV file spec audio_buf audio_len)
(SDL_LoadWAV_RW
(SDL_RWFromFile file "rb")
1 spec audio_buf audio_len))
(define-sdl2 SDL_FreeWAV (_fun _uint8* -> _void))
(define-sdl2 SDL_BuildAudioCVT
(_fun _SDL_AudioCVT* _SDL_AudioFormat _uint8 _int _SDL_AudioFormat _uint8 _int -> _int))
(define-sdl2 SDL_ConvertAudio (_fun _SDL_AudioCVT* -> _int))
(define-cpointer-type _SDL_AudioStream*)
(define-sdl2 SDL_NewAudioStream
(_fun _SDL_AudioFormat _uint8 _int _SDL_AudioFormat _uint8 _int -> _SDL_AudioStream*)
#:make-fail make-not-available)
(define-sdl2 SDL_AudioStreamPut (_fun _SDL_AudioStream* _pointer _int -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_AudioStreamGet (_fun _SDL_AudioStream* _pointer _int -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_AudioStreamAvailable (_fun _SDL_AudioStream* -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_AudioStreamFlush (_fun _SDL_AudioStream* -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_AudioStreamClear (_fun _SDL_AudioStream* -> _void)
#:make-fail make-not-available)
(define-sdl2 SDL_FreeAudioStream (_fun _SDL_AudioStream* -> _void)
#:make-fail make-not-available)
(define SDL_MIX_MAXVOLUME 128)
(define-sdl2 SDL_MixAudio (_fun _uint8* _uint8* _uint32 _int -> _void))
(define-sdl2 SDL_MixAudioFormat (_fun _uint8* _uint8* _SDL_AudioFormat _uint32 _int -> _void))
(define-sdl2 SDL_QueueAudio (_fun _SDL_AudioDeviceID _pointer _uint32 -> _int)
#:make-fail make-not-available)
(define-sdl2 SDL_DequeueAudio (_fun _SDL_AudioDeviceID _pointer _uint32 -> _uint32)
#:make-fail make-not-available)
(define-sdl2 SDL_GetQueuedAudioSize (_fun _SDL_AudioDeviceID -> _uint32)
#:make-fail make-not-available)
(define-sdl2 SDL_ClearQueuedAudio (_fun _SDL_AudioDeviceID -> _void)
#:make-fail make-not-available)
(define-sdl2 SDL_LockAudio (_fun -> _void))
(define-sdl2 SDL_LockAudioDevice (_fun _SDL_AudioDeviceID -> _void))
(define-sdl2 SDL_UnlockAudio (_fun -> _void))
(define-sdl2 SDL_UnlockAudioDevice (_fun -> _void))
(define-sdl2 SDL_CloseAudio (_fun -> _void))
(define-sdl2 SDL_CloseAudioDevice (_fun _SDL_AudioDeviceID -> _void))
;; SDL_clipboard.h
(define-sdl2 SDL_SetClipboardText (_fun _string -> _int))
(define-sdl2 SDL_GetClipboardText (_fun -> _string))
(define-sdl2 SDL_HasClipboardText (_fun -> _SDL_bool))
;; SDL_cpuinfo.h
(define SDL_CACHELINE_SIZE 128)
(define-sdl2 SDL_GetCPUCount (_fun -> _int))
(define-sdl2 SDL_GetCPUCacheLineSize (_fun -> _int))
(define-sdl2 SDL_HasRDTSC (_fun -> _SDL_bool))
(define-sdl2 SDL_HasAltiVec (_fun -> _SDL_bool))
(define-sdl2 SDL_HasMMX (_fun -> _SDL_bool))
(define-sdl2 SDL_Has3DNow (_fun -> _SDL_bool))
(define-sdl2 SDL_HasSSE (_fun -> _SDL_bool))
(define-sdl2 SDL_HasSSE2 (_fun -> _SDL_bool))
(define-sdl2 SDL_HasSSE3 (_fun -> _SDL_bool))
(define-sdl2 SDL_HasSSE41 (_fun -> _SDL_bool))
(define-sdl2 SDL_HasSSE42 (_fun -> _SDL_bool))
(define-sdl2 SDL_HasAVX (_fun -> _SDL_bool)
#:make-fail make-not-available)
(define-sdl2 SDL_HasAVX2 (_fun -> _SDL_bool)
#:make-fail make-not-available)
(define-sdl2 SDL_HasAVX512F (_fun -> _SDL_bool)
#:make-fail make-not-available)
(define-sdl2 SDL_HasNEON (_fun -> _SDL_bool)
#:make-fail make-not-available)
(define-sdl2 SDL_GetSystemRAM (_fun -> _int)
#:make-fail make-not-available)
;; SDL_endian.h
(define SDL_LIL_ENDIAN 1234)
(define SDL_BIG_ENDIAN 4321)
(define SDL_BYTEORDER (if (system-big-endian?) SDL_BIG_ENDIAN SDL_LIL_ENDIAN))
(begin-encourage-inline
(define/contract (SDL_Swap16 x)
(contract/->
(and/c exact-integer? (lambda (n) (<= (integer-length n) 16)))
(and/c exact-integer? (lambda (n) (<= (integer-length n) 16))))
(bitwise-and
(bitwise-ior
(arithmetic-shift x 8)
(arithmetic-shift x -8))
#xffff))
(define/contract (SDL_Swap32 x)
(contract/->
(and/c exact-integer? (lambda (n) (<= (integer-length n) 32)))
(and/c exact-integer? (lambda (n) (<= (integer-length n) 32))))
(bitwise-and
(bitwise-ior
(arithmetic-shift x 24)
(bitwise-and (arithmetic-shift x 8) #x00FF0000)
(bitwise-and (arithmetic-shift x -8) #x0000FF00)
(arithmetic-shift x -24))
#xffffffff))
(define/contract (SDL_Swap64 x)
(contract/->
(and/c exact-integer? (lambda (n) (<= (integer-length n) 64)))
(and/c exact-integer? (lambda (n) (<= (integer-length n) 64))))
(bitwise-and
(bitwise-ior
(arithmetic-shift
(SDL_Swap32 (bitwise-and x #xffffffff))
32)
(arithmetic-shift
(SDL_Swap32 (bitwise-and (arithmetic-shift x -32) #xffffffff))
32))
#xffffffffffffffff))
(define/contract (SDL_SwapFloat x)
(contract/->
single-flonum? flonum?)
;; TODO : somehow convert _float to single-flonum
(define _swapper (_union _float _uint32))
(define s (cast (list x) (_list-struct _float) _swapper))
(union-set! s 1 (SDL_Swap32 (union-ref s 1)))
(union-ref s 0)))
(define (SDL_SwapLE16 X) (if (system-big-endian?) (SDL_Swap16 X) X))
(define (SDL_SwapLE32 X) (if (system-big-endian?) (SDL_Swap32 X) X))
(define (SDL_SwapLE64 X) (if (system-big-endian?) (SDL_Swap64 X) X))
(define (SDL_SwapFloatLE X) (if (system-big-endian?) (SDL_SwapFloat X) X))
(define (SDL_SwapBE16 X) (if (system-big-endian?) X (SDL_Swap16 X)))
(define (SDL_SwapBE32 X) (if (system-big-endian?) X (SDL_Swap32 X)))
(define (SDL_SwapBE64 X) (if (system-big-endian?) X (SDL_Swap64 X)))
(define (SDL_SwapFloatBE X) (if (system-big-endian?) X (SDL_SwapFloat X)))
;; SDL_error.h
(define-sdl2-vararg SDL_SetError (_string) _int)
(define-sdl2 SDL_GetError (_fun -> _string))
(define-sdl2 SDL_ClearError (_fun -> _void))
;; SDL_scancode.h
(define _SDL_Scancode
(_enum
'(SDL_SCANCODE_UNKNOWN = 0
SDL_SCANCODE_A = 4
SDL_SCANCODE_B = 5
SDL_SCANCODE_C = 6
SDL_SCANCODE_D = 7
SDL_SCANCODE_E = 8
SDL_SCANCODE_F = 9
SDL_SCANCODE_G = 10
SDL_SCANCODE_H = 11
SDL_SCANCODE_I = 12
SDL_SCANCODE_J = 13
SDL_SCANCODE_K = 14
SDL_SCANCODE_L = 15
SDL_SCANCODE_M = 16
SDL_SCANCODE_N = 17
SDL_SCANCODE_O = 18
SDL_SCANCODE_P = 19
SDL_SCANCODE_Q = 20
SDL_SCANCODE_R = 21
SDL_SCANCODE_S = 22
SDL_SCANCODE_T = 23
SDL_SCANCODE_U = 24
SDL_SCANCODE_V = 25
SDL_SCANCODE_W = 26
SDL_SCANCODE_X = 27
SDL_SCANCODE_Y = 28
SDL_SCANCODE_Z = 29
SDL_SCANCODE_1 = 30
SDL_SCANCODE_2 = 31
SDL_SCANCODE_3 = 32
SDL_SCANCODE_4 = 33
SDL_SCANCODE_5 = 34
SDL_SCANCODE_6 = 35
SDL_SCANCODE_7 = 36
SDL_SCANCODE_8 = 37
SDL_SCANCODE_9 = 38
SDL_SCANCODE_0 = 39
SDL_SCANCODE_RETURN = 40
SDL_SCANCODE_ESCAPE = 41
SDL_SCANCODE_BACKSPACE = 42
SDL_SCANCODE_TAB = 43
SDL_SCANCODE_SPACE = 44
SDL_SCANCODE_MINUS = 45
SDL_SCANCODE_EQUALS = 46
SDL_SCANCODE_LEFTBRACKET = 47
SDL_SCANCODE_RIGHTBRACKET = 48
SDL_SCANCODE_BACKSLASH = 49
SDL_SCANCODE_NONUSHASH = 50
SDL_SCANCODE_SEMICOLON = 51
SDL_SCANCODE_APOSTROPHE = 52
SDL_SCANCODE_GRAVE = 53
SDL_SCANCODE_COMMA = 54
SDL_SCANCODE_PERIOD = 55
SDL_SCANCODE_SLASH = 56
SDL_SCANCODE_CAPSLOCK = 57
SDL_SCANCODE_F1 = 58
SDL_SCANCODE_F2 = 59
SDL_SCANCODE_F3 = 60
SDL_SCANCODE_F4 = 61
SDL_SCANCODE_F5 = 62
SDL_SCANCODE_F6 = 63
SDL_SCANCODE_F7 = 64
SDL_SCANCODE_F8 = 65
SDL_SCANCODE_F9 = 66
SDL_SCANCODE_F10 = 67
SDL_SCANCODE_F11 = 68
SDL_SCANCODE_F12 = 69
SDL_SCANCODE_PRINTSCREEN = 70
SDL_SCANCODE_SCROLLLOCK = 71
SDL_SCANCODE_PAUSE = 72
SDL_SCANCODE_INSERT = 73
SDL_SCANCODE_HOME = 74
SDL_SCANCODE_PAGEUP = 75
SDL_SCANCODE_DELETE = 76
SDL_SCANCODE_END = 77
SDL_SCANCODE_PAGEDOWN = 78
SDL_SCANCODE_RIGHT = 79
SDL_SCANCODE_LEFT = 80
SDL_SCANCODE_DOWN = 81
SDL_SCANCODE_UP = 82
SDL_SCANCODE_NUMLOCKCLEAR = 83
SDL_SCANCODE_KP_DIVIDE = 84
SDL_SCANCODE_KP_MULTIPLY = 85
SDL_SCANCODE_KP_MINUS = 86
SDL_SCANCODE_KP_PLUS = 87
SDL_SCANCODE_KP_ENTER = 88
SDL_SCANCODE_KP_1 = 89
SDL_SCANCODE_KP_2 = 90
SDL_SCANCODE_KP_3 = 91
SDL_SCANCODE_KP_4 = 92
SDL_SCANCODE_KP_5 = 93
SDL_SCANCODE_KP_6 = 94
SDL_SCANCODE_KP_7 = 95
SDL_SCANCODE_KP_8 = 96
SDL_SCANCODE_KP_9 = 97
SDL_SCANCODE_KP_0 = 98
SDL_SCANCODE_KP_PERIOD = 99
SDL_SCANCODE_NONUSBACKSLASH = 100
SDL_SCANCODE_APPLICATION = 101
SDL_SCANCODE_POWER = 102
SDL_SCANCODE_KP_EQUALS = 103
SDL_SCANCODE_F13 = 104
SDL_SCANCODE_F14 = 105
SDL_SCANCODE_F15 = 106
SDL_SCANCODE_F16 = 107
SDL_SCANCODE_F17 = 108
SDL_SCANCODE_F18 = 109
SDL_SCANCODE_F19 = 110
SDL_SCANCODE_F20 = 111
SDL_SCANCODE_F21 = 112
SDL_SCANCODE_F22 = 113
SDL_SCANCODE_F23 = 114
SDL_SCANCODE_F24 = 115
SDL_SCANCODE_EXECUTE = 116
SDL_SCANCODE_HELP = 117
SDL_SCANCODE_MENU = 118
SDL_SCANCODE_SELECT = 119
SDL_SCANCODE_STOP = 120
SDL_SCANCODE_AGAIN = 121
SDL_SCANCODE_UNDO = 122
SDL_SCANCODE_CUT = 123
SDL_SCANCODE_COPY = 124
SDL_SCANCODE_PASTE = 125
SDL_SCANCODE_FIND = 126
SDL_SCANCODE_MUTE = 127
SDL_SCANCODE_VOLUMEUP = 128
SDL_SCANCODE_VOLUMEDOWN = 129
SDL_SCANCODE_KP_COMMA = 133
SDL_SCANCODE_KP_EQUALSAS400 = 134
SDL_SCANCODE_INTERNATIONAL1 = 135
SDL_SCANCODE_INTERNATIONAL2 = 136
SDL_SCANCODE_INTERNATIONAL3 = 137
SDL_SCANCODE_INTERNATIONAL4 = 138
SDL_SCANCODE_INTERNATIONAL5 = 139
SDL_SCANCODE_INTERNATIONAL6 = 140
SDL_SCANCODE_INTERNATIONAL7 = 141
SDL_SCANCODE_INTERNATIONAL8 = 142
SDL_SCANCODE_INTERNATIONAL9 = 143
SDL_SCANCODE_LANG1 = 144
SDL_SCANCODE_LANG2 = 145
SDL_SCANCODE_LANG3 = 146
SDL_SCANCODE_LANG4 = 147
SDL_SCANCODE_LANG5 = 148
SDL_SCANCODE_LANG6 = 149
SDL_SCANCODE_LANG7 = 150
SDL_SCANCODE_LANG8 = 151
SDL_SCANCODE_LANG9 = 152
SDL_SCANCODE_ALTERASE = 153
SDL_SCANCODE_SYSREQ = 154
SDL_SCANCODE_CANCEL = 155
SDL_SCANCODE_CLEAR = 156
SDL_SCANCODE_PRIOR = 157
SDL_SCANCODE_RETURN2 = 158
SDL_SCANCODE_SEPARATOR = 159
SDL_SCANCODE_OUT = 160
SDL_SCANCODE_OPER = 161
SDL_SCANCODE_CLEARAGAIN = 162
SDL_SCANCODE_CRSEL = 163
SDL_SCANCODE_EXSEL = 164
SDL_SCANCODE_KP_00 = 176
SDL_SCANCODE_KP_000 = 177
SDL_SCANCODE_THOUSANDSSEPARATOR = 178
SDL_SCANCODE_DECIMALSEPARATOR = 179
SDL_SCANCODE_CURRENCYUNIT = 180
SDL_SCANCODE_CURRENCYSUBUNIT = 181
SDL_SCANCODE_KP_LEFTPAREN = 182
SDL_SCANCODE_KP_RIGHTPAREN = 183
SDL_SCANCODE_KP_LEFTBRACE = 184
SDL_SCANCODE_KP_RIGHTBRACE = 185
SDL_SCANCODE_KP_TAB = 186
SDL_SCANCODE_KP_BACKSPACE = 187
SDL_SCANCODE_KP_A = 188
SDL_SCANCODE_KP_B = 189
SDL_SCANCODE_KP_C = 190
SDL_SCANCODE_KP_D = 191
SDL_SCANCODE_KP_E = 192
SDL_SCANCODE_KP_F = 193
SDL_SCANCODE_KP_XOR = 194
SDL_SCANCODE_KP_POWER = 195
SDL_SCANCODE_KP_PERCENT = 196
SDL_SCANCODE_KP_LESS = 197
SDL_SCANCODE_KP_GREATER = 198
SDL_SCANCODE_KP_AMPERSAND = 199
SDL_SCANCODE_KP_DBLAMPERSAND = 200
SDL_SCANCODE_KP_VERTICALBAR = 201
SDL_SCANCODE_KP_DBLVERTICALBAR = 202
SDL_SCANCODE_KP_COLON = 203
SDL_SCANCODE_KP_HASH = 204
SDL_SCANCODE_KP_SPACE = 205
SDL_SCANCODE_KP_AT = 206
SDL_SCANCODE_KP_EXCLAM = 207
SDL_SCANCODE_KP_MEMSTORE = 208
SDL_SCANCODE_KP_MEMRECALL = 209
SDL_SCANCODE_KP_MEMCLEAR = 210
SDL_SCANCODE_KP_MEMADD = 211
SDL_SCANCODE_KP_MEMSUBTRACT = 212
SDL_SCANCODE_KP_MEMMULTIPLY = 213
SDL_SCANCODE_KP_MEMDIVIDE = 214
SDL_SCANCODE_KP_PLUSMINUS = 215
SDL_SCANCODE_KP_CLEAR = 216
SDL_SCANCODE_KP_CLEARENTRY = 217
SDL_SCANCODE_KP_BINARY = 218
SDL_SCANCODE_KP_OCTAL = 219
SDL_SCANCODE_KP_DECIMAL = 220
SDL_SCANCODE_KP_HEXADECIMAL = 221
SDL_SCANCODE_LCTRL = 224
SDL_SCANCODE_LSHIFT = 225
SDL_SCANCODE_LALT = 226
SDL_SCANCODE_LGUI = 227
SDL_SCANCODE_RCTRL = 228
SDL_SCANCODE_RSHIFT = 229
SDL_SCANCODE_RALT = 230
SDL_SCANCODE_RGUI = 231