-
Notifications
You must be signed in to change notification settings - Fork 17
/
SDL.hx
1972 lines (1448 loc) · 70.6 KB
/
SDL.hx
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
package sdl;
import haxe.io.Bytes;
import haxe.io.BytesData;
import sdl.Renderer;
import sdl.Surface;
import sdl.Cursor;
import sdl.Texture;
import sdl.Joystick;
import sdl.Window;
import sdl.GLContext;
import sdl.Thread;
import sdl.RWops;
import sdl.Haptic;
@:keep
@:allow(sdl.SDL)
#if !display
@:build(linc.Linc.touch())
@:build(linc.Linc.xml('sdl'))
#end
private extern class SDL_linc { private inline static var LINC = 1; }
@:keep
@:include('linc_sdl.h')
@:allow(SDL_helper)
extern class SDL {
private inline static var LINC = SDL_linc.LINC;
//:note:differences:
// - vargs type functions : use haxe string interpolation instead
//SDL.h
@:native('SDL_Init')
static function init(flags:SDLInitFlags):Int;
@:native('SDL_InitSubSystem')
static function initSubSystem(flags:SDLInitFlags):Int;
@:native('SDL_QuitSubSystem')
static function quitSubSystem(flags:SDLInitFlags):Void;
@:native('SDL_WasInit')
static function wasInit(flags:SDLInitFlags):UInt;
@:native('SDL_Quit')
private static function _quit():Void;
static inline function quit():Void {
SDL_helper.quit();
_quit();
}
//SDL_events.h
static inline function addEventWatch(filter:SDLEventFilter, userdata:Dynamic) : Void {
SDL_helper.add_event_watch(filter, userdata);
}
static inline function delEventWatch(filter:SDLEventFilter) : Void {
SDL_helper.del_event_watch(filter);
}
@:native('SDL_EventState')
static function eventState(type:SDLEventType, state:SDLEventState) : UInt;
//:todo: void SDL_FilterEvents(SDL_EventFilter filter, void* userdata)
@:native('SDL_FlushEvent')
static function flushEvent(type:SDLEventType) : Void;
@:native('SDL_FlushEvents')
static function flushEvents(min:SDLEventType, max:SDLEventType) : Void;
//:todo: SDL_bool SDL_GetEventFilter(SDL_EventFilter* filter, void** userdata)
@:native('SDL_GetNumTouchDevices')
static function getNumTouchDevices() : Int;
@:native('SDL_GetNumTouchFingers')
static function getNumTouchFingers(touchId:cpp.Int64) : Int;
@:native('SDL_GetTouchDevice')
static function getTouchDevice(index:Int) : cpp.Int64;
@:native('SDL_GetTouchFinger')
static function getTouchFinger(touchID:cpp.Int64, index:Int): sdl.Event.Finger;
//:note: Not SDL API, this was added to work
//better against pollEvent and haxe
static inline function hasAnEvent():Bool {
pumpEvents();
return hasEvents( SDL_FIRSTEVENT, SDL_LASTEVENT );
}
@:native('SDL_HasEvent')
static function hasEvent( type:SDLEventType ) : Bool;
@:native('SDL_HasEvents')
static function hasEvents( min:SDLEventType, max:SDLEventType ) : Bool;
@:native('SDL_LoadDollarTemplates')
static function loadDollarTemplates(touchId:cpp.Int64, src:RWops) : Int;
//:todo: int SDL_PeepEvents(SDL_Event* events,
// int numevents,
// SDL_eventaction action,
// Uint32 minType,
// Uint32 maxType
@:native('SDL_PumpEvents')
static function pumpEvents():Void;
@:native('linc::sdl::pollEvent')
static function pollEvent() : sdl.Event;
//:todo: int SDL_PushEvent(SDL_Event* event)
@:native('SDL_QuitRequested')
static function quitRequested(): Bool;
@:native('SDL_RecordGesture')
static function recordGesture(touchId:cpp.Int64): Int;
@:native('SDL_RegisterEvents')
static function registerEvents(numevents:Int):UInt;
@:native('SDL_SaveAllDollarTemplates')
static function SDL_SaveAllDollarTemplates(dst:RWops) : Int;
//:todo: void SDL_SetEventFilter(SDL_EventFilter filter, void* userdata)
@:native('linc::sdl::waitEvent')
static function waitEvent() : sdl.Event;
@:native('linc::sdl::waitEventTimeout')
static function waitEventTimeout(timeout_ms:Int) : sdl.Event;
//SDL_error.h
@:native('SDL_SetError')
static function setError(error:String):Int;
@:native("SDL_GetError")
private static function _getError() : cpp.ConstCharStar;
static inline function getError() : String return cast _getError();
@:native('SDL_clearError')
static function clearError() : Void;
//SDL_log.h
// - category must be int not strong typed because user can use custom
// priority values as well as the defaults, which are int abstracts so they work
@:native('SDL_Log')
static function log(value:String):Void;
@:native('SDL_LogCritical')
static function logCritical(category:Int, value:String):Void;
@:native('SDL_LogDebug')
static function logDebug(category:Int, value:String):Void;
@:native('SDL_LogError')
static function logError(category:Int, value:String):Void;
//:skipped: ?
// @:native('SDL_LogGetOutputFunction')
// static function logGetOutputFunction():Void;
@:native('SDL_LogGetPriority')
static function logGetPriority(category:Int):SDLLogPriority;
@:native('SDL_LogInfo')
static function logInfo(category:Int, value:String):Void;
@:native('SDL_LogMessage')
static function logMessage(priority:SDLLogPriority, category:Int, value:String):Void;
//:skipped: vargs
// @:native('SDL_LogMessageV')
// static function logMessageV():Void;
@:native('SDL_LogResetPriorities')
static function logResetPriorities():Void;
@:native('SDL_LogSetAllPriority')
static function logSetAllPriority(priority:SDLLogPriority):Void;
//:skipped: ?
// @:native('SDL_LogSetOutputFunction')
// static function logSetOutputFunction():
@:native('SDL_LogSetPriority')
static function logSetPriority(category:Int, priority:SDLLogPriority):Void;
@:native('SDL_LogVerbose')
static function logVerbose(category:Int, value:String):Void;
@:native('SDL_LogWarn')
static function logWarn(category:Int, value:String):Void;
//:todo:?: SDL_assert.h
//SDL_version.h
// - the version macros in c side are patterned for c,
// so the usage patterns are replicated in a haxe way
@:native('SDL_COMPILEDVERSION')
static function COMPILEDVERSION(): Int;
@:native("SDL_GetRevision")
private static function _getRevision() : cpp.ConstCharStar;
static inline function getRevision() : String return cast _getRevision();
@:native('SDL_GetRevisionNumber')
static function getRevisionNumber(): Int;
@:native('linc::sdl::getVersion')
static function getVersion(): SDLVersion;
@:native('linc::sdl::REVISION')
static function REVISION() : String;
@:native('SDL_VERSIONNUM')
static function VERSIONNUM(major:Int, minor:Int, patch:Int): Int;
@:native('linc::sdl::VERSION')
static function VERSION(): SDLVersion;
@:native('SDL_VERSION_ATLEAST')
static function VERSION_ATLEAST(major:Int, minor:Int, patch:Int) : Bool;
//SDL_Hints.h
@:native('SDL_SetHint')
static function setHint(name:SDLHint, value:String) : Bool;
//SDL_RWops.h
@:native('SDL_AllocRW')
static function allocRW() : RWops;
@:native('SDL_FreeRW')
static function freeRW(area:RWops) : Void;
@:native('SDL_RWFromFile')
static function RWFromFile(file:String, mode:String) : RWops;
@:native('linc::sdl::RWFromMem')
static function RWFromMem(source:BytesData, size:Int) : RWops;
@:native('linc::sdl::RWclose')
static function RWclose(context:RWops) : Int;
@:native('linc::sdl::RWread')
static function RWread(context:RWops, into:BytesData, size:UInt, maxnum:UInt) : UInt;
@:native('linc::sdl::RWwrite')
static function RWwrite(context:RWops, from:BytesData, size:UInt, num:UInt) : UInt;
@:native('linc::sdl::RWseek')
static function RWseek(context:RWops, offset:cpp.Int64, whence:Int) : cpp.Int64;
@:native('linc::sdl::RWsize')
static function RWsize(context:RWops) : cpp.Int64;
@:native('linc::sdl::RWtell')
static function RWtell(context:RWops) : cpp.Int64;
@:native('SDL_ReadBE16')
static function ReadBE16(src:RWops) : cpp.Int16;
@:native('SDL_ReadBE32')
static function ReadBE32(src:RWops) : cpp.Int32;
@:native('SDL_ReadBE64')
static function ReadBE64(src:RWops) : cpp.Int64;
@:native('SDL_ReadLE16')
static function ReadLE16(src:RWops) : cpp.Int16;
@:native('SDL_ReadLE32')
static function ReadLE32(src:RWops) : cpp.Int32;
@:native('SDL_ReadLE64')
static function ReadLE64(src:RWops) : cpp.Int64;
@:native('SDL_WriteBE16')
static function WriteBE16(dst:RWops, value:cpp.Int16) : UInt;
@:native('SDL_WriteBE32')
static function WriteBE32(dst:RWops, value:cpp.Int32) : UInt;
@:native('SDL_WriteBE64')
static function WriteBE64(dst:RWops, value:cpp.Int64) : UInt;
@:native('SDL_WriteLE16')
static function WriteLE16(dst:RWops, value:cpp.Int16) : UInt;
@:native('SDL_WriteLE32')
static function WriteLE32(dst:RWops, value:cpp.Int32) : UInt;
@:native('SDL_WriteLE64')
static function WriteLE64(dst:RWops, value:cpp.Int64) : UInt;
//SDL_surface.h
@:native('SDL_LoadBMP_RW')
static function loadBMP_RW(src:RWops, freesrc:Int) : Surface;
@:native('SDL_LoadBMP')
static function loadBMP(file:String) : Surface;
@:native('SDL_FreeSurface')
static function freeSurface(surface:Surface) : Void;
@:native('linc::sdl::blitSurface')
static function blitSurface(src:Surface, srcrect:SDLRect, dst:Surface, dstrect:SDLRect) : Int;
@:native('SDL_GetWindowSurface')
static function getWindowSurface(window:Window) : Surface;
@:native('SDL_UpdateWindowSurface')
static function updateWindowSurface(window:Window) : Int;
@:native('linc::sdl::createRGBSurfaceFrom')
static function createRGBSurfaceFrom(pixels:BytesData, width:Int, height:Int, depth:Int, pitch:Int, Rmask:Int, Gmask:Int, Bmask:Int, Amask:Int) : Surface;
//SDL_render.h
@:native('SDL_CreateRenderer')
static function createRenderer(window:Window, index:Int, flags:SDLRendererFlags):Renderer;
@:native('SDL_CreateSoftwareRenderer')
static function createSoftwareRenderer(surface:Surface):Renderer;
@:native('SDL_CreateTexture')
static function createTexture(renderer:Renderer, format:SDLPixelFormat, access:SDLTextureAccess, w:Int, h:Int): Texture;
@:native('SDL_CreateTextureFromSurface')
static function createTextureFromSurface(renderer:Renderer, surface:Surface):Texture;
@:native('linc::sdl::createWindowAndRenderer')
static function createWindowAndRenderer(w:Int, h:Int, flags:SDLWindowFlags) : { window:Window, renderer:Renderer };
@:native('SDL_DestroyRenderer')
static function destroyRenderer(renderer:Renderer):Void;
@:native('SDL_DestroyTexture')
static function destroyTexture(texture:Texture):Void;
@:native('linc::sdl::GL_BindTexture')
static function GL_BindTexture(texture:Texture): { texw:Float, texh:Float };
@:native('SDL_GL_UnbindTexture')
static function GL_UnbindTexture(texture:Texture):Void;
@:native('SDL_GetNumRenderDrivers')
static function getNumRenderDrivers():Int;
@:native('linc::sdl::getRenderDrawBlendMode')
static function getRenderDrawBlendMode(renderer:Renderer):SDLBlendMode;
@:native('linc::sdl::getRenderDrawColor')
static function getRenderDrawColor(renderer:Renderer, into:SDLColor) : SDLColor;
@:native('linc::sdl::getRenderDriverInfo')
static function getRenderDriverInfo(index:Int):SDLRendererInfo;
@:native('SDL_GetRenderTarget')
static function getRenderTarget(renderer:Renderer):Texture;
@:native('SDL_GetRenderer')
static function getRenderer(window:Window):Renderer;
@:native('linc::sdl::getRendererInfo')
static function getRendererInfo(renderer:Renderer):SDLRendererInfo;
@:native('linc::sdl::getRendererOutputSize')
static function getRendererOutputSize(renderer:Renderer, into:SDLSize):SDLSize;
@:native('linc::sdl::getTextureAlphaMod')
static function getTextureAlphaMod(texture:Texture):Int;
@:native('linc::sdl::getTextureBlendMode')
static function getTextureBlendMode(texture:Texture):SDLBlendMode;
@:native('linc::sdl::getTextureColorMod')
static function getTextureColorMod(texture:Texture, into:SDLColor):SDLColor;
@:native('linc::sdl::lockTexture')
static function lockTexture(texture:Texture, rect:SDLRect, dest:BytesData):Int;
@:native('linc::sdl::queryTexture')
static function queryTexture(texture:Texture, into:SDLTextureQuery):SDLTextureQuery;
@:native('SDL_RenderClear')
static function renderClear(renderer:Renderer):Int;
@:native('linc::sdl::renderCopy')
static function renderCopy(renderer:Renderer, texture:Texture, srcrect:SDLRect, dstrect:SDLRect) : Int;
@:native('linc::sdl::renderCopyEx')
static function renderCopyEx(renderer:Renderer, texture:Texture, srcrect:SDLRect, dstrect:SDLRect, angle:Float, center:SDLPoint, flip:SDLRenderFlip):Int;
@:native('SDL_RenderDrawLine')
static function renderDrawLine(renderer:Renderer, x1:Int, y1:Int, x2:Int, y2:Int):Int;
static inline function renderDrawLines(renderer:Renderer, points:Array<SDLPoint>):Void {
if(points.length % 2 != 0) throw "renderDrawLines: points not divisible by 2!";
var half = Std.int(points.length/2);
for(i in 0 ... half) {
var cur = points[i*2+0];
var nxt = points[i*2+1];
renderDrawLine(renderer, cur.x, cur.y, nxt.x, nxt.y);
}
} //renderDrawLines
@:native('SDL_RenderDrawPoint')
static function renderDrawPoint(renderer:Renderer, x:Int, y:Int):Int;
static inline function renderDrawPoints(renderer:Renderer, points:Array<SDLPoint>):Void {
for(p in points) renderDrawPoint(renderer, p.x, p.y);
} //renderDrawPoints
@:native('linc::sdl::renderDrawRect')
static function renderDrawRect(renderer:Renderer, rect:SDLRect):Int;
static inline function renderDrawRects(renderer:Renderer, rects:Array<SDLRect>):Void {
for(r in rects) renderDrawRect(renderer, r);
}
@:native('linc::sdl::renderFillRect')
static function renderFillRect(renderer:Renderer, rect:SDLRect):Void;
static inline function renderFillRects(renderer:Renderer, rects:Array<SDLRect>):Void {
for(r in rects) renderFillRect(renderer, r);
}
@:native('linc::sdl::renderGetClipRect')
static function renderGetClipRect(renderer:Renderer, into:SDLRect):SDLRect;
@:native('linc::sdl::renderGetLogicalSize')
static function renderGetLogicalSize(renderer:Renderer, into:SDLSize):SDLSize;
@:native('linc::sdl::renderGetScale')
static function renderGetScale(renderer:Renderer, into:SDLScale):SDLScale;
@:native('linc::sdl::renderGetViewport')
static function renderGetViewport(renderer:Renderer, into:SDLRect):SDLRect;
@:native('SDL_RenderIsClipEnabled')
static function renderIsClipEnabled(renderer:Renderer):Bool;
@:native('SDL_RenderPresent')
static function renderPresent(renderer:Renderer):Int;
@:native('linc::sdl::renderReadPixels')
static function renderReadPixels(renderer:Renderer, rect:SDLRect, format:SDLPixelFormat, dest:BytesData, pitch:Int):Int;
@:native('linc::sdl::renderSetClipRect')
static function renderSetClipRect(renderer:Renderer, rect:SDLRect):Int;
@:native('SDL_RenderSetLogicalSize')
static function renderSetLogicalSize(renderer:Renderer, w:Int, h:Int):Int;
@:native('SDL_RenderSetScale')
static function renderSetScale(renderer:Renderer, x:Float, y:Float):Int;
@:native('linc::sdl::renderSetViewport')
static function renderSetViewport(renderer:Renderer, rect:SDLRect):Int;
@:native('SDL_RenderTargetSupported')
static function renderTargetSupported(renderer:Renderer):Bool;
@:native('linc::sdl::setRenderDrawBlendMode')
static function setRenderDrawBlendMode(renderer:Renderer, mode:SDLBlendMode):Int;
@:native('SDL_SetRenderDrawColor')
static function setRenderDrawColor(renderer:Renderer, r:UInt, g:UInt, b:UInt, a:UInt):Int;
@:native('SDL_SetRenderTarget')
static function setRenderTarget(renderer:Renderer, target:Texture):Int;
@:native('SDL_SetTextureAlphaMod')
static function setTextureAlphaMod(texture:Texture, alpha:UInt):Int;
@:native('linc::sdl::setTextureBlendMode')
static function setTextureBlendMode(texture:Texture, mode:SDLBlendMode):Int;
@:native('SDL_SetTextureColorMod')
static function setTextureColorMod(texture:Texture, r:UInt, g:UInt, b:UInt):Int;
@:native('SDL_UnlockTexture')
static function unlockTexture(texture:Texture):Void;
@:native('linc::sdl::updateTexture')
static function updateTexture(texture:Texture, rect:SDLRect, pixels:BytesData, pitch:Int):Int;
@:native('linc::sdl::updateYUVTexture')
static function updateYUVTexture(texture:Texture, rect:SDLRect, Yplane:BytesData, Ypitch:Int, Uplane:BytesData, Upitch:Int, Vplane:BytesData, Vpitch:Int):Int;
//SDL_cpuinfo.h
@:native('SDL_GetCPUCacheLineSize')
static function getCPUCacheLineSize():Int;
@:native('SDL_GetCPUCount')
static function getCPUCount():Int;
@:native('SDL_GetSystemRAM')
static function getSystemRAM():Int;
@:native('SDL_Has3DNow')
static function has3DNow():Bool;
@:native('SDL_HasAVX')
static function hasAVX():Bool;
@:native('SDL_HasAVX2')
static function hasAVX2():Bool;
@:native('SDL_HasAltiVec')
static function hasAltiVec():Bool;
@:native('SDL_HasMMX')
static function hasMMX():Bool;
@:native('SDL_HasRDTSC')
static function hasRDTSC():Bool;
@:native('SDL_HasSSE')
static function hasSSE():Bool;
@:native('SDL_HasSSE2')
static function hasSSE2():Bool;
@:native('SDL_HasSSE3')
static function hasSSE3():Bool;
@:native('SDL_HasSSE41')
static function hasSSE41():Bool;
@:native('SDL_HasSSE42')
static function hasSSE42():Bool;
//SDL_bits.h
@:native('SDL_MostSignificantBitIndex32')
static function mostSignificantBitIndex32(x:UInt):Int;
//SDL_platform.h
@:native("SDL_GetPlatform")
private static function _getPlatform() : cpp.ConstCharStar;
static inline function getPlatform() : String return cast _getPlatform();
//SDL_timer.h
static inline function addTimer(interval:UInt, callback:SDLTimerCallback, userdata:Dynamic):SDLTimerID {
return SDL_helper.add_timer(interval, callback, userdata);
}
static inline function removeTimer(id:SDLTimerID):Bool {
return SDL_helper.remove_timer(id);
}
@:native('SDL_Delay')
static function delay(ms:UInt): Void;
@:native('SDL_GetTicks')
static function getTicks(): UInt;
@:native('SDL_GetPerformanceCounter')
static function getPerformanceCounter(): cpp.UInt64;
@:native('SDL_GetPerformanceFrequency')
static function getPerformanceFrequency(): cpp.UInt64;
//SDL_filesystem.h
@:native("linc::sdl::getBasePath")
static function getBasePath() : String;
@:native("linc::sdl::getPrefPath")
static function getPrefPath(org:String, app:String) : String;
//SDL_clipboard.h
@:native('SDL_GetClipboardText')
private static function _getClipboardText() : cpp.ConstCharStar;
static inline function getClipboardText() : String return cast _getClipboardText();
@:native('SDL_HasClipboardText')
static function hasClipboardText():Bool;
@:native('SDL_SetClipboardText')
static function setClipboardText(text:String):Int;
//SDL_keyboard.h
@:native('SDL_GetKeyFromName')
private static function _getKeyFromName(name:cpp.ConstCharStar):SDLKeycode;
static inline function getKeyFromName(name:String) : SDLKeycode return _getKeyFromName(cast name);
@:native('SDL_GetKeyFromScancode')
static function getKeyFromScancode(scan:SDLScancode):SDLKeycode;
@:native('SDL_GetKeyName')
private static function _getKeyName(key:SDLKeycode):cpp.ConstCharStar;
static inline function getKeyName(key:SDLKeycode):String return cast _getKeyName(key);
@:native('SDL_GetKeyboardFocus')
static function getKeyboardFocus():Window;
// @:native('SDL_GetKeyboardState')
//:note:not sure this makes sense: static function getKeyboardState():Array<Int>;
@:native('SDL_GetModState')
static function getModState():SDLKeymod;
@:native('SDL_GetScancodeFromKey')
static function getScancodeFromKey(key:SDLKeycode):SDLScancode;
@:native('SDL_GetScancodeFromName')
private static function _getScancodeFromName(name:cpp.ConstCharStar):SDLScancode;
static inline function getScancodeFromName(name:String):SDLScancode return _getScancodeFromName(cast name);
@:native('SDL_GetScancodeName')
private static function _getScancodeName(scan:SDLScancode):cpp.ConstCharStar;
static inline function getScancodeName(scan:SDLScancode):String return cast _getScancodeName(scan);
@:native('SDL_HasScreenKeyboardSupport')
static function hasScreenKeyboardSupport():Bool;
@:native('SDL_IsScreenKeyboardShown')
static function isScreenKeyboardShown(window:Window):Bool;
@:native('SDL_IsTextInputActive')
static function isTextInputActive():Bool;
@:native('linc::sdl::setModState')
static function setModState(modstate:SDLKeymod):Void;
@:native('linc::sdl::setTextInputRect')
static function setTextInputRect(x:Int, y:Int, w:Int, h:Int):Void;
@:native('SDL_StartTextInput')
static function startTextInput():Void;
@:native('SDL_StopTextInput')
static function stopTextInput():Void;
//SDL_mouse.h
static inline function captureMouse(enabled:Bool):Int {
var _enable = enabled ? 1 : 0;
return untyped __cpp__('SDL_CaptureMouse((SDL_bool){0})', _enable);
}
@:native('SDL_CreateColorCursor')
static function createColorCursor(surface:Surface, hot_x:Int, hot_y:Int):Cursor;
@:native('SDL_CreateCursor')
static function createCursor(data:BytesData, mask:BytesData, w:Int, h:Int, hot_x:Int, hot_y:Int):Cursor;
@:native('linc::sdl::createSystemCursor')
static function createSystemCursor(id:SDLSystemCursor):Cursor;
@:native('SDL_FreeCursor')
static function freeCursor(cursor:Cursor):Void;
@:native('SDL_GetCursor')
static function getCursor():Cursor;
@:native('SDL_GetDefaultCursor')
static function getDefaultCursor():Cursor;
@:native('linc::sdl::getGlobalMouseState')
static function getGlobalMouseState(into:SDLMouseState):SDLMouseState;
@:native('SDL_GetMouseFocus')
static function getMouseFocus():Window;
@:native('linc::sdl::getMouseState')
static function getMouseState(into:SDLMouseState):SDLMouseState;
@:native('SDL_GetRelativeMouseMode')
static function getRelativeMouseMode():Bool;
@:native('linc::sdl::SDL_GetRelativeMouseState')
static function getRelativeMouseState(into:SDLMouseState):SDLMouseState;
@:native('SDL_SetCursor')
static function setCursor(cursor:Cursor):Void;
static inline function setRelativeMouseMode(enabled:Bool):Int {
var _enable = enabled ? 1 : 0;
return untyped __cpp__('SDL_SetRelativeMouseMode((SDL_bool){0})', _enable);
}
@:native('SDL_ShowCursor')
static function showCursor(toggle:Int):Int;
@:native('SDL_WarpMouseGlobal')
static function warpMouseGlobal(x:Int, y:Int):Void;
@:native('SDL_WarpMouseInWindow')
static function warpMouseInWindow(window:Window, x:Int, y:Int):Void;
//SDL_gamecontroller.h
@:native('SDL_GameControllerAddMapping')
static function gameControllerAddMapping(mappingString:String):Int;
@:native('SDL_GameControllerAddMappingsFromFile')
static function gameControllerAddMappingsFromFile(filename:String):Int;
@:native('SDL_GameControllerAddMappingsFromRW')
static function gameControllerAddMappingsFromRW(rw:RWops, freerw:Int):Int;
@:native('SDL_GameControllerClose')
static function gameControllerClose(gamecontroller:GameController):Void;
@:native('SDL_GameControllerEventState')
static function gameControllerEventState(state:SDLEventState):Int;
@:native('SDL_GameControllerGetAttached')
static function gameControllerGetAttached(gamecontroller:GameController):Bool;
@:native('SDL_GameControllerGetAxis')
static function gameControllerGetAxis(gamecontroller:GameController, axis:SDLGameControllerAxis):cpp.Int16;
//:internal:
// @:native('SDL_GameControllerGetAxisFromString')
// static function gameControllerGetAxisFromString(SDLGameControllerAxis):Int;
// @:native('SDL_GameControllerGetBindForAxis')
//:todo: static function gameControllerGetBindForAxis(gamecontroller:GameController, axis:SDLGameControllerAxis):Int;
// @:native('SDL_GameControllerGetBindForButton')
//:todo: static function gameControllerGetBindForButton():Int;
@:native('SDL_GameControllerGetButton')
static function gameControllerGetButton(gamecontroller:GameController, button:SDLGameControllerButton):Int;
//:internal:
// @:native('SDL_GameControllerGetButtonFromString')
// static function gameControllerGetButtonFromString():Int;
@:native('SDL_GameControllerGetJoystick')
static function gameControllerGetJoystick(gamecontroller:GameController):Joystick;
//:internal:
// @:native('SDL_GameControllerGetStringForAxis')
// static function gameControllerGetStringForAxis():Int;
//:internal:
// @:native('SDL_GameControllerGetStringForButton')
// static function gameControllerGetStringForButton():Int;
@:native('SDL_GameControllerMapping')
private static function _gameControllerMapping(gamecontroller:GameController):cpp.ConstCharStar;
static inline function gameControllerMapping(gamecontroller:GameController):String return _gameControllerMapping(gamecontroller).toString();
// @:native('SDL_GameControllerMappingForGUID')
//:todo: static function gameControllerMappingForGUID():Int;
@:native('SDL_GameControllerName')
private static function _gameControllerName(gamecontroller:GameController):cpp.ConstCharStar;
static inline function gameControllerName(gamecontroller:GameController):String return _gameControllerName(gamecontroller).toString();
@:native('SDL_GameControllerNameForIndex')
private static function _gameControllerNameForIndex(joystick_index:Int):cpp.ConstCharStar;
static inline function gameControllerNameForIndex(joystick_index:Int):String return _gameControllerNameForIndex(joystick_index).toString();
@:native('SDL_GameControllerOpen')
static function gameControllerOpen(joystick_index:Int):GameController;
#if sdl_include_internal
@:native('SDL_GameControllerUpdate')
static function gameControllerUpdate():Void;
#end
@:native('SDL_IsGameController')
static function isGameController(joystick_index:Int):Bool;
//SDL_Joystick.h
@:native('SDL_JoystickClose')
static function joystickClose(joystick:Joystick):Void;
@:native('SDL_JoystickEventState')
static function joystickEventState(state:SDLEventState):Int;
@:native('SDL_JoystickGetAttached')
static function joystickGetAttached(joystick:Joystick):Bool;
@:native('SDL_JoystickGetAxis')
static function joystickGetAxis(joystick:Joystick, axis:Int):cpp.Int64;
@:native('linc::sdl::joystickGetBall')
static function joystickGetBall(joystick:Joystick, ball:Int, into:SDLPoint):SDLPoint;
@:native('SDL_JoystickGetButton')
static function joystickGetButton(joystick:Joystick, button:Int):UInt;
//:todo:
@:native('SDL_JoystickGetDeviceGUID')
static function joystickGetDeviceGUID(device_index:Int):String;
//:todo:
@:native('SDL_JoystickGetGUID')
static function joystickGetGUID(joystick:Joystick):String;
// @:native('SDL_JoystickGetGUIDFromString')
//:todo: static function joystickGetGUIDFromString(pchGUID:String):String;
@:native('linc::sdl::joystickGetGUIDString')
static function joystickGetGUIDString(guid:BytesData):String;
@:native('SDL_JoystickGetHat')
static function joystickGetHat(joystick:Joystick, hat:SDLHatValue):Int;
@:native('SDL_JoystickInstanceID')
static function joystickInstanceID(joystick:Joystick):UInt;
@:native('SDL_JoystickName')
private static function _joystickName(joystick:Joystick) : cpp.ConstCharStar;
static inline function joystickName(joystick:Joystick):String return _joystickName(joystick).toString();
@:native('SDL_JoystickNameForIndex')
private static function _joystickNameForIndex(device_index:Int) : cpp.ConstCharStar;
static inline function joystickNameForIndex(device_index:Int):String return _joystickNameForIndex(device_index).toString();
@:native('SDL_JoystickNumAxes')
static function joystickNumAxes(joystick:Joystick):Int;
@:native('SDL_JoystickNumBalls')
static function joystickNumBalls(joystick:Joystick):Int;
@:native('SDL_JoystickNumButtons')
static function joystickNumButtons(joystick:Joystick):Int;
@:native('SDL_JoystickNumHats')
static function joystickNumHats(joystick:Joystick):Int;
@:native('SDL_JoystickOpen')
static function joystickOpen(device_index:Int):Joystick;
@:native('SDL_JoystickUpdate')
static function joystickUpdate():Void;
@:native('SDL_NumJoysticks')
static function numJoysticks():Int;
//SDL_haptic.h
@:native('SDL_HapticClose')
static function hapticClose(haptic:Haptic):Void;
@:native('SDL_HapticDestroyEffect')
static function hapticDestroyEffect(haptic:Haptic, effect:Int):Void;
@:native('SDL_HapticEffectSupported')
static function hapticEffectSupported(haptic:Haptic, effect:HapticEffect):Int;
@:native('SDL_HapticGetEffectStatus')
static function hapticGetEffectStatus(haptic:Haptic, effect:Int):Int;
@:native('SDL_HapticIndex')
static function hapticIndex(haptic:Haptic):Int;
@:native('SDL_HapticName')
private static function _hapticName(device_index:Int) : cpp.ConstCharStar;
static inline function hapticName(device_index:Int):String return cast _hapticName(device_index);
@:native('SDL_HapticNewEffect')
static function hapticNewEffect(haptic:Haptic, effect:HapticEffect):Int;
@:native('SDL_HapticNumAxes')
static function hapticNumAxes(haptic:Haptic):Int;
@:native('SDL_HapticNumEffects')
static function hapticNumEffects(haptic:Haptic):Int;
@:native('SDL_HapticNumEffectsPlaying')
static function hapticNumEffectsPlaying(haptic:Haptic):Int;
@:native('SDL_HapticOpen')
static function hapticOpen(device_index:Int):Haptic;
@:native('SDL_HapticOpenFromJoystick')
static function hapticOpenFromJoystick(joystick:Joystick):Haptic;
@:native('SDL_HapticOpenFromMouse')
static function hapticOpenFromMouse():Haptic;
@:native('SDL_HapticOpened')
static function hapticOpened(device_index:Int):Int;
@:native('SDL_HapticPause')
static function hapticPause(haptic:Haptic):Int;
@:native('SDL_HapticQuery')
static function hapticQuery(haptic:Haptic):UInt;
@:native('SDL_HapticRumbleInit')
static function hapticRumbleInit(haptic:Haptic):Int;
@:native('SDL_HapticRumblePlay')
static function hapticRumblePlay(haptic:Haptic, strength:Float, length:UInt):Int;
@:native('SDL_HapticRumbleStop')
static function hapticRumbleStop(haptic:Haptic):Int;
@:native('SDL_HapticRumbleSupported')
static function hapticRumbleSupported(haptic:Haptic):Int;
@:native('SDL_HapticRunEffect')
static function hapticRunEffect(haptic:Haptic, effect:Int, iterations:UInt):Int;
@:native('SDL_HapticSetAutocenter')
static function hapticSetAutocenter(haptic:Haptic, value:Int):Int;
@:native('SDL_HapticSetGain')
static function hapticSetGain(haptic:Haptic, gain:Int):Int;
@:native('SDL_HapticStopAll')
static function hapticStopAll(haptic:Haptic):Int;
@:native('SDL_HapticStopEffect')
static function hapticStopEffect(haptic:Haptic, effect:Int):Int;
@:native('SDL_HapticUnpause')
static function hapticUnpause(haptic:Haptic):Int;
@:native('SDL_HapticUpdateEffect')
static function hapticUpdateEffect(haptic:Haptic, effect:Int, data:HapticEffect):Int;
@:native('SDL_JoystickIsHaptic')
static function joystickIsHaptic(joystick:Joystick):Int;
@:native('SDL_MouseIsHaptic')
static function mouseIsHaptic():Int;
@:native('SDL_NumHaptics')
static function numHaptics():Int;
//SDL_thread.h
//management
// @:native('SDL_CreateThread')
//:todo: static function createThread(fn:Dynamic->Void, name:String, data:Dynamic) : Thread;
@:native('SDL_DetachThread')
static function detachThread(thread:Thread) : Void;
@:native('SDL_GetThreadID')
static function getThreadID(thread:Thread) : ThreadID;
@:native('SDL_GetThreadName')
private static function _getThreadName(thread:Thread) : cpp.ConstCharStar;
static inline function getThreadName(thread:Thread) : String return cast _getThreadName(thread);
@:native('SDL_SetThreadPriority')
static function setThreadPriority(priority:SDLThreadPriority) : Int;
@:native('SDL_TLSCreate')
static function TLSCreate() : TLSID;
@:native('SDL_TLSGet')
static function TLSGet(id:TLSID) : Dynamic;
// @:native('SDL_TLSSet')
//:todo: static function TLSSet(id:TLSID, value:Dynamic, destructor:Dynamic->Void) : Int;
@:native('SDL_ThreadID')
static function threadID() : ThreadID;
@:native('linc::sdl::waitThread')
static function waitThread(thread:Thread) : Int;
//sync primitives
@:native('SDL_CondBroadcast')
static function CondBroadcast(cond:Cond) : Int;