Check-in [c9770d8f7f]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added sdl2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c9770d8f7fc62709f9291c04ff523112e0d525dc
User & Date: ovenpasta@pizzahack.eu 2016-08-17 07:47:19
Context
2016-08-17
08:03
fixed survey test for nanomsg check-in: b7b9cf1065 user: ovenpasta@pizzahack.eu tags: trunk
07:47
added sdl2 check-in: c9770d8f7f user: ovenpasta@pizzahack.eu tags: trunk
07:45
added json check-in: c00740301b user: ovenpasta@pizzahack.eu tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sdl2.sls.

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































































(library 
 (sdl2)
 (export sdl-init)





















































































































































































































































































































































































































































































































































































































































































 (import (chezscheme))





 
 (define library-init (load-shared-object "libSDL2.so"))


 
 (define sdl-init-flags%  '((timer           . #x00000001)
			    (audio           . #x00000010)
			    (video           . #x00000020)
			    (joystick        . #x00000200)
			    (haptic          . #x00001000)
			    (game-controller . #x00002000)
			    (events          . #x00004000)
			    (no-parachute    . #x00100000)))

 
 ; calculates 'everything flag
 (define sdl-init-flags 
   (append sdl-init-flags% (list (cons 'everything (fold (lambda (x acc) (logor (cdr x) acc) ) 0 sdl-init-flags)))))



 (define (sdl-init-flag-value x)
   (assert (and  sdl-init-flag-value (symbol? x)))
   (let ([v (assq x sdl-init-flags)])
     (assert (and sdl-init-flag-value (pair? v)))
     (cdr v)))





 (define (sdl-init-flags-or l)
   (assert (and sdl-init-flags-or (list? l)))
   (fold (lambda (x acc) (logor (sdl-init-flag-value x) acc)) 0 l))


 (define (sdl-init-flags-list flags)
   (assert (and sdl-init-flags-list (number? flags)))
   (fold (lambda (x acc) 
	   	   (if (not (zero? (logand flags (cdr x)))) 
		       (cons (car x) acc)
		       acc)) 
	 '() sdl-init-flags%))




 (define (sdl-main-ready)
    (let ([f (foreign-procedure "SDL_MainReady" () void)])
     (f)))


 (define (sdl-init sub-systems)
   (assert (and sdl-init (list? sub-systems)))
   (let ([f (foreign-procedure "SDL_Init" (unsigned-32) int)]
	 [x (sdl-init-flags-or sub-systems)])
     (f x)))



 (define (sdl-init-sub-system sub-system)
   (assert (and sdl-init-sub-system (symbol? sub-system)))
   (let ([f (foreign-procedure "SDL_InitSubSystem" (unsigned-32) int)]
	 [x (sdl-init-flag-value sub-system)])
     (f x)))



 (define (sdl-quit-sub-system sub-system)
   (assert (and sdl-quit-sub-system (symbol? sub-system)))
   (let ([f (foreign-procedure "SDL_QuitSubSystem" (unsigned-32) void)]
	 [x (sdl-init-flag-value sub-system)])
     (f x)))















 (define (sdl-was-init sub-systems)
   (assert (and sdl-init (list? sub-systems)))
   (let ([f (foreign-procedure "SDL_WasInit" (unsigned-32) unsigned-32)]
	 [x (sdl-init-flags-or sub-systems)])
     (sdl-init-flags-list (f x))))



   
 (define (sdl-quit)
   (let ([f (foreign-procedure "SDL_Quit" () void)])
     (f)))
 ) ; library sdl2





























































>
>
|

<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>

<
>
>

<
<
<
<
<
<
<
<
>
|
<
<
<
>
>

<
<
<
<
<
>
>
>
>
|
<
<
<
>

<
<
<
<
<
<
<
>

>

<
<
<
>

<
<
<
<
<
>
>

<
<
<
<
<
>
>

<
<
<
<
<
>

>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
>
>
>
|
|
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

#!r6rs

(library
 (sdl2)

 (export sdl-library-init sdl-initialization sdl-initialization-everything
	 sdl-init sdl-init-sub-system sdl-quit-sub-system sdl-was-init sdl-quit

	 ;;BASE TYPES
	 uint8 uint16 sint16 uint32 sint32 sint64 uint64 va-list
	 int% 
	 file sdl-bool-t
	 sdl-iconv-t

	 ;;FFI
	 define-ftype-allocator define-sdl-func sdl-let-ref-call new-struct
	 ;;GUARDIAN
	 sdl-guardian sdl-guard-pointer sdl-free-garbage sdl-free-garbage-set-func
	 
	 ;;HINT
	 sdl-set-hint-with-priority
	 sdl-set-hint
	 sdl-get-hint
	 sdl-add-hint-callback
	 sdl-del-hint-callback
	 sdl-clear-hints
	 ;types
	 sdl-hint-priority

	 ;;JOYSTICK
	 sdl-num-joysticks
	 sdl-joystick-name-for-index
	 sdl-joystick-open
	 sdl-joystick-name
	 sdl-joystick-get-device-guid
	 sdl-joystick-get-guid
	 sdl-joystick-get-guid-string
	 sdl-joystick-get-guid-from-string
	 sdl-joystick-get-attached
	 sdl-joystick-instance-id
	 sdl-joystick-num-axes
	 sdl-joystick-num-balls
	 sdl-joystick-num-hats
	 sdl-joystick-num-buttons
	 sdl-joystick-update
	 sdl-joystick-event-state
	 sdl-joystick-get-axis
	 sdl-joystick-get-hat
	 sdl-joystick-get-ball
	 sdl-joystick-get-button
	 sdl-joystick-close

	 ;;types
	 sdl-joystick-t
	 sdl-joystick-guid-t
	 
	 ;;KEYBOARD
	 sdl-get-keyboard-focus
	 sdl-get-keyboard-state
	 sdl-get-mod-state
	 sdl-set-mod-state
	 sdl-get-key-from-scancode
	 sdl-get-scancode-from-key
	 sdl-get-scancode-name
	 sdl-get-scancode-from-name
	 sdl-get-key-name
	 sdl-get-key-from-name
	 sdl-start-text-input
	 sdl-is-text-input-active
	 sdl-stop-text-input
	 sdl-set-text-input-rect
	 sdl-has-screen-keyboard-support
	 sdl-is-screen-keyboard-shown

	 ;;types 
	 sdl-keysym-t

	 ;;KEYCODE
	 scancode->keycode
	 sdl-keycode
	 sdl-keycode-ref
	 sdl-keycode-decode
	 sdl-keycode-t
	 sdl-keymod-t
	 
	 ;;MAIN
	 sdl-main sdl-set-main-ready 

	 ;;MESSAGEBOX
	  sdl-show-message-box
	  sdl-show-simple-message-box
	  ;types
	  sdl-message-box
	  sdl-message-box-button
	  sdl-message-box-color-type-t
	  sdl-message-box-button-data-t
	  sdl-message-box-color-t
	  sdl-message-box-color-scheme-t
	  sdl-message-box-data-t

	  ;;MOUSE
	  sdl-get-mouse-focus
	 sdl-get-mouse-state
	 sdl-get-relative-mouse-state
	 sdl-warp-mouse-in-window
	 sdl-set-relative-mouse-mode
	 sdl-get-relative-mouse-mode
	 sdl-create-cursor
	 sdl-create-color-cursor
	 sdl-create-system-cursor
	 sdl-set-cursor
	 sdl-get-cursor
	 sdl-get-default-cursor
	 sdl-free-cursor
	 sdl-show-cursor

	 ;types
	 sdl-system-cursor
	 sdl-cursor-t

	 sdl-button
	 sdl-button-ref
	 sdl-button-mask

	 ;;MUTEX
	 sdl-create-mutex
	 sdl-lock-mutex
	 sdl-try-lock-mutex
	 sdl-unlock-mutex
	 sdl-destroy-mutex
	 sdl-create-semaphore
	 sdl-destroy-semaphore
	 sdl-sem-wait
	 sdl-sem-try-wait
	 sdl-sem-wait-timeout
	 sdl-sem-post
	 sdl-sem-value
	 sdl-create-cond
	 sdl-destroy-cond
	 sdl-cond-signal
	 sdl-cond-broadcast
	 sdl-cond-wait
	 sdl-cond-wait-timeout

	 ;; types
	 sdl-mutex-t
	 sdl-sem-t
	 sdl-cond-t

	 ;;PIXELS
	 sdl-get-pixel-format-name
	 sdl-pixel-format-enum-to-masks
	 sdl-masks-to-pixel-format-enum
	 sdl-alloc-format
	 sdl-free-format
	 sdl-alloc-palette
	 sdl-set-pixel-format-palette
	 sdl-set-palette-colors
	 sdl-free-palette
	 sdl-map-rgb
	 sdl-map-rgba
	 sdl-get-rgb
	 sdl-get-rgba
	 sdl-calculate-gamma-ramp

	 ;;types
	 sdl-alpha-opaque
	 sdl-alpha-transparent
	 sdl-pixeltype
	 sdl-bitmaporder
	 sdl-packedorder
	 sdl-arrayorder
	 sdl-packedlayout
	 sdl-define-pixelformat

	 sdl-pixelflag%
	 sdl-pixeltype%
	 sdl-pixelorder%
	 sdl-pixellayout
	 sdl-bitsperpixel%
	 sdl-ispixelformat-fourcc
	 sdl-fourcc

	 sdl-fourcc/char
	 sdl-pixelformat
	 
	 sdl-pixel-format-t
	 sdl-color-t
	 sdl-palette-t

	 ;;RECT
	 sdl-rect-empty
	 sdl-rect-equals
	 sdl-has-intersection
	 sdl-intersect-rect
	 sdl-union-rect
	 sdl-enclose-points
	 sdl-intersect-rect-and-line
	 ;; types
	 sdl-point-t
	 sdl-rect-t
	 
	 ;;RENDER
	 sdl-get-num-render-drivers
	 sdl-get-render-driver-info
	 sdl-create-window-and-renderer
	 sdl-create-renderer
	 sdl-create-software-renderer
	 sdl-get-renderer
	 sdl-get-renderer-info
	 sdl-get-renderer-output-size
	 sdl-create-texture
	 sdl-create-texture-from-surface
	 sdl-query-texture
	 sdl-set-texture-color-mod
	 sdl-get-texture-color-mod
	 sdl-set-texture-alpha-mod
	 sdl-get-texture-alpha-mod
	 sdl-set-texture-blend-mode
	 sdl-get-texture-blend-mode
	 sdl-update-texture
	 sdl-update-yuv-texture
	 sdl-lock-texture
	 sdl-unlock-texture
	 sdl-render-target-supported
	 sdl-set-render-target
	 sdl-get-render-target
	 sdl-render-set-logical-size
	 sdl-render-get-logical-size
	 sdl-render-set-viewport
	 sdl-render-get-viewport
	 sdl-render-set-clip-rect
	 sdl-render-get-clip-rect
	 sdl-render-set-scale
	 sdl-render-get-scale
	 sdl-set-render-draw-color
	 sdl-get-render-draw-color
	 sdl-set-render-draw-blend-mode
	 sdl-get-render-draw-blend-mode
	 sdl-render-clear
	 sdl-render-draw-point
	 sdl-render-draw-points
	 sdl-render-draw-line
	 sdl-render-draw-lines
	 sdl-render-draw-rect
	 sdl-render-draw-rects
	 sdl-render-fill-rect
	 sdl-render-fill-rects
	 sdl-render-copy
	 sdl-render-copy-ex
	 sdl-render-read-pixels
	 sdl-render-present
	 sdl-destroy-texture
	 sdl-destroy-renderer
	 sdl-gl-bind-texture
	 sdl-gl-unbind-texture

	 sdl-renderer-flags
	 sdl-renderer-info-t
	 sdl-texture-access
	 sdl-texture-modulate
	 sdl-renderer-flip
	 sdl-renderer-t
	 sdl-texture-t
	 ;;types
	 sdl-renderer-flags
	 sdl-renderer-info-t
	 sdl-texture-access
	 sdl-texture-modulate
	 sdl-renderer-flip
	 sdl-renderer-t
	 sdl-texture-t

	 ;;BLENDMODE
	 sdl-blend-mode sdl-blend-mode-t

	 ;;CLIPBOARD
	 sdl-set-clipboard-text
	 sdl-get-clipboard-text
	 sdl-has-clipboard-text

	 ;;CPUINFO
	 sdl-get-cpu-count
	 sdl-get-cpu-cache-line-size
	 sdl-has-rdtsc
	 sdl-has-alti-vec
	 sdl-has-mmx
	 sdl-has3-d-now
	 sdl-has-sse
	 sdl-has-ss-e2
	 sdl-has-ss-e3
	 sdl-has-ss-e41
	 sdl-has-ss-e42
	 sdl-has-avx
	 sdl-get-system-ram

	 ;;ENDIAN
	 sdl-swap16
	 sdl-swap32
	 sdl-swap64
	 sdl-swap-float

	 ;;ERROR
	 sdl-errorcode sdl-errorcode-t 
	 sdl-set-error
	 sdl-get-error
	 sdl-clear-error
	 sdl-error

	 ;;EVENTS
	 sdl-pump-events
	 sdl-peep-events
	 sdl-has-event
	 sdl-has-events
	 sdl-flush-event
	 sdl-flush-events
	 sdl-poll-event
	 sdl-wait-event
	 sdl-wait-event-timeout
	 sdl-push-event
	 sdl-set-event-filter
	 sdl-get-event-filter
	 sdl-add-event-watch
	 sdl-del-event-watch
	 sdl-filter-events
	 sdl-event-state
	 sdl-register-events

	 ;; types

	 sdl-event-type
	 sdl-event-type-ref
	 sdl-common-event-t
	 sdl-window-event-t
	 sdl-keyboard-event-t
	 sdl-texteditingevent-text-size
	 sdl-textinputevent-text-size
	 sdl-text-input-event-t
	 sdl-mouse-motion-event-t
	 sdl-mouse-button-event-t
	 sdl-mouse-wheel-event-t
	 sdl-touch-finger-event-t
	 sdl-multi-gesture-event-t
	 sdl-dollar-gesture-event-t
	 sdl-drop-event-t
	 sdl-quit-event-t
	 sdl-user-event-t
	 sdl-sys-wm-msg
	 sdl-sys-wm-event-t
	 sdl-joy-axis-event-t
	 sdl-joy-hat-event-t
	 sdl-joy-device-event-t
	 sdl-joy-button-event-t
	 sdl-joy-ball-event-t
	 sdl-controller-button-event-t
	 sdl-controller-device-event-t
	 sdl-joystick-id-t
	 sdl-controller-axis-event-t
	 sdl-event-t
	 sdl-eventaction
	 sdl-event-filter-t
	 
	 ;;FILESYSTEM
	 sdl-get-base-path
	 sdl-get-pref-path

	 ;;VIDEO
	 sdl-get-num-video-drivers
	 sdl-get-video-driver
	 sdl-video-init
	 sdl-video-quit
	 sdl-get-current-video-driver
	 sdl-get-num-video-displays
	 sdl-get-display-name
	 sdl-get-display-bounds
	 sdl-get-num-display-modes
	 sdl-get-display-mode
	 sdl-get-desktop-display-mode
	 sdl-get-current-display-mode
	 sdl-get-closest-display-mode
	 sdl-get-window-display-index
	 sdl-set-window-display-mode
	 sdl-get-window-display-mode
	 sdl-get-window-pixel-format
	 sdl-create-window
	 sdl-create-window-from
	 sdl-get-window-id
	 sdl-get-window-from-id
	 sdl-get-window-flags
	 sdl-set-window-title
	 sdl-get-window-title
	 sdl-set-window-icon
	 sdl-set-window-data
	 sdl-get-window-data
	 sdl-set-window-position
	 sdl-get-window-position
	 sdl-set-window-size
	 sdl-get-window-size
	 sdl-set-window-minimum-size
	 sdl-get-window-minimum-size
	 sdl-set-window-maximum-size
	 sdl-get-window-maximum-size
	 sdl-set-window-bordered
	 sdl-show-window
	 sdl-hide-window
	 sdl-raise-window
	 sdl-maximize-window
	 sdl-minimize-window
	 sdl-restore-window
	 sdl-set-window-fullscreen
	 sdl-get-window-surface
	 sdl-update-window-surface
	 sdl-update-window-surface-rects
	 sdl-set-window-grab
	 sdl-get-window-grab
	 sdl-set-window-brightness
	 sdl-get-window-brightness
	 sdl-set-window-gamma-ramp
	 sdl-get-window-gamma-ramp
	 sdl-destroy-window
	 sdl-is-screen-saver-enabled
	 sdl-enable-screen-saver
	 sdl-disable-screen-saver
	 sdl-gl-load-library
	 sdl-gl-get-proc-address
	 sdl-gl-unload-library
	 sdl-gl-extension-supported
	 sdl-gl-reset-attributes
	 sdl-gl-set-attribute
	 sdl-gl-get-attribute
	 sdl-gl-create-context
	 sdl-gl-make-current
	 sdl-gl-get-current-window
	 sdl-gl-get-current-context
	 sdl-gl-get-drawable-size
	 sdl-gl-set-swap-interval
	 sdl-gl-get-swap-interval
	 sdl-gl-swap-window
	 sdl-gl-delete-context

	 ;; types 
	 sdl-display-mode-t
	 sdl-window-t

	 ;; FIXME: any way to export all this stuff with a single entry?
	 sdl-window-flags
	 sdl-window-flags-ref
	 sdl-window-flags-t
	 sdl-window-flags-decode
	 sdl-window-flags-flags

	 sdl-window-pos-undefined
	 sdl-window-pos-undefined?
	 sdl-window-pos-centered
	 sdl-window-pos-centered?
	 sdl-window-event-enum
	 sdl-window-event-enum-ref
	 sdl-gl-attr
	 sdl-gl-attr-t
	 sdl-gl-profile
	 sdl-gl-context-flag
	 sdl-gl-context-t

	 ;;VERSION
	 sdl-get-version
	 sdl-get-revision
	 sdl-get-revision-number
	 ;;types
	 sdl-version-t

	 ;;TOUCH
	 sdl-get-num-touch-devices
	 sdl-get-touch-device
	 sdl-get-num-touch-fingers
	 sdl-get-touch-finger

	 ;;types
	 sdl-finger-id-t
	 sdl-touch-id-t
	 sdl-finger-t

	 ;;TIMER
	 sdl-get-ticks
	 sdl-get-performance-counter
	 sdl-get-performance-frequency
	 sdl-delay
	 sdl-add-timer
	 sdl-remove-timer

	 sdl-timer-id-t
	 sdl-timer-callback-t

	 ;;THREAD 
	 sdl-create-thread
	 sdl-get-thread-name
	 sdl-thread-id
	 sdl-get-thread-id
	 sdl-set-thread-priority
	 sdl-wait-thread
	 sdl-detach-thread
	 sdl-tls-create
	 sdl-tls-get
	 sdl-tls-set
	 
	 ;; types
	 sdl-thread-t
	 sdl-thread-function-t
	 sdl-thread-id-t
	 sdl-tlsid-t
	 sdl-thread-priority
	 
	 sdl-create-rgb-surface
	 sdl-create-rgb-surface-from
	 sdl-free-surface
	 sdl-set-surface-palette
	 sdl-lock-surface
	 sdl-unlock-surface
	 sdl-load-bmp-rw
	 sdl-save-bmp-rw
	 sdl-load-bmp
	 sdl-save-bmp
	 sdl-set-surface-rle
	 sdl-set-color-key
	 sdl-get-color-key
	 sdl-set-surface-color-mod
	 sdl-get-surface-color-mod
	 sdl-set-surface-alpha-mod
	 sdl-get-surface-alpha-mod
	 sdl-set-surface-blend-mode
	 sdl-get-surface-blend-mode
	 sdl-set-clip-rect
	 sdl-get-clip-rect
	 sdl-convert-surface
	 sdl-convert-surface-format
	 sdl-convert-pixels
	 sdl-fill-rect
	 sdl-fill-rects
	 sdl-upper-blit
	 sdl-lower-blit
	 sdl-soft-stretch
	 sdl-upper-blit-scaled
	 sdl-lower-blit-scaled

	 ;;types
	 sdl-surface-t
	 sdl-blit-map-t

	 ;;SCANCODE
	 sdl-scancode sdl-scancode-t

	 ;;RWOPS
	 sdl-rw-from-file
	 sdl-rw-from-fp
	 sdl-rw-from-mem
	 sdl-rw-from-const-mem
	 sdl-alloc-rw
	 sdl-free-rw
	 sdl-read-u8
	 sdl-read-l-e16
	 sdl-read-b-e16
	 sdl-read-l-e32
	 sdl-read-b-e32
	 sdl-read-l-e64
	 sdl-read-b-e64

	 ;;types
	 sdl-rw-ops-t

	 ;;GESTURE
	 sdl-record-gesture
	 sdl-save-all-dollar-templates
	 sdl-save-dollar-template
	 sdl-load-dollar-templates
	 ;;types
	 sdl-gesture-id-t

	 ;;GAMECONTROLLER
	 sdl-game-controller-add-mappings-from-rw
	 sdl-game-controller-add-mapping
	 ;sdl-game-controller-mapping-for-guid
	 sdl-game-controller-mapping
	 sdl-is-game-controller
	 sdl-game-controller-name-for-index
	 sdl-game-controller-open
	 sdl-game-controller-name
	 sdl-game-controller-get-attached
	 sdl-game-controller-get-joystick
	 sdl-game-controller-event-state
	 sdl-game-controller-update
	 sdl-game-controller-get-axis-from-string
	 sdl-game-controller-get-string-for-axis
	 sdl-game-controller-get-bind-for-axis
	 sdl-game-controller-get-axis
	 sdl-game-controller-get-button-from-string
	 sdl-game-controller-get-string-for-button
	 sdl-game-controller-get-bind-for-button
	 sdl-game-controller-get-button
	 sdl-game-controller-close

	 ;types
	 sdl-game-controller-t
	 sdl-controller-bind-type
	 sdl-controller-bind-type-t
	 sdl-controller-axis-invalid
	 
	 sdl-game-controller-axis-t

	 ;;AUDIO
	 sdl-get-num-audio-drivers
	 sdl-get-audio-driver
	 sdl-audio-init
	 sdl-audio-quit
	 sdl-get-current-audio-driver
	 sdl-open-audio
	 sdl-get-num-audio-devices
	 sdl-get-audio-device-name
	 sdl-open-audio-device
	 sdl-get-audio-status
	 sdl-get-audio-device-status
	 sdl-pause-audio
	 sdl-pause-audio-device
	 sdl-load-wav-rw
	 sdl-free-wav
	 sdl-build-audio-cvt
	 sdl-convert-audio
	 sdl-mix-audio
	 sdl-mix-audio-format
	 sdl-lock-audio
	 sdl-lock-audio-device
	 sdl-unlock-audio
	 sdl-unlock-audio-device
	 sdl-close-audio
	 sdl-close-audio-device
					;types
	 sdl-audio-device-id-t
	 sdl-audio-status
	 sdl-audio-format-t
	 sdl-audio-callback-t
	 sdl-audio-spec-t
	 sdl-audio-cvt-t

	 ;;ATOMIC
	 sdl-atomic-try-lock
	 sdl-atomic-lock
	 sdl-atomic-unlock
	 sdl-atomic-cas
	 sdl-atomic-set
	 sdl-atomic-get
	 sdl-atomic-add
	 sdl-atomic-cas-ptr
	 sdl-atomic-set-ptr
	 sdl-atomic-get-ptr

	 ;;types
	 sdl-spin-lock-t
	 sdl-atomic-t

	 ;;ASSERT
	 sdl-report-assertion
	 sdl-set-assertion-handler
	 sdl-get-default-assertion-handler
	 sdl-get-assertion-handler
	 sdl-get-assertion-report
	 sdl-reset-assertion-report
	 )

 (import (chezscheme) 
	 (ffi-utils)
	 (only (srfi s1 lists) fold)
	 (only (thunder-utils) string-replace string-split) 
	 (only (srfi s13 strings) string-delete string-suffix? string-prefix?)
	 (srfi s14 char-sets))
 

 (include "sdl2/ffi.ss")
 (include "sdl2/base-types.ss")
 








 (include "sdl2/guardian.ss")




 (include "sdl2/error-types.ss")
 (include "sdl2/error-functions.ss")






 (include "sdl2/assert-types.ss")
 (include "sdl2/assert-functions.ss")
 (include "sdl2/render-types.ss")
 (include "sdl2/render-functions.ss")
 



 (include "sdl2/blendmode-types.ss")








 (include "sdl2/clipboard-functions.ss")

 (include "sdl2/cpuinfo-functions.ss")




 (include "sdl2/endian-functions.ss")






 (include "sdl2/hints-types.ss")
 (include "sdl2/hints-functions.ss")






 (include "sdl2/rect-types.ss")
 (include "sdl2/rect-functions.ss")






 (include "sdl2/scancode-types.ss")

 (include "sdl2/keycode-types.ss")

 (include "sdl2/keyboard-types.ss")
 (include "sdl2/keyboard-functions.ss")


 (include "sdl2/pixels-types.ss")
 (include "sdl2/pixels-functions.ss")

 (include "sdl2/surface-types.ss")
 (include "sdl2/surface-functions.ss")


 (define (sdl-load-bmp filename) 




   (let ([rw (sdl-rw-from-file filename "rb")])
     (assert (not (ftype-pointer-null? rw)))
     (sdl-load-bmp-rw rw 0)))

 (define (sdl-save-bmp surface filename) 



   (let ([rw (sdl-rw-from-file filename  "wb")])
     (assert (not (ftype-pointer-null? rw)))
     (sdl-save-bmp-rw surface rw 0)))



 (include "sdl2/filesystem-functions.ss")

 (include "sdl2/video-types.ss")
 (include "sdl2/video-functions.ss")

 (include "sdl2/messagebox-types.ss")
 (include "sdl2/messagebox-functions.ss")

 (include "sdl2/version-types.ss")
 (include "sdl2/version-functions.ss")

 (include "sdl2/mouse-types.ss")
 (include "sdl2/mouse-functions.ss")

 (include "sdl2/touch-types.ss")
 (include "sdl2/touch-functions.ss")

 (include "sdl2/mutex-types.ss")
 (include "sdl2/mutex-functions.ss")

 (include "sdl2/rwops-types.ss")
 (include "sdl2/rwops-functions.ss")

 (include "sdl2/timer-types.ss")
 (include "sdl2/timer-functions.ss")


 (include "sdl2/thread-types.ss")
 (include "sdl2/thread-functions.ss")

 (include "sdl2/gesture-types.ss")
 (include "sdl2/gesture-functions.ss")

 (include "sdl2/joystick-types.ss")
 (include "sdl2/joystick-functions.ss")

 (include "sdl2/gamecontroller-types.ss")
 (include "sdl2/gamecontroller-functions.ss")

 (include "sdl2/audio-types.ss")
 (include "sdl2/audio-functions.ss")

 (include "sdl2/events-types.ss")
 (include "sdl2/events-functions.ss")
 (include "sdl2/atomic-types.ss")
 (include "sdl2/atomic-functions.ss")

 (include "sdl2/main-functions.ss") 

 (include "sdl2/sdl-functions.ss")

 (include "sdl2/init.ss")

)

Added sdl2/assert-functions.ss.













>
>
>
>
>
>
1
2
3
4
5
6
(define-sdl-func sdl-assert-state-t sdl-report-assertion ((data (* sdl-assert-data-t)) (a string) (b string) (c int)) "SDL_ReportAssertion")
(define-sdl-func void sdl-set-assertion-handler ((handler sdl-assertion-handler-t) (userdata void*)) "SDL_SetAssertionHandler")
(define-sdl-func sdl-assertion-handler-t sdl-get-default-assertion-handler () "SDL_GetDefaultAssertionHandler")
(define-sdl-func sdl-assertion-handler-t sdl-get-assertion-handler ((puserdata (* void*))) "SDL_GetAssertionHandler")
(define-sdl-func (* sdl-assert-data-t) sdl-get-assertion-report () "SDL_GetAssertionReport")
(define-sdl-func void sdl-reset-assertion-report () "SDL_ResetAssertionReport")

Added sdl2/assert-types.ss.































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

 (define-enumeration* sdl-assert-state
   (retry break abort ignore always-ignore))

 (define-ftype sdl-assert-data-t
   (struct 
    (always-ignore int)
    (trigger-count unsigned-int)
    (condition (* char))
    (filename (* char))
    (linenum int)
    (function (* char))
    (next (* sdl-assert-data-t))))
 (define-ftype sdl-assertion-handler-t void*)

Added sdl2/atomic-functions.ss.





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
(define-sdl-func sdl-bool-t sdl-atomic-try-lock ((lock (* sdl-spin-lock-t))) "SDL_AtomicTryLock")
(define-sdl-func void sdl-atomic-lock ((lock (* sdl-spin-lock-t))) "SDL_AtomicLock")
(define-sdl-func void sdl-atomic-unlock ((lock (* sdl-spin-lock-t))) "SDL_AtomicUnlock")
(define-sdl-func sdl-bool-t sdl-atomic-cas ((a (* sdl-atomic-t)) (oldval int) (newval int)) "SDL_AtomicCAS")
(define-sdl-func int sdl-atomic-set ((a (* sdl-atomic-t)) (v int)) "SDL_AtomicSet")
(define-sdl-func int sdl-atomic-get ((a (* sdl-atomic-t))) "SDL_AtomicGet")
(define-sdl-func int sdl-atomic-add ((a (* sdl-atomic-t)) (v int)) "SDL_AtomicAdd")
(define-sdl-func sdl-bool-t sdl-atomic-cas-ptr ((a (* void*)) (oldval void*) (newval void*)) "SDL_AtomicCASPtr")
(define-sdl-func void* sdl-atomic-set-ptr ((a (* void*)) (v void*)) "SDL_AtomicSetPtr")
(define-sdl-func void* sdl-atomic-get-ptr ((a (* void*))) "SDL_AtomicGetPtr")

Added sdl2/atomic-types.ss.







>
>
>
1
2
3

 (define-ftype sdl-spin-lock-t int)
 (define-ftype sdl-atomic-t int)

Added sdl2/audio-functions.ss.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-sdl-func int sdl-get-num-audio-drivers () "SDL_GetNumAudioDrivers")
(define-sdl-func string sdl-get-audio-driver ((index int)) "SDL_GetAudioDriver")
(define-sdl-func int sdl-audio-init ((driver_name string)) "SDL_AudioInit")
(define-sdl-func void sdl-audio-quit () "SDL_AudioQuit")
(define-sdl-func string sdl-get-current-audio-driver () "SDL_GetCurrentAudioDriver")
(define-sdl-func int sdl-open-audio ((desired (* sdl-audio-spec-t)) (obtained (* sdl-audio-spec-t))) "SDL_OpenAudio")
(define-sdl-func int sdl-get-num-audio-devices ((iscapture int)) "SDL_GetNumAudioDevices")
(define-sdl-func string sdl-get-audio-device-name ((index int) (iscapture int)) "SDL_GetAudioDeviceName")
(define-sdl-func sdl-audio-device-id-t sdl-open-audio-device ((device string) (iscapture int) (desired (* sdl-audio-spec-t)) (obtained (* sdl-audio-spec-t)) (allowed_changes int)) "SDL_OpenAudioDevice")
(define-sdl-func sdl-audio-status-t sdl-get-audio-status () "SDL_GetAudioStatus")
(define-sdl-func sdl-audio-status-t sdl-get-audio-device-status ((dev sdl-audio-device-id-t)) "SDL_GetAudioDeviceStatus")
(define-sdl-func void sdl-pause-audio ((pause_on int)) "SDL_PauseAudio")
(define-sdl-func void sdl-pause-audio-device ((dev sdl-audio-device-id-t) (pause_on int)) "SDL_PauseAudioDevice")
(define-sdl-func (* sdl-audio-spec-t) sdl-load-wav-rw ((src (* sdl-rw-ops-t)) (freesrc int) (spec (* sdl-audio-spec-t)) (audio_buf (* uint8)) (audio_len (* uint32))) "SDL_LoadWAV_RW")
(define-sdl-func void sdl-free-wav ((audio_buf (* uint8))) "SDL_FreeWAV")
(define-sdl-func int sdl-build-audio-cvt ((cvt (* sdl-audio-cvt-t)) (src_format sdl-audio-format-t) (src_channels uint8) (src_rate int) (dst_format sdl-audio-format-t) (dst_channels uint8) (dst_rate int)) "SDL_BuildAudioCVT")
(define-sdl-func int sdl-convert-audio ((cvt (* sdl-audio-cvt-t))) "SDL_ConvertAudio")
(define-sdl-func void sdl-mix-audio ((dst (* uint8)) (src (* uint8)) (len uint32) (volume int)) "SDL_MixAudio")
(define-sdl-func void sdl-mix-audio-format ((dst (* uint8)) (src (* uint8)) (format sdl-audio-format-t) (len uint32) (volume int)) "SDL_MixAudioFormat")
(define-sdl-func void sdl-lock-audio () "SDL_LockAudio")
(define-sdl-func void sdl-lock-audio-device ((dev sdl-audio-device-id-t)) "SDL_LockAudioDevice")
(define-sdl-func void sdl-unlock-audio () "SDL_UnlockAudio")
(define-sdl-func void sdl-unlock-audio-device ((dev sdl-audio-device-id-t)) "SDL_UnlockAudioDevice")
(define-sdl-func void sdl-close-audio () "SDL_CloseAudio")
(define-sdl-func void sdl-close-audio-device ((dev sdl-audio-device-id-t)) "SDL_CloseAudioDevice")

Added sdl2/audio-types.ss.







































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

 (define-ftype sdl-audio-device-id-t uint32)
 (define-enumeration* sdl-audio-status
   (stopped playing paused))
 (define-ftype sdl-audio-format-t uint16)
 (define-ftype sdl-audio-callback-t void*)
 (define-ftype sdl-audio-spec-t
   (struct 
    (freq int)
    (format sdl-audio-format-t)
    (channels uint8)
    (silence uint8)
    (samples uint16)
    (padding uint16)
    (size uint32)
    (callback sdl-audio-callback-t)
    (userdata void*)))
 (define-ftype sdl-audio-cvt-t (struct))

Added sdl2/base-types.ss.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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


 (define-ftype sdl-bool-t boolean)
 (define-ftype uint8 unsigned-8)
 (define-ftype uint16 unsigned-16)
 (define-ftype sint16 integer-16)
 (define-ftype uint32 unsigned-32)
 (define-ftype sint32 integer-32)
 (define-ftype sint64 integer-64)
 (define-ftype uint64 integer-64)
 (define-ftype va-list void*)
 (define-ftype int% int)
 (define-ftype file (struct))

 (define-ftype sdl-iconv-t void*)

 ;; Conditions
 (define-record-type (&sdl2 make-sdl2-condition $sdl2-condition?)
   (parent &condition)
   (fields (immutable status $sdl2-condition-status)))

 (define rtd (record-type-descriptor &sdl2))
 (define sdl2-condition? (condition-predicate rtd))
 (define sdl2-status (condition-accessor rtd $sdl2-condition-status))

Added sdl2/blendmode-types.ss.











>
>
>
>
>
1
2
3
4
5
 (define-flags sdl-blend-mode
   (none 0)
   (blend 1)
   (add 2)
   (mod 4))

Added sdl2/clipboard-functions.ss.







>
>
>
1
2
3
(define-sdl-func int sdl-set-clipboard-text ((text string)) "SDL_SetClipboardText")
(define-sdl-func string sdl-get-clipboard-text () "SDL_GetClipboardText")
(define-sdl-func sdl-bool-t sdl-has-clipboard-text () "SDL_HasClipboardText")

Added sdl2/cpuinfo-functions.ss.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
(define-sdl-func int sdl-get-cpu-count () "SDL_GetCPUCount")
(define-sdl-func int sdl-get-cpu-cache-line-size () "SDL_GetCPUCacheLineSize")
(define-sdl-func sdl-bool-t sdl-has-rdtsc () "SDL_HasRDTSC")
(define-sdl-func sdl-bool-t sdl-has-alti-vec () "SDL_HasAltiVec")
(define-sdl-func sdl-bool-t sdl-has-mmx () "SDL_HasMMX")
(define-sdl-func sdl-bool-t sdl-has3-d-now () "SDL_Has3DNow")
(define-sdl-func sdl-bool-t sdl-has-sse () "SDL_HasSSE")
(define-sdl-func sdl-bool-t sdl-has-ss-e2 () "SDL_HasSSE2")
(define-sdl-func sdl-bool-t sdl-has-ss-e3 () "SDL_HasSSE3")
(define-sdl-func sdl-bool-t sdl-has-ss-e41 () "SDL_HasSSE41")
(define-sdl-func sdl-bool-t sdl-has-ss-e42 () "SDL_HasSSE42")
(define-sdl-func sdl-bool-t sdl-has-avx () "SDL_HasAVX")
(define-sdl-func int sdl-get-system-ram () "SDL_GetSystemRAM")

Added sdl2/endian-functions.ss.









>
>
>
>
1
2
3
4
(define-sdl-func uint16 sdl-swap16 ((x uint16)) "SDL_Swap16")
(define-sdl-func uint32 sdl-swap32 ((x uint32)) "SDL_Swap32")
(define-sdl-func uint64 sdl-swap64 ((x uint64)) "SDL_Swap64")
(define-sdl-func float sdl-swap-float ((x float)) "SDL_SwapFloat")

Added sdl2/error-functions.ss.









>
>
>
>
1
2
3
4
(define-sdl-func int sdl-set-error ((fmt string)) "SDL_SetError")
(define-sdl-func string sdl-get-error () "SDL_GetError")
(define-sdl-func void sdl-clear-error () "SDL_ClearError")
(define-sdl-func int sdl-error ((code sdl-errorcode-t)) "SDL_Error")

Added sdl2/error-types.ss.







>
>
>
1
2
3

 (define-enumeration* sdl-errorcode
   (enomem efread efwrite efseek unsupported lasterror))

Added sdl2/events-functions.ss.



































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(define-sdl-func void sdl-pump-events () "SDL_PumpEvents")
(define-sdl-func int sdl-peep-events ((events (* sdl-event-t)) (numevents int) (action sdl-eventaction-t) (minType uint32) (maxType uint32)) "SDL_PeepEvents")
(define-sdl-func sdl-bool-t sdl-has-event ((type uint32)) "SDL_HasEvent")
(define-sdl-func sdl-bool-t sdl-has-events ((minType uint32) (maxType uint32)) "SDL_HasEvents")
(define-sdl-func void sdl-flush-event ((type uint32)) "SDL_FlushEvent")
(define-sdl-func void sdl-flush-events ((minType uint32) (maxType uint32)) "SDL_FlushEvents")
(define-sdl-func int sdl-poll-event ((event (* sdl-event-t))) "SDL_PollEvent")
(define-sdl-func int sdl-wait-event ((event (* sdl-event-t))) "SDL_WaitEvent")
(define-sdl-func int sdl-wait-event-timeout ((event (* sdl-event-t)) (timeout int)) "SDL_WaitEventTimeout")
(define-sdl-func int sdl-push-event ((event (* sdl-event-t))) "SDL_PushEvent")
(define-sdl-func void sdl-set-event-filter ((filter sdl-event-filter-t) (userdata void*)) "SDL_SetEventFilter")
(define-sdl-func sdl-bool-t sdl-get-event-filter ((filter (* sdl-event-filter-t)) (userdata (* void*))) "SDL_GetEventFilter")
(define-sdl-func void sdl-add-event-watch ((filter sdl-event-filter-t) (userdata void*)) "SDL_AddEventWatch")
(define-sdl-func void sdl-del-event-watch ((filter sdl-event-filter-t) (userdata void*)) "SDL_DelEventWatch")
(define-sdl-func void sdl-filter-events ((filter sdl-event-filter-t) (userdata void*)) "SDL_FilterEvents")
(define-sdl-func uint8 sdl-event-state ((type uint32) (state int)) "SDL_EventState")
(define-sdl-func uint32 sdl-register-events ((numevents int)) "SDL_RegisterEvents")

Added sdl2/events-types.ss.





































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

(define-flags sdl-event-type
    (firstevent       0 ) ;     /**< unused (do not remove) */

    ;/* application events */
    (quit             #x100) ; /**< user-requested quit */

    ;/* these application events have special meaning on ios, see readme-ios.txt for details */
    (app-terminating   #x101);        /**< the application is being terminated by the os
                                 ;    called on ios in applicationwillterminate()
                                 ;    called on android in ondestroy()
                                
    (app-lowmemory   #x102) ;,          /**< the application is low on memory, free memory if possible.
                                 ;    called on ios in applicationdidreceivememorywarning()
                                 ;    called on android in onlowmemory()
                                
    (app-willenterbackground   #x103) ;,  /**< the application is about to enter the background
                                    ; called on ios in applicationwillresignactive()
                                    ; called on android in onpause()
                                 
    (app-didenterbackground   #x104) ;/**< the application did enter the background and may not get cpu for some time
                                     ;called on ios in applicationdidenterbackground()
                                     ;called on android in onpause()
                                
    (app-willenterforeground   #x105) ;/**< the application is about to enter the foreground
                                 ;    called on ios in applicationwillenterforeground()
                                 ;    called on android in onresume()
        
    (app-didenterforeground   #x106); /**< the application is now interactive
                                     ;called on ios in applicationdidbecomeactive()
                                     ;called on android in onresume()
                                     ;*/

   ;   /* window events */
    (windowevent      #x200); /**< window state change */
    (syswmevent       #x201); /**< system specific event */

    ;/* keyboard events */
    (keydown          #x300); /**< key pressed */
    (keyup            #x301); /**< key released */
    (textediting      #x302); /**< keyboard text editing (composition) */
    (textinput        #x303); /**< keyboard text input */

    ;* mouse events */
   (mousemotion       #x400);/**< mouse moved */
   (mousebuttondown   #x401);**< mouse button pressed */
   (mousebuttonup     #x402);**< mouse button released */
   (mousewheel        #x403);**< mouse wheel motion */

    ;* joystick events */
   (joyaxismotion    #x600);/**< joystick axis motion */
   (joyballmotion    #x601);/**< joystick trackball motion */
   (joyhatmotion     #x602);/**< joystick hat position change */
   (joybuttondown    #x603);/**< joystick button pressed */
   (joybuttonup      #x604);/**< joystick button released */
   (joydeviceadded   #x605);/**< a new joystick has been inserted into the system */
   (joydeviceremoved   #x606);1< an opened joystick has been removed */

   ;/* game controller events */
   (controlleraxismotion    #x650);/**< game controller axis motion */
   (controllerbuttondown    #x651);/**< game controller button pressed */
   (controllerbuttonup      #x652);/**< game controller button released */
   (controllerdeviceadded   #x653);/**< a new game controller has been inserted into the system */
   (controllerdeviceremoved   #x654);*< an opened game controller has been removed */
   (controllerdeviceremapped   #x655);*< the controller mapping was updated */

    ;* touch events */
   (fingerdown        #x700)
   (fingerup          #x701)
   (fingermotion      #x702)

    ;* gesture events */
   (dollargesture     #x800)
   (dollarrecord      #x801)
   (multigesture      #x802)

    ;* clipboard events */
   (clipboardupdate   #x900);/**< the clipboard changed */

    ;* drag and drop events */
   (dropfile          #x1000);/**< the system requests a file open */

    ;* render events */
   (render-targets-reset   #x2000);/**< the render targets have been reset */

  ; /** events ::userevent through ::lastevent are for your use,
  ;  *  and should be allocated with registerevents()
  ;  */
   (userevent      #x8000)

  ; /**
  ;  *  this last event is only for bounding internal arrays
  ;  */
   (lastevent      #xffff))

; Fields shared by every event
(define-ftype sdl-common-event-t
  (struct
   (type uint32)
   (timestamp uint32)))

 (define-ftype sdl-common-event-t* void*)

; Window state change event data (event.window.*)
(define-ftype sdl-window-event-t
  (struct
    (type uint32) ;        /**< ::SDL_WINDOWEVENT */
    (timestamp uint32)
    (window-id uint32);    /**< The associated window */
    (event uint8);        /**< ::SDL_WindowEventID */
    (padding1 uint8)
    (padding2 uint8)
    (padding3 uint8)
    (data1 sint32);       /**< event dependent data */
    (data2 sint32))) ;       /**< event dependent data */

; Keyboard button event structure (event.key.*)
(define-ftype sdl-keyboard-event-t
  (struct
    (type uint32) ;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
    (timestamp uint32)
    (window-id uint32) ;    /**< The window with keyboard focus, if any */
    (state uint8) ;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
    (repeat uint8) ;       /**< Non-zero if this is a key repeat */
    (padding2 uint8) 
    (padding3 uint8) 
    (keysym sdl-keysym-t)))  ;  /**< The key that was pressed or released */

(define-syntax sdl-texteditingevent-text-size (identifier-syntax 32))

; Keyboard text editing event structure (event.edit.*)
  (define-ftype sdl-text-editing-event-t
    (struct
     (type uint32)        ;                                /**< ::SDL_TEXTEDITING */
     (timestamp uint32)   
     (window-id uint32)   ;                            /**< The window with keyboard focus, if any */
     (text (array 32 char))     ; sdl-texteditingevent-text-size  /**< The editing text */
     (start sint32)   ;                               /**< The start cursor of selected editing text */
     (length sint32))) ;                              /**< The length of selected editing text */
 
(define-syntax sdl-textinputevent-text-size (identifier-syntax 32))

; Keyboard text input event structure (event.text.*)
(define-ftype sdl-text-input-event-t
  (struct
   (type uint32) ;                              /**< ::SDL_TEXTINPUT */
   (timestamp uint32);
   (window-id uint32);                          /**< The window with keyboard focus, if any */
   (text (array 32 char)))) ;sdl-textinputevent-text-size  /**< The input text */

; Mouse motion event structure (event.motion.*)
(define-ftype sdl-mouse-motion-event-t
  (struct
     (type uint32);        /**< ::SDL_MOUSEMOTION */
     (timestamp uint32);
     (window-id uint32);    /**< The window with mouse focus, if any */
     (which uint32);       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
     (state uint32);       /**< The current button state */
     (x sint32);           /**< X coordinate, relative to window */
     (y sint32);           /**< Y coordinate, relative to window */
     (xrel sint32);        /**< The relative motion in the X direction */
     (yrel sint32)));        /**< The relative motion in the Y direction */

; Mouse button event structure (event.button.*)
(define-ftype sdl-mouse-button-event-t
  (struct
    (type uint32);        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
    (timestamp uint32);
    (window-id uint32);    /**< The window with mouse focus, if any */
    (which uint32);       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
    (button uint8);       /**< The mouse button index */
    (state uint8);        /**< ::SDL_PRESSED or ::SDL_RELEASED */
    (clicks uint8);       /**< 1 for single-click, 2 for double-click, etc. */
    (padding1 uint8);
    (x sint32);           /**< X coordinate, relative to window */
    (y sint32)));           /**< Y coordinate, relative to window */

;  Mouse wheel event structure (event.wheel.*)
(define-ftype sdl-mouse-wheel-event-t
  (struct
   (type uint32);        /**< ::SDL_MOUSEWHEEL */
   (timestamp uint32);
   (window-id uint32);     /**< The window with mouse focus, if any */
   (which uint32);       /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
   (x sint32);           /**< The amount scrolled horizontally, positive to the right and negative to the left */
   (y sint32)));           /**< The amount scrolled vertically, positive away from the user and negative toward the user */

;; JOYSTICK AND CONTROLLERS ARE NOT OF MY INTEREST BUT YOU CAN IMPLEMENT THEM AS HOMEWORK


; Touch finger event structure (event.tfinger.*)
(define-ftype sdl-touch-finger-event-t
  (struct
   (type uint32);        /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
   (timestamp uint32);
    (touch-id sdl-touch-id-t); /**< The touch device id */
    (finger-id sdl-finger-id-t);
    (x float);            /**< Normalized in the range 0...1 */
    (y float);            /**< Normalized in the range 0...1 */
    (dx float);           /**< Normalized in the range 0...1 */
    (dy float);           /**< Normalized in the range 0...1 */
    (pressure float)))

; Multiple Finger Gesture Event (event.mgesture.*)
(define-ftype sdl-multi-gesture-event-t
  (struct
   (type uint32);        /**< ::SDL_MULTIGESTURE */
    (timestamp uint32);
    (touch-id sdl-touch-id-t); /**< The touch device index */
    (d-theta float)
    (d-dist float)
    (x float)
    (y float)
    (num-fingers uint16)
    (padding uint16)))


; Begin Recording a gesture on the specified touch, or all touches (-1)
;(define-sdl-func int% SDL_RecordGesture ((touch-id sdl-touch-id)))

;; ;(define-sdl-func int SDL_SaverAllDollarTemplates (SDL_RWops*))
;; ;(define-sdl-func int SDL_SaveDollarTemplate (SDL_GestureID SDL_RWops*))

; Dollar Gesture Event (event.dgesture.*)
(define-ftype sdl-dollar-gesture-event-t
  (struct
   (type uint32);        /**< ::SDL_DOLLARGESTURE */
    (timestamp uint32);
    (touch-id sdl-touch-id-t); /**< The touch device id */
    (gesture-id sdl-gesture-id-t);
    (num-fingers uint32)
    (error float);
    (x float);            /**< Normalized center of gesture */
    (y float)))

; An event used to request a file open by the system (event.drop.*)
; This event is disabled by default, you can enable it with SDL_EventState()
;: If you enable this event, you must free the filename in the event.
(define-ftype sdl-drop-event-t
  (struct
   (type uint32);        /**< ::SDL_DROPFILE */
   (timestamp uint32);
   (filename void*)));         /**< The file name, which should be freed with SDL_free() */

; The "quit requested" event
(define-ftype sdl-quit-event-t
  (struct 
   (type uint32) ; /**< ::SDL_QUIT */
   (timestamp uint32)))
; A user-defined event type (event.user.*)

(define-ftype sdl-user-event-t
  (struct
   (type uint32)      ;  /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
   (timestamp uint32)
   (window-id uint32) ;   /**< The associated window if any */
   (code sint32)  ;      /**< User defined event code */
   (data1 void*)  ;      /**< User defined data pointer */
   (data2 void*)));        /**< User defined data pointer */

(define-ftype sdl-sys-wm-msg (struct))

; *  \brief A video driver dependent system event (event.syswm.*)
; *         This event is disabled by default, you can enable it with SDL_EventState()
; *
; *  \note If you want to use this event, you should include SDL_syswm.h.

(define-ftype sdl-sys-wm-event-t
  (struct
   (type uint32)        ;/**< ::SDL_SYSWMEVENT */
   (timestamp uint32)
   (msg (* sdl-sys-wm-msg))))  ;/**< driver dependent data, defined in SDL_syswm.h */

(define-ftype sdl-joy-axis-event-t (struct))
(define-ftype sdl-joy-hat-event-t (struct))
(define-ftype sdl-joy-device-event-t (struct))
(define-ftype sdl-joy-button-event-t (struct))
(define-ftype sdl-joy-ball-event-t (struct))
(define-ftype sdl-controller-button-event-t (struct))
(define-ftype sdl-controller-device-event-t (struct))
(define-ftype sdl-joystick-id-t sint32)
(define-ftype sdl-controller-axis-event-t 
  (struct
   (type uint32)
   (timestamp uint32)
   (which sdl-joystick-id-t)
   (axis uint8)
   (padding1 uint8)
   (padding2 uint8)
   (padding3 uint8)
   (value sint16)
   (padding4 uint16)))

(define-ftype sdl-event-t
  (union
   (type uint32)                    ; /**< Event type, shared with all events */
   (common sdl-common-event-t)         ; /**< Common event data */
   (window sdl-window-event-t)         ; /**< Window event data */
   (key sdl-keyboard-event-t)          ; /**< Keyboard event data */
   (edit sdl-text-editing-event-t)      ; /**< Text editing event data */
   (text sdl-text-input-event-t)        ; /**< Text input event data */
   (motion sdl-mouse-motion-event-t)    ; /**< Mouse motion event data */
   (button sdl-mouse-button-event-t)    ; /**< Mouse button event data */
   (wheel sdl-mouse-wheel-event-t)      ; /**< Mouse wheel event data */
   (jaxis sdl-joy-axis-event-t)         ; /**< Joystick axis event data */
   (jball sdl-joy-ball-event-t)         ; /**< Joystick ball event data */
   (jhat sdl-joy-hat-event-t)           ; /**< Joystick hat event data */
   (jbutton sdl-joy-button-event-t)     ; /**< Joystick button event data */
   (jdevice sdl-joy-device-event-t)     ; /**< Joystick device change event data */
   (caxis sdl-controller-axis-event-t)      ; /**< Game Controller axis event data */
   (cbutton sdl-controller-button-event-t)  ; /**< Game Controller button event data */
   (cdevice sdl-controller-device-event-t)  ; /**< Game Controller device event data */
   (quit sdl-quit-event-t)             ; /**< Quit request event data */
   (user sdl-user-event-t)             ; /**< Custom event data */
   (syswm sdl-sys-wm-event-t)           ; /**< System dependent window event data */
   (tfinger sdl-touch-finger-event-t)   ; /**< Touch finger event data */
   (mgesture sdl-multi-gesture-event-t) ; /**< Gesture event data */
   (dgesture sdl-dollar-gesture-event-t) ; /**< Gesture event data */
   (drop sdl-drop-event-t)             ; /**< Drag and drop event data */

    ;; /* This is necessary for ABI compatibility between Visual C++ and GCC
    ;;    Visual C++ will respect the push pack pragma and use 52 bytes for
    ;;    this structure, and GCC will use the alignment of the largest datatype
    ;;    within the union, which is 8 bytes.

    ;;    So... we'll add padding to force the size to be 56 bytes for both.
    ;; */
   (padding (array 56 uint8))))

(define-enumeration* sdl-eventaction 
  (add peek get))
 
(define-ftype sdl-event-filter-t void*) ;FIXME (function (void* sdl-event*) int))

(define sdl-query -1)
(define sdl-ignore 0)
(define sdl-disable 0)
(define sdl-enable 1)

Added sdl2/ffi.ss.



















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
	
 (define-syntax define-ftype-allocator 
   (lambda (x)
     (syntax-case x () 
       [(_ name type) 
	#'(define (name) 
	    (sdl-guard-pointer (make-ftype-pointer type (foreign-alloc (ftype-sizeof type)))))])))

 (define-syntax define-sdl-func
   (lambda (x)
     (define (anti-camel x)
       (let* ([x (string-replace x #\_ #\-)]
	      [len (string-length x)]
	      [s (list->string
		  (reverse
		   (fold (lambda (i acc) 
			   (let ([a (string-ref x i)] 
				 [b (if (< (+ 1 i) len) (string-ref x (+ 1 i)) #f)]
				 [c (if (> i 0) (string-ref x (- i 1)) #f)])
			     (if (and (char-upper-case? a) 
				      b (not (char-upper-case? b)) c (not (char-upper-case? c)))
				 (cons (char-downcase a) (if (and c (char=? c #\-)) acc (cons #\- acc)))
				 (cons (char-downcase a) acc)))) '() (iota len))))])
	 
	 s))
     
     (define (rename-scheme->c type)
       (cond [(case (syntax->datum type)
		[(unknown) 'unknown]
		[else #f])
	      => (lambda (t)
		   (datum->syntax type t))]
	     [else type]))

     (define (convert-scheme->c function-name name type)
       name)

     (define (datum->string x)
       (symbol->string (syntax->datum x)))

     (define (string->datum t x)
       (datum->syntax t (string->symbol x)))

     (syntax-case x ()
       [(_ ret-type name ((arg-name arg-type) ...) c-name) 
	(with-syntax (;[name/string (datum->string #'name)]
		      ;[name (string->datum #'name (anti-camel (datum->string #'name)))]
		      [(renamed-type ...) (map rename-scheme->c #'(arg-type ...))]
		      [renamed-ret (rename-scheme->c #'ret-type)]
		      [function-ftype (datum->syntax #'name (string->symbol (string-append (symbol->string (syntax->datum #'name)) "-ft")))]
		      [((arg-name arg-convert) ...) (map (lambda (n t) 
							   (list n (convert-scheme->c #'name n t))) 
							 #'(arg-name ...) #'(arg-type ...))])
		     #`(begin
			 (define (name arg-name ...) 
			   (define-ftype function-ftype (function (renamed-type ...) renamed-ret))
			   (let* ([function-fptr  (make-ftype-pointer function-ftype c-name)]
				  [function       (ftype-ref function-ftype () function-fptr)]
				  [arg-name arg-convert] ...)
			     (let ([result (function arg-name ...)])
			       #,(case (syntax->datum #'ret-type)
				   [(int%)             #'(if (< result 0) (raise (make-sdl2-condition (sdl-get-error result))))]
				   [((* sdl-texture-t)
				     (* sdl-surface-t)
				     (* sdl-cursor-t)
				     (* sdl-pixel-format-t)
				     (* sdl-palette-t)
				     (* sdl-rw-ops-t)
				     (* sdl-mutex-t)
				     (* sdl-window-t)
				     (* sdl-sem-t)
				     (* sdl-cond-t)
				     (* sdl-renderer-t))  #'(sdl-guard-pointer result)]
				   [else #'result]))))))])))
     
 (define-syntax new-struct
   (lambda (x)
     (syntax-case x ()
       [(_ ftype-name (field value) ... )
	#'(let ([object (make-ftype-pointer 
			 ftype-name
			 (foreign-alloc (ftype-sizeof ftype-name)))])
	    (ftype-set! ftype-name (field) object value) ...
	    (sdl-guard-pointer object))])))


;; This is useful if the c function returns values by reference (pointers)
;; the macro automatically allocates the variables and references the values after the call.
;;
(define-syntax sdl-let-ref-call
  (lambda (x)
    (syntax-case x ()
      [(k func (param ...) result body ...) 
       (with-syntax ([((var val) ...) (map (lambda (p)
					     (let ([p* (syntax->datum p)])
					       (if (pair? p*)
						   (list (datum->syntax #'k (car p*)) 
							 #`(sdl-guard-pointer 
							    (make-ftype-pointer 
							     #,(datum->syntax #'k (cadr p*))
							     (foreign-alloc 
							      (ftype-sizeof #,(datum->syntax #'k (cadr p*)))))))
						   (list p p)))) #'(param ...))])
		    (with-syntax
		     ([(val2 ...) (map (lambda (p v)
					     (let ([p* (syntax->datum p)])
					       (if (pair? p*)
						     (if (memq '& p*)
							 #`(ftype-&ref
							    #,(datum->syntax #'k (cadr p*))
							    ()
							    #,v)
							 #`(ftype-ref 
							    #,(datum->syntax #'k (cadr p*))
							    ()
							    #,v))
						   p))) #'(param ...) #'(var ...) )])
		     #'(let ([var val] ...)
			 (let ([result (func var ...)])
			   (let ((var val2) ...)
			     body ...)))))])))

Added sdl2/filesystem-functions.ss.





>
>
1
2
(define-sdl-func string sdl-get-base-path () "SDL_GetBasePath")
(define-sdl-func string sdl-get-pref-path ((org string) (app string)) "SDL_GetPrefPath")

Added sdl2/gamecontroller-functions.ss.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(define-sdl-func int sdl-game-controller-add-mappings-from-rw ((rw (* sdl-rw-ops-t)) (freerw int)) "SDL_GameControllerAddMappingsFromRW")
(define-sdl-func int sdl-game-controller-add-mapping ((mappingString string)) "SDL_GameControllerAddMapping")
;(define-sdl-func string sdl-game-controller-mapping-for-guid ((guid sdl-joystick-guid-t)) "SDL_GameControllerMappingForGUID")
(define-sdl-func string sdl-game-controller-mapping ((gamecontroller (* sdl-game-controller-t))) "SDL_GameControllerMapping")
(define-sdl-func sdl-bool-t sdl-is-game-controller ((joystick_index int)) "SDL_IsGameController")
(define-sdl-func string sdl-game-controller-name-for-index ((joystick_index int)) "SDL_GameControllerNameForIndex")
(define-sdl-func (* sdl-game-controller-t) sdl-game-controller-open ((joystick_index int)) "SDL_GameControllerOpen")
(define-sdl-func string sdl-game-controller-name ((gamecontroller (* sdl-game-controller-t))) "SDL_GameControllerName")
(define-sdl-func sdl-bool-t sdl-game-controller-get-attached ((gamecontroller (* sdl-game-controller-t))) "SDL_GameControllerGetAttached")
(define-sdl-func (* sdl-joystick-t) sdl-game-controller-get-joystick ((gamecontroller (* sdl-game-controller-t))) "SDL_GameControllerGetJoystick")
(define-sdl-func int sdl-game-controller-event-state ((state int)) "SDL_GameControllerEventState")
(define-sdl-func void sdl-game-controller-update () "SDL_GameControllerUpdate")
(define-sdl-func sdl-game-controller-axis-t sdl-game-controller-get-axis-from-string ((pchString string)) "SDL_GameControllerGetAxisFromString")
(define-sdl-func string sdl-game-controller-get-string-for-axis ((axis sdl-game-controller-axis-t)) "SDL_GameControllerGetStringForAxis")
(define-sdl-func sdl-game-controller-button-bind-t sdl-game-controller-get-bind-for-axis ((gamecontroller (* sdl-game-controller-t)) (axis sdl-game-controller-axis-t)) "SDL_GameControllerGetBindForAxis")
(define-sdl-func sint16 sdl-game-controller-get-axis ((gamecontroller (* sdl-game-controller-t)) (axis sdl-game-controller-axis-t)) "SDL_GameControllerGetAxis")
(define-sdl-func sdl-game-controller-button-t sdl-game-controller-get-button-from-string ((pchString string)) "SDL_GameControllerGetButtonFromString")
(define-sdl-func string sdl-game-controller-get-string-for-button ((button sdl-game-controller-button-t)) "SDL_GameControllerGetStringForButton")
(define-sdl-func sdl-game-controller-button-bind-t sdl-game-controller-get-bind-for-button ((gamecontroller (* sdl-game-controller-t)) (button sdl-game-controller-button-t)) "SDL_GameControllerGetBindForButton")
(define-sdl-func uint8 sdl-game-controller-get-button ((gamecontroller (* sdl-game-controller-t)) (button sdl-game-controller-button-t)) "SDL_GameControllerGetButton")
(define-sdl-func void sdl-game-controller-close ((gamecontroller (* sdl-game-controller-t))) "SDL_GameControllerClose")

Added sdl2/gamecontroller-types.ss.





























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14

 (define-ftype sdl-game-controller-t (struct))

 (define-enumeration* sdl-controller-bind-type 
   (none button axis hat))
 
 (define sdl-controller-axis-invalid -1)
 (define-enumeration*  sdl-controller-axis
   (left-x left-y right-x right-y trigger-left trigger-right))
 
;;TODO IMPLEMENT THIS
 (define-ftype sdl-game-controller-axis-t void*)
 (define-ftype sdl-game-controller-button-bind-t void*)
(define-ftype sdl-game-controller-button-t void*)

Added sdl2/gesture-functions.ss.









>
>
>
>
1
2
3
4
(define-sdl-func int sdl-record-gesture ((touchId sdl-touch-id-t)) "SDL_RecordGesture")
(define-sdl-func int sdl-save-all-dollar-templates ((dst (* sdl-rw-ops-t))) "SDL_SaveAllDollarTemplates")
(define-sdl-func int sdl-save-dollar-template ((gestureId sdl-gesture-id-t) (dst (* sdl-rw-ops-t))) "SDL_SaveDollarTemplate")
(define-sdl-func int sdl-load-dollar-templates ((touchId sdl-touch-id-t) (src (* sdl-rw-ops-t))) "SDL_LoadDollarTemplates")

Added sdl2/gesture-types.ss.







>
>
>
1
2
3

 (define-ftype sdl-gesture-id-t integer-64)

Added sdl2/guardian.ss.





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
(define sdl-guardian (make-guardian))

 (define (sdl-guard-pointer obj) 
   (sdl-free-garbage) 
   (sdl-guardian obj) 
   obj)
 
 (define sdl-free-garbage-func (lambda () (if #f #f)))
 (define (sdl-free-garbage-set-func f) (set! sdl-free-garbage-func f))
 (define (sdl-free-garbage) (sdl-free-garbage-func))

Added sdl2/hints-functions.ss.













>
>
>
>
>
>
1
2
3
4
5
6
(define-sdl-func sdl-bool-t sdl-set-hint-with-priority ((name string) (value string) (priority sdl-hint-priority-t)) "SDL_SetHintWithPriority")
(define-sdl-func sdl-bool-t sdl-set-hint ((name string) (value string)) "SDL_SetHint")
(define-sdl-func string sdl-get-hint ((name string)) "SDL_GetHint")
(define-sdl-func void sdl-add-hint-callback ((name string) (callback sdl-hint-callback-t) (userdata void*)) "SDL_AddHintCallback")
(define-sdl-func void sdl-del-hint-callback ((name string) (callback sdl-hint-callback-t) (userdata void*)) "SDL_DelHintCallback")
(define-sdl-func void sdl-clear-hints () "SDL_ClearHints")

Added sdl2/hints-types.ss.















>
>
>
>
>
>
>
1
2
3
4
5
6
7

(define-enumeration* sdl-hint-priority
  (default
    normal
    override))

(define-ftype sdl-hint-callback-t void*)

Added sdl2/init.ss.







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

 (define (sdl-library-init . l)  

   #;(import (only (sdl2 video) sdl-window-t sdl-destroy-window)
	   (only (sdl2 surface) sdl-surface-t sdl-free-surface)
	   (only (sdl2 render) sdl-texture-t sdl-destroy-texture sdl-renderer-t sdl-destroy-renderer)
	   (only (sdl2 mutex) sdl-mutex-t sdl-destroy-mutex sdl-cond-t sdl-destroy-cond)
	   (only (sdl2 mouse) sdl-cursor-t sdl-free-cursor)
	   (only (sdl2 pixels) sdl-pixel-format-t sdl-free-format sdl-palette-t sdl-free-palette)
	   (only (sdl2 rwops) sdl-rw-ops-t sdl-free-rw)	   
	   (only (sdl2 guardian) sdl-guardian sdl-free-garbage))
   (load-shared-object (if (null? l) "libSDL2.so" l))
   (sdl-free-garbage-set-func
	 (lambda ()
	   (let loop ([p (sdl-guardian)])
	     (when p
		   (when (ftype-pointer? p)
			 ;(printf "sdl-free-garbage: freeing memory at ~x\n" p)
			 ;;[(ftype-pointer? usb-device*-array p)
			 (cond 
			  [(ftype-pointer? sdl-window-t p) (sdl-destroy-window p)]
			  [(ftype-pointer? sdl-surface-t p) (sdl-free-surface p)]
			  [(ftype-pointer? sdl-texture-t p) (sdl-destroy-texture p)]
			  [(ftype-pointer? sdl-renderer-t p) (sdl-destroy-renderer p)]
			  [(ftype-pointer? sdl-mutex-t p) (sdl-destroy-mutex p)]			 
			  [(ftype-pointer? sdl-sem-t p) (sdl-destroy-semaphore p)]

			  [(ftype-pointer? sdl-cond-t p) (sdl-destroy-cond p)]
			  [(ftype-pointer? sdl-cursor-t p) (sdl-free-cursor p)]
			  [(ftype-pointer? sdl-pixel-format-t p) (sdl-free-format p)]
			  [(ftype-pointer? sdl-palette-t p) (sdl-free-palette p)]
			  [(ftype-pointer? sdl-rw-ops-t p) (sdl-free-rw p)]
			  [else
			   (foreign-free (ftype-pointer-address p))]
			  ))
		   (loop (sdl-guardian)))))))

 (define-flags sdl-initialization
   (timer           #x00000001)
   (audio           #x00000010)
   (video           #x00000020)
   (joystick        #x00000200)
   (haptic          #x00001000)
   (game-controller #x00002000)
   (events          #x00004000)
   (no-parachute    #x00100000))

 ;; calculates 'everything flag
 (define sdl-initialization-everything 
   (fold (lambda (x acc) (logor (cdr x) acc) ) 0 (flags-alist sdl-initialization-flags)))

Added sdl2/joystick-functions.ss.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-sdl-func int sdl-num-joysticks () "SDL_NumJoysticks")
(define-sdl-func string sdl-joystick-name-for-index ((device_index int)) "SDL_JoystickNameForIndex")
(define-sdl-func (* sdl-joystick-t) sdl-joystick-open ((device_index int)) "SDL_JoystickOpen")
(define-sdl-func string sdl-joystick-name ((joystick (* sdl-joystick-t))) "SDL_JoystickName")
;;blacklisted probably because it uses a struct as value.
(define sdl-joystick-get-device-guid #f)
;;blacklisted probably because it uses a struct as value.
(define sdl-joystick-get-guid #f)
;;blacklisted probably because it uses a struct as value.
(define sdl-joystick-get-guid-string #f)
;;blacklisted probably because it uses a struct as value.
(define sdl-joystick-get-guid-from-string #f)
(define-sdl-func sdl-bool-t sdl-joystick-get-attached ((joystick (* sdl-joystick-t))) "SDL_JoystickGetAttached")
;;blacklisted probably because it uses a struct as value.
(define sdl-joystick-instance-id #f)
(define-sdl-func int sdl-joystick-num-axes ((joystick (* sdl-joystick-t))) "SDL_JoystickNumAxes")
(define-sdl-func int sdl-joystick-num-balls ((joystick (* sdl-joystick-t))) "SDL_JoystickNumBalls")
(define-sdl-func int sdl-joystick-num-hats ((joystick (* sdl-joystick-t))) "SDL_JoystickNumHats")
(define-sdl-func int sdl-joystick-num-buttons ((joystick (* sdl-joystick-t))) "SDL_JoystickNumButtons")
(define-sdl-func void sdl-joystick-update () "SDL_JoystickUpdate")
(define-sdl-func int sdl-joystick-event-state ((state int)) "SDL_JoystickEventState")
(define-sdl-func sint16 sdl-joystick-get-axis ((joystick (* sdl-joystick-t)) (axis int)) "SDL_JoystickGetAxis")
(define-sdl-func uint8 sdl-joystick-get-hat ((joystick (* sdl-joystick-t)) (hat int)) "SDL_JoystickGetHat")
(define-sdl-func int sdl-joystick-get-ball ((joystick (* sdl-joystick-t)) (ball int) (dx (* int)) (dy (* int))) "SDL_JoystickGetBall")
(define-sdl-func uint8 sdl-joystick-get-button ((joystick (* sdl-joystick-t)) (button int)) "SDL_JoystickGetButton")
(define-sdl-func void sdl-joystick-close ((joystick (* sdl-joystick-t))) "SDL_JoystickClose")

Added sdl2/joystick-types.ss.









>
>
>
>
1
2
3
4

 (define-ftype sdl-joystick-t (struct))
 (define-ftype sdl-joystick-guid-t (struct (data (array 16 uint8))))

Added sdl2/keyboard-functions.ss.

































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(define-sdl-func (* sdl-window-t) sdl-get-keyboard-focus () "SDL_GetKeyboardFocus")
(define-sdl-func (* uint8) sdl-get-keyboard-state ((numkeys (* int))) "SDL_GetKeyboardState")
(define-sdl-func sdl-keymod-t sdl-get-mod-state () "SDL_GetModState")
(define-sdl-func void sdl-set-mod-state ((modstate sdl-keymod-t)) "SDL_SetModState")
(define-sdl-func sdl-keycode-t sdl-get-key-from-scancode ((scancode sdl-scancode-t)) "SDL_GetKeyFromScancode")
(define-sdl-func sdl-scancode-t sdl-get-scancode-from-key ((key sdl-keycode-t)) "SDL_GetScancodeFromKey")
(define-sdl-func string sdl-get-scancode-name ((scancode sdl-scancode-t)) "SDL_GetScancodeName")
(define-sdl-func sdl-scancode-t sdl-get-scancode-from-name ((name string)) "SDL_GetScancodeFromName")
(define-sdl-func string sdl-get-key-name ((key sdl-keycode-t)) "SDL_GetKeyName")
(define-sdl-func sdl-keycode-t sdl-get-key-from-name ((name string)) "SDL_GetKeyFromName")
(define-sdl-func void sdl-start-text-input () "SDL_StartTextInput")
(define-sdl-func sdl-bool-t sdl-is-text-input-active () "SDL_IsTextInputActive")
(define-sdl-func void sdl-stop-text-input () "SDL_StopTextInput")
(define-sdl-func void sdl-set-text-input-rect ((rect (* sdl-rect-t))) "SDL_SetTextInputRect")
(define-sdl-func sdl-bool-t sdl-has-screen-keyboard-support () "SDL_HasScreenKeyboardSupport")
(define-sdl-func sdl-bool-t sdl-is-screen-keyboard-shown ((window (* sdl-window-t))) "SDL_IsScreenKeyboardShown")

Added sdl2/keyboard-types.ss.















>
>
>
>
>
>
>
1
2
3
4
5
6
7

 (define-ftype sdl-keysym-t
   (struct
       (scancode sdl-scancode-t) 
       (sym sdl-keycode-t) 
       (mod unsigned-16) 
       (unused unsigned-32)))

Added sdl2/keycode-types.ss.











































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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


(define (scancode->keycode s)
  (logor (sdl-scancode s) (bitwise-arithmetic-shift-left 1 30)))

(define-flags sdl-keycode
    (unknown   0)
    (return    (char->integer #\return))
    (escape    (char->integer #\esc))
    (backspace    (char->integer #\backspace))
    (tab    (char->integer #\tab))
    (space    (char->integer #\space))
    (exclaim (char->integer #\!))
    (quotedbl    (char->integer #\"))
    (hash    (char->integer #\#))
    (percent    (char->integer #\%))
    (dollar    (char->integer #\$))
    (ampersand    (char->integer #\&))
    (quote    (char->integer #\'))
    (leftparen    (char->integer #\())
    (rightparen    (char->integer #\)))
    (asterisk    (char->integer #\*))
    (plus    (char->integer #\+))
    (comma    (char->integer #\,))
    (minus    (char->integer #\-))
    (period    (char->integer #\.))
    (slash    (char->integer #\/))
    (0    (char->integer #\0))
    (1    (char->integer #\1))
    (2    (char->integer #\2))
    (3    (char->integer #\3))
    (4    (char->integer #\4))
    (5    (char->integer #\5))
    (6    (char->integer #\6))
    (7    (char->integer #\7))
    (8    (char->integer #\8))
    (9    (char->integer #\9))
    (colon    (char->integer #\:))
    (semicolon    (char->integer #\;))
    (less    (char->integer #\<))
    (equals    (char->integer #\=))
    (greater    (char->integer #\>))
    (question    (char->integer #\?))
    (at    (char->integer #\@))
    ;; /*
    ;;    skip uppercase letters
    ;;  */
    (leftbracket    (char->integer #\[))
    (backslash    (char->integer #\\))
    (rightbracket    (char->integer #\]))
    (caret    (char->integer #\^))
    (underscore    (char->integer #\_))
    (backquote    (char->integer #\`))
    (a    (char->integer #\a))
    (b    (char->integer #\b))
    (c    (char->integer #\c))
    (d    (char->integer #\d))
    (e    (char->integer #\e))
    (f    (char->integer #\f))
    (g    (char->integer #\g))
    (h    (char->integer #\h))
    (i    (char->integer #\i))
    (j    (char->integer #\j))
    (k    (char->integer #\k))
    (l    (char->integer #\l))
    (m    (char->integer #\m))
    (n    (char->integer #\n))
    (o    (char->integer #\o))
    (p    (char->integer #\p))
    (q    (char->integer #\q))
    (r    (char->integer #\r))
    (s    (char->integer #\s))
    (t    (char->integer #\t))
    (u    (char->integer #\u))
    (v    (char->integer #\v))
    (w    (char->integer #\w))
    (x    (char->integer #\x))
    (y    (char->integer #\y))
    (z    (char->integer #\z))

    (capslock    (sdl-scancode 'capslock))

    (f1    (scancode->keycode 'f1))
    (f2    (scancode->keycode 'f2))
    (f3    (scancode->keycode 'f3))
    (f4    (scancode->keycode 'f4))
    (f5    (scancode->keycode 'f5))
    (f6    (scancode->keycode 'f6))
    (f7    (scancode->keycode 'f7))
    (f8    (scancode->keycode 'f8))
    (f9    (scancode->keycode 'f9))
    (f10    (scancode->keycode 'f10))
    (f11    (scancode->keycode 'f11))
    (f12    (scancode->keycode 'f12))

    (printscreen    (scancode->keycode 'printscreen))
    (scrolllock    (scancode->keycode 'scrolllock))
    (pause    (scancode->keycode 'pause))
    (insert    (scancode->keycode 'insert))
    (home    (scancode->keycode 'home))
    (pageup    (scancode->keycode 'pageup))
    (delete    (char->integer #\delete))
    (end    (scancode->keycode 'end))
    (pagedown    (scancode->keycode 'pagedown))
    (right    (scancode->keycode 'right))
    (left    (scancode->keycode 'left))
    (down    (scancode->keycode 'down))
    (up    (scancode->keycode 'up))

    (numlockclear    (scancode->keycode 'numlockclear))
    (kp-divide    (scancode->keycode 'kp-divide))
    (kp-multiply    (scancode->keycode 'kp-multiply))
    (kp-minus    (scancode->keycode 'kp-minus))
    (kp-plus    (scancode->keycode 'kp-plus))
    (kp-enter    (scancode->keycode 'kp-enter))
    (kp-1    (scancode->keycode 'kp-1))
    (kp-2    (scancode->keycode 'kp-2))
    (kp-3    (scancode->keycode 'kp-3))
    (kp-4    (scancode->keycode 'kp-4))
    (kp-5    (scancode->keycode 'kp-5))
    (kp-6    (scancode->keycode 'kp-6))
    (kp-7    (scancode->keycode 'kp-7))
    (kp-8    (scancode->keycode 'kp-8))
    (kp-9    (scancode->keycode 'kp-9))
    (kp-0    (scancode->keycode 'kp-0))
    (kp-period    (scancode->keycode 'kp-period))

    (application    (scancode->keycode 'application))
    (power    (scancode->keycode 'power))
    (kp-equals    (scancode->keycode 'kp-equals))
    (f13    (scancode->keycode 'f13))
    (f14    (scancode->keycode 'f14))
    (f15    (scancode->keycode 'f15))
    (f16    (scancode->keycode 'f16))
    (f17    (scancode->keycode 'f17))
    (f18    (scancode->keycode 'f18))
    (f19    (scancode->keycode 'f19))
    (f20    (scancode->keycode 'f20))
    (f21    (scancode->keycode 'f21))
    (f22    (scancode->keycode 'f22))
    (f23    (scancode->keycode 'f23))
    (f24    (scancode->keycode 'f24))
    (execute    (scancode->keycode 'execute))
    (help    (scancode->keycode 'help))
    (menu    (scancode->keycode 'menu))
    (select    (scancode->keycode 'select))
    (stop    (scancode->keycode 'stop))
    (again    (scancode->keycode 'again))
    (undo    (scancode->keycode 'undo))
    (cut    (scancode->keycode 'cut))
    (copy    (scancode->keycode 'copy))
    (paste    (scancode->keycode 'paste))
    (find    (scancode->keycode 'find))
    (mute    (scancode->keycode 'mute))
    (volumeup    (scancode->keycode 'volumeup))
    (volumedown    (scancode->keycode 'volumedown))
    (kp-comma    (scancode->keycode 'kp-comma))
    (kp-equalsas400     (scancode->keycode 'kp-equalsas400))

    (alterase    (scancode->keycode 'alterase))
    (sysreq    (scancode->keycode 'sysreq))
    (cancel    (scancode->keycode 'cancel))
    (clear    (scancode->keycode 'clear))
    (prior    (scancode->keycode 'prior))
    (return2    (scancode->keycode 'return2))
    (separator    (scancode->keycode 'separator))
    (out    (scancode->keycode 'out))
    (oper    (scancode->keycode 'oper))
    (clearagain    (scancode->keycode 'clearagain))
    (crsel    (scancode->keycode 'crsel))
    (exsel    (scancode->keycode 'exsel))

    (kp-00    (scancode->keycode 'kp-00))
    (kp-000    (scancode->keycode 'kp-000))
    (thousandsseparator (scancode->keycode 'thousandsseparator))
    (decimalseparator  (scancode->keycode 'decimalseparator))
    (currencyunit    (scancode->keycode 'currencyunit))
    (currencysubunit  (scancode->keycode 'currencysubunit))
    (kp-leftparen    (scancode->keycode 'kp-leftparen))
    (kp-rightparen    (scancode->keycode 'kp-rightparen))
    (kp-leftbrace    (scancode->keycode 'kp-leftbrace))
    (kp-rightbrace    (scancode->keycode 'kp-rightbrace))
    (kp-tab    (scancode->keycode 'kp-tab))
    (kp-backspace    (scancode->keycode 'kp-backspace))
    (kp-a    (scancode->keycode 'kp-a))
    (kp-b    (scancode->keycode 'kp-b))
    (kp-c    (scancode->keycode 'kp-c))
    (kp-d    (scancode->keycode 'kp-d))
    (kp-e    (scancode->keycode 'kp-e))
    (kp-f    (scancode->keycode 'kp-f))
    (kp-xor    (scancode->keycode 'kp-xor))
    (kp-power    (scancode->keycode 'kp-power))
    (kp-percent    (scancode->keycode 'kp-percent))
    (kp-less    (scancode->keycode 'kp-less))
    (kp-greater    (scancode->keycode 'kp-greater))
    (kp-ampersand    (scancode->keycode 'kp-ampersand))
    (kp-dblampersand  (scancode->keycode 'kp-dblampersand))
    (kp-verticalbar (scancode->keycode 'kp-verticalbar))
    (kp-dblverticalbar (scancode->keycode 'kp-dblverticalbar))
    (kp-colon    (scancode->keycode 'kp-colon))
    (kp-hash    (scancode->keycode 'kp-hash))
    (kp-space    (scancode->keycode 'kp-space))
    (kp-at    (scancode->keycode 'kp-at))
    (kp-exclam    (scancode->keycode 'kp-exclam))
    (kp-memstore    (scancode->keycode 'kp-memstore))
    (kp-memrecall    (scancode->keycode 'kp-memrecall))
    (kp-memclear    (scancode->keycode 'kp-memclear))
    (kp-memadd    (scancode->keycode 'kp-memadd))
    (kp-memsubtract  (scancode->keycode 'kp-memsubtract))
    (kp-memmultiply   (scancode->keycode 'kp-memmultiply))
    (kp-memdivide    (scancode->keycode 'kp-memdivide))
    (kp-plusminus    (scancode->keycode 'kp-plusminus))
    (kp-clear    (scancode->keycode 'kp-clear))
    (kp-clearentry    (scancode->keycode 'kp-clearentry))
    (kp-binary    (scancode->keycode 'kp-binary))
    (kp-octal    (scancode->keycode 'kp-octal))
    (kp-decimal    (scancode->keycode 'kp-decimal))
    (kp-hexadecimal (scancode->keycode 'kp-hexadecimal))

    (lctrl    (scancode->keycode 'lctrl))
    (lshift    (scancode->keycode 'lshift))
    (lalt    (scancode->keycode 'lalt))
    (lgui    (scancode->keycode 'lgui))
    (rctrl    (scancode->keycode 'rctrl))
    (rshift    (scancode->keycode 'rshift))
    (ralt    (scancode->keycode 'ralt))
    (rgui    (scancode->keycode 'rgui))

    (mode    (scancode->keycode 'mode))

    (audionext    (scancode->keycode 'audionext))
    (audioprev    (scancode->keycode 'audioprev))
    (audiostop    (scancode->keycode 'audiostop))
    (audioplay    (scancode->keycode 'audioplay))
    (audiomute    (scancode->keycode 'audiomute))
    (mediaselect    (scancode->keycode 'mediaselect))
    (www    (scancode->keycode 'www))
    (mail    (scancode->keycode 'mail))
    (calculator    (scancode->keycode 'calculator))
    (computer    (scancode->keycode 'computer))
    (ac-search    (scancode->keycode 'ac-search))
    (ac-home    (scancode->keycode 'ac-home))
    (ac-back    (scancode->keycode 'ac-back))
    (ac-forward    (scancode->keycode 'ac-forward))
    (ac-stop    (scancode->keycode 'ac-stop))
    (ac-refresh    (scancode->keycode 'ac-refresh))
    (ac-bookmarks    (scancode->keycode 'ac-bookmarks))

    (brightnessdown (scancode->keycode 'brightnessdown))
    (brightnessup    (scancode->keycode 'brightnessup))
    (displayswitch    (scancode->keycode 'displayswitch))
    (kbdillumtoggle (scancode->keycode 'kbdillumtoggle))
    (kbdillumdown    (scancode->keycode 'kbdillumdown))
    (kbdillumup    (scancode->keycode 'kbdillumup))
    (eject    (scancode->keycode 'eject))
    (sleep    (scancode->keycode 'sleep))
    );; flags sdl-keycode   

(define-flags sdl-keymod
    (none    #x0000)
    (lshift    #x0001)
    (rshift    #x0002)
    (lctrl    #x0040)
    (rctrl    #x0080)
    (lalt    #x0100)
    (ralt    #x0200)
    (lgui    #x0400)
    (rgui    #x0800)
    (num    #x1000)
    (caps    #x2000)
    (mode    #x4000)
    (reserved    #x8000)
    (ctrl     #x00C0)
    (shift    3)
    (alt    #x0300)
    (gui    #x0c00))

Added sdl2/loadso-functions.ss.







>
>
>
1
2
3
(define-sdl-func void* sdl-load-object ((sofile string)) "SDL_LoadObject")
(define-sdl-func void* sdl-load-function ((handle void*) (name string)) "SDL_LoadFunction")
(define-sdl-func void sdl-unload-object ((handle void*)) "SDL_UnloadObject")

Added sdl2/log-functions.ss.































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(define-sdl-func void sdl-log-set-all-priority ((priority sdl-log-priority-t)) "SDL_LogSetAllPriority")
(define-sdl-func void sdl-log-set-priority ((category int) (priority sdl-log-priority-t)) "SDL_LogSetPriority")
(define-sdl-func sdl-log-priority-t sdl-log-get-priority ((category int)) "SDL_LogGetPriority")
(define-sdl-func void sdl-log-reset-priorities () "SDL_LogResetPriorities")
(define-sdl-func void sdl-log ((fmt string)) "SDL_Log")
(define-sdl-func void sdl-log-verbose ((category int) (fmt string)) "SDL_LogVerbose")
(define-sdl-func void sdl-log-debug ((category int) (fmt string)) "SDL_LogDebug")
(define-sdl-func void sdl-log-info ((category int) (fmt string)) "SDL_LogInfo")
(define-sdl-func void sdl-log-warn ((category int) (fmt string)) "SDL_LogWarn")
(define-sdl-func void sdl-log-error ((category int) (fmt string)) "SDL_LogError")
(define-sdl-func void sdl-log-critical ((category int) (fmt string)) "SDL_LogCritical")
(define-sdl-func void sdl-log-message ((category int) (priority sdl-log-priority-t) (fmt string)) "SDL_LogMessage")
(define-sdl-func void sdl-log-messagev ((category int) (priority sdl-log-priority-t) (fmt string) (ap va-list)) "SDL_LogMessageV")
(define-sdl-func void sdl-log-get-output-function ((callback (* sdl-log-output-function-t)) (userdata (* void*))) "SDL_LogGetOutputFunction")
(define-sdl-func void sdl-log-set-output-function ((callback sdl-log-output-function-t) (userdata void*)) "SDL_LogSetOutputFunction")

Added sdl2/main-functions.ss.





>
>
1
2
(define-sdl-func int sdl-main ((argc int) (argv void*)) "SDL_main")
(define-sdl-func void sdl-set-main-ready () "SDL_SetMainReady")

Added sdl2/messagebox-functions.ss.





>
>
1
2
(define-sdl-func int sdl-show-message-box ((messageboxdata (* sdl-message-box-data-t)) (buttonid (* int))) "SDL_ShowMessageBox")
(define-sdl-func int sdl-show-simple-message-box ((flags uint32) (title string) (message string) (window (* sdl-window-t))) "SDL_ShowSimpleMessageBox")

Added sdl2/messagebox-types.ss.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

 (define-flags sdl-message-box (error  #x10) (warning #x20) (information #x40))
                                     
 (define-flags sdl-message-box-button
   (returnkey-default 1) (escapekey-default 2))
                                       
 (define-enumeration* sdl-message-box-color-type-t
   (background text button-border button-backgrond
	       button-selected color-max))


 (define-ftype sdl-message-box-button-data-t (struct (flags uint32) (buttonid int) (text (* char))))
 (define-ftype sdl-message-box-color-t (struct (r uint8) (g uint8) (b uint8)))
 ;;FIXME USE THE VALUE OF SDL_MESSAGEBOX_COLOR_MAX (=6) ?
 (define-ftype sdl-message-box-color-scheme-t (struct (colors (array 6 sdl-message-box-color-t))))

 (define-ftype sdl-message-box-data-t
   (struct
       (flags unsigned-32)
     (window (* sdl-window-t))
     (title (* char))
     (message (* char))
     (numbuttons int)
     (buttons (* sdl-message-box-button-data-t))
     (color-scheme (* sdl-message-box-color-scheme-t))))

Added sdl2/mouse-functions.ss.





























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(define-sdl-func (* sdl-window-t) sdl-get-mouse-focus () "SDL_GetMouseFocus")
(define-sdl-func uint32 sdl-get-mouse-state ((x (* int)) (y (* int))) "SDL_GetMouseState")
(define-sdl-func uint32 sdl-get-relative-mouse-state ((x (* int)) (y (* int))) "SDL_GetRelativeMouseState")
(define-sdl-func void sdl-warp-mouse-in-window ((window (* sdl-window-t)) (x int) (y int)) "SDL_WarpMouseInWindow")
(define-sdl-func int sdl-set-relative-mouse-mode ((enabled sdl-bool-t)) "SDL_SetRelativeMouseMode")
(define-sdl-func sdl-bool-t sdl-get-relative-mouse-mode () "SDL_GetRelativeMouseMode")
(define-sdl-func (* sdl-cursor-t) sdl-create-cursor ((data (* uint8)) (mask (* uint8)) (w int) (h int) (hot_x int) (hot_y int)) "SDL_CreateCursor")
(define-sdl-func (* sdl-cursor-t) sdl-create-color-cursor ((surface (* sdl-surface-t)) (hot_x int) (hot_y int)) "SDL_CreateColorCursor")
(define-sdl-func (* sdl-cursor-t) sdl-create-system-cursor ((id sdl-system-cursor-t)) "SDL_CreateSystemCursor")
(define-sdl-func void sdl-set-cursor ((cursor (* sdl-cursor-t))) "SDL_SetCursor")
(define-sdl-func (* sdl-cursor-t) sdl-get-cursor () "SDL_GetCursor")
(define-sdl-func (* sdl-cursor-t) sdl-get-default-cursor () "SDL_GetDefaultCursor")
(define-sdl-func void sdl-free-cursor ((cursor (* sdl-cursor-t))) "SDL_FreeCursor")
(define-sdl-func int sdl-show-cursor ((toggle int)) "SDL_ShowCursor")

Added sdl2/mouse-types.ss.

















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

 (define-enumeration* sdl-system-cursor
   (arrow     ; arrow */
    i-beam     ; i-beam */
    wait      ; wait */
    crosshair ; crosshair */
    waitarrow ; small wait cursor (or wait if not available) */
    size-nw-se  ; double arrow pointing northwest and southeast */
    size-ne-sw  ; double arrow pointing northeast and southwest */
    size-we    ; double arrow pointing west and east */
    size-ns    ; double arrow pointing north and south */
    size-all   ; four pointed arrow pointing north, south, east, and west */
    no        ; slashed circle or crossbones */
    hand      ; hand */
    num-system-cursors))

 (define-ftype sdl-cursor-t (struct))

 (define-flags sdl-button (left 1) (middle 2) (right 3) (x1 4) (x2 5))
 (define (sdl-button-mask button)
   (bitwise-arithmetic-shift-left
    1
    (- (cdr (assq button (flags-alist sdl-button-flags)))
       1)))

Added sdl2/mutex-functions.ss.





































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(define-sdl-func (* sdl-mutex-t) sdl-create-mutex () "SDL_CreateMutex")
(define-sdl-func int sdl-lock-mutex ((mutex (* sdl-mutex-t))) "SDL_LockMutex")
(define-sdl-func int sdl-try-lock-mutex ((mutex (* sdl-mutex-t))) "SDL_TryLockMutex")
(define-sdl-func int sdl-unlock-mutex ((mutex (* sdl-mutex-t))) "SDL_UnlockMutex")
(define-sdl-func void sdl-destroy-mutex ((mutex (* sdl-mutex-t))) "SDL_DestroyMutex")
(define-sdl-func (* sdl-sem-t) sdl-create-semaphore ((initial_value uint32)) "SDL_CreateSemaphore")
(define-sdl-func void sdl-destroy-semaphore ((sem (* sdl-sem-t))) "SDL_DestroySemaphore")
(define-sdl-func int sdl-sem-wait ((sem (* sdl-sem-t))) "SDL_SemWait")
(define-sdl-func int sdl-sem-try-wait ((sem (* sdl-sem-t))) "SDL_SemTryWait")
(define-sdl-func int sdl-sem-wait-timeout ((sem (* sdl-sem-t)) (ms uint32)) "SDL_SemWaitTimeout")
(define-sdl-func int sdl-sem-post ((sem (* sdl-sem-t))) "SDL_SemPost")
(define-sdl-func uint32 sdl-sem-value ((sem (* sdl-sem-t))) "SDL_SemValue")
(define-sdl-func (* sdl-cond-t) sdl-create-cond () "SDL_CreateCond")
(define-sdl-func void sdl-destroy-cond ((cond (* sdl-cond-t))) "SDL_DestroyCond")
(define-sdl-func int sdl-cond-signal ((cond (* sdl-cond-t))) "SDL_CondSignal")
(define-sdl-func int sdl-cond-broadcast ((cond (* sdl-cond-t))) "SDL_CondBroadcast")
(define-sdl-func int sdl-cond-wait ((cond (* sdl-cond-t)) (mutex (* sdl-mutex-t))) "SDL_CondWait")
(define-sdl-func int sdl-cond-wait-timeout ((cond (* sdl-cond-t)) (mutex (* sdl-mutex-t)) (ms uint32)) "SDL_CondWaitTimeout")

Added sdl2/mutex-types.ss.









>
>
>
>
1
2
3
4

 (define-ftype sdl-mutex-t (struct))
 (define-ftype sdl-sem-t (struct))
 (define-ftype sdl-cond-t (struct))

Added sdl2/parse-sdl-json.ss.



















































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

(import (scheme)
	(json))

(define sdl-json-text (read-file "sdl2.json"))
(define sdl-json (string->json sdl-json-text))

(with-output-to-file "sdl2.sexp" (lambda () (pretty-print sdl-json)) 'truncate)

(import (only (thunder-utils) string-replace string-split) 
	(only (srfi s13 strings) string-drop string-downcase string-prefix? string-suffix? string-delete)
	(only (srfi s1 lists) fold)
	(srfi s14 char-sets))

;; (define (anti-camel x)
;;   (let* ([x (string-replace x #\_ #\-)]
;; 	 [len (string-length x)]
;; 	 [s (list->string
;; 	     (reverse
;; 	      (fold (lambda (i acc) 
;; 		      (let ([a (string-ref x i)] 
;; 			    [b (if (< (+ 1 i) len) (string-ref x (+ 1 i)) #f)]
;; 			    [c (if (> i 0) (string-ref x (- i 1)) #f)])
;; 			(if (and (char-upper-case? a) 
;; 				 b (not (char-upper-case? b)) c (not (char-upper-case? c)))
;; 			    (cons (char-downcase a) 
;; 				  (if (and c (char=? c #\-)) 
;; 				      acc 
;; 				      (cons #\- acc)))
;; 			    (cons (char-downcase a) acc)))) '() (iota len))))])
    
;;     s))

(define (anti-camel x)
  (let* ([x (string-replace x #\_ #\-)]
	 [len (string-length x)]
	 [f (lambda (s len)
	      (list->string
	       (reverse
		(fold (lambda (i acc) 
			(let ([a (string-ref s i)] 
			      [next (if (< (+ 1 i) len) (string-ref s (+ 1 i)) #f)]
			      [prev (if (> i 0) (string-ref s (- i 1)) #f)])
			  (if (and (char-upper-case? a)  next prev
				   (not 
				    (or (char=? a #\-) (char=? prev #\-) (char=? next #\-)
					(and (char-upper-case? next) (char-upper-case? prev)))))
			      (cons (char-downcase a) (cons #\- acc))
			      (cons (char-downcase a) acc)))) '() (iota len)))))])
    (cond
     [(string-prefix? "SDL-GL-" x)
      (string-append "sdl-gl-" (f (string-drop x 7) (- len 7)))]
     [(string-prefix? "SDL-GL" x)
      (string-append "sdl-gl-" (f (string-drop x 6) (- len 6)))]
     [(equal? "SDL-RWops" x) "sdl-rw-ops"] ;HACK
     [else (f x len)])))

(define (add-t x)
  (let ([xd (string-downcase x)])
    (if (and (string-prefix? "sdl-" xd) 
	     (not  (or (string-suffix? "*" x) (string-suffix? "-t" x))))
	(string-append x "-t")
	x)))

(define (add-* x)
  (string-append x "*"))
 
(define (decode-type t)
  (if t
      (let-json-object t (tag type)
		       (let ([tag* (if (string? tag) (string->symbol tag) tag)])
			 (case tag*
			   [:function-pointer 'void*]
			   [:int 'int]
			   [:unsigned-int 'unsigned-int]
			   [:unsigned-long-long 'unsigned-long-long]
			   [:unsigned-long 'unsigned-long]
			   [:long 'long]
			   [:double 'double]
			   [:long-double 'long-double]
			   [:float 'float]
			   [:pointer (let ([pt (decode-type type)])
				       (case pt
					 (char 'string)
					 (void 'void*)
					 (else
					  (if (and (pair? pt ) (eq? (car pt) '*))
					      pt ;; DOUBLE STAR SEEMS NOT SUPPORTED ON CHEZ
					      `(* ,pt))
					  #;(string->symbol 
					   (add-*
					    (symbol->string pt))))))]
			   [:void 'void]
			   [:char 'char]
			   [else (if (symbol? tag*)
				     (string->symbol 
				      (add-t
				       (anti-camel 
					(symbol->string tag*))))
				     tag*)])))
      #f))
(define (decode-param p)
  (let-json-object p (tag name type)
		   (if (equal? name "") 
		       (decode-type type)
		       (list name (decode-type type)))))

(define blacklist '(sdl-joystick-instance-id 
		    sdl-joystick-get-device-guid
		    sdl-joystick-get-guid 
		    sdl-joystick-get-guid-string 
		    sdl-joystick-get-guid-from-string
		    sdl-game-controller-mapping-for-guid))

(import (only (srfi s13 strings) string-contains))
(define (parse-json-function x m)
  (let-json-object x (tag name location return-type parameters) 
		   (if (and (or (string-contains location m) 
				(and (equal? "sdl" m) (string-contains location "SDL.h")))
			    (equal? tag "function")
			    (string-prefix? "SDL_" name))
		       (cond
			[(memq (string->symbol (anti-camel name)) blacklist)
			 (printf ";;blacklisted probably because it uses a struct as value.\n(define ~d #f)\n" (anti-camel name))]
			[else
			   (printf "(define-sdl-func ~d ~d ~d \"~d\")\n"
				   (decode-type return-type) 
				   (case name
				     ("SDL_log" "sdl-logn")
				     (else (anti-camel name)))
				   
				   (map (lambda (p) (decode-param p)) (vector->list parameters))
				   name)]))))

(define sdl2-modules-func
  '(assert atomic audio clipboard
    cpuinfo endian error events 
    filesystem hints joystick
    keyboard loadso log main messagebox
    mouse mutex pixels platform power
    rect render rwops surface system
    thread timer touch version video gamecontroller gesture sdl))

(for-each (lambda (m) 
	    (with-output-to-file (string-append m "-functions.ss")
	      (lambda () 
		(vector-for-each 
		 (lambda (x) 
		   (parse-json-function x m))
		 sdl-json))
	      'truncate)) (map symbol->string sdl2-modules-func))


Added sdl2/pixels-functions.ss.





























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(define-sdl-func string sdl-get-pixel-format-name ((format uint32)) "SDL_GetPixelFormatName")
(define-sdl-func sdl-bool-t sdl-pixel-format-enum-to-masks ((format uint32) (bpp (* int)) (Rmask (* uint32)) (Gmask (* uint32)) (Bmask (* uint32)) (Amask (* uint32))) "SDL_PixelFormatEnumToMasks")
(define-sdl-func uint32 sdl-masks-to-pixel-format-enum ((bpp int) (Rmask uint32) (Gmask uint32) (Bmask uint32) (Amask uint32)) "SDL_MasksToPixelFormatEnum")
(define-sdl-func (* sdl-pixel-format-t) sdl-alloc-format ((pixel_format uint32)) "SDL_AllocFormat")
(define-sdl-func void sdl-free-format ((format (* sdl-pixel-format-t))) "SDL_FreeFormat")
(define-sdl-func (* sdl-palette-t) sdl-alloc-palette ((ncolors int)) "SDL_AllocPalette")
(define-sdl-func int sdl-set-pixel-format-palette ((format (* sdl-pixel-format-t)) (palette (* sdl-palette-t))) "SDL_SetPixelFormatPalette")
(define-sdl-func int sdl-set-palette-colors ((palette (* sdl-palette-t)) (colors (* sdl-color-t)) (firstcolor int) (ncolors int)) "SDL_SetPaletteColors")
(define-sdl-func void sdl-free-palette ((palette (* sdl-palette-t))) "SDL_FreePalette")
(define-sdl-func uint32 sdl-map-rgb ((format (* sdl-pixel-format-t)) (r uint8) (g uint8) (b uint8)) "SDL_MapRGB")
(define-sdl-func uint32 sdl-map-rgba ((format (* sdl-pixel-format-t)) (r uint8) (g uint8) (b uint8) (a uint8)) "SDL_MapRGBA")
(define-sdl-func void sdl-get-rgb ((pixel uint32) (format (* sdl-pixel-format-t)) (r (* uint8)) (g (* uint8)) (b (* uint8))) "SDL_GetRGB")
(define-sdl-func void sdl-get-rgba ((pixel uint32) (format (* sdl-pixel-format-t)) (r (* uint8)) (g (* uint8)) (b (* uint8)) (a (* uint8))) "SDL_GetRGBA")
(define-sdl-func void sdl-calculate-gamma-ramp ((gamma float) (ramp (* uint16))) "SDL_CalculateGammaRamp")

Added sdl2/pixels-types.ss.



























































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(begin
  (define sdl-alpha-opaque 255)
  (define sdl-alpha-transparent 0)

  (define-enumeration* sdl-pixeltype ( unknown index-1 index-4 index-8 packed-8 packed-16 
						packed-32 array-u8 array-u16 array-u32 array-f16 array-f32))

  (define-enumeration* sdl-bitmaporder  (none $4321 $1234))

  (define-enumeration* sdl-packedorder (none xrgb rgbx argb rgba xbgr bgrx abgr bgra))

  (define-enumeration* sdl-arrayorder (none rgb rgba argb bgr bgra abgr))

  (define-enumeration* sdl-packedlayout (none $332 $4444 $1555 $5551 $565 $8888 $2101010 $1010102))

  (define (sdl-define-pixelformat type order layout bits bytes)
    (define << bitwise-arithmetic-shift-left)
    (logor (<< 1 28) (<< type 24) (<< order 20) (<< layout 16) (<< bits 8) (<< bytes 0)))

  (define (sdl-pixelflag% x)
    (logand (bitwise-arithmetic-shift-right x 28) #x0f))
  (define (sdl-pixeltype% x)
    (logand (bitwise-arithmetic-shift-right x 24) #x0f))
  (define (sdl-pixelorder% x)
    (logand (bitwise-arithmetic-shift-right x 20) #x0f))
  (define (sdl-pixellayout x)
    (logand (bitwise-arithmetic-shift-right x 16) #x0f))
  (define (sdl-bitsperpixel% x)
    (logand (bitwise-arithmetic-shift-right x 8) #xff))
  
  (define (sdl-ispixelformat-fourcc format)
    (not (or (zero? format) (= (sdl-pixelflag% format) 1))))

  ;;TODO: NEEDS TEST
  (define (sdl-fourcc a b c d)
    (define << bitwise-arithmetic-shift-left)
    (logor (<< (logand a #xff) 0)
	   (<< (logand b #xff) 8)
	   (<< (logand c #xff) 16)
	   (<< (logand d #xff) 24)))

  (define (sdl-fourcc/char a b c d)
    (sdl-fourcc (char->integer a) (char->integer b) (char->integer c) (char->integer d)))
  
  (define-flags sdl-pixelformat
      (unknown  0)
      (index-1-lsb   (sdl-define-pixelformat (sdl-pixeltype 'index-1) (sdl-bitmaporder '$4321) 0 1 0))
      (index-1-msb   (sdl-define-pixelformat (sdl-pixeltype 'index-1) (sdl-bitmaporder '$1234) 0 1 0))
      (index-4-lsb   (sdl-define-pixelformat (sdl-pixeltype 'index-4) (sdl-bitmaporder '$4321) 0 4 0))
      (index-4-msb   (sdl-define-pixelformat (sdl-pixeltype 'index-4) (sdl-bitmaporder '$1234) 0 4 0))
      (index-8    (sdl-define-pixelformat (sdl-pixeltype 'index-8) 0 0 8 1))
      (rgb-332    (sdl-define-pixelformat (sdl-pixeltype 'packed-8) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$332) 8 1))
      (rgb-444    (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$4444) 12 2))
      (rgb-555    (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$1555) 15 2))
      (bgr-555    (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'xbgr) 
					    (sdl-packedlayout '$1555) 15 2))
      (argb-4444  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'argb) 
					    (sdl-packedlayout '$4444) 16 2))
      (rgba-4444  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'rgba) 
					    (sdl-packedlayout '$4444) 16 2))
      (abgr-4444  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'abgr) 
					    (sdl-packedlayout '$4444) 16 2))
      (bgra-4444  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'bgra) 
					    (sdl-packedlayout '$4444) 16 2))
      (argb-1555  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'argb) 
					    (sdl-packedlayout '$1555) 16 2))
      (rgba-5551  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'rgba) 
					    (sdl-packedlayout '$5551) 16 2))
      (abgr-1555  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'abgr) 
					    (sdl-packedlayout '$1555) 16 2))
      (bgra-5551  (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'bgra) 
					    (sdl-packedlayout '$5551) 16 2))
      (rgb-565    (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$565) 16 2))
      (bgr-565    (sdl-define-pixelformat (sdl-pixeltype 'packed-16) (sdl-packedorder 'xbgr) 
					    (sdl-packedlayout '$565) 16 2))
      (rgb-24     (sdl-define-pixelformat (sdl-pixeltype 'array-u8) (sdl-arrayorder 'rgb) 
					    0 24 3))
      (bgr-24     (sdl-define-pixelformat (sdl-pixeltype 'array-u8) (sdl-arrayorder 'bgr) 
					    0 24 3))
      (rgb-888    (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$8888) 24 4))
      (rgbx-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'rgbx) 
					    (sdl-packedlayout '$8888) 24 4))
      (rgb-888    (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'xrgb) 
					    (sdl-packedlayout '$8888) 24 4))
      (rgbx-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'rgbx) 
					    (sdl-packedlayout '$8888) 24 4))
      (bgr-888    (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'xbgr) 
					    (sdl-packedlayout '$8888) 24 4))
      (bgrx-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'bgrx) 
					    (sdl-packedlayout '$8888) 24 4))
      (argb-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'argb) 
					    (sdl-packedlayout '$8888) 32 4))
      (rgba-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'rgba) 
					    (sdl-packedlayout '$8888) 32 4))
      (abgr-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'abgr) 
					    (sdl-packedlayout '$8888) 32 4))
      (bgra-8888  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'bgra) 
					    (sdl-packedlayout '$8888) 32 4))
      (argb-2101010  (sdl-define-pixelformat (sdl-pixeltype 'packed-32) (sdl-packedorder 'argb) 
					       (sdl-packedlayout '$2101010) 32 4))
      
      (yv12  (sdl-fourcc/char #\Y #\V #\1 #\2))
      (iyuv  (sdl-fourcc/char #\I #\Y #\U #\V))
      (yuy2  (sdl-fourcc/char #\Y #\U #\Y #\2))
      (uyvy  (sdl-fourcc/char #\U #\Y #\V #\Y))
      (yvyu  (sdl-fourcc/char #\Y #\V #\Y #\U))
      ))
  
 (define-ftype sdl-color-t 
   (struct (r uint8) (g uint8) (b uint8) (a uint8)))
 (define-ftype sdl-palette-t 
   (struct (ncolors int) (colors (* sdl-color-t)) (version uint32) (refcount int)))

 (define-ftype sdl-pixel-format-t
   (struct 
    (format uint32)
    (palette (* sdl-palette-t))
    (bits-per-pixel uint8)
    (bytes-per-pixel uint8)
    (padding (array 2 uint8))
    (r-mask uint32)
    (g-mask uint32)
    (b-mask uint32)
    (a-mask uint32)
    (r-loss uint8)
    (g-loss uint8)
    (b-loss uint8)
    (a-loss uint8)
    (r-shift uint8)
    (g-shift uint8)
    (b-shift uint8)
    (a-shift uint8)
    (refcount int)
    (next (* sdl-pixel-format-t))))


Added sdl2/platform-functions.ss.



>
1
(define-sdl-func string sdl-get-platform () "SDL_GetPlatform")

Added sdl2/power-functions.ss.



>
1
(define-sdl-func sdl-power-state-t sdl-get-power-info ((secs (* int)) (pct (* int))) "SDL_GetPowerInfo")

Added sdl2/rect-functions.ss.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
(define-sdl-func sdl-bool-t sdl-rect-empty ((r (* sdl-rect-t))) "SDL_RectEmpty")
(define-sdl-func sdl-bool-t sdl-rect-equals ((a (* sdl-rect-t)) (b (* sdl-rect-t))) "SDL_RectEquals")
(define-sdl-func sdl-bool-t sdl-has-intersection ((A (* sdl-rect-t)) (B (* sdl-rect-t))) "SDL_HasIntersection")
(define-sdl-func sdl-bool-t sdl-intersect-rect ((A (* sdl-rect-t)) (B (* sdl-rect-t)) (result (* sdl-rect-t))) "SDL_IntersectRect")
(define-sdl-func void sdl-union-rect ((A (* sdl-rect-t)) (B (* sdl-rect-t)) (result (* sdl-rect-t))) "SDL_UnionRect")
(define-sdl-func sdl-bool-t sdl-enclose-points ((points (* sdl-point-t)) (count int) (clip (* sdl-rect-t)) (result (* sdl-rect-t))) "SDL_EnclosePoints")
(define-sdl-func sdl-bool-t sdl-intersect-rect-and-line ((rect (* sdl-rect-t)) (X1 (* int)) (Y1 (* int)) (X2 (* int)) (Y2 (* int))) "SDL_IntersectRectAndLine")

Added sdl2/rect-types.ss.







>
>
>
1
2
3
(define-ftype sdl-point-t (struct (x int) (y int)))
(define-ftype sdl-rect-t (struct (x int) (y int) (w int) (h int)))
 

Added sdl2/render-functions.ss.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-sdl-func int sdl-get-num-render-drivers () "SDL_GetNumRenderDrivers")
(define-sdl-func int sdl-get-render-driver-info ((index int) (info (* sdl-renderer-info-t))) "SDL_GetRenderDriverInfo")
(define-sdl-func int sdl-create-window-and-renderer ((width int) (height int) (window_flags uint32) (window (* sdl-window-t)) (renderer (* sdl-renderer-t))) "SDL_CreateWindowAndRenderer")
(define-sdl-func (* sdl-renderer-t) sdl-create-renderer ((window (* sdl-window-t)) (index int) (flags uint32)) "SDL_CreateRenderer")
(define-sdl-func (* sdl-renderer-t) sdl-create-software-renderer ((surface (* sdl-surface-t))) "SDL_CreateSoftwareRenderer")
(define-sdl-func (* sdl-renderer-t) sdl-get-renderer ((window (* sdl-window-t))) "SDL_GetRenderer")
(define-sdl-func int sdl-get-renderer-info ((renderer (* sdl-renderer-t)) (info (* sdl-renderer-info-t))) "SDL_GetRendererInfo")
(define-sdl-func int sdl-get-renderer-output-size ((renderer (* sdl-renderer-t)) (w (* int)) (h (* int))) "SDL_GetRendererOutputSize")
(define-sdl-func (* sdl-texture-t) sdl-create-texture ((renderer (* sdl-renderer-t)) (format uint32) (access int) (w int) (h int)) "SDL_CreateTexture")
(define-sdl-func (* sdl-texture-t) sdl-create-texture-from-surface ((renderer (* sdl-renderer-t)) (surface (* sdl-surface-t))) "SDL_CreateTextureFromSurface")
(define-sdl-func int sdl-query-texture ((texture (* sdl-texture-t)) (format (* uint32)) (access (* int)) (w (* int)) (h (* int))) "SDL_QueryTexture")
(define-sdl-func int sdl-set-texture-color-mod ((texture (* sdl-texture-t)) (r uint8) (g uint8) (b uint8)) "SDL_SetTextureColorMod")
(define-sdl-func int sdl-get-texture-color-mod ((texture (* sdl-texture-t)) (r (* uint8)) (g (* uint8)) (b (* uint8))) "SDL_GetTextureColorMod")
(define-sdl-func int sdl-set-texture-alpha-mod ((texture (* sdl-texture-t)) (alpha uint8)) "SDL_SetTextureAlphaMod")
(define-sdl-func int sdl-get-texture-alpha-mod ((texture (* sdl-texture-t)) (alpha (* uint8))) "SDL_GetTextureAlphaMod")
(define-sdl-func int sdl-set-texture-blend-mode ((texture (* sdl-texture-t)) (blendMode sdl-blend-mode-t)) "SDL_SetTextureBlendMode")
(define-sdl-func int sdl-get-texture-blend-mode ((texture (* sdl-texture-t)) (blendMode (* sdl-blend-mode-t))) "SDL_GetTextureBlendMode")
(define-sdl-func int sdl-update-texture ((texture (* sdl-texture-t)) (rect (* sdl-rect-t)) (pixels void*) (pitch int)) "SDL_UpdateTexture")
(define-sdl-func int sdl-update-yuv-texture ((texture (* sdl-texture-t)) (rect (* sdl-rect-t)) (Yplane (* uint8)) (Ypitch int) (Uplane (* uint8)) (Upitch int) (Vplane (* uint8)) (Vpitch int)) "SDL_UpdateYUVTexture")
(define-sdl-func int sdl-lock-texture ((texture (* sdl-texture-t)) (rect (* sdl-rect-t)) (pixels (* void*)) (pitch (* int))) "SDL_LockTexture")
(define-sdl-func void sdl-unlock-texture ((texture (* sdl-texture-t))) "SDL_UnlockTexture")
(define-sdl-func sdl-bool-t sdl-render-target-supported ((renderer (* sdl-renderer-t))) "SDL_RenderTargetSupported")
(define-sdl-func int sdl-set-render-target ((renderer (* sdl-renderer-t)) (texture (* sdl-texture-t))) "SDL_SetRenderTarget")
(define-sdl-func (* sdl-texture-t) sdl-get-render-target ((renderer (* sdl-renderer-t))) "SDL_GetRenderTarget")
(define-sdl-func int sdl-render-set-logical-size ((renderer (* sdl-renderer-t)) (w int) (h int)) "SDL_RenderSetLogicalSize")
(define-sdl-func void sdl-render-get-logical-size ((renderer (* sdl-renderer-t)) (w (* int)) (h (* int))) "SDL_RenderGetLogicalSize")
(define-sdl-func int sdl-render-set-viewport ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderSetViewport")
(define-sdl-func void sdl-render-get-viewport ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderGetViewport")
(define-sdl-func int sdl-render-set-clip-rect ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderSetClipRect")
(define-sdl-func void sdl-render-get-clip-rect ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderGetClipRect")
(define-sdl-func int sdl-render-set-scale ((renderer (* sdl-renderer-t)) (scaleX float) (scaleY float)) "SDL_RenderSetScale")
(define-sdl-func void sdl-render-get-scale ((renderer (* sdl-renderer-t)) (scaleX (* float)) (scaleY (* float))) "SDL_RenderGetScale")
(define-sdl-func int sdl-set-render-draw-color ((renderer (* sdl-renderer-t)) (r uint8) (g uint8) (b uint8) (a uint8)) "SDL_SetRenderDrawColor")
(define-sdl-func int sdl-get-render-draw-color ((renderer (* sdl-renderer-t)) (r (* uint8)) (g (* uint8)) (b (* uint8)) (a (* uint8))) "SDL_GetRenderDrawColor")
(define-sdl-func int sdl-set-render-draw-blend-mode ((renderer (* sdl-renderer-t)) (blendMode sdl-blend-mode-t)) "SDL_SetRenderDrawBlendMode")
(define-sdl-func int sdl-get-render-draw-blend-mode ((renderer (* sdl-renderer-t)) (blendMode (* sdl-blend-mode-t))) "SDL_GetRenderDrawBlendMode")
(define-sdl-func int sdl-render-clear ((renderer (* sdl-renderer-t))) "SDL_RenderClear")
(define-sdl-func int sdl-render-draw-point ((renderer (* sdl-renderer-t)) (x int) (y int)) "SDL_RenderDrawPoint")
(define-sdl-func int sdl-render-draw-points ((renderer (* sdl-renderer-t)) (points (* sdl-point-t)) (count int)) "SDL_RenderDrawPoints")
(define-sdl-func int sdl-render-draw-line ((renderer (* sdl-renderer-t)) (x1 int) (y1 int) (x2 int) (y2 int)) "SDL_RenderDrawLine")
(define-sdl-func int sdl-render-draw-lines ((renderer (* sdl-renderer-t)) (points (* sdl-point-t)) (count int)) "SDL_RenderDrawLines")
(define-sdl-func int sdl-render-draw-rect ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderDrawRect")
(define-sdl-func int sdl-render-draw-rects ((renderer (* sdl-renderer-t)) (rects (* sdl-rect-t)) (count int)) "SDL_RenderDrawRects")
(define-sdl-func int sdl-render-fill-rect ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t))) "SDL_RenderFillRect")
(define-sdl-func int sdl-render-fill-rects ((renderer (* sdl-renderer-t)) (rects (* sdl-rect-t)) (count int)) "SDL_RenderFillRects")
(define-sdl-func int sdl-render-copy ((renderer (* sdl-renderer-t)) (texture (* sdl-texture-t)) (srcrect (* sdl-rect-t)) (dstrect (* sdl-rect-t))) "SDL_RenderCopy")
(define-sdl-func int sdl-render-copy-ex ((renderer (* sdl-renderer-t)) (texture (* sdl-texture-t)) (srcrect (* sdl-rect-t)) (dstrect (* sdl-rect-t)) (angle double) (center (* sdl-point-t)) (flip sdl-renderer-flip-t)) "SDL_RenderCopyEx")
(define-sdl-func int sdl-render-read-pixels ((renderer (* sdl-renderer-t)) (rect (* sdl-rect-t)) (format uint32) (pixels void*) (pitch int)) "SDL_RenderReadPixels")
(define-sdl-func void sdl-render-present ((renderer (* sdl-renderer-t))) "SDL_RenderPresent")
(define-sdl-func void sdl-destroy-texture ((texture (* sdl-texture-t))) "SDL_DestroyTexture")
(define-sdl-func void sdl-destroy-renderer ((renderer (* sdl-renderer-t))) "SDL_DestroyRenderer")
(define-sdl-func int sdl-gl-bind-texture ((texture (* sdl-texture-t)) (texw (* float)) (texh (* float))) "SDL_GL_BindTexture")
(define-sdl-func int sdl-gl-unbind-texture ((texture (* sdl-texture-t))) "SDL_GL_UnbindTexture")

Added sdl2/render-types.ss.



































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

(define-flags sdl-renderer-flags
  (software 1)
  (accelerated 2)
  (presentvsync 4)
  (targettexture 8))

(define-ftype sdl-renderer-info-t
  (struct 
   (name (* char))
   (flags uint32)
   (num-texture-formats uint32)
   (texture_formats (array 16 uint32))
   (max-texture-width int)
   (max-texture-height int)))

(define-flags sdl-texture-access 
  (static 0)
  (streaming 1)
  (target 2))

(define-flags sdl-texture-modulate 
  (none 0)
  (color 1) 
  (alpha 2))

(define-flags sdl-renderer-flip
  (none 0)
  (horizontal 1)
  (vertical 2))

(define-ftype sdl-renderer-t (struct))
(define-ftype sdl-texture-t (struct))

Added sdl2/romeladen.bmp.

cannot compute difference between binary files

Added sdl2/rwops-functions.ss.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
(define-sdl-func (* sdl-rw-ops-t) sdl-rw-from-file ((file string) (mode string)) "SDL_RWFromFile")
(define-sdl-func (* sdl-rw-ops-t) sdl-rw-from-fp ((fp (* file)) (autoclose sdl-bool-t)) "SDL_RWFromFP")
(define-sdl-func (* sdl-rw-ops-t) sdl-rw-from-mem ((mem void*) (size int)) "SDL_RWFromMem")
(define-sdl-func (* sdl-rw-ops-t) sdl-rw-from-const-mem ((mem void*) (size int)) "SDL_RWFromConstMem")
(define-sdl-func (* sdl-rw-ops-t) sdl-alloc-rw () "SDL_AllocRW")
(define-sdl-func void sdl-free-rw ((area (* sdl-rw-ops-t))) "SDL_FreeRW")
(define-sdl-func uint8 sdl-read-u8 ((src (* sdl-rw-ops-t))) "SDL_ReadU8")
(define-sdl-func uint16 sdl-read-l-e16 ((src (* sdl-rw-ops-t))) "SDL_ReadLE16")
(define-sdl-func uint16 sdl-read-b-e16 ((src (* sdl-rw-ops-t))) "SDL_ReadBE16")
(define-sdl-func uint32 sdl-read-l-e32 ((src (* sdl-rw-ops-t))) "SDL_ReadLE32")
(define-sdl-func uint32 sdl-read-b-e32 ((src (* sdl-rw-ops-t))) "SDL_ReadBE32")
(define-sdl-func uint64 sdl-read-l-e64 ((src (* sdl-rw-ops-t))) "SDL_ReadLE64")
(define-sdl-func uint64 sdl-read-b-e64 ((src (* sdl-rw-ops-t))) "SDL_ReadBE64")

Added sdl2/rwops-types.ss.







>
>
>
1
2
3

 (define-ftype sdl-rw-ops-t (struct))

Added sdl2/scancode-types.ss.







































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-flags sdl-scancode
    (unknown   0)

    ;; /**
    ;;  *  \name usage page 0x07
    ;;  *
    ;;  *  these values are from usage page 0x07 (usb keyboard page).
    ;;  */
    ;; /* @{ */

    (a   4)
    (b   5)
    (c   6)
    (d   7)
    (e   8)
    (f   9)
    (g   10)
    (h   11)
    (i   12)
    (j   13)
    (k   14)
    (l   15)
    (m   16)
    (n   17)
    (o   18)
    (p   19)
    (q   20)
    (r   21)
    (s   22)
    (t   23)
    (u   24)
    (v   25)
    (w   26)
    (x   27)
    (y   28)
    (z   29)

    (1   30)
    (2   31)
    (3   32)
    (4   33)
    (5   34)
    (6   35)
    (7   36)
    (8   37)
    (9   38)
    (0   39)

    (return   40)
    (escape   41)
    (backspace   42)
    (tab   43)
    (space   44)

    (minus   45)
    (equals   46)
    (leftbracket   47)
    (rightbracket   48)
    (backslash   49) ;; /**< located at the lower left of the return
    ;;                  *   key on iso keyboards and at the right end
    ;;                  *   of the qwerty row on ansi keyboards.
    ;;                  *   produces reverse solidus (backslash) and
    ;;                  *   vertical line in a us layout, reverse
    ;;                  *   solidus and vertical line in a uk mac
    ;;                  *   layout, number sign and tilde in a uk
    ;;                  *   windows layout, dollar sign and pound sign
    ;;                  *   in a swiss german layout, number sign and
    ;;                  *   apostrophe in a german layout, grave
    ;;                  *   accent and pound sign in a french mac
    ;;                  *   layout, and asterisk and micro sign in a
    ;;                  *   french windows layout.
    ;;                  */
    (nonushash   50) ;; /**< iso usb keyboards actually use this code
    ;;                  *   instead of 49 for the same key, but all
    ;;                  *   oses i've seen treat the two codes
    ;;                  *   identically. so, as an implementor, unless
    ;;                  *   your keyboard generates both of those
    ;;                  *   codes and your os treats them differently,
    ;;                  *   you should generate sdl-scancode-backslash
    ;;                  *   instead of this code. as a user, you
    ;;                  *   should not rely on this code because sdl
    ;;                  *   will never generate it with most (all?)
    ;;                  *   keyboards.
    ;;                  */
    (semicolon   51)
    (apostrophe   52)
    (grave   53) ;; /**< located in the top left corner (on both ansi
    ;;                  *   and iso keyboards). produces grave accent and
    ;;                  *   tilde in a us windows layout and in us and uk
    ;;                  *   mac layouts on ansi keyboards, grave accent
    ;;                  *   and not sign in a uk windows layout, section
    ;;                  *   sign and plus-minus sign in us and uk mac
    ;;                  *   layouts on iso keyboards, section sign and
    ;;                  *   degree sign in a swiss german layout (mac:
    ;;                  *   only on iso keyboards), circumflex accent and
    ;;                  *   degree sign in a german layout (mac: only on
    ;;                  *   iso keyboards), superscript two and tilde in a
    ;;                  *   french windows layout, commercial at and
    ;;                  *   number sign in a french mac layout on iso
    ;;                  *   keyboards, and less-than sign and greater-than
    ;;                  *   sign in a swiss german, german, or french mac
    ;;                  *   layout on ansi keyboards.
    ;;                  */
    (comma   54)
    (period   55)
    (slash   56)

    (capslock   57)

    (f1   58)
    (f2   59)
    (f3   60)
    (f4   61)
    (f5   62)
    (f6   63)
    (f7   64)
    (f8   65)
    (f9   66)
    (f10   67)
    (f11   68)
    (f12   69)

    (printscreen   70)
    (scrolllock   71)
    (pause   72)
    (insert   73); /**< insert on pc, help on some mac keyboards (but
                                        ;                      does send code 73, not 117) */
    (home   74)
    (pageup   75)
    (delete   76)
    (end   77)
    (pagedown   78)
    (right   79)
    (left   80)
    (down   81)
    (up   82)

    (numlockclear   83) ;/**< num lock on pc, clear on mac keyboards
                                        ;               */
    (kp-divide   84)
    (kp-multiply   85)
    (kp-minus   86)
    (kp-plus   87)
    (kp-enter   88)
    (kp-1   89)
    (kp-2   90)
    (kp-3   91)
    (kp-4   92)
    (kp-5   93)
    (kp-6   94)
    (kp-7   95)
    (kp-8   96)
    (kp-9   97)
    (kp-0   98)
    (kp-period   99)

    (nonusbackslash   100) ;/**< this is the additional key that iso
    ;; *   keyboards have over ansi ones,
    ;; *   located between left shift and y.
    ;; *   produces grave accent and tilde in a
    ;; *   us or uk mac layout, reverse solidus
    ;; *   (backslash) and vertical line in a
    ;; *   us or uk windows layout, and
    ;; *   less-than sign and greater-than sign
    ;; *   in a swiss german, german, or french
    ;; *   layout. */
    (application   101); /**< windows contextual menu, compose */
    (power   102) ;/**< the usb document says this is a status flag,
                                        ;                 *   not a physical key - but some mac keyboards
                                        ;                 *   do have a power key. */
    (kp-equals   103)
    (f13   104)
    (f14   105)
    (f15   106)
    (f16   107)
    (f17   108)
    (f18   109)
    (f19   110)
    (f20   111)
    (f21   112)
    (f22   113)
    (f23   114)
    (f24   115)
    (execute   116)
    (help   117)
    (menu   118)
    (select   119)
    (stop   120)
    (again   121)  ; /**< redo */
    (undo   122)
    (cut   123)
    (copy   124)
    (paste   125)
    (find   126)
    (mute   127)
    (volumeup   128)
    (volumedown   129)
                                        ;/* not sure whether there's a reason to enable these */
                                        ;/* (lockingcapslock   130,  */
                                        ;/* (lockingnumlock   131, */
                                        ;/* (lockingscrolllock   132, */
    (kp-comma   133)
    (kp-equalsas400   134)

    (international1   135) ;/**< used on asian keyboards, see
                                        ;footnotes in usb doc */
    (international2   136)
    (international3   137) ;/**< yen */
    (international4   138)
    (international5   139)
    (international6   140)
    (international7   141)
    (international8   142)
    (international9   143)
    (lang1   144) ;/**< hangul/english toggle */
    (lang2   145) ;/**< hanja conversion */
    (lang3   146) ;/**< katakana */
    (lang4   147) ;/**< hiragana */
    (lang5   148) ;/**< zenkaku/hankaku */
    (lang6   149) ;/**< reserved */
    (lang7   150) ;/**< reserved */
    (lang8   151) ;/**< reserved */
    (lang9   152) ;/**< reserved */

    (alterase   153) ;/**< erase-eaze */
    (sysreq   154)
    (cancel   155)
    (clear   156)
    (prior   157)
    (return2   158)
    (separator   159)
    (out   160)
    (oper   161)
    (clearagain   162)
    (crsel   163)
    (exsel   164)

    (kp-00   176)
    (kp-000   177)
    (thousandsseparator   178)
    (decimalseparator   179)
    (currencyunit   180)
    (currencysubunit   181)
    (kp-leftparen   182)
    (kp-rightparen   183)
    (kp-leftbrace   184)
    (kp-rightbrace   185)
    (kp-tab   186)
    (kp-backspace   187)
    (kp-a   188)
    (kp-b   189)
    (kp-c   190)
    (kp-d   191)
    (kp-e   192)
    (kp-f   193)
    (kp-xor   194)
    (kp-power   195)
    (kp-percent   196)
    (kp-less   197)
    (kp-greater   198)
    (kp-ampersand   199)
    (kp-dblampersand   200)
    (kp-verticalbar   201)
    (kp-dblverticalbar   202)
    (kp-colon   203)
    (kp-hash   204)
    (kp-space   205)
    (kp-at   206)
    (kp-exclam   207)
    (kp-memstore   208)
    (kp-memrecall   209)
    (kp-memclear   210)
    (kp-memadd   211)
    (kp-memsubtract   212)
    (kp-memmultiply   213)
    (kp-memdivide   214)
    (kp-plusminus   215)
    (kp-clear   216)
    (kp-clearentry   217)
    (kp-binary   218)
    (kp-octal   219)
    (kp-decimal   220)
    (kp-hexadecimal   221)

    (lctrl   224)
    (lshift   225)
    (lalt   226) ; /**< alt, option */
    (lgui   227) ;/**< windows, command (apple)) meta */
    (rctrl   228)
    (rshift   229)
    (ralt   230) ; /**< alt gr, option */
    (rgui   231) ; /**< windows, command (apple), meta */

    (mode   257)  ;;   /**< i'm not sure if this is really not covered
    ;;                              *   by any of the above, but since there's a
    ;;                              *   special kmod-mode for it i'm adding it here
    ;;                              */

    ;; /* @} *//* usage page 0x07 */

    ;; /**
    ;;  *  \name usage page 0x0c
    ;;  *
    ;;  *  these values are mapped from usage page 0x0c (usb consumer page).
    ;;  */
    ;; /* @{ */

    (audionext   258)
    (audioprev   259)
    (audiostop   260)
    (audioplay   261)
    (audiomute   262)
    (mediaselect   263)
    (www   264)
    (mail   265)
    (calculator   266)
    (computer   267)
    (ac-search   268)
    (ac-home   269)
    (ac-back   270)
    (ac-forward   271)
    (ac-stop   272)
    (ac-refresh   273)
    (ac-bookmarks   274)

    ;; /* @} *//* usage page 0x0c */

    ;; /**
    ;;  *  \name walther keys
    ;;  *
    ;;  *  these are values that christian walther added (for mac keyboard?).
    ;;  */
    ;; /* @{ */

    (brightnessdown   275)
    (brightnessup   276)
    (displayswitch   277) ;; /**< display mirroring/dual display
    ;;                      switch, video mode switch */
    (kbdillumtoggle   278)
    (kbdillumdown   279)
    (kbdillumup   280)
    (eject   281)
    (sleep   282)

    (app1   283)
    (app2   284)

    ;; /* @} *//* walther keys */

    ;; /* add any other keys here. */

    (sdl-num-scancodes   512) ;; /**< not a key, just marks the number of scancodes
    ;;    for array bounds */

    ) ; sdl-scancode

Added sdl2/sdl-functions.ss.











>
>
>
>
>
1
2
3
4
5
(define-sdl-func int sdl-init ((flags uint32)) "SDL_Init")
(define-sdl-func int sdl-init-sub-system ((flags uint32)) "SDL_InitSubSystem")
(define-sdl-func void sdl-quit-sub-system ((flags uint32)) "SDL_QuitSubSystem")
(define-sdl-func uint32 sdl-was-init ((flags uint32)) "SDL_WasInit")
(define-sdl-func void sdl-quit () "SDL_Quit")

Added sdl2/sdl2.json.

cannot compute difference between binary files

Added sdl2/sdl2.sexp.

more than 10,000 changes

Added sdl2/surface-functions.ss.



























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-sdl-func (* sdl-surface-t) sdl-create-rgb-surface ((flags uint32) (width int) (height int) (depth int) (Rmask uint32) (Gmask uint32) (Bmask uint32) (Amask uint32)) "SDL_CreateRGBSurface")
(define-sdl-func (* sdl-surface-t) sdl-create-rgb-surface-from ((pixels void*) (width int) (height int) (depth int) (pitch int) (Rmask uint32) (Gmask uint32) (Bmask uint32) (Amask uint32)) "SDL_CreateRGBSurfaceFrom")
(define-sdl-func void sdl-free-surface ((surface (* sdl-surface-t))) "SDL_FreeSurface")
(define-sdl-func int sdl-set-surface-palette ((surface (* sdl-surface-t)) (palette (* sdl-palette-t))) "SDL_SetSurfacePalette")
(define-sdl-func int sdl-lock-surface ((surface (* sdl-surface-t))) "SDL_LockSurface")
(define-sdl-func void sdl-unlock-surface ((surface (* sdl-surface-t))) "SDL_UnlockSurface")
(define-sdl-func (* sdl-surface-t) sdl-load-bmp-rw ((src (* sdl-rw-ops-t)) (freesrc int)) "SDL_LoadBMP_RW")
(define-sdl-func int sdl-save-bmp-rw ((surface (* sdl-surface-t)) (dst (* sdl-rw-ops-t)) (freedst int)) "SDL_SaveBMP_RW")
(define-sdl-func int sdl-set-surface-rle ((surface (* sdl-surface-t)) (flag int)) "SDL_SetSurfaceRLE")
(define-sdl-func int sdl-set-color-key ((surface (* sdl-surface-t)) (flag int) (key uint32)) "SDL_SetColorKey")
(define-sdl-func int sdl-get-color-key ((surface (* sdl-surface-t)) (key (* uint32))) "SDL_GetColorKey")
(define-sdl-func int sdl-set-surface-color-mod ((surface (* sdl-surface-t)) (r uint8) (g uint8) (b uint8)) "SDL_SetSurfaceColorMod")
(define-sdl-func int sdl-get-surface-color-mod ((surface (* sdl-surface-t)) (r (* uint8)) (g (* uint8)) (b (* uint8))) "SDL_GetSurfaceColorMod")
(define-sdl-func int sdl-set-surface-alpha-mod ((surface (* sdl-surface-t)) (alpha uint8)) "SDL_SetSurfaceAlphaMod")
(define-sdl-func int sdl-get-surface-alpha-mod ((surface (* sdl-surface-t)) (alpha (* uint8))) "SDL_GetSurfaceAlphaMod")
(define-sdl-func int sdl-set-surface-blend-mode ((surface (* sdl-surface-t)) (blendMode sdl-blend-mode-t)) "SDL_SetSurfaceBlendMode")
(define-sdl-func int sdl-get-surface-blend-mode ((surface (* sdl-surface-t)) (blendMode (* sdl-blend-mode-t))) "SDL_GetSurfaceBlendMode")
(define-sdl-func sdl-bool-t sdl-set-clip-rect ((surface (* sdl-surface-t)) (rect (* sdl-rect-t))) "SDL_SetClipRect")
(define-sdl-func void sdl-get-clip-rect ((surface (* sdl-surface-t)) (rect (* sdl-rect-t))) "SDL_GetClipRect")
(define-sdl-func (* sdl-surface-t) sdl-convert-surface ((src (* sdl-surface-t)) (fmt (* sdl-pixel-format-t)) (flags uint32)) "SDL_ConvertSurface")
(define-sdl-func (* sdl-surface-t) sdl-convert-surface-format ((src (* sdl-surface-t)) (pixel_format uint32) (flags uint32)) "SDL_ConvertSurfaceFormat")
(define-sdl-func int sdl-convert-pixels ((width int) (height int) (src_format uint32) (src void*) (src_pitch int) (dst_format uint32) (dst void*) (dst_pitch int)) "SDL_ConvertPixels")
(define-sdl-func int sdl-fill-rect ((dst (* sdl-surface-t)) (rect (* sdl-rect-t)) (color uint32)) "SDL_FillRect")
(define-sdl-func int sdl-fill-rects ((dst (* sdl-surface-t)) (rects (* sdl-rect-t)) (count int) (color uint32)) "SDL_FillRects")
(define-sdl-func int sdl-upper-blit ((src (* sdl-surface-t)) (srcrect (* sdl-rect-t)) (dst (* sdl-surface-t)) (dstrect (* sdl-rect-t))) "SDL_UpperBlit")
(define-sdl-func int sdl-lower-blit ((src (* sdl-surface-t)) (srcrect (* sdl-rect-t)) (dst (* sdl-surface-t)) (dstrect (* sdl-rect-t))) "SDL_LowerBlit")
(define-sdl-func int sdl-soft-stretch ((src (* sdl-surface-t)) (srcrect (* sdl-rect-t)) (dst (* sdl-surface-t)) (dstrect (* sdl-rect-t))) "SDL_SoftStretch")
(define-sdl-func int sdl-upper-blit-scaled ((src (* sdl-surface-t)) (srcrect (* sdl-rect-t)) (dst (* sdl-surface-t)) (dstrect (* sdl-rect-t))) "SDL_UpperBlitScaled")
(define-sdl-func int sdl-lower-blit-scaled ((src (* sdl-surface-t)) (srcrect (* sdl-rect-t)) (dst (* sdl-surface-t)) (dstrect (* sdl-rect-t))) "SDL_LowerBlitScaled")

Added sdl2/surface-types.ss.





































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

 (define-ftype sdl-blit-map-t (struct))
 (define-ftype sdl-surface-t
  (struct
   (flags uint32)
   (format (* sdl-pixel-format-t))
   (w int)
   (h int)
   (pitch int)
   (pixels void*)
   (userdata void*)
   (locked int)
   (lock_data void*)
   (clip_rect sdl-rect-t)
   (map (* sdl-blit-map-t)) ;; /usr/include/SDL2/SDL_surface.h:881:2
   (refcount int)))


Added sdl2/system-functions.ss.





>
>
1
2
(define-sdl-func string sdl-get-base-path () "SDL_GetBasePath")
(define-sdl-func string sdl-get-pref-path ((org string) (app string)) "SDL_GetPrefPath")

Added sdl2/thread-functions.ss.





















>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
(define-sdl-func (* sdl-thread-t) sdl-create-thread ((fn sdl-thread-function-t) (name string) (data void*)) "SDL_CreateThread")
(define-sdl-func string sdl-get-thread-name ((thread (* sdl-thread-t))) "SDL_GetThreadName")
(define-sdl-func sdl-thread-id-t sdl-thread-id () "SDL_ThreadID")
(define-sdl-func sdl-thread-id-t sdl-get-thread-id ((thread (* sdl-thread-t))) "SDL_GetThreadID")
(define-sdl-func int sdl-set-thread-priority ((priority sdl-thread-priority-t)) "SDL_SetThreadPriority")
(define-sdl-func void sdl-wait-thread ((thread (* sdl-thread-t)) (status (* int))) "SDL_WaitThread")
(define-sdl-func void sdl-detach-thread ((thread (* sdl-thread-t))) "SDL_DetachThread")
(define-sdl-func sdl-tlsid-t sdl-tls-create () "SDL_TLSCreate")
(define-sdl-func void* sdl-tls-get ((id sdl-tlsid-t)) "SDL_TLSGet")
(define-sdl-func int sdl-tls-set ((id sdl-tlsid-t) (value void*) (destructor void*)) "SDL_TLSSet")

Added sdl2/thread-types.ss.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
 (define-ftype sdl-thread-t (struct))
 (define-ftype sdl-thread-function-t void*)
 (define-ftype sdl-thread-id-t unsigned-long)
 (define-ftype sdl-tlsid-t unsigned-int)

 (define-enumeration* sdl-thread-priority
   ( low normal high ))

Added sdl2/timer-functions.ss.













>
>
>
>
>
>
1
2
3
4
5
6
(define-sdl-func uint32 sdl-get-ticks () "SDL_GetTicks")
(define-sdl-func uint64 sdl-get-performance-counter () "SDL_GetPerformanceCounter")
(define-sdl-func uint64 sdl-get-performance-frequency () "SDL_GetPerformanceFrequency")
(define-sdl-func void sdl-delay ((ms uint32)) "SDL_Delay")
(define-sdl-func sdl-timer-id-t sdl-add-timer ((interval uint32) (callback sdl-timer-callback-t) (param void*)) "SDL_AddTimer")
(define-sdl-func sdl-bool-t sdl-remove-timer ((id sdl-timer-id-t)) "SDL_RemoveTimer")

Added sdl2/timer-types.ss.









>
>
>
>
1
2
3
4

 (define-ftype sdl-timer-id-t int)
 ;(define-ftype sdl-timer-callback-t (function (uint32 void*) uint32))
 (define-ftype sdl-timer-callback-t void*)

Added sdl2/touch-functions.ss.









>
>
>
>
1
2
3
4
(define-sdl-func int sdl-get-num-touch-devices () "SDL_GetNumTouchDevices")
(define-sdl-func sdl-touch-id-t sdl-get-touch-device ((index int)) "SDL_GetTouchDevice")
(define-sdl-func int sdl-get-num-touch-fingers ((touchID sdl-touch-id-t)) "SDL_GetNumTouchFingers")
(define-sdl-func (* sdl-finger-t) sdl-get-touch-finger ((touchID sdl-touch-id-t) (index int)) "SDL_GetTouchFinger")

Added sdl2/touch-types.ss.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13

(define-ftype sdl-finger-id-t integer-64)
(define-ftype sdl-touch-id-t integer-64)

(define sdl-touch-mouseid #xffffffff)

(define-ftype sdl-finger-t
  (struct 
   (id sdl-finger-id-t)
   (x float)
   (y float)
   (pressure float)))

Added sdl2/version-functions.ss.







>
>
>
1
2
3
(define-sdl-func void sdl-get-version ((ver (* sdl-version-t))) "SDL_GetVersion")
(define-sdl-func string sdl-get-revision () "SDL_GetRevision")
(define-sdl-func int sdl-get-revision-number () "SDL_GetRevisionNumber")

Added sdl2/version-types.ss.



>
1
 (define-ftype sdl-version-t (struct (major uint8) (minor uint8) (patch uint8)))

Added sdl2/video-functions.ss.

















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
(define-sdl-func int sdl-get-num-video-drivers () "SDL_GetNumVideoDrivers")
(define-sdl-func string sdl-get-video-driver ((index int)) "SDL_GetVideoDriver")
(define-sdl-func int sdl-video-init ((driver_name string)) "SDL_VideoInit")
(define-sdl-func void sdl-video-quit () "SDL_VideoQuit")
(define-sdl-func string sdl-get-current-video-driver () "SDL_GetCurrentVideoDriver")
(define-sdl-func int sdl-get-num-video-displays () "SDL_GetNumVideoDisplays")
(define-sdl-func string sdl-get-display-name ((displayIndex int)) "SDL_GetDisplayName")
(define-sdl-func int sdl-get-display-bounds ((displayIndex int) (rect (* sdl-rect-t))) "SDL_GetDisplayBounds")
(define-sdl-func int sdl-get-num-display-modes ((displayIndex int)) "SDL_GetNumDisplayModes")
(define-sdl-func int sdl-get-display-mode ((displayIndex int) (modeIndex int) (mode (* sdl-display-mode-t))) "SDL_GetDisplayMode")
(define-sdl-func int sdl-get-desktop-display-mode ((displayIndex int) (mode (* sdl-display-mode-t))) "SDL_GetDesktopDisplayMode")
(define-sdl-func int sdl-get-current-display-mode ((displayIndex int) (mode (* sdl-display-mode-t))) "SDL_GetCurrentDisplayMode")
(define-sdl-func (* sdl-display-mode-t) sdl-get-closest-display-mode ((displayIndex int) (mode (* sdl-display-mode-t)) (closest (* sdl-display-mode-t))) "SDL_GetClosestDisplayMode")
(define-sdl-func int sdl-get-window-display-index ((window (* sdl-window-t))) "SDL_GetWindowDisplayIndex")
(define-sdl-func int sdl-set-window-display-mode ((window (* sdl-window-t)) (mode (* sdl-display-mode-t))) "SDL_SetWindowDisplayMode")
(define-sdl-func int sdl-get-window-display-mode ((window (* sdl-window-t)) (mode (* sdl-display-mode-t))) "SDL_GetWindowDisplayMode")
(define-sdl-func uint32 sdl-get-window-pixel-format ((window (* sdl-window-t))) "SDL_GetWindowPixelFormat")
(define-sdl-func (* sdl-window-t) sdl-create-window ((title string) (x int) (y int) (w int) (h int) (flags uint32)) "SDL_CreateWindow")
(define-sdl-func (* sdl-window-t) sdl-create-window-from ((data void*)) "SDL_CreateWindowFrom")
(define-sdl-func uint32 sdl-get-window-id ((window (* sdl-window-t))) "SDL_GetWindowID")
(define-sdl-func (* sdl-window-t) sdl-get-window-from-id ((id uint32)) "SDL_GetWindowFromID")
(define-sdl-func uint32 sdl-get-window-flags ((window (* sdl-window-t))) "SDL_GetWindowFlags")
(define-sdl-func void sdl-set-window-title ((window (* sdl-window-t)) (title string)) "SDL_SetWindowTitle")
(define-sdl-func string sdl-get-window-title ((window (* sdl-window-t))) "SDL_GetWindowTitle")
(define-sdl-func void sdl-set-window-icon ((window (* sdl-window-t)) (icon (* sdl-surface-t))) "SDL_SetWindowIcon")
(define-sdl-func void* sdl-set-window-data ((window (* sdl-window-t)) (name string) (userdata void*)) "SDL_SetWindowData")
(define-sdl-func void* sdl-get-window-data ((window (* sdl-window-t)) (name string)) "SDL_GetWindowData")
(define-sdl-func void sdl-set-window-position ((window (* sdl-window-t)) (x int) (y int)) "SDL_SetWindowPosition")
(define-sdl-func void sdl-get-window-position ((window (* sdl-window-t)) (x (* int)) (y (* int))) "SDL_GetWindowPosition")
(define-sdl-func void sdl-set-window-size ((window (* sdl-window-t)) (w int) (h int)) "SDL_SetWindowSize")
(define-sdl-func void sdl-get-window-size ((window (* sdl-window-t)) (w (* int)) (h (* int))) "SDL_GetWindowSize")
(define-sdl-func void sdl-set-window-minimum-size ((window (* sdl-window-t)) (min_w int) (min_h int)) "SDL_SetWindowMinimumSize")
(define-sdl-func void sdl-get-window-minimum-size ((window (* sdl-window-t)) (w (* int)) (h (* int))) "SDL_GetWindowMinimumSize")
(define-sdl-func void sdl-set-window-maximum-size ((window (* sdl-window-t)) (max_w int) (max_h int)) "SDL_SetWindowMaximumSize")
(define-sdl-func void sdl-get-window-maximum-size ((window (* sdl-window-t)) (w (* int)) (h (* int))) "SDL_GetWindowMaximumSize")
(define-sdl-func void sdl-set-window-bordered ((window (* sdl-window-t)) (bordered sdl-bool-t)) "SDL_SetWindowBordered")
(define-sdl-func void sdl-show-window ((window (* sdl-window-t))) "SDL_ShowWindow")
(define-sdl-func void sdl-hide-window ((window (* sdl-window-t))) "SDL_HideWindow")
(define-sdl-func void sdl-raise-window ((window (* sdl-window-t))) "SDL_RaiseWindow")
(define-sdl-func void sdl-maximize-window ((window (* sdl-window-t))) "SDL_MaximizeWindow")
(define-sdl-func void sdl-minimize-window ((window (* sdl-window-t))) "SDL_MinimizeWindow")
(define-sdl-func void sdl-restore-window ((window (* sdl-window-t))) "SDL_RestoreWindow")
(define-sdl-func int sdl-set-window-fullscreen ((window (* sdl-window-t)) (flags uint32)) "SDL_SetWindowFullscreen")
(define-sdl-func (* sdl-surface-t) sdl-get-window-surface ((window (* sdl-window-t))) "SDL_GetWindowSurface")
(define-sdl-func int sdl-update-window-surface ((window (* sdl-window-t))) "SDL_UpdateWindowSurface")
(define-sdl-func int sdl-update-window-surface-rects ((window (* sdl-window-t)) (rects (* sdl-rect-t)) (numrects int)) "SDL_UpdateWindowSurfaceRects")
(define-sdl-func void sdl-set-window-grab ((window (* sdl-window-t)) (grabbed sdl-bool-t)) "SDL_SetWindowGrab")
(define-sdl-func sdl-bool-t sdl-get-window-grab ((window (* sdl-window-t))) "SDL_GetWindowGrab")
(define-sdl-func int sdl-set-window-brightness ((window (* sdl-window-t)) (brightness float)) "SDL_SetWindowBrightness")
(define-sdl-func float sdl-get-window-brightness ((window (* sdl-window-t))) "SDL_GetWindowBrightness")
(define-sdl-func int sdl-set-window-gamma-ramp ((window (* sdl-window-t)) (red (* uint16)) (green (* uint16)) (blue (* uint16))) "SDL_SetWindowGammaRamp")
(define-sdl-func int sdl-get-window-gamma-ramp ((window (* sdl-window-t)) (red (* uint16)) (green (* uint16)) (blue (* uint16))) "SDL_GetWindowGammaRamp")
(define-sdl-func void sdl-destroy-window ((window (* sdl-window-t))) "SDL_DestroyWindow")
(define-sdl-func sdl-bool-t sdl-is-screen-saver-enabled () "SDL_IsScreenSaverEnabled")
(define-sdl-func void sdl-enable-screen-saver () "SDL_EnableScreenSaver")
(define-sdl-func void sdl-disable-screen-saver () "SDL_DisableScreenSaver")
(define-sdl-func int sdl-gl-load-library ((path string)) "SDL_GL_LoadLibrary")
(define-sdl-func void* sdl-gl-get-proc-address ((proc string)) "SDL_GL_GetProcAddress")
(define-sdl-func void sdl-gl-unload-library () "SDL_GL_UnloadLibrary")
(define-sdl-func sdl-bool-t sdl-gl-extension-supported ((extension string)) "SDL_GL_ExtensionSupported")
(define-sdl-func void sdl-gl-reset-attributes () "SDL_GL_ResetAttributes")
(define-sdl-func int sdl-gl-set-attribute ((attr sdl-gl-attr-t) (value int)) "SDL_GL_SetAttribute")
(define-sdl-func int sdl-gl-get-attribute ((attr sdl-gl-attr-t) (value (* int))) "SDL_GL_GetAttribute")
(define-sdl-func sdl-gl-context-t sdl-gl-create-context ((window (* sdl-window-t))) "SDL_GL_CreateContext")
(define-sdl-func int sdl-gl-make-current ((window (* sdl-window-t)) (context sdl-gl-context-t)) "SDL_GL_MakeCurrent")
(define-sdl-func (* sdl-window-t) sdl-gl-get-current-window () "SDL_GL_GetCurrentWindow")
(define-sdl-func sdl-gl-context-t sdl-gl-get-current-context () "SDL_GL_GetCurrentContext")
(define-sdl-func void sdl-gl-get-drawable-size ((window (* sdl-window-t)) (w (* int)) (h (* int))) "SDL_GL_GetDrawableSize")
(define-sdl-func int sdl-gl-set-swap-interval ((interval int)) "SDL_GL_SetSwapInterval")
(define-sdl-func int sdl-gl-get-swap-interval () "SDL_GL_GetSwapInterval")
(define-sdl-func void sdl-gl-swap-window ((window (* sdl-window-t))) "SDL_GL_SwapWindow")
(define-sdl-func void sdl-gl-delete-context ((context sdl-gl-context-t)) "SDL_GL_DeleteContext")

Added sdl2/video-types.ss.















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

 (define-ftype sdl-display-mode-t ; /usr/include/SDL2/SDL_video.h:53:9
   (struct 
    (format uint32)
    (w int)
    (h int)
    (refresh-rate int)
    (driverdata void*)))

 (define-ftype sdl-window-t (struct))

 (define-flags sdl-window-flags
     (fullscreen   #x00000001)        ; fullscreen window */
     (opengl   #x00000002)            ; window usable with opengl context */
     (shown   #x00000004)             ; window is visible */
     (hidden   #x00000008)            ; window is not visible */
     (borderless   #x00000010)        ; no window decoration */
     (resizable   #x00000020)         ; window can be resized */
     (minimized   #x00000040)         ; window is minimized */
     (maximized   #x00000080)         ; window is maximized */
     (input_grabbed   #x00000100)     ; window has grabbed input focus */
     (input-focus   #x00000200)       ; window has input focus */
     (mouse-focus   #x00000400)       ; window has mouse focus */
     (fullscreen-desktop   #x00001001)
     (foreign   #x00000800)           ; window not created by sdl */
     (allow-highdpi   #x00002000))    ; window should be created in high-dpi mode if supported */



 (define sdl-window-pos-undefined #x1fff0000)
 (define (sdl-window-pos-undefined? x)
   (= (logand x #xffff0000) sdl-window-pos-undefined))

 (define sdl-window-pos-centered #x2fff0000)
 (define (sdl-window-pos-centered? x)
   (= (logand x #xffff0000) sdl-window-pos-centered))

 (define-enumeration* sdl-window-event-enum
    (none       ; never used */
     shown        ; window has been shown */
     hidden       ; window has been hidden */
     exposed      ; window has been exposed and should beredrawn */
     moved        ; window has been moved to data1, data2 */
     resized      ; window has been resized to data1xdata2 */
     size-changed ; the window size has changed, either as a result of an
                                        ; api call or through the system or user changing the window size. */
     minimized    ; window has been minimized */
     maximized    ; window has been maximized */
     restored     ; window has been restored to normal sizeand position */
     enter        ; window has gained mouse focus */
     leave        ; window has lost mouse focus */
     focus-gained ; window has gained keyboard focus */
     focus-lost   ; window has lost keyboard focus */
     close      ; The window manager requests that thewindow be closed */
     ))

 (define-enumeration* sdl-gl-attr
   (red-size green-size blue-size
	     alpha-size buffer-size doublebuffer depth-size stencil-size
	      accum-red-size accum-green-size accum-blue-size accum-alpha-size
	      stereo multisamplebuffers multisamplesamples accelerated-visual
	      retained-backing context-major-version context-minor-version
	      context-egl context-flags context-profile-mask
	      share-with-current-context framebuffer-srgb-capable))

 (define-flags sdl-gl-profile (core 1) (compatibility 2) (es 4))

 (define-flags sdl-gl-context-flag (debug 1) (forward-compatible 2) (robust-access 4) (reset-isolation 8))

(define-ftype sdl-gl-context-t void*)