-
Notifications
You must be signed in to change notification settings - Fork 70
/
sdl2.nim
4206 lines (3702 loc) · 163 KB
/
sdl2.nim
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
## The Simple DirectMedia Layer Library.
import macros
import strutils
export strutils.`%`
# Add for people running sdl 2.0.0
{.push warning[user]: off}
when defined(SDL_Static):
static: echo "SDL_Static option is deprecated and will soon be removed. Instead please use --dynlibOverride:SDL2."
else:
when defined(windows):
const LibName* = "SDL2.dll"
elif defined(macosx):
const LibName* = "libSDL2.dylib"
elif defined(openbsd):
const LibName* = "libSDL2.so.0.6"
elif defined(haiku):
const LibName* = "libSDL2-2.0.so.0"
else:
const LibName* = "libSDL2(|-2.0).so(|.0)"
{.pop.}
include sdl2/private/keycodes
const
SDL_TEXTEDITINGEVENT_TEXT_SIZE* = 32
SDL_TEXTINPUTEVENT_TEXT_SIZE* = 32
type
WindowEventID* {.size: sizeof(byte).} = enum
## Event subtype for window events
WindowEvent_None = 0, ## Never used
WindowEvent_Shown, ## Window has been shown
WindowEvent_Hidden, ## Window has been hidden
WindowEvent_Exposed, ## Window has been exposed and should be redrawn
WindowEvent_Moved, ## Window has been moved to data1, data2
WindowEvent_Resized, ## Window has been resized to data1*data2
WindowEvent_SizeChanged,
## The window size has changed, either as a result of an API call or
## through the system or user changing the window size.
WindowEvent_Minimized, ## Window has been minimized
WindowEvent_Maximized, ## Window has been maximized
WindowEvent_Restored,
## Window has been restored to normal size and position
WindowEvent_Enter, ## Window has gained mouse focus
WindowEvent_Leave, ## Window has lost mouse focus
WindowEvent_FocusGained, ## Window has gained keyboard focus
WindowEvent_FocusLost, ## Window has lost keyboard focus
WindowEvent_Close,
WindowEvent_TakeFocus,
## The window manager requests that the window be closed
WindowEvent_HitTest
## Window had a hit test that wasn't `SDL_HITTEST_NORMAL`.
EventType* {.size: sizeof(uint32).} = enum
## The types of events that can be delivered.
# Application events
QuitEvent = 0x100, ## User-requested quit
AppTerminating,
## The application is being terminated by the OS
## Called on iOS in `applicationWillTerminate()`
## Called on Android in `onDestroy()`
AppLowMemory,
## The application is low on memory, free memory if possible.
## Called on iOS in `applicationDidReceiveMemoryWarning()`
## Called on Android in `onLowMemory()`
AppWillEnterBackground,
## The application is about to enter the background
## Called on iOS in `applicationWillResignActive()`
## Called on Android in `onPause()`
AppDidEnterBackground,
## The application did enter the background
## and may not get CPU for some time
## Called on iOS in `applicationDidEnterBackground()`
## Called on Android in `onPause()`
AppWillEnterForeground,
## The application is about to enter the foreground
## Called on iOS in `applicationWillEnterForeground()`
## Called on Android in `onResume()`
AppDidEnterForeground,
## The application is now interactive
## Called on iOS in `applicationDidBecomeActive()`
## Called on Android in `onResume()`
# Display events
DisplayEvent = 0x150, ## Display state change
# Window events
WindowEvent = 0x200, ## Window state change
SysWMEvent, ## System specific event
# Keyboard events
KeyDown = 0x300, ## Key pressed
KeyUp, ## Key released
TextEditing, ## Keyboard text editing (composition)
TextInput, ## Keyboard text input
KeymapChanged,
## Keymap changed due to a system event such as
## an input language or keyboard layout change.
# Mouse events
MouseMotion = 0x400, ## Mouse moved
MouseButtonDown, ## Mouse button pressed
MouseButtonUp, ## Mouse button released
MouseWheel, ## Mouse wheel motion
# Joysticks events
JoyAxisMotion = 0x600, ## Joystick axis motion
JoyBallMotion, ## Joystick trackball motion
JoyHatMotion, ## Joystick hat position change
JoyButtonDown, ## Joystick button pressed
JoyButtonUp, ## Joystick button released
JoyDeviceAdded, ## A new joystick has been inserted into the system
JoyDeviceRemoved, ## An opened joystick has been removed
# Game controller events
ControllerAxisMotion = 0x650, ## Game controller axis motion
ControllerButtonDown, ## Game controller button pressed
ControllerButtonUp, ## Game controller button released
ControllerDeviceAdded, ## A new Game controller has been inserted into the system
ControllerDeviceRemoved, ## An opened Game controller has been removed
ControllerDeviceRemapped, ## The controller mapping was updated
# Touch events
FingerDown = 0x700,
FingerUp,
FingerMotion,
# Gesture events
DollarGesture = 0x800,
DollarRecord,
MultiGesture,
# Clipboard events
ClipboardUpdate = 0x900, ## The clipboard changed
# Drag and drop events
DropFile = 0x1000, ## The system requests a file open
DropText, ## Text/plain drag-and-drop event
DropBegin, ## A new set of drops is beginning (`nil` filename)
DropComplete, ## Current set of drops is now complete (`nil` filename)
# Audio hotplug events
AudioDeviceAdded = 0x1100, ## A new audio device is available
AudioDeviceRemoved = 0x1101, ## An audio device has been removed
# Sensor events
SensorUpdate = 0x1200, ## A sensor was updated
# Render events
RenderTargetsReset = 0x2000,
## The render targets have been reset and their contents need to be updated
RenderDeviceReset,
## The device has beed reset and all textures need to be recreated
UserEvent = 0x8000,
## Events `USEREVENT` through `LASTEVENT` are for your use,
## and should be allocated with `registerEvents()`
UserEvent1,
UserEvent2,
UserEvent3,
UserEvent4,
UserEvent5,
LastEvent = 0xFFFF, ## This last event is only for bounding internal arrays
Event* = object
## General event structure
kind*: EventType ## Event type, shared with all events
padding: array[56-sizeof(EventType), byte]
QuitEventPtr* = ptr QuitEventObj
QuitEventObj* = object
## The "quit requested" event
kind*: EventType ## `QuitEvent`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
WindowEventPtr* = ptr WindowEventObj
WindowEventObj* = object
## Window state change event data (`event.window.*`)
kind*: EventType ## `WindowEvent`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The associated window
event*: WindowEventID ## WindowEvent ID
pad1,pad2,pad3: uint8
data1*, data2*: cint ## event dependent data
pad*: array[56-24, byte]
KeyboardEventPtr* = ptr KeyboardEventObj
KeyboardEventObj* = object
## Keyboard button event structure (`event.key.*`)
kind*: EventType ## `KEYDOWN` or `KEYUP`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The window with keyboard focus, if any
state*: uint8 ## `PRESSED` or `RELEASED`
repeat*: bool ## Non-zero if this is a key repeat
keysym*: KeySym ## The key that was pressed or released
pad*: array[24, byte]
TextEditingEventPtr* = ptr TextEditingEventObj
TextEditingEventObj* = object
## Keyboard text editing event structure (`event.edit.*`)
kind*: EventType ## `TEXTEDITING`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The window with keyboard focus, if any
text*: array[SDL_TEXTEDITINGEVENT_TEXT_SIZE, char] ## The editing text
start*: int32 ## The start cursor of selected editing text
length*: int32 ## The length of selected editing text
pad*: array[8, byte]
TextInputEventPtr* = ptr TextInputEventObj
TextInputEventObj* = object
## Keyboard text input event structure (`event.text.*`)
kind*: EventType ## `TEXTINPUT`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The window with keyboard focus, if any
text*: array[SDL_TEXTINPUTEVENT_TEXT_SIZE, char] ## The input text
pad*: array[24, byte]
MouseMotionEventPtr* = ptr MouseMotionEventObj
MouseMotionEventObj* = object
## Mouse motion event structure (`event.motion.*`)
kind*: EventType ## `MOUSEMOTION`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: 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*: int32 ## X coordinate, relative to window
y*: int32 ## Y coordinate, relative to window
xrel*: int32 ## The relative motion in the X direction
yrel*: int32 ## The relative motion in the Y direction
pad*: array[20, byte]
MouseButtonEventPtr* = ptr MouseButtonEventObj
MouseButtonEventObj* = object
## Mouse button event structure (`event.button.*`)
kind*: EventType ## `MOUSEBUTTONDOWN` or `MOUSEBUTTONUP`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: 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 ## `PRESSED` or `RELEASED`
clicks*: uint8 ## `1` for single-click, `2` for double-click, etc.
x*: cint ## X coordinate, relative to window
y*: cint ## Y coordinate, relative to window
pad*: array[28, byte]
MouseWheelEventPtr* = ptr MouseWheelEventObj
MouseWheelEventObj* = object
## Mouse wheel event structure (`event.wheel.*`)
kind*: EventType ## `MOUSEWHEEL`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The window with mouse focus, if any
which*: uint32 ## The mouse instance id, or `SDL_TOUCH_MOUSEID`
x*: cint
## The amount scrolled horizontally,
## positive to the right and negative to the left
y*: cint
## The amount scrolled vertically,
## positive away from the user and negative toward the user
direction*: MouseWheelDirection
## Set to one of the `SDL_MOUSEWHEEL_*`.
## When `SDL_MOUSEWHEEL_FLIPPED` the values in X and Y will be opposite.
## Multiply by `-1` to change them back.
pad*: array[28, byte]
JoyAxisEventPtr* = ptr JoyAxisEventObj
JoyAxisEventObj* = object
## Joystick axis motion event structure (`event.jaxis.*`)
kind*: EventType ## `JOYAXISMOTION`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
axis*: uint8 ## The joystick axis index
pad1,pad2,pad3: uint8
value*: int16 ## The axis value (range: `-32768` to `32767`)
JoyBallEventPtr* = ptr JoyBallEventObj
JoyBallEventObj* = object
## Joystick trackball motion event structure (`event.jball.*`)
kind*: EventType ## `JOYBALLMOTION`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
ball*: uint8 ## The joystick trackball index
pad1,pad2,pad3: uint8
xrel*: int16 ## The relative motion in the X direction
yrel*: int16 ## The relative motion in the Y direction
JoyHatEventPtr* = ptr JoyHatEventObj
JoyHatEventObj* = object
## Joystick hat position change event structure (`event.jhat.*`)
kind*: EventType ## `JOYHATMOTION`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
hat*: uint8 ## The joystick hat index
value*: uint8
## The hat position value (`joystick.SDL_HAT_*` consts)
## Note that zero means the POV is centered.
JoyButtonEventPtr* = ptr JoyButtonEventObj
JoyButtonEventObj* = object
## Joystick button event structure (`event.jbutton.*`)
kind*: EventType ## `JOYBUTTONDOWN` or `JOYBUTTONUP`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
button*: uint8 ## The joystick button index
state*: uint8 ## `PRESSED` or `RELEASED`
JoyDeviceEventPtr* = ptr JoyDeviceEventObj
JoyDeviceEventObj* = object
## Joystick device event structure (`event.jdevice.*`)
kind*: EventType ## `JOYDEVICEADDED` or `JOYDEVICEREMOVED`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32
## The joystick device index for the `ADDED` event,
## instance id for the `REMOVED` event
ControllerAxisEventPtr* = ptr ControllerAxisEventObj
ControllerAxisEventObj* = object
## Game controller axis motion event structure (`event.caxis.*`)
kind*: EventType ## `CONTROLLERAXISMOTION`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
axis*: uint8 ## The controller axis (`GameControllerAxis`)
pad1,pad2,pad3: uint8
value*: int16 ## The axis value
ControllerButtonEventPtr* = ptr ControllerButtonEventObj
ControllerButtonEventObj* = object
## Game controller button event structure (`event.cbutton.*`)
kind*: EventType ## `CONTROLLERBUTTONDOWN` or `CONTROLLERBUTTONUP`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32 ## The joystick instance id
button*: uint8 ## The controller button (`GameControllerButton`)
state*: uint8 ## `PRESSED` or `RELEASED`
ControllerDeviceEventPtr* = ptr ControllerDeviceEventObj
ControllerDeviceEventObj* = object
## Controller device event structure (`event.cdevice.*`)
kind*: EventType
## `CONTROLLERDEVICEADDED`,
## `CONTROLLERDEVICEREMOVED` or
## `CONTROLLERDEVICEREMAPPED`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
which*: int32
## The joystick device index for the `ADDED` event,
## instance id for the `REMOVED` or `REMAPPED` event
TouchID* = int64
FingerID* = int64
TouchFingerEventPtr* = ptr TouchFingerEventObj
TouchFingerEventObj* = object
## Touch finger event structure (`event.tfinger.*`)
kind*: EventType ## `FINGERMOTION` or `FINGERDOWN` or `FINGERUP`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
touchID*: TouchID ## The touch device id
fingerID*: FingerID ## Normalized in the range 0...1
x*: cfloat ## Normalized in the range 0..1
y*: cfloat ## Normalized in the range 0..1
dx*: cfloat ## Normalized in the range -1..1
dy*: cfloat ## Normalized in the range -1..1
pressure*: cfloat ## Normalized in the range 0..1
pad*: array[24, byte]
MultiGestureEventPtr* = ptr MultiGestureEventObj
MultiGestureEventObj* = object
## Multiple Finger Gesture Event (`event.mgesture.*`)
kind*: EventType ## `MULTIGESTURE`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
touchID*: TouchID ## The touch device index
dTheta*, dDist*, x*, y*: cfloat
numFingers*: uint16
Finger* = object
id*: FingerID
x*,y*: cfloat
pressure*: cfloat
GestureID = int64
DollarGestureEventPtr* = ptr DollarGestureEventObj
DollarGestureEventObj* = object
## Dollar Gesture Event (`event.dgesture.*`)
kind*: EventType ## `DOLLARGESTURE` or `DOLLARRECORD`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
touchID*: TouchID ## The touch device id
gestureID*: GestureID
numFingers*: uint32
error*: cfloat
x*: cfloat ## Normalized center of gesture
y*: cfloat ## Normalized center of gesture
DropEventPtr* = ptr DropEventObj
DropEventObj* = object
## An event used to request a file open by the system (`event.drop.*`)
## This event is enabled by default, you can disable it with `eventState()`
##
## **Note:** If this event is enabled, you must free the filename in the event.
kind*: EventType ## `DROPBEGIN`, `DROPFILE`, `DROPTEXT` or `DROPCOMPLETE`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
file*: cstring ## The file name, which should be freed with `free()`
UserEventPtr* = ptr UserEventObj
UserEventObj* = object
## A user-defined event type (`event.user.*`)
kind*: EventType ## `USEREVENT` through `LASTEVENT-1`
timestamp*: uint32 ## In milliseconds, populated using `getTicks()`
windowID*: uint32 ## The associated window if any
code*: int32 ## User defined event code
data1*: pointer ## User defined data pointer
data2*: pointer ## User defined data pointer
Eventaction* {.size: sizeof(cint).} = enum
SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT
EventFilter* = proc (userdata: pointer; event: ptr Event): Bool32 {.cdecl.}
SDL_Return* {.size: sizeof(cint).} = enum
## Return value for many SDL functions.
## Any function that returns like this should also be discardable
SdlError = -1, SdlSuccess = 0
Bool32* {.size: sizeof(cint).} = enum ## SDL_bool
False32 = 0, True32 = 1
KeyState* {.size: sizeof(byte).} = enum KeyReleased = 0, KeyPressed
KeySym* {.pure.} = object
## The SDL keysym object, used in key events.
##
## **Note:** If you are looking for translated character input,
## see the `TextInput` event.
scancode*: ScanCode ## SDL physical key code - see `ScanCode` for details
sym*: cint ## SDL virtual key code - see `Keycode` for details
modstate*: int16 ## current key modifiers
unicode*: cint
Point* = tuple
## A 2D point
x, y: cint
PointF* = object
## A 2D point
x*, y*: cfloat
Rect* = tuple
## A rectangle with the origin at the upper left
x, y: cint
w, h: cint
RectF* = object
## A rectangle with the origin at the upper left
x*, y*: cfloat
w*, h*: cfloat
GLattr*{.size: sizeof(cint).} = enum
## OpenGL configuration attributes
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_RETAINED_BACKING,
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION,
SDL_GL_CONTEXT_EGL,
SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
SDL_GL_CONTEXT_RESET_NOTIFICATION,
SDL_GL_CONTEXT_NO_ERROR
MouseWheelDirection* {.size: sizeof(uint32).} = enum
## Scroll direction types for the Scroll event
SDL_MOUSEWHEEL_NORMAL, ## The scroll direction is normal
SDL_MOUSEWHEEL_FLIPPED ## The scroll direction is flipped / natural
const
# GLprofile enum.
SDL_GL_CONTEXT_PROFILE_CORE*: cint = 0x0001
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY*: cint = 0x0002
SDL_GL_CONTEXT_PROFILE_ES*: cint = 0x0004
# GLcontextFlag enum.
SDL_GL_CONTEXT_DEBUG_FLAG*: cint = 0x0001
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG*: cint = 0x0002
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG*: cint = 0x0004
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG*: cint = 0x0008
# GLcontextRelease enum.
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE*: cint = 0x0000
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH*: cint = 0x0001
type
DisplayMode* = object
## The object that defines a display mode
##
## **See also:**
## * `getNumDisplayModes proc<#getNumDisplayModes,cint>`_
## * `getDisplayMode proc<#getDisplayMode,WindowPtr,DisplayMode>`_
## * `getDesktopDisplayMode proc<#getDesktopDisplayMode,cint,DisplayMode>`_
## * `getCurrentDisplayMode proc<#getCurrentDisplayMode,cint,DisplayMode>`_
## * `getClosestDisplayMode proc<#getClosestDisplayMode,cint,ptr.DisplayMode,ptr.DisplayMode>`_
format*: cuint ## pixel format
w*: cint ## width, in screen coordinates
h*: cint ## height, in screen coordinates
refresh_rate*: cint ## refresh rate (or zero for unspecified)
driverData*: pointer ## driver-specific data, initialize to 0
WindowPtr* = ptr object ## The type used to identify a window
RendererPtr* = ptr object
TexturePtr* = ptr object
CursorPtr* = ptr object
GlContextPtr* = ptr object ## An opaque handle to an OpenGL context.
SDL_Version* = object
## Information about the version of SDL in use.
##
## Represents the library's version as three levels: major revision
## (increments with massive changes, additions, and enhancements),
## minor revision (increments with backwards-compatible changes to the
## major revision), and patchlevel (increments with fixes to the minor
## revision).
##
## **See also:**
## * `getVersion proc<#getVersion,SDL_Version>`_
major*, minor*, patch*: uint8
RendererInfoPtr* = ptr RendererInfo
RendererInfo* {.pure, final.} = object
## Information on the capabilities of a render driver or context
name*: cstring ## The name of the renderer
flags*: uint32 ## Supported `RendererFlags`
num_texture_formats*: uint32 ## The number of available texture formats
texture_formats*: array[0..16 - 1, uint32] ## The available texture formats
max_texture_width*: cint ## The maximimum texture width
max_texture_height*: cint ## The maximimum texture height
TextureAccess* {.size: sizeof(cint).} = enum
## The access pattern allowed for a texture
SDL_TEXTUREACCESS_STATIC, ## Changes rarely, not lockable
SDL_TEXTUREACCESS_STREAMING, ## Changes frequently, lockable
SDL_TEXTUREACCESS_TARGET ## Texture can be used as a render target
TextureModulate*{.size:sizeof(cint).} = enum
## The texture channel modulation used in `copy proc<#copy,RendererPtr,TexturPtr,ptr.Rect,ptr.Rect>`_
SDL_TEXTUREMODULATE_NONE, ## No modulation
SDL_TEXTUREMODULATE_COLOR, ## srcC = srcC * color
SDL_TEXTUREMODULATE_ALPHA ## srcA = srcA * alpha
RendererFlip* = cint
SysWMType* {.size: sizeof(cint).}=enum
SysWM_Unknown, SysWM_Windows, SysWM_X11, SysWM_DirectFB,
SysWM_Cocoa, SysWM_UIkit, SysWM_Wayland, SysWM_Mir, SysWM_WinRT, SysWM_Android, SysWM_Vivante
WMinfo* = object
version*: SDL_Version
subsystem*: SysWMType
padding*: array[64, byte]
## if the low-level stuff is important to you check
## SDL_syswm.h and cast padding to the right type
const # WindowFlags
SDL_WINDOW_FULLSCREEN*: cuint = 0x00000001 ## fullscreen window
SDL_WINDOW_OPENGL*: cuint = 0x00000002 ## window usable with OpenGL context
SDL_WINDOW_SHOWN*: cuint = 0x00000004 ## window is visible
SDL_WINDOW_HIDDEN*: cuint = 0x00000008 ## window is not visible
SDL_WINDOW_BORDERLESS*: cuint = 0x00000010 ## no window decoration
SDL_WINDOW_RESIZABLE*: cuint = 0x00000020 ## window can be resized
SDL_WINDOW_MINIMIZED*: cuint = 0x00000040 ## window is minimized
SDL_WINDOW_MAXIMIZED*: cuint = 0x00000080 ## window is maximized
SDL_WINDOW_INPUT_GRABBED*: cuint = 0x00000100 ## window has grabbed input focus
SDL_WINDOW_INPUT_FOCUS*: cuint = 0x00000200 ## window has input focus
SDL_WINDOW_MOUSE_FOCUS*: cuint = 0x00000400 ## window has mouse focus
SDL_WINDOW_FULLSCREEN_DESKTOP*: cuint = ( SDL_WINDOW_FULLSCREEN or 0x00001000 )
SDL_WINDOW_FOREIGN*: cuint = 0x00000800 ## window not created by SDL
SDL_WINDOW_ALLOW_HIGHDPI*: cuint = 0x00002000
## window should be created in high-DPI mode if supported
## On macOS `NSHighResolutionCapable` must be set true
## in the application's `Info.plist` for this to have any effect.
SDL_WINDOW_MOUSE_CAPTURE*: cuint = 0x00004000
## window has mouse captured (unrelated to INPUT_GRABBED)
SDL_WINDOW_VULKAN*: cuint = 0x10000000 ## window usable for Vulkan surface
SDL_FLIP_NONE*: cint = 0x00000000 ## Do not flip
SDL_FLIP_HORIZONTAL*: cint = 0x00000001 ## flip horizontally
SDL_FLIP_VERTICAL*: cint = 0x00000002 ## flip vertically
converter toBool*(some: Bool32): bool = bool(some)
converter toBool*(some: SDL_Return): bool = some == SdlSuccess
converter toCint*(some: TextureAccess): cint = some.cint
# pixel format flags
const
SDL_ALPHA_OPAQUE* = 255
SDL_ALPHA_TRANSPARENT* = 0
const
SDL_PIXELTYPE_UNKNOWN* = 0
SDL_PIXELTYPE_INDEX1* = 1
SDL_PIXELTYPE_INDEX4* = 2
SDL_PIXELTYPE_INDEX8* = 3
SDL_PIXELTYPE_PACKED8* = 4
SDL_PIXELTYPE_PACKED16* = 5
SDL_PIXELTYPE_PACKED32* = 6
SDL_PIXELTYPE_ARRAYU8* = 7
SDL_PIXELTYPE_ARRAYU16* = 8
SDL_PIXELTYPE_ARRAYU32* = 9
SDL_PIXELTYPE_ARRAYF16* = 10
SDL_PIXELTYPE_ARRAYF32* = 11
# Bitmap pixel order, high bit -> low bit.
const
SDL_BITMAPORDER_NONE* = 0
SDL_BITMAPORDER_4321* = 1
SDL_BITMAPORDER_1234* = 2
# Packed component order, high bit -> low bit.
const
SDL_PACKEDORDER_NONE* = 0
SDL_PACKEDORDER_XRGB* = 1
SDL_PACKEDORDER_RGBX* = 2
SDL_PACKEDORDER_ARGB* = 3
SDL_PACKEDORDER_RGBA* = 4
SDL_PACKEDORDER_XBGR* = 5
SDL_PACKEDORDER_BGRX* = 6
SDL_PACKEDORDER_ABGR* = 7
SDL_PACKEDORDER_BGRA* = 8
# Array component order, low byte -> high byte.
const
SDL_ARRAYORDER_NONE* = 0
SDL_ARRAYORDER_RGB* = 1
SDL_ARRAYORDER_RGBA* = 2
SDL_ARRAYORDER_ARGB* = 3
SDL_ARRAYORDER_BGR* = 4
SDL_ARRAYORDER_BGRA* = 5
SDL_ARRAYORDER_ABGR* = 6
# Packed component layout.
const
SDL_PACKEDLAYOUT_NONE* = 0
SDL_PACKEDLAYOUT_332* = 1
SDL_PACKEDLAYOUT_4444* = 2
SDL_PACKEDLAYOUT_1555* = 3
SDL_PACKEDLAYOUT_5551* = 4
SDL_PACKEDLAYOUT_565* = 5
SDL_PACKEDLAYOUT_8888* = 6
SDL_PACKEDLAYOUT_2101010* = 7
SDL_PACKEDLAYOUT_1010102* = 8
template SDL_FOURCC (a,b,c,d: uint8): uint32 =
uint32(a) or (uint32(b) shl 8) or (uint32(c) shl 16) or (uint32(d) shl 24)
template SDL_DEFINE_PIXELFOURCC*(A, B, C, D: char): uint32 =
SDL_FOURCC(A.uint8, B.uint8, C.uint8, D.uint8)
template SDL_DEFINE_PIXELFORMAT*(`type`, order, layout, bits, bytes: int): uint32 =
uint32((1 shl 28) or ((`type`) shl 24) or ((order) shl 20) or ((layout) shl 16) or
((bits) shl 8) or ((bytes) shl 0))
template SDL_PIXELFLAG*(X: uint32): int =
int(((X) shr 28) and 0x0000000F)
template SDL_PIXELTYPE*(X: uint32): int =
int(((X) shr 24) and 0x0000000F)
template SDL_PIXELORDER*(X: uint32): int =
int(((X) shr 20) and 0x0000000F)
template SDL_PIXELLAYOUT*(X: uint32): int =
int(((X) shr 16) and 0x0000000F)
template SDL_BITSPERPIXEL*(X: uint32): int =
int(((X) shr 8) and 0x000000FF)
template SDL_BYTESPERPIXEL*(X: uint32): int =
int(if SDL_ISPIXELFORMAT_FOURCC(X): (if (((X) == SDL_PIXELFORMAT_YUY2) or
((X) == SDL_PIXELFORMAT_UYVY) or ((X) == SDL_PIXELFORMAT_YVYU)): 2 else: 1) else: (
((X) shr 0) and 0x000000FF))
template SDL_ISPIXELFORMAT_INDEXED*(format: uint32): bool =
(not SDL_ISPIXELFORMAT_FOURCC(format) and
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) or
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) or
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
template SDL_ISPIXELFORMAT_ALPHA*(format: uint32): bool =
(not SDL_ISPIXELFORMAT_FOURCC(format) and
((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) or
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) or
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) or
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
# The flag is set to 1 because 0x1? is not in the printable ASCII range
template SDL_ISPIXELFORMAT_FOURCC*(format: uint32): bool =
((format != 0) and (SDL_PIXELFLAG(format) != 1))
# Note: If you modify this list, update SDL_GetPixelFormatName()
const
SDL_PIXELFORMAT_UNKNOWN* = 0
SDL_PIXELFORMAT_INDEX1LSB* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1,
SDL_BITMAPORDER_4321, 0, 1, 0)
SDL_PIXELFORMAT_INDEX1MSB* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1,
SDL_BITMAPORDER_1234, 0, 1, 0)
SDL_PIXELFORMAT_INDEX4LSB* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4,
SDL_BITMAPORDER_4321, 0, 4, 0)
SDL_PIXELFORMAT_INDEX4MSB* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4,
SDL_BITMAPORDER_1234, 0, 4, 0)
SDL_PIXELFORMAT_INDEX8* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0,
8, 1)
SDL_PIXELFORMAT_RGB332* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8,
SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1)
SDL_PIXELFORMAT_RGB444* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2)
SDL_PIXELFORMAT_RGB555* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2)
SDL_PIXELFORMAT_BGR555* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2)
SDL_PIXELFORMAT_ARGB4444* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2)
SDL_PIXELFORMAT_RGBA4444* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2)
SDL_PIXELFORMAT_ABGR4444* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2)
SDL_PIXELFORMAT_BGRA4444* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2)
SDL_PIXELFORMAT_ARGB1555* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2)
SDL_PIXELFORMAT_RGBA5551* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2)
SDL_PIXELFORMAT_ABGR1555* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2)
SDL_PIXELFORMAT_BGRA5551* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2)
SDL_PIXELFORMAT_RGB565* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2)
SDL_PIXELFORMAT_BGR565* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2)
SDL_PIXELFORMAT_RGB24* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8,
SDL_ARRAYORDER_RGB, 0, 24, 3)
SDL_PIXELFORMAT_BGR24* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8,
SDL_ARRAYORDER_BGR, 0, 24, 3)
SDL_PIXELFORMAT_RGB888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4)
SDL_PIXELFORMAT_RGBX8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4)
SDL_PIXELFORMAT_BGR888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4)
SDL_PIXELFORMAT_BGRX8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4)
SDL_PIXELFORMAT_ARGB8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4)
SDL_PIXELFORMAT_RGBA8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4)
SDL_PIXELFORMAT_ABGR8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4)
SDL_PIXELFORMAT_BGRA8888* = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4)
SDL_PIXELFORMAT_ARGB2101010* = SDL_DEFINE_PIXELFORMAT(
SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010,
32, 4)
SDL_PIXELFORMAT_YV12* = SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2') #*< Planar mode: Y + V + U (3 planes)
## Planar mode: Y + V + U (3 planes)
SDL_PIXELFORMAT_IYUV* = SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V') #*< Planar mode: Y + U + V (3 planes)
## Planar mode: Y + U + V (3 planes)
SDL_PIXELFORMAT_YUY2* = SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2') #*< Packed mode: Y0+U0+Y1+V0 (1 plane)
## Packed mode: Y0+U0+Y1+V0 (1 plane)
SDL_PIXELFORMAT_UYVY* = SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y') #*< Packed mode: U0+Y0+V0+Y1 (1 plane)
## Packed mode: U0+Y0+V0+Y1 (1 plane)
SDL_PIXELFORMAT_YVYU* = SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U') #*< Packed mode: Y0+V0+Y1+U0 (1 plane)
## Packed mode: Y0+V0+Y1+U0 (1 plane)
type
Color* {.pure, final.} = tuple
r: uint8
g: uint8
b: uint8
a: uint8
Palette* {.pure, final.} = object
ncolors*: cint
colors*: ptr Color
version*: uint32
refcount*: cint
PixelFormat* {.pure, final.} = object
## **Note:** Everything in the pixel format object is read-only.
format*: uint32
palette*: ptr Palette
BitsPerPixel*: uint8
BytesPerPixel*: uint8
padding*: array[0..2 - 1, uint8]
Rmask*: uint32
Gmask*: uint32
Bmask*: uint32
Amask*: uint32
Rloss*: uint8
Gloss*: uint8
Bloss*: uint8
Aloss*: uint8
Rshift*: uint8
Gshift*: uint8
Bshift*: uint8
Ashift*: uint8
refcount*: cint
next*: ptr PixelFormat
BlitMapPtr* {.pure.} = ptr object ## couldnt find SDL_BlitMap ?
SurfacePtr* = ptr Surface
Surface* {.pure, final.} = object
## A collection of pixels used in software blitting.
##
## **Note:** This object should be treated as read-only, except for
## `pixels`, which, if not `nil`, contains the raw pixel data
## for the surface.
flags*: uint32 ## Read-only
format*: ptr PixelFormat ## Read-only
w*, h*, pitch*: int32 ## Read-only
pixels*: pointer ## Read-write
userdata*: pointer ## Application data associated with the surface. Read-write
locked*: int32 ## Read-only ## see if this should be Bool32
lock_data*: pointer ## Read-only
clip_rect*: Rect ## clipping information. Read-only
map: BlitMapPtr
## info for fast blit mapping to other surfaces. Private
refcount*: cint
## Reference count, used when freeing surface. Read-mostly
BlendMode* {.size: sizeof(cint).} = enum
## The blend mode used in `copy proc<#copy,RendererPtr,TexturPtr,ptr.Rect,ptr.Rect>`_ and drawing operations.
BlendMode_None = 0x00000000,
## no blending
## dstRGBA = srcRGBA
BlendMode_Blend = 0x00000001,
## alpha blending
## dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
## dstA = srcA + (dstA * (1-srcA))
BlendMode_Add = 0x00000002,
## additive blending
## dstRGB = (srcRGB * srcA) + dstRGB
## dstA = dstA
BlendMode_Mod = 0x00000004
## color modulate
## dstRGB = srcRGB * dstRGB
## dstA = dstA
BlitFunction* = proc(src: SurfacePtr; srcrect: ptr Rect;
dst: SurfacePtr; dstrect: ptr Rect): cint{.cdecl.}
## The type of procedure used for surface blitting procedures.
TimerCallback* = proc (interval: uint32; param: pointer): uint32{.cdecl.}
## Procedure prototype for the timer callback procedure.
##
## The callback procedure is passed the current timer interval and returns
## the next timer interval. If the returned value is the same as the one
## passed in, the periodic alarm continues, otherwise a new alarm is
## scheduled. If the callback returns `0`, the periodic alarm is
## cancelled.
TimerID* = cint
const ## RendererFlags
Renderer_Software*: cint = 0x00000001
## The renderer is a software fallback
Renderer_Accelerated*: cint = 0x00000002
## The renderer uses hardware acceleration
Renderer_PresentVsync*: cint = 0x00000004
## Present is synchronized with the refresh rate
Renderer_TargetTexture*: cint = 0x00000008
## Ther render supports rendering to texture
const ## These are the currently supported flags for the `Surface`.
SDL_SWSURFACE* = 0 ## Just here for compatibility
SDL_PREALLOC* = 0x00000001 ## Surface uses preallocated memory
SDL_RLEACCEL* = 0x00000002 ## Surface is RLE encoded
SDL_DONTFREE* = 0x00000004 ## Surface is referenced internally
template SDL_MUSTLOCK*(some: SurfacePtr): bool =
## Checks if the surface needs to be locked before access.
(some.flags and SDL_RLEACCEL) != 0
const
INIT_TIMER* = 0x00000001
INIT_AUDIO* = 0x00000010
INIT_VIDEO* = 0x00000020
INIT_JOYSTICK* = 0x00000200
INIT_HAPTIC* = 0x00001000
INIT_GAMECONTROLLER* = 0x00002000
INIT_EVENTS* = 0x00004000
INIT_NOPARACHUTE* = 0x00100000
INIT_EVERYTHING* = 0x0000FFFF
const SDL_WINDOWPOS_UNDEFINED_MASK* = 0x1FFF0000
template SDL_WINDOWPOS_UNDEFINED_DISPLAY*(X: cint): untyped =
## Used to indicate that you don't care what the window position is.
cint(SDL_WINDOWPOS_UNDEFINED_MASK or X)
const SDL_WINDOWPOS_UNDEFINED*: cint = SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
template SDL_WINDOWPOS_ISUNDEFINED*(X: cint): bool = (((X) and 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
const SDL_WINDOWPOS_CENTERED_MASK* = 0x2FFF0000
template SDL_WINDOWPOS_CENTERED_DISPLAY*(X: cint): cint =
## Used to indicate that the window position should be centered.
cint(SDL_WINDOWPOS_CENTERED_MASK or X)
const SDL_WINDOWPOS_CENTERED*: cint = SDL_WINDOWPOS_CENTERED_DISPLAY(0)
template SDL_WINDOWPOS_ISCENTERED*(X: cint): bool = (((X) and 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
template evConv(name, name2, ptype: untyped; valid: openarray[EventType]): untyped =
proc `name`*(event: Event): ptype =
assert event.kind in valid
return cast[ptype](unsafeAddr event)
proc `name2`*(event: Event): ptype =
assert event.kind in valid
return cast[ptype](unsafeAddr event)
evConv(evWindow, window, WindowEventPtr, [WindowEvent])
evConv(evKeyboard, key, KeyboardEventPtr, [KeyDown, KeyUP])
evConv(evTextEditing, edit, TextEditingEventPtr, [TextEditing])
evConv(evTextInput, text, TextInputEventPtr, [TextInput])
evConv(evMouseMotion, motion, MouseMotionEventPtr, [MouseMotion])
evConv(evMouseButton, button, MouseButtonEventPtr, [MouseButtonDown, MouseButtonUp])
evConv(evMouseWheel, wheel, MouseWheelEventPtr, [MouseWheel])
evConv(EvJoyAxis, jaxis, JoyAxisEventPtr, [JoyAxisMotion])
evConv(EvJoyBall, jball, JoyBallEventPtr, [JoyBallMotion])
evConv(EvJoyHat, jhat, JoyHatEventPtr, [JoyHatMotion])
evConv(EvJoyButton, jbutton, JoyButtonEventPtr, [JoyButtonDown, JoyButtonUp])
evConv(EvJoyDevice, jdevice, JoyDeviceEventPtr, [JoyDeviceAdded, JoyDeviceRemoved])
evConv(EvControllerAxis, caxis, ControllerAxisEventPtr, [ControllerAxisMotion])
evConv(EvControllerButton, cbutton, ControllerButtonEventPtr, [ControllerButtonDown, ControllerButtonUp])
evConv(EvControllerDevice, cdevice, ControllerDeviceEventPtr, [ControllerDeviceAdded, ControllerDeviceRemoved])
evConv(EvTouchFinger, tfinger, TouchFingerEventPtr, [FingerMotion, FingerDown, FingerUp])
evConv(EvMultiGesture, mgesture, MultiGestureEventPtr, [MultiGesture])
evConv(EvDollarGesture, dgesture, DollarGestureEventPtr, [DollarGesture])
evConv(evDropFile, drop, DropEventPtr, [DropFile])
evConv(evQuit, quit, QuitEventPtr, [QuitEvent])
evConv(evUser, user, UserEventPtr, [UserEvent, UserEvent1, UserEvent2, UserEvent3, UserEvent4, UserEvent5])
#evConv(EvSysWM, syswm, SysWMEventPtr, {SysWMEvent})
const ## SDL_MessageBox flags. If supported will display warning icon, etc.
SDL_MESSAGEBOX_ERROR* = 0x00000010 ## error dialog
SDL_MESSAGEBOX_WARNING* = 0x00000020 ## warning dialog
SDL_MESSAGEBOX_INFORMATION* = 0x00000040 ## informational dialog
# Flags for SDL_MessageBoxButtonData.
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT* = 0x00000001
## Marks the default button when return is hit
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT* = 0x00000002
## Marks the default button when escape is hit
type
MessageBoxColor* {.pure, final.} = object
## RGB value used in a message box color scheme
r*: uint8
g*: uint8
b*: uint8
MessageBoxColorType* = enum
SDL_MESSAGEBOX_COLOR_BACKGROUND, SDL_MESSAGEBOX_COLOR_TEXT,
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, SDL_MESSAGEBOX_COLOR_MAX
MessageBoxColorScheme* {.pure, final.} = object
## A set of colors to use for message box dialogs
colors*: array[MessageBoxColorType, MessageBoxColor]
MessageBoxButtonData* {.pure, final.} = object
## Individual button data
flags*: cint ## MessageBoxButtonFlags
buttonid*: cint
## User defined button id (value returned via SDL_MessageBox)
text*: cstring ## The UTF-8 button text