ruby2d 0.9.4 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/SDL2/SDL.h +4 -1
  3. data/assets/include/SDL2/SDL_assert.h +3 -1
  4. data/assets/include/SDL2/SDL_atomic.h +1 -1
  5. data/assets/include/SDL2/SDL_audio.h +1 -1
  6. data/assets/include/SDL2/SDL_bits.h +1 -1
  7. data/assets/include/SDL2/SDL_blendmode.h +4 -1
  8. data/assets/include/SDL2/SDL_clipboard.h +1 -1
  9. data/assets/include/SDL2/SDL_config.h +1 -1
  10. data/assets/include/SDL2/SDL_config_android.h +7 -3
  11. data/assets/include/SDL2/SDL_config_iphoneos.h +16 -10
  12. data/assets/include/SDL2/SDL_config_macosx.h +40 -14
  13. data/assets/include/SDL2/SDL_config_minimal.h +1 -1
  14. data/assets/include/SDL2/SDL_config_os2.h +26 -8
  15. data/assets/include/SDL2/SDL_config_pandora.h +4 -2
  16. data/assets/include/SDL2/SDL_config_psp.h +2 -1
  17. data/assets/include/SDL2/SDL_config_windows.h +40 -9
  18. data/assets/include/SDL2/SDL_config_winrt.h +5 -2
  19. data/assets/include/SDL2/SDL_config_wiz.h +5 -2
  20. data/assets/include/SDL2/SDL_copying.h +1 -1
  21. data/assets/include/SDL2/SDL_cpuinfo.h +32 -3
  22. data/assets/include/SDL2/SDL_egl.h +4 -1
  23. data/assets/include/SDL2/SDL_endian.h +6 -3
  24. data/assets/include/SDL2/SDL_error.h +38 -2
  25. data/assets/include/SDL2/SDL_events.h +64 -28
  26. data/assets/include/SDL2/SDL_filesystem.h +1 -1
  27. data/assets/include/SDL2/SDL_gamecontroller.h +160 -9
  28. data/assets/include/SDL2/SDL_gesture.h +1 -1
  29. data/assets/include/SDL2/SDL_haptic.h +10 -1
  30. data/assets/include/SDL2/SDL_hints.h +316 -4
  31. data/assets/include/SDL2/SDL_joystick.h +115 -24
  32. data/assets/include/SDL2/SDL_keyboard.h +1 -1
  33. data/assets/include/SDL2/SDL_keycode.h +11 -9
  34. data/assets/include/SDL2/SDL_loadso.h +1 -1
  35. data/assets/include/SDL2/SDL_locale.h +101 -0
  36. data/assets/include/SDL2/SDL_log.h +3 -3
  37. data/assets/include/SDL2/SDL_main.h +1 -1
  38. data/assets/include/SDL2/SDL_messagebox.h +6 -4
  39. data/assets/include/SDL2/SDL_metal.h +117 -0
  40. data/assets/include/SDL2/SDL_misc.h +75 -0
  41. data/assets/include/SDL2/SDL_mouse.h +1 -1
  42. data/assets/include/SDL2/SDL_mutex.h +1 -1
  43. data/assets/include/SDL2/SDL_name.h +1 -1
  44. data/assets/include/SDL2/SDL_opengl.h +1 -1
  45. data/assets/include/SDL2/SDL_opengl_glext.h +3 -0
  46. data/assets/include/SDL2/SDL_opengles.h +1 -1
  47. data/assets/include/SDL2/SDL_opengles2.h +1 -1
  48. data/assets/include/SDL2/SDL_pixels.h +25 -16
  49. data/assets/include/SDL2/SDL_platform.h +1 -1
  50. data/assets/include/SDL2/SDL_power.h +1 -1
  51. data/assets/include/SDL2/SDL_quit.h +1 -1
  52. data/assets/include/SDL2/SDL_rect.h +1 -1
  53. data/assets/include/SDL2/SDL_render.h +63 -3
  54. data/assets/include/SDL2/SDL_revision.h +2 -2
  55. data/assets/include/SDL2/SDL_rwops.h +2 -10
  56. data/assets/include/SDL2/SDL_scancode.h +1 -1
  57. data/assets/include/SDL2/SDL_sensor.h +25 -9
  58. data/assets/include/SDL2/SDL_shape.h +1 -1
  59. data/assets/include/SDL2/SDL_stdinc.h +44 -4
  60. data/assets/include/SDL2/SDL_surface.h +11 -2
  61. data/assets/include/SDL2/SDL_system.h +50 -4
  62. data/assets/include/SDL2/SDL_syswm.h +29 -2
  63. data/assets/include/SDL2/SDL_test.h +1 -1
  64. data/assets/include/SDL2/SDL_test_assert.h +1 -1
  65. data/assets/include/SDL2/SDL_test_common.h +14 -1
  66. data/assets/include/SDL2/SDL_test_compare.h +1 -1
  67. data/assets/include/SDL2/SDL_test_crc32.h +1 -1
  68. data/assets/include/SDL2/SDL_test_font.h +1 -1
  69. data/assets/include/SDL2/SDL_test_fuzzer.h +1 -1
  70. data/assets/include/SDL2/SDL_test_harness.h +1 -1
  71. data/assets/include/SDL2/SDL_test_images.h +1 -1
  72. data/assets/include/SDL2/SDL_test_log.h +1 -1
  73. data/assets/include/SDL2/SDL_test_md5.h +1 -1
  74. data/assets/include/SDL2/SDL_test_memory.h +1 -1
  75. data/assets/include/SDL2/SDL_test_random.h +1 -1
  76. data/assets/include/SDL2/SDL_thread.h +34 -11
  77. data/assets/include/SDL2/SDL_timer.h +1 -1
  78. data/assets/include/SDL2/SDL_touch.h +1 -1
  79. data/assets/include/SDL2/SDL_types.h +1 -1
  80. data/assets/include/SDL2/SDL_version.h +2 -2
  81. data/assets/include/SDL2/SDL_video.h +11 -5
  82. data/assets/include/SDL2/SDL_vulkan.h +6 -8
  83. data/assets/include/SDL2/begin_code.h +5 -9
  84. data/assets/include/SDL2/close_code.h +1 -1
  85. data/assets/macos/lib/libFLAC.a +0 -0
  86. data/assets/macos/lib/libSDL2.a +0 -0
  87. data/assets/macos/lib/libSDL2_image.a +0 -0
  88. data/assets/macos/lib/libSDL2_mixer.a +0 -0
  89. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  90. data/assets/macos/lib/libfreetype.a +0 -0
  91. data/assets/macos/lib/libjpeg.a +0 -0
  92. data/assets/macos/lib/libmodplug.a +0 -0
  93. data/assets/macos/lib/libmpg123.a +0 -0
  94. data/assets/macos/lib/libogg.a +0 -0
  95. data/assets/macos/lib/libpng16.a +0 -0
  96. data/assets/macos/lib/libtiff.a +0 -0
  97. data/assets/macos/lib/libvorbis.a +0 -0
  98. data/assets/macos/lib/libvorbisfile.a +0 -0
  99. data/assets/macos/lib/libwebp.a +0 -0
  100. data/assets/mingw/bin/SDL2.dll +0 -0
  101. data/assets/mingw/lib/libSDL2.a +0 -0
  102. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  103. data/assets/mingw/lib/libSDL2_test.a +0 -0
  104. data/assets/mingw/lib/libSDL2main.a +0 -0
  105. data/bin/ruby2d +1 -0
  106. data/{assets/linux/simple2d/src/simple2d.c → ext/ruby2d/common.c} +32 -32
  107. data/{assets/linux/simple2d/src → ext/ruby2d}/controllers.c +17 -17
  108. data/ext/ruby2d/extconf.rb +37 -59
  109. data/ext/ruby2d/font.c +35 -0
  110. data/{assets/linux/simple2d/src → ext/ruby2d}/gl.c +66 -98
  111. data/ext/ruby2d/gl2.c +86 -0
  112. data/{assets/linux/simple2d/src → ext/ruby2d}/gl3.c +69 -112
  113. data/{assets/linux/simple2d/src → ext/ruby2d}/gles.c +22 -81
  114. data/ext/ruby2d/image.c +58 -0
  115. data/{assets/linux/simple2d/src → ext/ruby2d}/input.c +8 -8
  116. data/{assets/linux/simple2d/src → ext/ruby2d}/music.c +30 -17
  117. data/ext/ruby2d/ruby2d.c +449 -439
  118. data/ext/ruby2d/ruby2d.h +652 -0
  119. data/{assets/linux/simple2d/src → ext/ruby2d}/shapes.c +18 -18
  120. data/{assets/linux/simple2d/src → ext/ruby2d}/sound.c +39 -14
  121. data/ext/ruby2d/text.c +22 -0
  122. data/{assets/linux/simple2d/src → ext/ruby2d}/window.c +63 -63
  123. data/lib/ruby2d/circle.rb +21 -3
  124. data/lib/ruby2d/cli/build.rb +4 -7
  125. data/lib/ruby2d/dsl.rb +16 -9
  126. data/lib/ruby2d/entity.rb +17 -0
  127. data/lib/ruby2d/font.rb +23 -3
  128. data/lib/ruby2d/image.rb +35 -7
  129. data/lib/ruby2d/line.rb +23 -1
  130. data/lib/ruby2d/music.rb +5 -0
  131. data/lib/ruby2d/pixel.rb +17 -0
  132. data/lib/ruby2d/quad.rb +21 -1
  133. data/lib/ruby2d/rectangle.rb +12 -3
  134. data/lib/ruby2d/renderable.rb +4 -20
  135. data/lib/ruby2d/sound.rb +30 -0
  136. data/lib/ruby2d/sprite.rb +57 -75
  137. data/lib/ruby2d/square.rb +10 -1
  138. data/lib/ruby2d/text.rb +55 -12
  139. data/lib/ruby2d/texture.rb +28 -0
  140. data/lib/ruby2d/tileset.rb +87 -0
  141. data/lib/ruby2d/triangle.rb +19 -1
  142. data/lib/ruby2d/version.rb +1 -1
  143. data/lib/ruby2d/vertices.rb +84 -0
  144. data/lib/ruby2d/window.rb +259 -22
  145. data/lib/ruby2d.rb +6 -1
  146. metadata +30 -26
  147. data/assets/include/simple2d.h +0 -757
  148. data/assets/linux/simple2d/Makefile +0 -260
  149. data/assets/linux/simple2d/bin/simple2d.sh +0 -1318
  150. data/assets/linux/simple2d/include/simple2d.h +0 -757
  151. data/assets/linux/simple2d/src/gl2.c +0 -146
  152. data/assets/linux/simple2d/src/image.c +0 -138
  153. data/assets/linux/simple2d/src/sprite.c +0 -147
  154. data/assets/linux/simple2d/src/text.c +0 -129
  155. data/assets/macos/lib/libsimple2d.a +0 -0
  156. data/assets/mingw/lib/libsimple2d.a +0 -0
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -67,6 +67,7 @@
67
67
  #define HAVE_STRCHR 1
68
68
  #define HAVE_STRRCHR 1
69
69
  #define HAVE_STRSTR 1
70
+ #define HAVE_STRTOK_R 1
70
71
  #define HAVE_STRTOL 1
71
72
  #define HAVE_STRTOUL 1
72
73
  #define HAVE_STRTOLL 1
@@ -116,6 +117,8 @@
116
117
  #define HAVE_SQRTF 1
117
118
  #define HAVE_TAN 1
118
119
  #define HAVE_TANF 1
120
+ #define HAVE_TRUNC 1
121
+ #define HAVE_TRUNCF 1
119
122
  #define HAVE_SIGACTION 1
120
123
  #define HAVE_SETJMP 1
121
124
  #define HAVE_NANOSLEEP 1
@@ -125,8 +128,8 @@
125
128
  #define SDL_AUDIO_DRIVER_OSS 1
126
129
 
127
130
  #define SDL_INPUT_LINUXEV 1
128
- #define SDL_INPUT_TSLIB 1
129
131
  #define SDL_JOYSTICK_LINUX 1
132
+ #define SDL_JOYSTICK_VIRTUAL 1
130
133
  #define SDL_HAPTIC_LINUX 1
131
134
 
132
135
  #define SDL_SENSOR_DUMMY 1
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -73,8 +73,8 @@
73
73
  # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
74
74
  # endif
75
75
  # if defined (_M_ARM64)
76
- # include <armintr.h>
77
- # include <arm_neon.h>
76
+ # include <arm64intr.h>
77
+ # include <arm64_neon.h>
78
78
  # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
79
79
  # endif
80
80
  # endif
@@ -186,6 +186,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
186
186
  */
187
187
  extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
188
188
 
189
+ /**
190
+ * This function returns true if the CPU has ARM SIMD (ARMv6) features.
191
+ */
192
+ extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
193
+
189
194
  /**
190
195
  * This function returns true if the CPU has NEON (ARM SIMD) features.
191
196
  */
@@ -241,10 +246,33 @@ extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
241
246
  * \return Pointer to newly-allocated block, NULL if out of memory.
242
247
  *
243
248
  * \sa SDL_SIMDAlignment
249
+ * \sa SDL_SIMDRealloc
244
250
  * \sa SDL_SIMDFree
245
251
  */
246
252
  extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
247
253
 
254
+ /**
255
+ * \brief Reallocate memory obtained from SDL_SIMDAlloc
256
+ *
257
+ * It is not valid to use this function on a pointer from anything but
258
+ * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc,
259
+ * SDL_malloc, memalign, new[], etc.
260
+ *
261
+ * \param mem The pointer obtained from SDL_SIMDAlloc. This function also
262
+ * accepts NULL, at which point this function is the same as
263
+ * calling SDL_realloc with a NULL pointer.
264
+ * \param len The length, in bytes, of the block to allocated. The actual
265
+ * allocated block might be larger due to padding, etc. Passing 0
266
+ * will return a non-NULL pointer, assuming the system isn't out of
267
+ * memory.
268
+ * \return Pointer to newly-reallocated block, NULL if out of memory.
269
+ *
270
+ * \sa SDL_SIMDAlignment
271
+ * \sa SDL_SIMDAlloc
272
+ * \sa SDL_SIMDFree
273
+ */
274
+ extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
275
+
248
276
  /**
249
277
  * \brief Deallocate memory obtained from SDL_SIMDAlloc
250
278
  *
@@ -255,6 +283,7 @@ extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
255
283
  * However, SDL_SIMDFree(NULL) is a legal no-op.
256
284
  *
257
285
  * \sa SDL_SIMDAlloc
286
+ * \sa SDL_SIMDRealloc
258
287
  */
259
288
  extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr);
260
289
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -390,6 +390,9 @@ typedef enum {
390
390
  #ifndef WIN32_LEAN_AND_MEAN
391
391
  #define WIN32_LEAN_AND_MEAN 1
392
392
  #endif
393
+ #ifndef NOMINMAX /* don't define min() and max(). */
394
+ #define NOMINMAX
395
+ #endif
393
396
  #include <windows.h>
394
397
 
395
398
  #if __WINRT__
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -42,10 +42,13 @@
42
42
  #ifdef __linux__
43
43
  #include <endian.h>
44
44
  #define SDL_BYTEORDER __BYTE_ORDER
45
- #else /* __linux__ */
45
+ #elif defined(__OpenBSD__)
46
+ #include <endian.h>
47
+ #define SDL_BYTEORDER BYTE_ORDER
48
+ #else
46
49
  #if defined(__hppa__) || \
47
50
  defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
48
- (defined(__MIPS__) && defined(__MISPEB__)) || \
51
+ (defined(__MIPS__) && defined(__MIPSEB__)) || \
49
52
  defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
50
53
  defined(__sparc__)
51
54
  #define SDL_BYTEORDER SDL_BIG_ENDIAN
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -37,9 +37,45 @@ extern "C" {
37
37
  #endif
38
38
 
39
39
  /* Public functions */
40
- /* SDL_SetError() unconditionally returns -1. */
40
+
41
+
42
+ /**
43
+ * \brief Set the error message for the current thread
44
+ *
45
+ * \return -1, there is no error handling for this function
46
+ */
41
47
  extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
48
+
49
+ /**
50
+ * \brief Get the last error message that was set
51
+ *
52
+ * SDL API functions may set error messages and then succeed, so you should
53
+ * only use the error value if a function fails.
54
+ *
55
+ * This returns a pointer to a static buffer for convenience and should not
56
+ * be called by multiple threads simultaneously.
57
+ *
58
+ * \return a pointer to the last error message that was set
59
+ */
42
60
  extern DECLSPEC const char *SDLCALL SDL_GetError(void);
61
+
62
+ /**
63
+ * \brief Get the last error message that was set for the current thread
64
+ *
65
+ * SDL API functions may set error messages and then succeed, so you should
66
+ * only use the error value if a function fails.
67
+ *
68
+ * \param errstr A buffer to fill with the last error message that was set
69
+ * for the current thread
70
+ * \param maxlen The size of the buffer pointed to by the errstr parameter
71
+ *
72
+ * \return errstr
73
+ */
74
+ extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
75
+
76
+ /**
77
+ * \brief Clear the error message for the current thread
78
+ */
43
79
  extern DECLSPEC void SDLCALL SDL_ClearError(void);
44
80
 
45
81
  /**
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -85,6 +85,8 @@ typedef enum
85
85
  Called on Android in onResume()
86
86
  */
87
87
 
88
+ SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
89
+
88
90
  /* Display events */
89
91
  SDL_DISPLAYEVENT = 0x150, /**< Display state change */
90
92
 
@@ -123,6 +125,10 @@ typedef enum
123
125
  SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
124
126
  SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
125
127
  SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
128
+ SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
129
+ SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
130
+ SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
131
+ SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
126
132
 
127
133
  /* Touch events */
128
134
  SDL_FINGERDOWN = 0x700,
@@ -413,6 +419,33 @@ typedef struct SDL_ControllerDeviceEvent
413
419
  Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
414
420
  } SDL_ControllerDeviceEvent;
415
421
 
422
+ /**
423
+ * \brief Game controller touchpad event structure (event.ctouchpad.*)
424
+ */
425
+ typedef struct SDL_ControllerTouchpadEvent
426
+ {
427
+ Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
428
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
429
+ SDL_JoystickID which; /**< The joystick instance id */
430
+ Sint32 touchpad; /**< The index of the touchpad */
431
+ Sint32 finger; /**< The index of the finger on the touchpad */
432
+ float x; /**< Normalized in the range 0...1 with 0 being on the left */
433
+ float y; /**< Normalized in the range 0...1 with 0 being at the top */
434
+ float pressure; /**< Normalized in the range 0...1 */
435
+ } SDL_ControllerTouchpadEvent;
436
+
437
+ /**
438
+ * \brief Game controller sensor event structure (event.csensor.*)
439
+ */
440
+ typedef struct SDL_ControllerSensorEvent
441
+ {
442
+ Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
443
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
444
+ SDL_JoystickID which; /**< The joystick instance id */
445
+ Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
446
+ float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
447
+ } SDL_ControllerSensorEvent;
448
+
416
449
  /**
417
450
  * \brief Audio device event structure (event.adevice.*)
418
451
  */
@@ -442,6 +475,7 @@ typedef struct SDL_TouchFingerEvent
442
475
  float dx; /**< Normalized in the range -1...1 */
443
476
  float dy; /**< Normalized in the range -1...1 */
444
477
  float pressure; /**< Normalized in the range 0...1 */
478
+ Uint32 windowID; /**< The window underneath the finger, if any */
445
479
  } SDL_TouchFingerEvent;
446
480
 
447
481
 
@@ -556,33 +590,35 @@ typedef struct SDL_SysWMEvent
556
590
  */
557
591
  typedef union SDL_Event
558
592
  {
559
- Uint32 type; /**< Event type, shared with all events */
560
- SDL_CommonEvent common; /**< Common event data */
561
- SDL_DisplayEvent display; /**< Window event data */
562
- SDL_WindowEvent window; /**< Window event data */
563
- SDL_KeyboardEvent key; /**< Keyboard event data */
564
- SDL_TextEditingEvent edit; /**< Text editing event data */
565
- SDL_TextInputEvent text; /**< Text input event data */
566
- SDL_MouseMotionEvent motion; /**< Mouse motion event data */
567
- SDL_MouseButtonEvent button; /**< Mouse button event data */
568
- SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
569
- SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
570
- SDL_JoyBallEvent jball; /**< Joystick ball event data */
571
- SDL_JoyHatEvent jhat; /**< Joystick hat event data */
572
- SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
573
- SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
574
- SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
575
- SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
576
- SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
577
- SDL_AudioDeviceEvent adevice; /**< Audio device event data */
578
- SDL_SensorEvent sensor; /**< Sensor event data */
579
- SDL_QuitEvent quit; /**< Quit request event data */
580
- SDL_UserEvent user; /**< Custom event data */
581
- SDL_SysWMEvent syswm; /**< System dependent window event data */
582
- SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
583
- SDL_MultiGestureEvent mgesture; /**< Gesture event data */
584
- SDL_DollarGestureEvent dgesture; /**< Gesture event data */
585
- SDL_DropEvent drop; /**< Drag and drop event data */
593
+ Uint32 type; /**< Event type, shared with all events */
594
+ SDL_CommonEvent common; /**< Common event data */
595
+ SDL_DisplayEvent display; /**< Display event data */
596
+ SDL_WindowEvent window; /**< Window event data */
597
+ SDL_KeyboardEvent key; /**< Keyboard event data */
598
+ SDL_TextEditingEvent edit; /**< Text editing event data */
599
+ SDL_TextInputEvent text; /**< Text input event data */
600
+ SDL_MouseMotionEvent motion; /**< Mouse motion event data */
601
+ SDL_MouseButtonEvent button; /**< Mouse button event data */
602
+ SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
603
+ SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
604
+ SDL_JoyBallEvent jball; /**< Joystick ball event data */
605
+ SDL_JoyHatEvent jhat; /**< Joystick hat event data */
606
+ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
607
+ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
608
+ SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
609
+ SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
610
+ SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
611
+ SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
612
+ SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
613
+ SDL_AudioDeviceEvent adevice; /**< Audio device event data */
614
+ SDL_SensorEvent sensor; /**< Sensor event data */
615
+ SDL_QuitEvent quit; /**< Quit request event data */
616
+ SDL_UserEvent user; /**< Custom event data */
617
+ SDL_SysWMEvent syswm; /**< System dependent window event data */
618
+ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
619
+ SDL_MultiGestureEvent mgesture; /**< Gesture event data */
620
+ SDL_DollarGestureEvent dgesture; /**< Gesture event data */
621
+ SDL_DropEvent drop; /**< Drag and drop event data */
586
622
 
587
623
  /* This is necessary for ABI compatibility between Visual C++ and GCC
588
624
  Visual C++ will respect the push pack pragma and use 52 bytes for
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -31,6 +31,7 @@
31
31
  #include "SDL_stdinc.h"
32
32
  #include "SDL_error.h"
33
33
  #include "SDL_rwops.h"
34
+ #include "SDL_sensor.h"
34
35
  #include "SDL_joystick.h"
35
36
 
36
37
  #include "begin_code.h"
@@ -57,6 +58,17 @@ extern "C" {
57
58
  struct _SDL_GameController;
58
59
  typedef struct _SDL_GameController SDL_GameController;
59
60
 
61
+ typedef enum
62
+ {
63
+ SDL_CONTROLLER_TYPE_UNKNOWN = 0,
64
+ SDL_CONTROLLER_TYPE_XBOX360,
65
+ SDL_CONTROLLER_TYPE_XBOXONE,
66
+ SDL_CONTROLLER_TYPE_PS3,
67
+ SDL_CONTROLLER_TYPE_PS4,
68
+ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
69
+ SDL_CONTROLLER_TYPE_VIRTUAL,
70
+ SDL_CONTROLLER_TYPE_PS5
71
+ } SDL_GameControllerType;
60
72
 
61
73
  typedef enum
62
74
  {
@@ -161,7 +173,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID
161
173
  *
162
174
  * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
163
175
  */
164
- extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
176
+ extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
165
177
 
166
178
  /**
167
179
  * Is the joystick on this index supported by the game controller interface?
@@ -175,6 +187,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
175
187
  */
176
188
  extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
177
189
 
190
+ /**
191
+ * Get the type of a game controller.
192
+ * This can be called before any controllers are opened.
193
+ */
194
+ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
195
+
178
196
  /**
179
197
  * Get the mapping of a game controller.
180
198
  * This can be called before any controllers are opened.
@@ -199,11 +217,21 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_
199
217
  */
200
218
  extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
201
219
 
220
+ /**
221
+ * Return the SDL_GameController associated with a player index.
222
+ */
223
+ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
224
+
202
225
  /**
203
226
  * Return the name for this currently opened controller
204
227
  */
205
228
  extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
206
229
 
230
+ /**
231
+ * Return the type of this currently opened controller
232
+ */
233
+ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
234
+
207
235
  /**
208
236
  * Get the player index of an opened game controller, or -1 if it's not available
209
237
  *
@@ -211,23 +239,35 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *g
211
239
  */
212
240
  extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
213
241
 
242
+ /**
243
+ * Set the player index of an opened game controller
244
+ */
245
+ extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
246
+
214
247
  /**
215
248
  * Get the USB vendor ID of an opened controller, if available.
216
249
  * If the vendor ID isn't available this function returns 0.
217
250
  */
218
- extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
251
+ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
219
252
 
220
253
  /**
221
254
  * Get the USB product ID of an opened controller, if available.
222
255
  * If the product ID isn't available this function returns 0.
223
256
  */
224
- extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
257
+ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
225
258
 
226
259
  /**
227
260
  * Get the product version of an opened controller, if available.
228
261
  * If the product version isn't available this function returns 0.
229
262
  */
230
- extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
263
+ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
264
+
265
+ /**
266
+ * Get the serial number of an opened controller, if available.
267
+ *
268
+ * Returns the serial number of the controller, or NULL if it is not available.
269
+ */
270
+ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
231
271
 
232
272
  /**
233
273
  * Returns SDL_TRUE if the controller has been opened and currently connected,
@@ -298,6 +338,12 @@ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
298
338
  SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
299
339
  SDL_GameControllerAxis axis);
300
340
 
341
+ /**
342
+ * Return whether a game controller has a given axis
343
+ */
344
+ extern DECLSPEC SDL_bool SDLCALL
345
+ SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
346
+
301
347
  /**
302
348
  * Get the current state of an axis control on a game controller.
303
349
  *
@@ -307,8 +353,7 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
307
353
  * The axis indices start at index 0.
308
354
  */
309
355
  extern DECLSPEC Sint16 SDLCALL
310
- SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
311
- SDL_GameControllerAxis axis);
356
+ SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
312
357
 
313
358
  /**
314
359
  * The list of buttons available from a controller
@@ -331,6 +376,12 @@ typedef enum
331
376
  SDL_CONTROLLER_BUTTON_DPAD_DOWN,
332
377
  SDL_CONTROLLER_BUTTON_DPAD_LEFT,
333
378
  SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
379
+ SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button */
380
+ SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
381
+ SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
382
+ SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
383
+ SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
384
+ SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
334
385
  SDL_CONTROLLER_BUTTON_MAX
335
386
  } SDL_GameControllerButton;
336
387
 
@@ -351,6 +402,11 @@ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
351
402
  SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
352
403
  SDL_GameControllerButton button);
353
404
 
405
+ /**
406
+ * Return whether a game controller has a given button
407
+ */
408
+ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
409
+ SDL_GameControllerButton button);
354
410
 
355
411
  /**
356
412
  * Get the current state of a button on a game controller.
@@ -361,7 +417,68 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
361
417
  SDL_GameControllerButton button);
362
418
 
363
419
  /**
364
- * Trigger a rumble effect
420
+ * Get the number of touchpads on a game controller.
421
+ */
422
+ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
423
+
424
+ /**
425
+ * Get the number of supported simultaneous fingers on a touchpad on a game controller.
426
+ */
427
+ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
428
+
429
+ /**
430
+ * Get the current state of a finger on a touchpad on a game controller.
431
+ */
432
+ extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
433
+
434
+ /**
435
+ * Return whether a game controller has a particular sensor.
436
+ *
437
+ * \param gamecontroller The controller to query
438
+ * \param type The type of sensor to query
439
+ *
440
+ * \return SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
441
+ */
442
+ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
443
+
444
+ /**
445
+ * Set whether data reporting for a game controller sensor is enabled
446
+ *
447
+ * \param gamecontroller The controller to update
448
+ * \param type The type of sensor to enable/disable
449
+ * \param enabled Whether data reporting should be enabled
450
+ *
451
+ * \return 0 or -1 if an error occurred.
452
+ */
453
+ extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
454
+
455
+ /**
456
+ * Query whether sensor data reporting is enabled for a game controller
457
+ *
458
+ * \param gamecontroller The controller to query
459
+ * \param type The type of sensor to query
460
+ *
461
+ * \return SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
462
+ */
463
+ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
464
+
465
+ /**
466
+ * Get the current state of a game controller sensor.
467
+ *
468
+ * The number of values and interpretation of the data is sensor dependent.
469
+ * See SDL_sensor.h for the details for each type of sensor.
470
+ *
471
+ * \param gamecontroller The controller to query
472
+ * \param type The type of sensor to query
473
+ * \param data A pointer filled with the current sensor state
474
+ * \param num_values The number of values to write to data
475
+ *
476
+ * \return 0 or -1 if an error occurred.
477
+ */
478
+ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
479
+
480
+ /**
481
+ * Start a rumble effect
365
482
  * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
366
483
  *
367
484
  * \param gamecontroller The controller to vibrate
@@ -369,10 +486,44 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
369
486
  * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
370
487
  * \param duration_ms The duration of the rumble effect, in milliseconds
371
488
  *
372
- * \return 0, or -1 if rumble isn't supported on this joystick
489
+ * \return 0, or -1 if rumble isn't supported on this controller
373
490
  */
374
491
  extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
375
492
 
493
+ /**
494
+ * Start a rumble effect in the game controller's triggers
495
+ * Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
496
+ *
497
+ * \param gamecontroller The controller to vibrate
498
+ * \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF
499
+ * \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF
500
+ * \param duration_ms The duration of the rumble effect, in milliseconds
501
+ *
502
+ * \return 0, or -1 if rumble isn't supported on this controller
503
+ */
504
+ extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
505
+
506
+ /**
507
+ * Return whether a controller has an LED
508
+ *
509
+ * \param gamecontroller The controller to query
510
+ *
511
+ * \return SDL_TRUE, or SDL_FALSE if this controller does not have a modifiable LED
512
+ */
513
+ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
514
+
515
+ /**
516
+ * Update a controller's LED color.
517
+ *
518
+ * \param gamecontroller The controller to update
519
+ * \param red The intensity of the red LED
520
+ * \param green The intensity of the green LED
521
+ * \param blue The intensity of the blue LED
522
+ *
523
+ * \return 0, or -1 if this controller does not have a modifiable LED
524
+ */
525
+ extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
526
+
376
527
  /**
377
528
  * Close a controller previously opened with SDL_GameControllerOpen().
378
529
  */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -336,6 +336,14 @@ typedef struct _SDL_Haptic SDL_Haptic;
336
336
  */
337
337
  #define SDL_HAPTIC_SPHERICAL 2
338
338
 
339
+ /**
340
+ * \brief Use this value to play an effect on the steering wheel axis. This
341
+ * provides better compatibility across platforms and devices as SDL will guess
342
+ * the correct axis.
343
+ * \sa SDL_HapticDirection
344
+ */
345
+ #define SDL_HAPTIC_STEERING_AXIS 3
346
+
339
347
  /* @} *//* Direction encodings */
340
348
 
341
349
  /* @} *//* Haptic features */
@@ -444,6 +452,7 @@ typedef struct _SDL_Haptic SDL_Haptic;
444
452
  * \sa SDL_HAPTIC_POLAR
445
453
  * \sa SDL_HAPTIC_CARTESIAN
446
454
  * \sa SDL_HAPTIC_SPHERICAL
455
+ * \sa SDL_HAPTIC_STEERING_AXIS
447
456
  * \sa SDL_HapticEffect
448
457
  * \sa SDL_HapticNumAxes
449
458
  */