@kmamal/sdl 1.0.0-8 → 1.0.0-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +2 -2
  3. package/binding.gyp +18 -4
  4. package/package.json +1 -1
  5. package/scripts/build.mjs +3 -1
  6. package/scripts/install.mjs +2 -0
  7. package/scripts/util/common.js +1 -0
  8. package/src/javascript/audio/audio-stream.js +4 -3
  9. package/src/javascript/audio/prevent-exit.js +1 -1
  10. package/src/javascript/events/events-via-poll.js +2 -4
  11. package/src/javascript/events/index.js +14 -1
  12. package/src/javascript/events/try.js +3 -0
  13. package/src/javascript/joystick/joystick-device-instance.js +1 -0
  14. package/src/javascript/validate.js +5 -0
  15. package/src/javascript/video/events.js +3 -3
  16. package/src/javascript/video/window.js +53 -7
  17. package/src/native/audio.cpp +24 -26
  18. package/src/native/audio.h +24 -24
  19. package/src/native/clipboard.h +2 -2
  20. package/src/native/enums.cpp +14 -1
  21. package/src/native/enums.h +1 -1
  22. package/src/native/events.cpp +1 -69
  23. package/src/native/events.h +69 -69
  24. package/src/native/gamepad.cpp +65 -4
  25. package/src/native/gamepad.h +8 -8
  26. package/src/native/global.cpp +11 -273
  27. package/src/native/global.h +9 -9
  28. package/src/native/joystick.cpp +26 -3
  29. package/src/native/joystick.h +13 -13
  30. package/src/native/keyboard.cpp +6 -6
  31. package/src/native/keyboard.h +3 -3
  32. package/src/native/module.cpp +3 -0
  33. package/src/native/mouse.cpp +1 -1
  34. package/src/native/mouse.h +9 -9
  35. package/src/native/packed.cpp +5 -12
  36. package/src/native/packed.h +8 -13
  37. package/src/native/power.cpp +7 -1
  38. package/src/native/power.h +2 -2
  39. package/src/native/sensor.cpp +19 -2
  40. package/src/native/sensor.h +6 -6
  41. package/src/native/testing.cpp +17 -0
  42. package/src/native/testing.h +6 -5
  43. package/src/native/threads.cpp +1 -0
  44. package/src/native/threads.h +13 -13
  45. package/src/native/touch.cpp +7 -2
  46. package/src/native/touch.h +2 -2
  47. package/src/native/video.cpp +68 -5
  48. package/src/native/video.h +5 -5
  49. package/src/native/window.cpp +46 -1
  50. package/src/native/window.h +24 -21
  51. package/src/types/index.d.ts +16 -1
@@ -16,17 +16,14 @@ namespace packed {
16
16
  using Array = std::vector<Value>;
17
17
 
18
18
  struct Str {
19
- Str () = default;
20
- Str (const Str &) = delete;
21
- Str &operator= (const Str &) = delete;
22
- Str &operator= (const char *value) { string = value; return *this; }
19
+ template <size_t N>
20
+ constexpr Str (const char (&value)[N]) : string(value) {}
23
21
 
24
- const std::string &str () const { return string; }
25
- const char *c_str () const { return string.c_str(); }
26
- operator const std::string & () const { return string; }
22
+ constexpr const char *c_str () const { return string; }
23
+ constexpr operator const char * () const { return string; }
27
24
 
28
25
  private:
29
- std::string string;
26
+ const char *string;
30
27
  };
31
28
 
32
29
  struct Value {
@@ -38,7 +35,7 @@ namespace packed {
38
35
  double,
39
36
  int64_t,
40
37
  uint64_t,
41
- const std::string *,
38
+ const char *,
42
39
  std::string,
43
40
  Object,
44
41
  Array
@@ -58,8 +55,7 @@ namespace packed {
58
55
  Value (const std::string &value) : data(std::in_place_type<std::string>, value) {}
59
56
  Value (std::string &&value) : data(std::in_place_type<std::string>, std::move(value)) {}
60
57
 
61
- static Value ref (const Str &value);
62
- static Value ref (Str &&value) = delete;
58
+ static Value ref (Str value);
63
59
  static Value ref (const std::string &value) = delete;
64
60
  static Value ref (std::string &&value) = delete;
65
61
  static Value object ();
@@ -70,8 +66,7 @@ namespace packed {
70
66
  const Value *get (const char *key) const;
71
67
  const Object &members () const { return std::get<Object>(data); }
72
68
  Value &set (const char *key, Value value);
73
- Value &set (const Str &key, Value value);
74
- Value &set (Str &&key, Value value) = delete;
69
+ Value &set (Str key, Value value);
75
70
  Value &set (const std::string &key, Value value) = delete;
76
71
  Value &set (std::string &&key, Value value) = delete;
77
72
  Value &push (Value value);
@@ -4,7 +4,13 @@
4
4
  #include <map>
5
5
 
6
6
 
7
- std::map<SDL_PowerState, packed::Str> power::states;
7
+ const std::map<SDL_PowerState, packed::Str> power::states {
8
+ // { SDL_POWERSTATE_UNKNOWN, nullptr },
9
+ { SDL_POWERSTATE_NO_BATTERY, "noBattery" },
10
+ { SDL_POWERSTATE_ON_BATTERY, "battery" },
11
+ { SDL_POWERSTATE_CHARGING, "charging" },
12
+ { SDL_POWERSTATE_CHARGED, "charged" },
13
+ };
8
14
 
9
15
 
10
16
  Napi::Value
@@ -8,9 +8,9 @@
8
8
 
9
9
  namespace power {
10
10
 
11
- extern std::map<SDL_PowerState, packed::Str> states;
11
+ extern const std::map<SDL_PowerState, packed::Str> states;
12
12
 
13
- Napi::Value getInfo(const Napi::CallbackInfo &info);
13
+ Napi::Value getInfo (const Napi::CallbackInfo &info);
14
14
 
15
15
  }; // namespace power
16
16
 
@@ -6,8 +6,25 @@
6
6
  #include <string>
7
7
 
8
8
 
9
- std::map<SDL_SensorType, packed::Str> sensor::types;
10
- std::map<SDL_SensorType, packed::Str> sensor::sides;
9
+ const std::map<SDL_SensorType, packed::Str> sensor::types {
10
+ // { SDL_SENSOR_UNKNOWN, nullptr },
11
+ { SDL_SENSOR_ACCEL, "accelerometer" },
12
+ { SDL_SENSOR_GYRO, "gyroscope" },
13
+ { SDL_SENSOR_ACCEL_L, "accelerometer" },
14
+ { SDL_SENSOR_GYRO_L, "gyroscope" },
15
+ { SDL_SENSOR_ACCEL_R, "accelerometer" },
16
+ { SDL_SENSOR_GYRO_R, "gyroscope" },
17
+ };
18
+
19
+ const std::map<SDL_SensorType, packed::Str> sensor::sides {
20
+ // { SDL_SENSOR_UNKNOWN, nullptr },
21
+ // { SDL_SENSOR_ACCEL, nullptr },
22
+ // { SDL_SENSOR_GYRO, nullptr },
23
+ { SDL_SENSOR_ACCEL_L, "left" },
24
+ { SDL_SENSOR_GYRO_L, "left" },
25
+ { SDL_SENSOR_ACCEL_R, "right" },
26
+ { SDL_SENSOR_GYRO_R, "right" },
27
+ };
11
28
 
12
29
 
13
30
  Napi::Value
@@ -8,13 +8,13 @@
8
8
 
9
9
  namespace sensor {
10
10
 
11
- extern std::map<SDL_SensorType, packed::Str> types;
12
- extern std::map<SDL_SensorType, packed::Str> sides;
11
+ extern const std::map<SDL_SensorType, packed::Str> types;
12
+ extern const std::map<SDL_SensorType, packed::Str> sides;
13
13
 
14
- Napi::Value getDevices(const Napi::CallbackInfo &info);
15
- Napi::Value open(const Napi::CallbackInfo &info);
16
- Napi::Value getData(const Napi::CallbackInfo &info);
17
- Napi::Value close(const Napi::CallbackInfo &info);
14
+ Napi::Value getDevices (const Napi::CallbackInfo &info);
15
+ Napi::Value open (const Napi::CallbackInfo &info);
16
+ Napi::Value getData (const Napi::CallbackInfo &info);
17
+ Napi::Value close (const Napi::CallbackInfo &info);
18
18
 
19
19
  }; // namespace sensor
20
20
 
@@ -1,5 +1,6 @@
1
1
  #include "testing.h"
2
2
  #include "global.h"
3
+ #include "window.h"
3
4
  #include <SDL3/SDL.h>
4
5
  #include <cmath>
5
6
 
@@ -129,3 +130,19 @@ testing::pushAudioDeviceEvent (const Napi::CallbackInfo &info)
129
130
 
130
131
  return env.Undefined();
131
132
  }
133
+
134
+ Napi::Value
135
+ testing::hitTest (const Napi::CallbackInfo &info)
136
+ {
137
+ Napi::Env env = info.Env();
138
+
139
+ SDL_WindowID window_id = info[0].As<Napi::Number>().Uint32Value();
140
+ SDL_Point point = {
141
+ info[1].As<Napi::Number>().Int32Value(),
142
+ info[2].As<Napi::Number>().Int32Value(),
143
+ };
144
+
145
+ SDL_Window *window = global::fromIdOrThrow(env, SDL_GetWindowFromID(window_id), "SDL_GetWindowFromID", "window", window_id);
146
+
147
+ return Napi::Number::New(env, window::hitTest(window, &point, nullptr));
148
+ }
@@ -5,11 +5,12 @@
5
5
 
6
6
  namespace testing {
7
7
 
8
- Napi::Value attachVirtualJoystick(const Napi::CallbackInfo &info);
9
- Napi::Value setVirtualJoystickAxis(const Napi::CallbackInfo &info);
10
- Napi::Value setVirtualJoystickButton(const Napi::CallbackInfo &info);
11
- Napi::Value detachVirtualJoystick(const Napi::CallbackInfo &info);
12
- Napi::Value pushAudioDeviceEvent(const Napi::CallbackInfo &info);
8
+ Napi::Value attachVirtualJoystick (const Napi::CallbackInfo &info);
9
+ Napi::Value setVirtualJoystickAxis (const Napi::CallbackInfo &info);
10
+ Napi::Value setVirtualJoystickButton (const Napi::CallbackInfo &info);
11
+ Napi::Value detachVirtualJoystick (const Napi::CallbackInfo &info);
12
+ Napi::Value pushAudioDeviceEvent (const Napi::CallbackInfo &info);
13
+ Napi::Value hitTest (const Napi::CallbackInfo &info);
13
14
 
14
15
  }; // namespace testing
15
16
 
@@ -17,6 +17,7 @@ struct Thread {
17
17
  bool wake_pending = false;
18
18
  };
19
19
 
20
+ // Lock order must always be global::lock() before this mutex.
20
21
  static std::mutex mutex;
21
22
  static std::map<napi_env, Thread> all_threads;
22
23
  static std::atomic<int> num_demanding { 0 };
@@ -17,19 +17,19 @@ namespace threads {
17
17
  std::shared_ptr<const packed::Value> value;
18
18
  };
19
19
 
20
- void trackOpen(Napi::Env &env, Kind kind, Uint32 id);
21
- void trackClose(Napi::Env &env, Kind kind, Uint32 id);
22
-
23
- void leave(napi_env env);
24
- void distribute(const Event &event, napi_env except);
25
- void drain(Napi::Env &env, Napi::Function &callback);
26
- bool isPollingFast();
27
- bool hasWorkers();
28
- void wakeMain();
29
- void shutdown();
30
-
31
- Napi::Value registerThread(const Napi::CallbackInfo &info);
32
- Napi::Value setDemand(const Napi::CallbackInfo &info);
20
+ void trackOpen (Napi::Env &env, Kind kind, Uint32 id);
21
+ void trackClose (Napi::Env &env, Kind kind, Uint32 id);
22
+
23
+ void leave (napi_env env);
24
+ void distribute (const Event &event, napi_env except);
25
+ void drain (Napi::Env &env, Napi::Function &callback);
26
+ bool isPollingFast ();
27
+ bool hasWorkers ();
28
+ void wakeMain ();
29
+ void shutdown ();
30
+
31
+ Napi::Value registerThread (const Napi::CallbackInfo &info);
32
+ Napi::Value setDemand (const Napi::CallbackInfo &info);
33
33
 
34
34
  }; // namespace threads
35
35
 
@@ -3,10 +3,15 @@
3
3
  #include <SDL3/SDL.h>
4
4
  #include <string>
5
5
 
6
- std::map<SDL_TouchDeviceType, packed::Str> touch::device_types;
6
+ const std::map<SDL_TouchDeviceType, packed::Str> touch::device_types {
7
+ // { SDL_TOUCH_DEVICE_INVALID, nullptr },
8
+ { SDL_TOUCH_DEVICE_DIRECT, "direct" },
9
+ { SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "indirectAbsolute" },
10
+ { SDL_TOUCH_DEVICE_INDIRECT_RELATIVE, "indirectRelative" },
11
+ };
7
12
 
8
13
  Napi::Value
9
- touch::getDevices(const Napi::CallbackInfo &info)
14
+ touch::getDevices (const Napi::CallbackInfo &info)
10
15
  {
11
16
  Napi::Env env = info.Env();
12
17
 
@@ -8,9 +8,9 @@
8
8
 
9
9
  namespace touch {
10
10
 
11
- extern std::map<SDL_TouchDeviceType, packed::Str> device_types;
11
+ extern const std::map<SDL_TouchDeviceType, packed::Str> device_types;
12
12
 
13
- Napi::Value getDevices(const Napi::CallbackInfo &info);
13
+ Napi::Value getDevices (const Napi::CallbackInfo &info);
14
14
 
15
15
  }; // namespace touch
16
16
 
@@ -5,8 +5,71 @@
5
5
  #include <map>
6
6
 
7
7
 
8
- std::map<SDL_DisplayOrientation, packed::Str> video::orientations;
9
- std::map<SDL_PixelFormat, packed::Str> video::formats;
8
+ const std::map<SDL_DisplayOrientation, packed::Str> video::orientations {
9
+ // { SDL_ORIENTATION_UNKNOWN, nullptr },
10
+ { SDL_ORIENTATION_LANDSCAPE, "landscape" },
11
+ { SDL_ORIENTATION_LANDSCAPE_FLIPPED, "landscapeFlipped" },
12
+ { SDL_ORIENTATION_PORTRAIT, "portrait" },
13
+ { SDL_ORIENTATION_PORTRAIT_FLIPPED, "portraitFlipped" },
14
+ };
15
+
16
+ const std::map<SDL_PixelFormat, packed::Str> video::formats {
17
+ { SDL_PIXELFORMAT_RGB332, "rgb332" },
18
+ { SDL_PIXELFORMAT_XRGB4444, "xrgb4444" },
19
+ { SDL_PIXELFORMAT_XBGR4444, "xbgr4444" },
20
+ { SDL_PIXELFORMAT_XRGB1555, "xrgb1555" },
21
+ { SDL_PIXELFORMAT_XBGR1555, "xbgr1555" },
22
+ { SDL_PIXELFORMAT_ARGB4444, "argb4444" },
23
+ { SDL_PIXELFORMAT_RGBA4444, "rgba4444" },
24
+ { SDL_PIXELFORMAT_ABGR4444, "abgr4444" },
25
+ { SDL_PIXELFORMAT_BGRA4444, "bgra4444" },
26
+ { SDL_PIXELFORMAT_ARGB1555, "argb1555" },
27
+ { SDL_PIXELFORMAT_RGBA5551, "rgba5551" },
28
+ { SDL_PIXELFORMAT_ABGR1555, "abgr1555" },
29
+ { SDL_PIXELFORMAT_BGRA5551, "bgra5551" },
30
+ { SDL_PIXELFORMAT_RGB565, "rgb565" },
31
+ { SDL_PIXELFORMAT_BGR565, "bgr565" },
32
+ { SDL_PIXELFORMAT_RGB24, "rgb24" },
33
+ { SDL_PIXELFORMAT_BGR24, "bgr24" },
34
+ { SDL_PIXELFORMAT_XRGB8888, "xrgb8888" },
35
+ { SDL_PIXELFORMAT_RGBX8888, "rgbx8888" },
36
+ { SDL_PIXELFORMAT_XBGR8888, "xbgr8888" },
37
+ { SDL_PIXELFORMAT_BGRX8888, "bgrx8888" },
38
+ { SDL_PIXELFORMAT_ARGB8888, "argb8888" },
39
+ { SDL_PIXELFORMAT_RGBA8888, "rgba8888" },
40
+ { SDL_PIXELFORMAT_ABGR8888, "abgr8888" },
41
+ { SDL_PIXELFORMAT_BGRA8888, "bgra8888" },
42
+ { SDL_PIXELFORMAT_ARGB2101010, "argb2101010" },
43
+ { SDL_PIXELFORMAT_XRGB2101010, "xrgb2101010" },
44
+ { SDL_PIXELFORMAT_XBGR2101010, "xbgr2101010" },
45
+ { SDL_PIXELFORMAT_ABGR2101010, "abgr2101010" },
46
+ { SDL_PIXELFORMAT_RGB48, "rgb48" },
47
+ { SDL_PIXELFORMAT_BGR48, "bgr48" },
48
+ { SDL_PIXELFORMAT_RGBA64, "rgba64" },
49
+ { SDL_PIXELFORMAT_ARGB64, "argb64" },
50
+ { SDL_PIXELFORMAT_BGRA64, "bgra64" },
51
+ { SDL_PIXELFORMAT_ABGR64, "abgr64" },
52
+ { SDL_PIXELFORMAT_RGB48_FLOAT, "rgb48f" },
53
+ { SDL_PIXELFORMAT_BGR48_FLOAT, "bgr48f" },
54
+ { SDL_PIXELFORMAT_RGBA64_FLOAT, "rgba64f" },
55
+ { SDL_PIXELFORMAT_ARGB64_FLOAT, "argb64f" },
56
+ { SDL_PIXELFORMAT_BGRA64_FLOAT, "bgra64f" },
57
+ { SDL_PIXELFORMAT_ABGR64_FLOAT, "abgr64f" },
58
+ { SDL_PIXELFORMAT_RGB96_FLOAT, "rgb96f" },
59
+ { SDL_PIXELFORMAT_BGR96_FLOAT, "bgr96f" },
60
+ { SDL_PIXELFORMAT_RGBA128_FLOAT, "rgba128f" },
61
+ { SDL_PIXELFORMAT_ARGB128_FLOAT, "argb128f" },
62
+ { SDL_PIXELFORMAT_BGRA128_FLOAT, "bgra128f" },
63
+ { SDL_PIXELFORMAT_ABGR128_FLOAT, "abgr128f" },
64
+ { SDL_PIXELFORMAT_YV12, "yv12" },
65
+ { SDL_PIXELFORMAT_IYUV, "iyuv" },
66
+ { SDL_PIXELFORMAT_YUY2, "yuy2" },
67
+ { SDL_PIXELFORMAT_UYVY, "uyvy" },
68
+ { SDL_PIXELFORMAT_YVYU, "yvyu" },
69
+ { SDL_PIXELFORMAT_NV12, "nv12" },
70
+ { SDL_PIXELFORMAT_NV21, "nv21" },
71
+ { SDL_PIXELFORMAT_P010, "p010" },
72
+ };
10
73
 
11
74
 
12
75
  packed::Value
@@ -94,7 +157,7 @@ video::_getDisplays (Napi::Env &env)
94
157
  }
95
158
 
96
159
  Napi::Value
97
- video::getDrivers(const Napi::CallbackInfo &info)
160
+ video::getDrivers (const Napi::CallbackInfo &info)
98
161
  {
99
162
  Napi::Env env = info.Env();
100
163
 
@@ -114,7 +177,7 @@ video::getDrivers(const Napi::CallbackInfo &info)
114
177
  }
115
178
 
116
179
  Napi::Value
117
- video::getDisplays(const Napi::CallbackInfo &info)
180
+ video::getDisplays (const Napi::CallbackInfo &info)
118
181
  {
119
182
  Napi::Env env = info.Env();
120
183
 
@@ -122,7 +185,7 @@ video::getDisplays(const Napi::CallbackInfo &info)
122
185
  }
123
186
 
124
187
  Napi::Value
125
- video::convert(const Napi::CallbackInfo &info)
188
+ video::convert (const Napi::CallbackInfo &info)
126
189
  {
127
190
  Napi::Env env = info.Env();
128
191
 
@@ -8,15 +8,15 @@
8
8
 
9
9
  namespace video {
10
10
 
11
- extern std::map<SDL_DisplayOrientation, packed::Str> orientations;
12
- extern std::map<SDL_PixelFormat, packed::Str> formats;
11
+ extern const std::map<SDL_DisplayOrientation, packed::Str> orientations;
12
+ extern const std::map<SDL_PixelFormat, packed::Str> formats;
13
13
 
14
14
  packed::Value _getDisplay (SDL_DisplayID display_id);
15
15
  Napi::Array _getDisplays (Napi::Env &env);
16
16
 
17
- Napi::Value getDrivers(const Napi::CallbackInfo &info);
18
- Napi::Value getDisplays(const Napi::CallbackInfo &info);
19
- Napi::Value convert(const Napi::CallbackInfo &info);
17
+ Napi::Value getDrivers (const Napi::CallbackInfo &info);
18
+ Napi::Value getDisplays (const Napi::CallbackInfo &info);
19
+ Napi::Value convert (const Napi::CallbackInfo &info);
20
20
 
21
21
  }; // namespace video
22
22
 
@@ -19,6 +19,8 @@ window::resetTexture (SDL_Window *window)
19
19
  }
20
20
  }
21
21
 
22
+ static Napi::FunctionReference hit_test_handler;
23
+
22
24
  static SDL_Window *
23
25
  getWindow (Napi::Env &env, SDL_WindowID window_id)
24
26
  {
@@ -77,7 +79,7 @@ getWindow (Napi::Env &env, SDL_WindowID window_id)
77
79
  #endif
78
80
 
79
81
  static void
80
- updateRenderer(
82
+ updateRenderer (
81
83
  Napi::Env &env,
82
84
  SDL_Window *window,
83
85
  bool *is_accelerated,
@@ -770,6 +772,49 @@ window::flash (const Napi::CallbackInfo &info)
770
772
  return env.Undefined();
771
773
  }
772
774
 
775
+ SDL_HitTestResult SDLCALL
776
+ window::hitTest (SDL_Window *window, const SDL_Point *area, void *)
777
+ {
778
+ Napi::Env env = hit_test_handler.Env();
779
+ Napi::HandleScope scope(env);
780
+
781
+ Napi::Value result = hit_test_handler.Call({
782
+ Napi::Number::New(env, SDL_GetWindowID(window)),
783
+ Napi::Number::New(env, area->x),
784
+ Napi::Number::New(env, area->y),
785
+ });
786
+
787
+ return (SDL_HitTestResult) result.As<Napi::Number>().Int32Value();
788
+ }
789
+
790
+ Napi::Value
791
+ window::registerHitTestHandler (const Napi::CallbackInfo &info)
792
+ {
793
+ Napi::Env env = info.Env();
794
+
795
+ hit_test_handler = Napi::Persistent(info[0].As<Napi::Function>());
796
+ hit_test_handler.SuppressDestruct();
797
+
798
+ return env.Undefined();
799
+ }
800
+
801
+ Napi::Value
802
+ window::setHitTest (const Napi::CallbackInfo &info)
803
+ {
804
+ Napi::Env env = info.Env();
805
+
806
+ SDL_WindowID window_id = info[0].As<Napi::Number>().Uint32Value();
807
+ bool enabled = info[1].As<Napi::Boolean>().Value();
808
+
809
+ SDL_Window *window = getWindow(env, window_id);
810
+
811
+ if (!SDL_SetWindowHitTest(window, enabled ? window::hitTest : nullptr, nullptr)) {
812
+ throw global::sdlError(env, "SDL_SetWindowHitTest", window_id, enabled);
813
+ }
814
+
815
+ return env.Undefined();
816
+ }
817
+
773
818
  Napi::Value
774
819
  window::destroy (const Napi::CallbackInfo &info)
775
820
  {
@@ -6,27 +6,30 @@
6
6
 
7
7
  namespace window {
8
8
 
9
- void resetTexture(SDL_Window *window);
10
- Napi::Value create(const Napi::CallbackInfo &info);
11
- Napi::Value setTitle(const Napi::CallbackInfo &info);
12
- Napi::Value setPosition(const Napi::CallbackInfo &info);
13
- Napi::Value setSize(const Napi::CallbackInfo &info);
14
- Napi::Value setFullscreen(const Napi::CallbackInfo &info);
15
- Napi::Value setResizable(const Napi::CallbackInfo &info);
16
- Napi::Value setBorderless(const Napi::CallbackInfo &info);
17
- Napi::Value setRelativeMouseMode(const Napi::CallbackInfo &info);
18
- Napi::Value getMouseCaptured(const Napi::CallbackInfo &info);
19
- Napi::Value setAcceleratedAndVsync(const Napi::CallbackInfo &info);
20
- Napi::Value focus(const Napi::CallbackInfo &info);
21
- Napi::Value show(const Napi::CallbackInfo &info);
22
- Napi::Value hide(const Napi::CallbackInfo &info);
23
- Napi::Value maximize(const Napi::CallbackInfo &info);
24
- Napi::Value minimize(const Napi::CallbackInfo &info);
25
- Napi::Value restore(const Napi::CallbackInfo &info);
26
- Napi::Value render(const Napi::CallbackInfo &info);
27
- Napi::Value setIcon(const Napi::CallbackInfo &info);
28
- Napi::Value flash(const Napi::CallbackInfo &info);
29
- Napi::Value destroy(const Napi::CallbackInfo &info);
9
+ void resetTexture (SDL_Window *window);
10
+ SDL_HitTestResult SDLCALL hitTest (SDL_Window *window, const SDL_Point *area, void *data);
11
+ Napi::Value create (const Napi::CallbackInfo &info);
12
+ Napi::Value setTitle (const Napi::CallbackInfo &info);
13
+ Napi::Value setPosition (const Napi::CallbackInfo &info);
14
+ Napi::Value setSize (const Napi::CallbackInfo &info);
15
+ Napi::Value setFullscreen (const Napi::CallbackInfo &info);
16
+ Napi::Value setResizable (const Napi::CallbackInfo &info);
17
+ Napi::Value setBorderless (const Napi::CallbackInfo &info);
18
+ Napi::Value setRelativeMouseMode (const Napi::CallbackInfo &info);
19
+ Napi::Value getMouseCaptured (const Napi::CallbackInfo &info);
20
+ Napi::Value setAcceleratedAndVsync (const Napi::CallbackInfo &info);
21
+ Napi::Value focus (const Napi::CallbackInfo &info);
22
+ Napi::Value show (const Napi::CallbackInfo &info);
23
+ Napi::Value hide (const Napi::CallbackInfo &info);
24
+ Napi::Value maximize (const Napi::CallbackInfo &info);
25
+ Napi::Value minimize (const Napi::CallbackInfo &info);
26
+ Napi::Value restore (const Napi::CallbackInfo &info);
27
+ Napi::Value render (const Napi::CallbackInfo &info);
28
+ Napi::Value setIcon (const Napi::CallbackInfo &info);
29
+ Napi::Value flash (const Napi::CallbackInfo &info);
30
+ Napi::Value registerHitTestHandler (const Napi::CallbackInfo &info);
31
+ Napi::Value setHitTest (const Napi::CallbackInfo &info);
32
+ Napi::Value destroy (const Napi::CallbackInfo &info);
30
33
 
31
34
  }; // namespace window
32
35
 
@@ -12,7 +12,7 @@ export namespace Events {
12
12
  export namespace Display {
13
13
 
14
14
  interface DisplayEvent extends BaseEvent {
15
- readonly device: Sdl.Video.Display
15
+ readonly display: Sdl.Video.Display
16
16
  }
17
17
 
18
18
  export interface Add extends DisplayEvent {
@@ -547,6 +547,18 @@ export namespace Sdl {
547
547
  = 'nearest'
548
548
  | 'linear'
549
549
 
550
+ export type HitTestResult
551
+ = 'normal'
552
+ | 'draggable'
553
+ | 'resizeTopLeft'
554
+ | 'resizeTop'
555
+ | 'resizeTopRight'
556
+ | 'resizeRight'
557
+ | 'resizeBottomRight'
558
+ | 'resizeBottom'
559
+ | 'resizeBottomLeft'
560
+ | 'resizeLeft'
561
+
550
562
  export interface Display {
551
563
  readonly id: number
552
564
  readonly name: string | null
@@ -666,6 +678,9 @@ export namespace Sdl {
666
678
  setRelativeMouseMode (relative?: boolean): void
667
679
  unsetRelativeMouseMode (): void
668
680
 
681
+ setHitTest (hitTest: ((x: Points, y: Points) => HitTestResult | undefined) | null): void
682
+ unsetHitTest (): void
683
+
669
684
  render (width: number, height: number, stride: number, format: Format | FormatAlias, buffer: Buffer, options?: {
670
685
  scaling?: Scaling,
671
686
  dstRect?: {