-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDL.d
1202 lines (1100 loc) · 33.8 KB
/
SDL.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MIT License
Copyright (c) 2019 Seth Ballantyne
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
_ _ ___ _____ _ __ _____ _ _ _____
| | | | / _ \/ __ \| | / / |_ _| | | || ___|
| |_| |/ /_\ \ / \/| |/ / | | | |_| || |__
| _ || _ | | | \ | | | _ || __|
| | | || | | | \__/\| |\ \ | | | | | || |___
\_| |_/\_| |_/\____/\_| \_/ \_/ \_| |_/\____/
______ _ ___ _ _ _____ _____
| ___ \ | / _ \ | \ | || ___|_ _|
| |_/ / | / /_\ \| \| || |__ | |
| __/| | | _ || . ` || __| | |
| | | |____| | | || |\ || |___ | |
\_| \_____/\_| |_/\_| \_/\____/ \_/
*/
module SDL;
import std;
enum SDL_LIL_ENDIAN = 1234;
enum SDL_BIG_ENDIAN = 4321;
// x86* is assumed, because that's what I'm using. :P
enum SDL_BYTEORDER = SDL_LIL_ENDIAN;
//---------------------------------------------------------------------
// SDL-flavoured basic data types from SDL_stdinc.h
//---------------------------------------------------------------------
// don't really need SDL_bool but it's here for completeness
enum SDL_bool { SDL_FALSE = 0, SDL_TRUE = 1 }
alias byte Sint8;
alias ubyte Uint8;
alias short Sint16;
alias ushort Uint16;
alias int Sint32;
alias uint Uint32;
alias long Sint64;
alias ulong Uint64;
// Everything below this line is found within the SDL docs. If it's
// not in the docs, it's not here and you'll have to port it yourself.
// missing: SDL_envvars. I don't need it.
//---------------------------------------------------------------------
// Chap 5. GENERAL
//---------------------------------------------------------------------
// I could have done it the enum FLAGS {...} way, but I want it
// to resemble the C version of SDL as close as possible for when people
// are porting C code to D; also handy if someone is using old
//tutorials/books and wants to use D instead of C (like me from time to time).
enum Uint32 SDL_INIT_TIMER = 0x00000001;
enum Uint32 SDL_INIT_AUDIO = 0x00000010;
enum Uint32 SDL_INIT_VIDEO = 0x00000020;
enum Uint32 SDL_INIT_CDROM = 0x00000100;
enum Uint32 SDL_INIT_JOYSTICK = 0x00000200;
enum Uint32 SDL_INIT_NOPARACHUTE = 0x00100000;
enum Uint32 SDL_INIT_EVENTTHREAD = 0x01000000;
enum Uint32 SDL_INIT_EVERYTHING = 0x0000FFFF;
extern(C) int SDL_Init(Uint32 flags);
extern(C) int SDL_InitSubSystem(Uint32 flags);
extern(C) void SDL_QuitSubSystem(Uint32 flags);
extern(C) void SDL_Quit();
extern(C) Uint32 SDL_WasInit(Uint32 flags);
extern(C) char *SDL_GetError();
extern(C) void SDL_SetError(const char *fmt, ...);
extern(C) void SDL_ClearError();
//---------------------------------------------------------------------
// Chap 6. VIDEO
//--------------------------------------------------------------------
extern (C) struct SDL_Color
{
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 unused;
}
extern (C) struct SDL_Palette
{
int ncolors;
SDL_Color *colors;
}
extern (C) struct SDL_PixelFormat
{
SDL_Palette *palette;
Uint8 BitsPerPixel;
Uint8 BytesPerPixel;
Uint8 Rloss;
Uint8 Gloss;
Uint8 Bloss;
Uint8 Aloss;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
Uint32 colorkey;
Uint8 alpha;
}
extern (C) struct SDL_Rect
{
Sint16 x, y;
Uint16 w, h;
}
struct private_hwdata;
struct SDL_BlitMap;
extern (C) struct SDL_Surface
{
Uint32 flags;
SDL_PixelFormat *format;
int w, h;
Uint16 pitch;
void *pixels;
int offset;
private_hwdata *hwdata;
SDL_Rect clip_rect;
Uint32 unused1;
Uint32 locked;
SDL_BlitMap *map;
uint format_version;
int refcount;
}
extern(C) struct SDL_VideoInfo
{
mixin(bitfields!(
Uint32, "hw_available",1,
Uint32, "wm_available",1,
Uint32, "blit_hw",1,
Uint32, "blit_hw_CC",1,
Uint32, "blit_hw_A",1,
Uint32, "blit_sw",1,
Uint32, "blit_sw_CC",1,
Uint32, "blit_sw_A",1));
Uint32 blit_fill;
Uint32 video_mem;
SDL_PixelFormat *vfmt;
}
struct WMcursor;
extern(C) struct SDL_Cursor {
SDL_Rect area;
Sint16 hot_x, hot_y;
Uint8 *data;
Uint8 *mask;
Uint8*[2] save;
WMcursor *wm_cursor;
}
struct private_yuvhwfuncs;
struct private_yuvhwdata;
struct SDL_Overlay {
Uint32 format;
int w, h;
int planes;
Uint16 *pitches;
Uint8 **pixels;
private_yuvhwfuncs *hwfuncs;
private_yuvhwdata *hwdata;
mixin(bitfields!(
Uint32, "hw_overlay",1,
Uint32, "UnusedBits",31));
}
enum Uint32 SDL_SWSURFACE = 0x00000000;
enum Uint32 SDL_HWSURFACE = 0x00000001;
enum Uint32 SDL_ASYNCBLIT = 0x00000004;
enum Uint32 SDL_ANYFORMAT = 0x10000000;
enum Uint32 SDL_HWPALETTE = 0x20000000;
enum Uint32 SDL_DOUBLEBUF = 0x40000000;
enum Uint32 SDL_FULLSCREEN = 0x80000000;
enum Uint32 SDL_OPENGL = 0x00000002;
enum Uint32 SDL_OPENGLBLIT = 0x0000000A;
enum Uint32 SDL_RESIZABLE = 0x00000010;
enum Uint32 SDL_NOFRAME = 0x00000020;
// only used internally by SDL. They're here because SDL_MUSTLOCK
// requires SDL_RLEACCEL and fuck it. Might need the others down the road.
enum Uint32 SDL_HWACCEL = 0x00000100;
enum Uint32 SDL_SRCCOLORKEY = 0x00001000;
enum Uint32 SDL_RLEACCELOK = 0x00002000;
enum Uint32 SDL_RLEACCEL = 0x00004000;
enum Uint32 SDL_SRCALPHA = 0x00010000;
enum Uint32 SDL_PREALLOC = 0x01000000;
// couldn't find these in the headers but they're mentioned in the docs
// for SDL_SetAlpha().
enum Uint8 SDL_ALPHA_TRANSPARENT = 0x0;
enum Uint8 SDL_ALPHA_OPAQUE = 0xFF;
enum int SDL_QUERY =-1;
enum int SDL_IGNORE = 0;
enum int SDL_DISABLE = 0;
enum int SDL_ENABLE = 1;
enum SDL_GLattr
{
SDL_GL_RED_SIZE,
SDL_GL_GREEN_SIZE,
SDL_GL_BLUE_SIZE,
SDL_GL_ALPHA_SIZE,
SDL_GL_BUFFER_SIZE,
SDL_GL_DOUBLEBUFFER,
SDL_GL_DEPTH_SIZE,
SDL_GL_STENCIL_SIZE,
SDL_GL_ACCUM_RED_SIZE,
SDL_GL_ACCUM_GREEN_SIZE,
SDL_GL_ACCUM_BLUE_SIZE,
SDL_GL_ACCUM_ALPHA_SIZE,
SDL_GL_STEREO,
SDL_GL_MULTISAMPLEBUFFERS,
SDL_GL_MULTISAMPLESAMPLES,
SDL_GL_ACCELERATED_VISUAL,
SDL_GL_SWAP_CONTROL
}
extern(C) struct SDL_RWops {
//int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
int function(SDL_RWops *context, int offset, int whence) seek;
//int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
int function(SDL_RWops *context, void *ptr, int size, int maxnum) read;
//int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
int function(SDL_RWops *context, const void *ptr, int size, int num) write;
//int (SDLCALL *close)(struct SDL_RWops *context);
int function(SDL_RWops *context) close;
Uint32 type;
union _hidden
{
//#if defined(__WIN32__) && !defined(__SYMBIAN32__)
version(Windows)
{
struct _win32io
{
int append;
void *h;
struct _buffer
{
void *data;
int size;
int left;
}
_buffer buffer;
}
_win32io win32io;
}
//#endif
struct _stdio
{
int autoclose;
FILE *fp;
}
_stdio stdio;
struct _mem
{
Uint8 *base;
Uint8 *here;
Uint8 *stop;
}
_mem mem;
struct _unknown
{
void *data1;
}
_unknown unknown;
}
_hidden hidden;
}
bool SDL_MUSTLOCK(SDL_Surface *surface)
{
pragma(inline, true);
return (surface.offset || ((surface.flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0));
}
extern(C) SDL_RWops *SDL_RWFromFile(const char *file, const char *mode);
SDL_Surface *SDL_LoadBMP(const char *file)
{
pragma(inline, true);
return SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1);
}
int SDL_SaveBMP(SDL_Surface *surface, const char *file)
{
pragma(inline, true);
return SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1);
}
extern(C) SDL_Surface *SDL_GetVideoSurface();
extern(C) SDL_VideoInfo *SDL_GetVideoInfo();
extern(C) char* SDL_VideoDriverName(char *namebuf, int maxlen);
extern(C) SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
extern(C) int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);
extern(C) SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
extern(C) void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
extern(C) void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);
extern(C) int SDL_Flip(SDL_Surface *screen);
extern(C) int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
extern(C) int SDL_SetPalette(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);
extern(C) int SDL_SetGamma(float redgamma, float greengamma, float bluegamma);
extern(C) int SDL_GetGammaRamp(Uint16 *redtable, Uint16 *greentable, Uint16 *bluetable);
extern(C) int SDL_SetGammaRamp(Uint16 *redtable, Uint16 *greentable, Uint16 *bluetable);
extern(C) Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);
extern(C) Uint32 SDL_MapRGBA(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern(C) void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b);
extern(C) void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
extern(C) SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern(C) SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern(C) void SDL_FreeSurface(SDL_Surface *surface);
extern(C) int SDL_LockSurface(SDL_Surface *surface);
extern(C) void SDL_UnlockSurface(SDL_Surface *surface);
extern(C) SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
extern(C) int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
extern(C) int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
extern(C) int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
extern(C) void SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect);
extern(C) void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
extern(C) SDL_Surface *SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
extern(C) int SDL_UpperBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
alias SDL_UpperBlit SDL_BlitSurface;
extern(C) int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
extern(C) SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface);
extern(C) SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface);
extern(C) void SDL_WarpMouse(Uint16 x, Uint16 y);
extern(C) SDL_Cursor *SDL_CreateCursor(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
extern(C) void SDL_FreeCursor(SDL_Cursor *cursor);
extern(C) void SDL_SetCursor(SDL_Cursor *cursor);
extern(C) SDL_Cursor *SDL_GetCursor();
extern(C) int SDL_ShowCursor(int toggle);
extern(C) int SDL_GL_LoadLibrary(const char *path);
extern(C) void *SDL_GL_GetProcAddress(const char* proc);
extern(C) int SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
extern(C) int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
extern(C) void SDL_GL_SwapBuffers();
extern(C) SDL_Overlay *SDL_CreateYUVOverlay(int width, int height, Uint32 format, SDL_Surface *display);
extern(C) int SDL_LockYUVOverlay(SDL_Overlay *overlay);
extern(C) void SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
extern(C) int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
extern(C) void SDL_FreeYUVOverlay(SDL_Overlay *overlay);
//---------------------------------------------------------------------
// CHAPTER 7. WINDOW MANAGEMENT
//---------------------------------------------------------------------
enum SDL_GrabMode
{
SDL_GRAB_QUERY = -1,
SDL_GRAB_OFF = 0,
SDL_GRAB_ON = 1,
SDL_GRAB_FULLSCREEN // only used internally by SDL but here for completeness.
}
extern(C) void SDL_WM_SetCaption(const char *title, const char *icon);
extern(C) void SDL_WM_GetCaption(char **title, char **icon);
extern(C) void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);
extern(C) int SDL_WM_IconifyWindow();
extern(C) int SDL_WM_ToggleFullScreen(SDL_Surface *surface);
extern(C) SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode);
//--------------------------------------------------------------------
// CHAPTER 8. EVENTS
//--------------------------------------------------------------------
extern(C) struct SDL_ActiveEvent
{
Uint8 type;
Uint8 gain;
Uint8 state;
}
extern(C) struct SDL_KeyboardEvent
{
Uint8 type;
Uint8 which;
Uint8 state;
SDL_keysym keysym;
}
extern(C) struct SDL_MouseMotionEvent
{
Uint8 type;
Uint8 which;
Uint8 state;
Uint16 x, y;
Sint16 xrel;
Sint16 yrel;
}
extern(C) struct SDL_MouseButtonEvent
{
Uint8 type;
Uint8 which;
Uint8 button;
Uint8 state;
Uint16 x, y;
}
extern(C) struct SDL_JoyAxisEvent
{
Uint8 type;
Uint8 which;
Uint8 axis;
Sint16 value;
}
extern(C) struct SDL_JoyBallEvent
{
Uint8 type;
Uint8 which;
Uint8 ball;
Sint16 xrel;
Sint16 yrel;
}
extern(C) struct SDL_JoyHatEvent
{
Uint8 type;
Uint8 which;
Uint8 hat;
Uint8 value;
}
extern(C) struct SDL_JoyButtonEvent
{
Uint8 type;
Uint8 which;
Uint8 button;
Uint8 state;
}
extern(C) struct SDL_ResizeEvent
{
Uint8 type;
int w;
int h;
}
extern(C) struct SDL_ExposeEvent
{
Uint8 type;
}
extern(C) struct SDL_QuitEvent
{
Uint8 type;
}
extern(C) struct SDL_UserEvent
{
Uint8 type;
int code;
void *data1;
void *data2;
}
struct SDL_SysWMmsg;
extern(C) struct SDL_SysWMEvent
{
Uint8 type;
SDL_SysWMmsg *msg;
}
extern(C) union SDL_Event
{
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
SDL_MouseMotionEvent motion;
SDL_MouseButtonEvent button;
SDL_JoyAxisEvent jaxis;
SDL_JoyBallEvent jball;
SDL_JoyHatEvent jhat;
SDL_JoyButtonEvent jbutton;
SDL_ResizeEvent resize;
SDL_ExposeEvent expose;
SDL_QuitEvent quit;
SDL_UserEvent user;
SDL_SysWMEvent syswm;
}
enum SDL_EventType
{
SDL_NOEVENT = 0,
SDL_ACTIVEEVENT,
SDL_KEYDOWN,
SDL_KEYUP,
SDL_MOUSEMOTION,
SDL_MOUSEBUTTONDOWN,
SDL_MOUSEBUTTONUP,
SDL_JOYAXISMOTION,
SDL_JOYBALLMOTION,
SDL_JOYHATMOTION,
SDL_JOYBUTTONDOWN,
SDL_JOYBUTTONUP,
SDL_QUIT,
SDL_SYSWMEVENT,
SDL_EVENT_RESERVEDA,
SDL_EVENT_RESERVEDB,
SDL_VIDEORESIZE,
SDL_VIDEOEXPOSE,
SDL_EVENT_RESERVED2,
SDL_EVENT_RESERVED3,
SDL_EVENT_RESERVED4,
SDL_EVENT_RESERVED5,
SDL_EVENT_RESERVED6,
SDL_EVENT_RESERVED7,
// Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
SDL_USEREVENT = 24,
// used internally by SDL
SDL_NUMEVENTS = 32
}
enum Uint8 SDL_APPMOUSEFOCUS = 0x01;
enum Uint8 SDL_APPINPUTFOCUS = 0x02;
enum Uint8 SDL_APPACTIVE = 0x04;
enum Uint8 SDL_RELEASED = 0;
enum Uint8 SDL_PRESSED = 1;
/*enum Uint8 SDL_HAT_CENTERED = 0x00;
enum Uint8 SDL_HAT_UP = 0x01;
enum Uint8 SDL_HAT_RIGHT = 0x02;
enum Uint8 SDL_HAT_DOWN = 0x04;
enum Uint8 SDL_HAT_LEFT = 0x08;
enum Uint8 SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT|SDL_HAT_UP);
enum Uint8 SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT|SDL_HAT_DOWN);
enum Uint8 SDL_HAT_LEFTUP = (SDL_HAT_LEFT|SDL_HAT_UP);
enum Uint8 SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT|SDL_HAT_DOWN);*/
extern(C) struct SDL_version {
Uint8 major;
Uint8 minor;
Uint8 patch;
}
enum Uint8 SDL_MAJOR_VERSION = 1;
enum Uint8 SDL_MINOR_VERSION = 2;
enum Uint8 SDL_PATCHLEVEL = 15;
void SDL_VERSION(SDL_version *x)
{
pragma(inline, true);
x.major = SDL_MAJOR_VERSION;
x.minor = SDL_MINOR_VERSION;
x.patch = SDL_PATCHLEVEL;
}
extern(C) const(SDL_version) *SDL_Linked_Version();
/*#define SDL_QuitRequested() \
(SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK))*/
int SDL_QuitRequested()
{
pragma(inline, true);
SDL_PumpEvents();
return SDL_PeepEvents(null, 0, SDL_eventaction.SDL_PEEKEVENT, SDL_EventMask.SDL_QUITMASK);
}
enum SDL_eventaction
{
SDL_ADDEVENT,
SDL_PEEKEVENT,
SDL_GETEVENT
};
extern(C) struct SDL_keysym
{
Uint8 scancode;
SDLKey sym;
SDLMod mod;
Uint16 unicode;
}
//#define SDL_EVENTMASK(X) (1<<(X))
Uint32 SDL_EVENTMASK(Uint32 X)
{
pragma(inline, true);
return (1 << X);
}
enum SDL_EventMask
{
SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_EventType.SDL_ACTIVEEVENT),
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_EventType.SDL_KEYDOWN),
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_EventType.SDL_KEYUP),
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_EventType.SDL_KEYDOWN)|
SDL_EVENTMASK(SDL_EventType.SDL_KEYUP),
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_EventType.SDL_MOUSEMOTION),
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_EventType.SDL_MOUSEBUTTONDOWN),
SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_EventType.SDL_MOUSEBUTTONUP),
SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_EventType.SDL_MOUSEMOTION)|
SDL_EVENTMASK(SDL_EventType.SDL_MOUSEBUTTONDOWN)|
SDL_EVENTMASK(SDL_EventType.SDL_MOUSEBUTTONUP),
SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYAXISMOTION),
SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYBALLMOTION),
SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYHATMOTION),
SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYBUTTONDOWN),
SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYBUTTONUP),
SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_EventType.SDL_JOYAXISMOTION)|
SDL_EVENTMASK(SDL_EventType.SDL_JOYBALLMOTION)|
SDL_EVENTMASK(SDL_EventType.SDL_JOYHATMOTION)|
SDL_EVENTMASK(SDL_EventType.SDL_JOYBUTTONDOWN)|
SDL_EVENTMASK(SDL_EventType.SDL_JOYBUTTONUP),
SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_EventType.SDL_VIDEORESIZE),
SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_EventType.SDL_VIDEOEXPOSE),
SDL_QUITMASK = SDL_EVENTMASK(SDL_EventType.SDL_QUIT),
SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_EventType.SDL_SYSWMEVENT)
}
enum SDLKey
{
SDLK_UNKNOWN = 0,
SDLK_FIRST = 0,
SDLK_BACKSPACE = 8,
SDLK_TAB = 9,
SDLK_CLEAR = 12,
SDLK_RETURN = 13,
SDLK_PAUSE = 19,
SDLK_ESCAPE = 27,
SDLK_SPACE = 32,
SDLK_EXCLAIM = 33,
SDLK_QUOTEDBL = 34,
SDLK_HASH = 35,
SDLK_DOLLAR = 36,
SDLK_AMPERSAND = 38,
SDLK_QUOTE = 39,
SDLK_LEFTPAREN = 40,
SDLK_RIGHTPAREN = 41,
SDLK_ASTERISK = 42,
SDLK_PLUS = 43,
SDLK_COMMA = 44,
SDLK_MINUS = 45,
SDLK_PERIOD = 46,
SDLK_SLASH = 47,
SDLK_0 = 48,
SDLK_1 = 49,
SDLK_2 = 50,
SDLK_3 = 51,
SDLK_4 = 52,
SDLK_5 = 53,
SDLK_6 = 54,
SDLK_7 = 55,
SDLK_8 = 56,
SDLK_9 = 57,
SDLK_COLON = 58,
SDLK_SEMICOLON = 59,
SDLK_LESS = 60,
SDLK_EQUALS = 61,
SDLK_GREATER = 62,
SDLK_QUESTION = 63,
SDLK_AT = 64,
/*
Skip uppercase letters
*/
SDLK_LEFTBRACKET = 91,
SDLK_BACKSLASH = 92,
SDLK_RIGHTBRACKET = 93,
SDLK_CARET = 94,
SDLK_UNDERSCORE = 95,
SDLK_BACKQUOTE = 96,
SDLK_a = 97,
SDLK_b = 98,
SDLK_c = 99,
SDLK_d = 100,
SDLK_e = 101,
SDLK_f = 102,
SDLK_g = 103,
SDLK_h = 104,
SDLK_i = 105,
SDLK_j = 106,
SDLK_k = 107,
SDLK_l = 108,
SDLK_m = 109,
SDLK_n = 110,
SDLK_o = 111,
SDLK_p = 112,
SDLK_q = 113,
SDLK_r = 114,
SDLK_s = 115,
SDLK_t = 116,
SDLK_u = 117,
SDLK_v = 118,
SDLK_w = 119,
SDLK_x = 120,
SDLK_y = 121,
SDLK_z = 122,
SDLK_DELETE = 127,
SDLK_WORLD_0 = 160, /* 0xA0 */
SDLK_WORLD_1 = 161,
SDLK_WORLD_2 = 162,
SDLK_WORLD_3 = 163,
SDLK_WORLD_4 = 164,
SDLK_WORLD_5 = 165,
SDLK_WORLD_6 = 166,
SDLK_WORLD_7 = 167,
SDLK_WORLD_8 = 168,
SDLK_WORLD_9 = 169,
SDLK_WORLD_10 = 170,
SDLK_WORLD_11 = 171,
SDLK_WORLD_12 = 172,
SDLK_WORLD_13 = 173,
SDLK_WORLD_14 = 174,
SDLK_WORLD_15 = 175,
SDLK_WORLD_16 = 176,
SDLK_WORLD_17 = 177,
SDLK_WORLD_18 = 178,
SDLK_WORLD_19 = 179,
SDLK_WORLD_20 = 180,
SDLK_WORLD_21 = 181,
SDLK_WORLD_22 = 182,
SDLK_WORLD_23 = 183,
SDLK_WORLD_24 = 184,
SDLK_WORLD_25 = 185,
SDLK_WORLD_26 = 186,
SDLK_WORLD_27 = 187,
SDLK_WORLD_28 = 188,
SDLK_WORLD_29 = 189,
SDLK_WORLD_30 = 190,
SDLK_WORLD_31 = 191,
SDLK_WORLD_32 = 192,
SDLK_WORLD_33 = 193,
SDLK_WORLD_34 = 194,
SDLK_WORLD_35 = 195,
SDLK_WORLD_36 = 196,
SDLK_WORLD_37 = 197,
SDLK_WORLD_38 = 198,
SDLK_WORLD_39 = 199,
SDLK_WORLD_40 = 200,
SDLK_WORLD_41 = 201,
SDLK_WORLD_42 = 202,
SDLK_WORLD_43 = 203,
SDLK_WORLD_44 = 204,
SDLK_WORLD_45 = 205,
SDLK_WORLD_46 = 206,
SDLK_WORLD_47 = 207,
SDLK_WORLD_48 = 208,
SDLK_WORLD_49 = 209,
SDLK_WORLD_50 = 210,
SDLK_WORLD_51 = 211,
SDLK_WORLD_52 = 212,
SDLK_WORLD_53 = 213,
SDLK_WORLD_54 = 214,
SDLK_WORLD_55 = 215,
SDLK_WORLD_56 = 216,
SDLK_WORLD_57 = 217,
SDLK_WORLD_58 = 218,
SDLK_WORLD_59 = 219,
SDLK_WORLD_60 = 220,
SDLK_WORLD_61 = 221,
SDLK_WORLD_62 = 222,
SDLK_WORLD_63 = 223,
SDLK_WORLD_64 = 224,
SDLK_WORLD_65 = 225,
SDLK_WORLD_66 = 226,
SDLK_WORLD_67 = 227,
SDLK_WORLD_68 = 228,
SDLK_WORLD_69 = 229,
SDLK_WORLD_70 = 230,
SDLK_WORLD_71 = 231,
SDLK_WORLD_72 = 232,
SDLK_WORLD_73 = 233,
SDLK_WORLD_74 = 234,
SDLK_WORLD_75 = 235,
SDLK_WORLD_76 = 236,
SDLK_WORLD_77 = 237,
SDLK_WORLD_78 = 238,
SDLK_WORLD_79 = 239,
SDLK_WORLD_80 = 240,
SDLK_WORLD_81 = 241,
SDLK_WORLD_82 = 242,
SDLK_WORLD_83 = 243,
SDLK_WORLD_84 = 244,
SDLK_WORLD_85 = 245,
SDLK_WORLD_86 = 246,
SDLK_WORLD_87 = 247,
SDLK_WORLD_88 = 248,
SDLK_WORLD_89 = 249,
SDLK_WORLD_90 = 250,
SDLK_WORLD_91 = 251,
SDLK_WORLD_92 = 252,
SDLK_WORLD_93 = 253,
SDLK_WORLD_94 = 254,
SDLK_WORLD_95 = 255, /* 0xFF */
/*Numeric keypad */
SDLK_KP0 = 256,
SDLK_KP1 = 257,
SDLK_KP2 = 258,
SDLK_KP3 = 259,
SDLK_KP4 = 260,
SDLK_KP5 = 261,
SDLK_KP6 = 262,
SDLK_KP7 = 263,
SDLK_KP8 = 264,
SDLK_KP9 = 265,
SDLK_KP_PERIOD = 266,
SDLK_KP_DIVIDE = 267,
SDLK_KP_MULTIPLY = 268,
SDLK_KP_MINUS = 269,
SDLK_KP_PLUS = 270,
SDLK_KP_ENTER = 271,
SDLK_KP_EQUALS = 272,
/*Arrows + Home/End pad */
SDLK_UP = 273,
SDLK_DOWN = 274,
SDLK_RIGHT = 275,
SDLK_LEFT = 276,
SDLK_INSERT = 277,
SDLK_HOME = 278,
SDLK_END = 279,
SDLK_PAGEUP = 280,
SDLK_PAGEDOWN = 281,
/* Function keys */
SDLK_F1 = 282,
SDLK_F2 = 283,
SDLK_F3 = 284,
SDLK_F4 = 285,
SDLK_F5 = 286,
SDLK_F6 = 287,
SDLK_F7 = 288,
SDLK_F8 = 289,
SDLK_F9 = 290,
SDLK_F10 = 291,
SDLK_F11 = 292,
SDLK_F12 = 293,
SDLK_F13 = 294,
SDLK_F14 = 295,
SDLK_F15 = 296,
/*Key state modifier keys */
SDLK_NUMLOCK = 300,
SDLK_CAPSLOCK = 301,
SDLK_SCROLLOCK = 302,
SDLK_RSHIFT = 303,
SDLK_LSHIFT = 304,
SDLK_RCTRL = 305,
SDLK_LCTRL = 306,
SDLK_RALT = 307,
SDLK_LALT = 308,
SDLK_RMETA = 309,
SDLK_LMETA = 310,
SDLK_LSUPER = 311, /*Left "Windows" key */
SDLK_RSUPER = 312, /*Right "Windows" key */
SDLK_MODE = 313, /*"Alt Gr" key */
SDLK_COMPOSE = 314, /*Multi-key compose key */
/*Miscellaneous function keys */
SDLK_HELP = 315,
SDLK_PRINT = 316,
SDLK_SYSREQ = 317,
SDLK_BREAK = 318,
SDLK_MENU = 319,
SDLK_POWER = 320, /* Power Macintosh power key */
SDLK_EURO = 321, /* Some european keyboards */
SDLK_UNDO = 322, /* Atari keyboard has Undo */
/* Add any other keys here */
SDLK_LAST
}
enum SDLMod
{
KMOD_NONE = 0x0000,
KMOD_LSHIFT= 0x0001,
KMOD_RSHIFT= 0x0002,
KMOD_LCTRL = 0x0040,
KMOD_RCTRL = 0x0080,
KMOD_LALT = 0x0100,
KMOD_RALT = 0x0200,
KMOD_LMETA = 0x0400,
KMOD_RMETA = 0x0800,
KMOD_NUM = 0x1000,
KMOD_CAPS = 0x2000,
KMOD_MODE = 0x4000,
KMOD_RESERVED = 0x8000
}
enum KMOD_CTRL = (SDLMod.KMOD_LCTRL|SDLMod.KMOD_RCTRL);
enum KMOD_SHIFT = (SDLMod.KMOD_LSHIFT|SDLMod.KMOD_RSHIFT);
enum KMOD_ALT = (SDLMod.KMOD_LALT|SDLMod.KMOD_RALT);
enum KMOD_META =(SDLMod.KMOD_LMETA|SDLMod.KMOD_RMETA);
enum int SDL_DEFAULT_REPEAT_DELAY = 500;
enum int SDL_DEFAULT_REPEAT_INTERVAL = 30;
//#define SDL_BUTTON(X) (1 << ((X)-1))
Uint8 SDL_BUTTON(Uint8 X)
{
pragma(inline, true);
return cast(ubyte)(1 << (X - 1));
}
enum SDL_BUTTON_LEFT = 1;
enum SDL_BUTTON_MIDDLE = 2;
enum SDL_BUTTON_RIGHT = 3;
enum SDL_BUTTON_WHEELUP = 4;
enum SDL_BUTTON_WHEELDOWN = 5;
enum SDL_BUTTON_X1 = 6;
enum SDL_BUTTON_X2 = 7;
enum SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT);
enum SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE);
enum SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT);
enum SDL_BUTTON_X1MASK = SDL_BUTTON(SDL_BUTTON_X1);
enum SDL_BUTTON_X2MASK = SDL_BUTTON(SDL_BUTTON_X2);
extern(C) void SDL_PumpEvents();
extern(C) int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask);
extern(C) int SDL_PollEvent(SDL_Event *event);
extern(C) int SDL_WaitEvent(SDL_Event *event);
extern(C) int SDL_PushEvent(SDL_Event *event);
extern(C) alias SDL_EventFilter = int function(const SDL_Event *event);
extern(C) void SDL_SetEventFilter(SDL_EventFilter filter);
extern(C) SDL_EventFilter SDL_GetEventFilter();
extern(C) Uint8 SDL_EventState(Uint8 type, int state);
extern(C) Uint8 *SDL_GetKeyState(int *numkeys);
extern(C) SDLMod SDL_GetModState();
extern(C) void SDL_SetModState(SDLMod modstate);
extern(C) char *SDL_GetKeyName(SDLKey key);
extern(C) int SDL_EnableUNICODE(int enable);
extern(C) int SDL_EnableKeyRepeat(int delay, int interval);
extern(C) Uint8 SDL_GetMouseState(int *x, int *y);
extern(C) Uint8 SDL_GetRelativeMouseState(int *x, int *y);
extern(C) Uint8 SDL_GetAppState();
int SDL_JoystickEventState(int state);
//--------------------------------------------------------------------
// CHAPTER 9. JOYSTICK
//--------------------------------------------------------------------
enum SDL_HAT_CENTERED = 0x00;
enum SDL_HAT_UP = 0x01;
enum SDL_HAT_RIGHT = 0x02;
enum SDL_HAT_DOWN = 0x04;
enum SDL_HAT_LEFT = 0x08;
enum SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT|SDL_HAT_UP);
enum SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT|SDL_HAT_DOWN);
enum SDL_HAT_LEFTUP = (SDL_HAT_LEFT|SDL_HAT_UP);
enum SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT|SDL_HAT_DOWN);
struct SDL_Joystick;
extern(C) int SDL_NumJoysticks();
extern(C) const(char)* SDL_JoystickName(int index);
extern(C) SDL_Joystick *SDL_JoystickOpen(int index);
extern(C) int SDL_JoystickOpened(int index);
extern(C) int SDL_JoystickIndex(SDL_Joystick *joystick);
extern(C) int SDL_JoystickNumAxes(SDL_Joystick *joystick);
extern(C) int SDL_JoystickNumBalls(SDL_Joystick *joystick);
extern(C) int SDL_JoystickNumHats(SDL_Joystick *joystick);
extern(C) int SDL_JoystickNumButtons(SDL_Joystick *joystick);
extern(C) void SDL_JoystickUpdate();
extern(C) Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
extern(C) Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
extern(C) Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
extern(C) int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
extern(C) void SDL_JoystickClose(SDL_Joystick *joystick);
//---------------------------------------------------------------------
// CHAPTER 10. AUDIO
//---------------------------------------------------------------------
extern(C) alias Callback = void function(void *userdata, Uint8 *stream, int len);
extern(C) struct SDL_AudioSpec
{
int freq;
Uint16 format;
Uint8 channels;
Uint8 silence;
Uint16 samples;