@kmamal/sdl 0.9.4 → 0.9.6-0
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 +34 -15
- package/binding.gyp +25 -5
- package/package.json +7 -4
- package/src/javascript/audio/audio-instance.js +9 -6
- package/src/javascript/cleanup.js +1 -1
- package/src/javascript/clipboard/index.js +2 -1
- package/src/javascript/controller/controller-instance.js +6 -0
- package/src/javascript/enums.js +1 -1
- package/src/javascript/events/index.js +302 -305
- package/src/javascript/index.js +1 -1
- package/src/javascript/joystick/joystick-instance.js +7 -0
- package/src/javascript/keyboard/index.js +3 -3
- package/src/javascript/keyboard/key-mapping.js +14 -6
- package/src/javascript/mouse/index.js +13 -12
- package/src/javascript/power/index.js +0 -2
- package/src/javascript/sensor/sensor-instance.js +1 -5
- package/src/javascript/video/window.js +17 -16
- package/src/native/audio.cpp +178 -0
- package/src/native/audio.h +21 -0
- package/src/native/clipboard.cpp +45 -0
- package/src/native/clipboard.h +13 -0
- package/src/native/cocoa-global.h +8 -0
- package/src/native/cocoa-global.mm +8 -0
- package/src/native/cocoa-window.h +9 -4
- package/src/native/cocoa-window.mm +6 -9
- package/src/native/controller.cpp +154 -0
- package/src/native/controller.h +17 -0
- package/src/native/enums.cpp +477 -0
- package/src/native/enums.h +67 -0
- package/src/native/events.cpp +339 -0
- package/src/native/events.h +15 -0
- package/src/native/global.cpp +187 -0
- package/src/native/global.h +15 -0
- package/src/native/joystick.cpp +388 -0
- package/src/native/joystick.h +22 -0
- package/src/native/keyboard.cpp +55 -0
- package/src/native/keyboard.h +18 -0
- package/src/native/module.cpp +98 -0
- package/src/native/mouse.cpp +186 -0
- package/src/native/mouse.h +21 -0
- package/src/native/power.cpp +18 -0
- package/src/native/power.h +12 -0
- package/src/native/sensor.cpp +117 -0
- package/src/native/sensor.h +15 -0
- package/src/native/video.cpp +90 -0
- package/src/native/video.h +12 -0
- package/src/native/window.cpp +755 -0
- package/src/native/window.h +29 -0
- package/src/types/index.d.ts +7 -4
- package/scripts/test.mjs +0 -12
- package/src/native/asprintf.c +0 -47
- package/src/native/asprintf.h +0 -37
- package/src/native/binding.cpp +0 -1680
- package/src/native/sdl-helpers.cpp +0 -2619
- package/src/native/sdl-helpers.h +0 -182
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#ifndef _WINDOW_H_
|
|
2
|
+
#define _WINDOW_H_
|
|
3
|
+
|
|
4
|
+
#include <napi.h>
|
|
5
|
+
|
|
6
|
+
namespace window {
|
|
7
|
+
|
|
8
|
+
Napi::Value create(const Napi::CallbackInfo &info);
|
|
9
|
+
Napi::Value setTitle(const Napi::CallbackInfo &info);
|
|
10
|
+
Napi::Value setPosition(const Napi::CallbackInfo &info);
|
|
11
|
+
Napi::Value setSize(const Napi::CallbackInfo &info);
|
|
12
|
+
Napi::Value setFullscreen(const Napi::CallbackInfo &info);
|
|
13
|
+
Napi::Value setResizable(const Napi::CallbackInfo &info);
|
|
14
|
+
Napi::Value setBorderless(const Napi::CallbackInfo &info);
|
|
15
|
+
Napi::Value setAcceleratedAndVsync(const Napi::CallbackInfo &info);
|
|
16
|
+
Napi::Value focus(const Napi::CallbackInfo &info);
|
|
17
|
+
Napi::Value show(const Napi::CallbackInfo &info);
|
|
18
|
+
Napi::Value hide(const Napi::CallbackInfo &info);
|
|
19
|
+
Napi::Value maximize(const Napi::CallbackInfo &info);
|
|
20
|
+
Napi::Value minimize(const Napi::CallbackInfo &info);
|
|
21
|
+
Napi::Value restore(const Napi::CallbackInfo &info);
|
|
22
|
+
Napi::Value render(const Napi::CallbackInfo &info);
|
|
23
|
+
Napi::Value setIcon(const Napi::CallbackInfo &info);
|
|
24
|
+
Napi::Value flash(const Napi::CallbackInfo &info);
|
|
25
|
+
Napi::Value destroy(const Napi::CallbackInfo &info);
|
|
26
|
+
|
|
27
|
+
}; // namespace window
|
|
28
|
+
|
|
29
|
+
#endif // _WINDOW_H_
|
package/src/types/index.d.ts
CHANGED
|
@@ -761,8 +761,8 @@ export namespace Sdl {
|
|
|
761
761
|
interface Module {
|
|
762
762
|
readonly SCANCODE: { [name in ScancodeNames]: Scancode }
|
|
763
763
|
|
|
764
|
-
getKey (scancode: Scancode): Key
|
|
765
|
-
getScancode (key: Key): Scancode
|
|
764
|
+
getKey (scancode: Scancode): Key | null
|
|
765
|
+
getScancode (key: Key): Scancode | null
|
|
766
766
|
|
|
767
767
|
getState (): boolean[]
|
|
768
768
|
}
|
|
@@ -804,10 +804,12 @@ export namespace Sdl {
|
|
|
804
804
|
setPosition (x: number, y: number): void
|
|
805
805
|
|
|
806
806
|
setCursor (cursor: Cursor): void
|
|
807
|
+
resetCursor (): void
|
|
807
808
|
setCursorImage (width: number, height: number, stride: number, format: Video.Format, buffer: Buffer): void
|
|
808
809
|
|
|
809
810
|
showCursor (show?: boolean): void
|
|
810
811
|
hideCursor (): void
|
|
812
|
+
redrawCursor (): void
|
|
811
813
|
|
|
812
814
|
capture (): void
|
|
813
815
|
uncapture (): void
|
|
@@ -834,8 +836,7 @@ export namespace Sdl {
|
|
|
834
836
|
| 'leftdown'
|
|
835
837
|
|
|
836
838
|
export type PowerLevel
|
|
837
|
-
= '
|
|
838
|
-
| 'empty'
|
|
839
|
+
= 'empty'
|
|
839
840
|
| 'low'
|
|
840
841
|
| 'medium'
|
|
841
842
|
| 'full'
|
|
@@ -875,6 +876,7 @@ export namespace Sdl {
|
|
|
875
876
|
readonly power: PowerLevel
|
|
876
877
|
|
|
877
878
|
setPlayer (index: number): void
|
|
879
|
+
resetPlayer (): void
|
|
878
880
|
|
|
879
881
|
readonly hasLed: boolean
|
|
880
882
|
setLed (red: number, green: number, blue: number): void
|
|
@@ -963,6 +965,7 @@ export namespace Sdl {
|
|
|
963
965
|
readonly power: Joystick.PowerLevel
|
|
964
966
|
|
|
965
967
|
setPlayer (index: number): void
|
|
968
|
+
resetPlayer (): void
|
|
966
969
|
|
|
967
970
|
readonly hasLed: boolean
|
|
968
971
|
setLed (red: number, green: number, blue: number): void
|
package/scripts/test.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Path from 'node:path'
|
|
2
|
-
import { execSync } from 'node:child_process'
|
|
3
|
-
import Fs from 'node:fs'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
const __dirname = Path.dirname(fileURLToPath(import.meta.url))
|
|
6
|
-
|
|
7
|
-
process.chdir(Path.join(__dirname, '../tests'))
|
|
8
|
-
const files = await Fs.promises.readdir('.')
|
|
9
|
-
for (const name of files) {
|
|
10
|
-
if (!name.endsWith('.test.js')) { continue }
|
|
11
|
-
execSync(`node ${name}`, { stdio: 'inherit' })
|
|
12
|
-
}
|
package/src/native/asprintf.c
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2014 insane coder (http://insanecoding.blogspot.com/, http://asprintf.insanecoding.org/)
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
6
|
-
copyright notice and this permission notice appear in all copies.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
#include "asprintf.h"
|
|
18
|
-
|
|
19
|
-
#include <stdio.h>
|
|
20
|
-
#include <stdlib.h>
|
|
21
|
-
#include <limits.h>
|
|
22
|
-
|
|
23
|
-
int asprintf(char **strp, const char *fmt, ...)
|
|
24
|
-
{
|
|
25
|
-
int r;
|
|
26
|
-
va_list ap;
|
|
27
|
-
va_start(ap, fmt);
|
|
28
|
-
r = vasprintf(strp, fmt, ap);
|
|
29
|
-
va_end(ap);
|
|
30
|
-
return(r);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
34
|
-
{
|
|
35
|
-
int r = -1, size = _vscprintf(fmt, ap);
|
|
36
|
-
if ((size >= 0) && (size < INT_MAX))
|
|
37
|
-
{
|
|
38
|
-
*strp = (char *)malloc(size+1); //+1 for null
|
|
39
|
-
if (*strp)
|
|
40
|
-
{
|
|
41
|
-
r = vsnprintf(*strp, size+1, fmt, ap); //+1 for null
|
|
42
|
-
if (r == -1) { insane_free(*strp); }
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else { *strp = 0; }
|
|
46
|
-
return(r);
|
|
47
|
-
}
|
package/src/native/asprintf.h
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2014 insane coder (http://insanecoding.blogspot.com/, http://asprintf.insanecoding.org/)
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
6
|
-
copyright notice and this permission notice appear in all copies.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
#ifndef INSANE_ASPRINTF_H
|
|
18
|
-
#define INSANE_ASPRINTF_H
|
|
19
|
-
|
|
20
|
-
#ifndef __cplusplus
|
|
21
|
-
#include <stdarg.h>
|
|
22
|
-
#else
|
|
23
|
-
#include <cstdarg>
|
|
24
|
-
extern "C"
|
|
25
|
-
{
|
|
26
|
-
#endif
|
|
27
|
-
|
|
28
|
-
#define insane_free(ptr) { free(ptr); ptr = 0; }
|
|
29
|
-
|
|
30
|
-
int vasprintf(char **strp, const char *fmt, va_list ap);
|
|
31
|
-
int asprintf(char **strp, const char *fmt, ...);
|
|
32
|
-
|
|
33
|
-
#ifdef __cplusplus
|
|
34
|
-
}
|
|
35
|
-
#endif
|
|
36
|
-
|
|
37
|
-
#endif
|