@kmamal/sdl 0.6.2 → 0.6.3
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.
- package/README.md +5 -2
- package/package.json +1 -1
- package/src/native/sdl-helpers.cpp +14 -10
package/README.md
CHANGED
|
@@ -289,15 +289,18 @@ This event will be followed by a call to `process.exit()`.
|
|
|
289
289
|
* `drivers: <object>`
|
|
290
290
|
* `video: <object>`
|
|
291
291
|
* `all: <string>[]` A list of all video drivers.
|
|
292
|
-
* `current: <string>` The video driver that is currently selected.
|
|
292
|
+
* `current: <string>|<null>` The video driver that is currently selected.
|
|
293
293
|
* `audio: <object>`
|
|
294
294
|
* `all: <string>[]` A list of all audio drivers.
|
|
295
|
-
* `current: <string>` The audio driver that is currently selected.
|
|
295
|
+
* `current: <string>|<null>` The audio driver that is currently selected.
|
|
296
296
|
|
|
297
297
|
This object is filled with the information produced during the initialization of SDL.
|
|
298
298
|
All the values will remain constant throughout the execution of the program.
|
|
299
299
|
If you want to initialize SDL with drivers other than the default ones, you can do so via its [environment variables](https://wiki.libsdl.org/FAQUsingSDL).
|
|
300
300
|
|
|
301
|
+
Note that the `current` video or audio driver can be `null`.
|
|
302
|
+
This can happen on systems that don't have any compatible devices, such as on a CI pipeline.
|
|
303
|
+
|
|
301
304
|
Sample data for Ubuntu:
|
|
302
305
|
|
|
303
306
|
```js
|
package/package.json
CHANGED
|
@@ -698,13 +698,11 @@ initialize (Variant & object)
|
|
|
698
698
|
{
|
|
699
699
|
int subsystems = 0
|
|
700
700
|
| SDL_INIT_EVENTS
|
|
701
|
-
| SDL_INIT_VIDEO
|
|
702
701
|
| SDL_INIT_JOYSTICK
|
|
703
702
|
| SDL_INIT_GAMECONTROLLER
|
|
704
|
-
| SDL_INIT_HAPTIC
|
|
705
|
-
| SDL_INIT_AUDIO;
|
|
703
|
+
| SDL_INIT_HAPTIC;
|
|
706
704
|
if (SDL_Init(subsystems) != 0) {
|
|
707
|
-
RETURN_ERROR("SDL_Init(
|
|
705
|
+
RETURN_ERROR("SDL_Init() error: %s\n", SDL_GetError());
|
|
708
706
|
}
|
|
709
707
|
}
|
|
710
708
|
|
|
@@ -774,12 +772,16 @@ initialize (Variant & object)
|
|
|
774
772
|
|
|
775
773
|
// Selected Video Driver
|
|
776
774
|
{
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
775
|
+
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) {
|
|
776
|
+
const char * driver_name = SDL_GetCurrentVideoDriver();
|
|
777
|
+
if(driver_name == nullptr) {
|
|
778
|
+
RETURN_ERROR("SDL_GetCurrentVideoDriver() error: %s\n", SDL_GetError());
|
|
779
|
+
}
|
|
781
780
|
|
|
782
|
-
|
|
781
|
+
SET_STRING(video, "current", driver_name);
|
|
782
|
+
} else {
|
|
783
|
+
SET_NULL(video, "current");
|
|
784
|
+
}
|
|
783
785
|
}
|
|
784
786
|
|
|
785
787
|
// Available Audio Drivers
|
|
@@ -809,13 +811,15 @@ initialize (Variant & object)
|
|
|
809
811
|
}
|
|
810
812
|
|
|
811
813
|
// Selected Audio Driver
|
|
812
|
-
{
|
|
814
|
+
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0) {
|
|
813
815
|
const char * driver_name = SDL_GetCurrentAudioDriver();
|
|
814
816
|
if(driver_name == nullptr) {
|
|
815
817
|
RETURN_ERROR("SDL_GetCurrentAudioDriver() error: %s\n", SDL_GetError());
|
|
816
818
|
}
|
|
817
819
|
|
|
818
820
|
SET_STRING(audio, "current", driver_name);
|
|
821
|
+
} else {
|
|
822
|
+
SET_NULL(audio, "current");
|
|
819
823
|
}
|
|
820
824
|
|
|
821
825
|
SET_MAP(drivers, "video", video);
|