@kmamal/sdl 1.0.0-5 → 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.
- package/CHANGELOG.md +12 -6
- package/README.md +2 -2
- package/binding.gyp +21 -4
- package/package.json +5 -12
- package/scripts/build.mjs +3 -1
- package/scripts/install.mjs +2 -0
- package/scripts/util/common.js +3 -2
- package/src/javascript/audio/audio-playback-stream.js +9 -10
- package/src/javascript/audio/audio-recording-stream.js +9 -8
- package/src/javascript/audio/audio-stream.js +101 -44
- package/src/javascript/audio/conversion.js +41 -0
- package/src/javascript/audio/devices.js +11 -0
- package/src/javascript/audio/events.js +65 -0
- package/src/javascript/audio/format-helpers.js +8 -4
- package/src/javascript/audio/index.js +25 -20
- package/src/javascript/audio/prevent-exit.js +13 -10
- package/src/javascript/audio/validate.js +9 -0
- package/src/javascript/cleanup.js +9 -6
- package/src/javascript/clipboard/index.js +8 -3
- package/src/javascript/device-instance.js +61 -0
- package/src/javascript/events/events-via-poll.js +32 -28
- package/src/javascript/events/index.js +85 -479
- package/src/javascript/events/try.js +25 -0
- package/src/javascript/gamepad/{device.js → devices.js} +4 -5
- package/src/javascript/gamepad/events.js +66 -0
- package/src/javascript/gamepad/gamepad-instance.js +12 -160
- package/src/javascript/gamepad/index.js +15 -16
- package/src/javascript/globals.js +10 -1
- package/src/javascript/index.js +2 -5
- package/src/javascript/joystick/devices.js +43 -0
- package/src/javascript/joystick/events.js +129 -0
- package/src/javascript/joystick/index.js +9 -18
- package/src/javascript/joystick/joystick-device-instance.js +176 -0
- package/src/javascript/joystick/joystick-instance.js +12 -158
- package/src/javascript/keyboard/index.js +20 -10
- package/src/javascript/keyboard/key-mapping.js +46 -27
- package/src/javascript/mouse/index.js +36 -29
- package/src/javascript/sensor/events.js +21 -0
- package/src/javascript/sensor/index.js +13 -2
- package/src/javascript/sensor/sensor-instance.js +7 -47
- package/src/javascript/subsystems.js +56 -0
- package/src/javascript/touch/index.js +9 -4
- package/src/javascript/validate.js +119 -0
- package/src/javascript/video/conversion.js +63 -0
- package/src/javascript/video/events.js +179 -0
- package/src/javascript/video/format-helpers.js +10 -8
- package/src/javascript/video/index.js +28 -14
- package/src/javascript/video/validate.js +45 -0
- package/src/javascript/video/window.js +196 -167
- package/src/native/audio.cpp +457 -153
- package/src/native/audio.h +25 -19
- package/src/native/clipboard.cpp +8 -37
- package/src/native/clipboard.h +2 -2
- package/src/native/enums.cpp +16 -1
- package/src/native/enums.h +1 -1
- package/src/native/events.cpp +351 -357
- package/src/native/events.h +70 -68
- package/src/native/gamepad.cpp +147 -103
- package/src/native/gamepad.h +10 -11
- package/src/native/global.cpp +183 -340
- package/src/native/global.h +51 -5
- package/src/native/joystick.cpp +204 -275
- package/src/native/joystick.h +21 -15
- package/src/native/keyboard.cpp +63 -25
- package/src/native/keyboard.h +5 -4
- package/src/native/module.cpp +23 -3
- package/src/native/mouse.cpp +28 -59
- package/src/native/mouse.h +9 -9
- package/src/native/packed.cpp +99 -0
- package/src/native/packed.h +86 -0
- package/src/native/power.cpp +13 -1
- package/src/native/power.h +3 -3
- package/src/native/sensor.cpp +78 -69
- package/src/native/sensor.h +7 -7
- package/src/native/testing.cpp +148 -0
- package/src/native/testing.h +17 -0
- package/src/native/threads.cpp +301 -0
- package/src/native/threads.h +36 -0
- package/src/native/touch.cpp +38 -44
- package/src/native/touch.h +3 -2
- package/src/native/video.cpp +211 -98
- package/src/native/video.h +7 -4
- package/src/native/window.cpp +201 -219
- package/src/native/window.h +24 -20
- package/src/types/index.d.ts +157 -70
- package/src/javascript/audio/device.js +0 -37
- package/src/javascript/joystick/device.js +0 -13
- package/src/javascript/joystick/shared.js +0 -90
- package/src/javascript/worker.js +0 -88
- package/src/types/worker.d.ts +0 -71
package/src/native/window.h
CHANGED
|
@@ -6,26 +6,30 @@
|
|
|
6
6
|
|
|
7
7
|
namespace window {
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
29
33
|
|
|
30
34
|
}; // namespace window
|
|
31
35
|
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events'
|
|
2
2
|
|
|
3
|
+
export type Points = number
|
|
4
|
+
export type Pixels = number
|
|
5
|
+
|
|
3
6
|
export namespace Events {
|
|
4
7
|
|
|
5
8
|
interface BaseEvent { readonly type: string }
|
|
@@ -9,7 +12,7 @@ export namespace Events {
|
|
|
9
12
|
export namespace Display {
|
|
10
13
|
|
|
11
14
|
interface DisplayEvent extends BaseEvent {
|
|
12
|
-
readonly
|
|
15
|
+
readonly display: Sdl.Video.Display
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export interface Add extends DisplayEvent {
|
|
@@ -20,20 +23,15 @@ export namespace Events {
|
|
|
20
23
|
}
|
|
21
24
|
export interface Orient extends DisplayEvent {
|
|
22
25
|
readonly type: 'displayOrient'
|
|
23
|
-
readonly orientation: Sdl.Video.Orientation | null
|
|
24
26
|
}
|
|
25
27
|
export interface Move extends DisplayEvent {
|
|
26
28
|
readonly type: 'displayMove'
|
|
27
29
|
}
|
|
28
30
|
export interface Scale extends DisplayEvent {
|
|
29
31
|
readonly type: 'displayScaleChange'
|
|
30
|
-
readonly scale: number | null
|
|
31
32
|
}
|
|
32
33
|
export interface Mode extends DisplayEvent {
|
|
33
34
|
readonly type: 'displayModeChange'
|
|
34
|
-
readonly format: Sdl.Video.Format | null
|
|
35
|
-
readonly frequency: number | null
|
|
36
|
-
readonly geometry: Sdl.Video.Display['geometry']
|
|
37
35
|
}
|
|
38
36
|
export interface Usable extends DisplayEvent {
|
|
39
37
|
readonly type: 'displayUsableChange'
|
|
@@ -71,16 +69,16 @@ export namespace Events {
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
interface MouseEvent extends WindowEvent {
|
|
74
|
-
readonly x:
|
|
75
|
-
readonly y:
|
|
72
|
+
readonly x: Points
|
|
73
|
+
readonly y: Points
|
|
76
74
|
readonly touch: boolean
|
|
77
75
|
readonly pen: boolean
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
export interface MouseMove extends MouseEvent {
|
|
81
79
|
readonly type: 'mouseMove'
|
|
82
|
-
readonly dx:
|
|
83
|
-
readonly dy:
|
|
80
|
+
readonly dx: Points
|
|
81
|
+
readonly dy: Points
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
interface MouseButtonEvent extends MouseEvent {
|
|
@@ -123,17 +121,19 @@ export namespace Events {
|
|
|
123
121
|
export interface Minimize extends WindowEvent { readonly type: 'minimize' }
|
|
124
122
|
export interface Maximize extends WindowEvent { readonly type: 'maximize' }
|
|
125
123
|
export interface Restore extends WindowEvent { readonly type: 'restore' }
|
|
124
|
+
export interface EnterFullscreen extends WindowEvent { readonly type: 'enterFullscreen' }
|
|
125
|
+
export interface LeaveFullscreen extends WindowEvent { readonly type: 'leaveFullscreen' }
|
|
126
126
|
export interface Move extends WindowEvent {
|
|
127
127
|
readonly type: 'move'
|
|
128
|
-
readonly x:
|
|
129
|
-
readonly y:
|
|
128
|
+
readonly x: Points,
|
|
129
|
+
readonly y: Points
|
|
130
130
|
}
|
|
131
131
|
export interface Resize extends WindowEvent {
|
|
132
132
|
readonly type: 'resize'
|
|
133
|
-
readonly width:
|
|
134
|
-
readonly height:
|
|
135
|
-
readonly pixelWidth:
|
|
136
|
-
readonly pixelHeight:
|
|
133
|
+
readonly width: Points
|
|
134
|
+
readonly height: Points
|
|
135
|
+
readonly pixelWidth: Pixels
|
|
136
|
+
readonly pixelHeight: Pixels
|
|
137
137
|
}
|
|
138
138
|
export interface DisplayChange extends WindowEvent {
|
|
139
139
|
readonly type: 'displayChange'
|
|
@@ -178,6 +178,8 @@ export namespace Events {
|
|
|
178
178
|
| Minimize
|
|
179
179
|
| Maximize
|
|
180
180
|
| Restore
|
|
181
|
+
| EnterFullscreen
|
|
182
|
+
| LeaveFullscreen
|
|
181
183
|
| Move
|
|
182
184
|
| Resize
|
|
183
185
|
| DisplayChange
|
|
@@ -318,6 +320,10 @@ export namespace Events {
|
|
|
318
320
|
|
|
319
321
|
export interface Update extends SensorEvent {
|
|
320
322
|
readonly type: 'update'
|
|
323
|
+
readonly x: number
|
|
324
|
+
readonly y: number
|
|
325
|
+
readonly z: number
|
|
326
|
+
readonly timestamp: bigint
|
|
321
327
|
}
|
|
322
328
|
|
|
323
329
|
export interface Close extends SensorEvent { readonly type: 'close' }
|
|
@@ -348,9 +354,20 @@ export namespace Events {
|
|
|
348
354
|
interface AudioEvent extends BaseEvent {}
|
|
349
355
|
|
|
350
356
|
export interface Close extends AudioEvent { readonly type: 'close' }
|
|
357
|
+
export interface Drain extends AudioEvent {
|
|
358
|
+
readonly type: 'drain'
|
|
359
|
+
readonly underruns: number
|
|
360
|
+
readonly missing: number
|
|
361
|
+
}
|
|
362
|
+
export interface Readable extends AudioEvent {
|
|
363
|
+
readonly type: 'readable'
|
|
364
|
+
readonly available: number
|
|
365
|
+
}
|
|
351
366
|
|
|
352
367
|
export type Any
|
|
353
368
|
= Close
|
|
369
|
+
| Drain
|
|
370
|
+
| Readable
|
|
354
371
|
|
|
355
372
|
}
|
|
356
373
|
|
|
@@ -382,6 +399,11 @@ export namespace Events {
|
|
|
382
399
|
|
|
383
400
|
export namespace Sdl {
|
|
384
401
|
|
|
402
|
+
export interface Drivers {
|
|
403
|
+
readonly all: string[]
|
|
404
|
+
readonly current: string
|
|
405
|
+
}
|
|
406
|
+
|
|
385
407
|
export interface Info {
|
|
386
408
|
readonly version: {
|
|
387
409
|
readonly compile: {
|
|
@@ -429,24 +451,6 @@ export namespace Sdl {
|
|
|
429
451
|
| 'tvOS'
|
|
430
452
|
| 'visionOS'
|
|
431
453
|
| null
|
|
432
|
-
readonly drivers: {
|
|
433
|
-
readonly video: {
|
|
434
|
-
readonly all: string[]
|
|
435
|
-
readonly current: string | null
|
|
436
|
-
}
|
|
437
|
-
readonly audio: {
|
|
438
|
-
readonly all: string[]
|
|
439
|
-
readonly current: string | null
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
readonly initialized: {
|
|
443
|
-
readonly video: boolean
|
|
444
|
-
readonly audio: boolean
|
|
445
|
-
readonly joystick: boolean
|
|
446
|
-
readonly gamepad: boolean
|
|
447
|
-
readonly haptic: boolean
|
|
448
|
-
readonly sensor: boolean
|
|
449
|
-
}
|
|
450
454
|
}
|
|
451
455
|
|
|
452
456
|
export namespace Video {
|
|
@@ -524,26 +528,53 @@ export namespace Sdl {
|
|
|
524
528
|
| 'bgrx32'
|
|
525
529
|
| 'xbgr32'
|
|
526
530
|
|
|
531
|
+
export interface ConversionSrcSpec {
|
|
532
|
+
readonly width: number
|
|
533
|
+
readonly height: number
|
|
534
|
+
readonly stride?: number
|
|
535
|
+
readonly format: Format | FormatAlias
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface ConversionDstSpec {
|
|
539
|
+
readonly width?: number
|
|
540
|
+
readonly height?: number
|
|
541
|
+
readonly stride?: number
|
|
542
|
+
readonly format: Format | FormatAlias
|
|
543
|
+
readonly scaling?: Scaling
|
|
544
|
+
}
|
|
545
|
+
|
|
527
546
|
export type Scaling
|
|
528
547
|
= 'nearest'
|
|
529
548
|
| 'linear'
|
|
530
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
|
+
|
|
531
562
|
export interface Display {
|
|
532
563
|
readonly id: number
|
|
533
564
|
readonly name: string | null
|
|
534
565
|
readonly format: Format | null
|
|
535
566
|
readonly frequency: number | null
|
|
536
567
|
readonly geometry: {
|
|
537
|
-
readonly x:
|
|
538
|
-
readonly y:
|
|
539
|
-
readonly width:
|
|
540
|
-
readonly height:
|
|
568
|
+
readonly x: Points
|
|
569
|
+
readonly y: Points
|
|
570
|
+
readonly width: Points
|
|
571
|
+
readonly height: Points
|
|
541
572
|
}
|
|
542
573
|
readonly usable: {
|
|
543
|
-
readonly x:
|
|
544
|
-
readonly y:
|
|
545
|
-
readonly width:
|
|
546
|
-
readonly height:
|
|
574
|
+
readonly x: Points
|
|
575
|
+
readonly y: Points
|
|
576
|
+
readonly width: Points
|
|
577
|
+
readonly height: Points
|
|
547
578
|
}
|
|
548
579
|
readonly scale: number | null
|
|
549
580
|
readonly orientation: Orientation | null
|
|
@@ -556,6 +587,8 @@ export namespace Sdl {
|
|
|
556
587
|
on (event: 'minimize', listener: (event: Events.Window.Minimize) => void): this
|
|
557
588
|
on (event: 'maximize', listener: (event: Events.Window.Maximize) => void): this
|
|
558
589
|
on (event: 'restore', listener: (event: Events.Window.Restore) => void): this
|
|
590
|
+
on (event: 'enterFullscreen', listener: (event: Events.Window.EnterFullscreen) => void): this
|
|
591
|
+
on (event: 'leaveFullscreen', listener: (event: Events.Window.LeaveFullscreen) => void): this
|
|
559
592
|
on (event: 'move', listener: (event: Events.Window.Move) => void): this
|
|
560
593
|
on (event: 'resize', listener: (event: Events.Window.Resize) => void): this
|
|
561
594
|
on (event: 'displayChange', listener: (event: Events.Window.DisplayChange) => void): this
|
|
@@ -588,17 +621,17 @@ export namespace Sdl {
|
|
|
588
621
|
readonly title: string
|
|
589
622
|
setTitle (title: string): void
|
|
590
623
|
|
|
591
|
-
readonly x:
|
|
592
|
-
readonly y:
|
|
593
|
-
setPosition (x:
|
|
624
|
+
readonly x: Points
|
|
625
|
+
readonly y: Points
|
|
626
|
+
setPosition (x: Points, y: Points): void
|
|
594
627
|
|
|
595
|
-
readonly width:
|
|
596
|
-
readonly height:
|
|
597
|
-
setSize (width:
|
|
628
|
+
readonly width: Points
|
|
629
|
+
readonly height: Points
|
|
630
|
+
setSize (width: Points, height: Points): void
|
|
598
631
|
|
|
599
|
-
readonly pixelWidth:
|
|
600
|
-
readonly pixelHeight:
|
|
601
|
-
setSizeInPixels (pixelWidth:
|
|
632
|
+
readonly pixelWidth: Pixels
|
|
633
|
+
readonly pixelHeight: Pixels
|
|
634
|
+
setSizeInPixels (pixelWidth: Pixels, pixelHeight: Pixels): void
|
|
602
635
|
|
|
603
636
|
readonly display: Display | null
|
|
604
637
|
|
|
@@ -645,14 +678,17 @@ export namespace Sdl {
|
|
|
645
678
|
setRelativeMouseMode (relative?: boolean): void
|
|
646
679
|
unsetRelativeMouseMode (): void
|
|
647
680
|
|
|
681
|
+
setHitTest (hitTest: ((x: Points, y: Points) => HitTestResult | undefined) | null): void
|
|
682
|
+
unsetHitTest (): void
|
|
683
|
+
|
|
648
684
|
render (width: number, height: number, stride: number, format: Format | FormatAlias, buffer: Buffer, options?: {
|
|
649
685
|
scaling?: Scaling,
|
|
650
686
|
dstRect?: {
|
|
651
|
-
x:
|
|
652
|
-
y:
|
|
653
|
-
width:
|
|
654
|
-
height:
|
|
655
|
-
}
|
|
687
|
+
x: Points,
|
|
688
|
+
y: Points,
|
|
689
|
+
width: Points,
|
|
690
|
+
height: Points,
|
|
691
|
+
}
|
|
656
692
|
}): void
|
|
657
693
|
|
|
658
694
|
setIcon (width: number, height: number, stride: number, format: Format | FormatAlias, buffer: Buffer): void
|
|
@@ -666,6 +702,8 @@ export namespace Sdl {
|
|
|
666
702
|
}
|
|
667
703
|
|
|
668
704
|
interface Module extends EventEmitter {
|
|
705
|
+
isAvailable (): boolean
|
|
706
|
+
|
|
669
707
|
on (event: 'displayAdd', listener: (event: Events.Display.Add) => void): this
|
|
670
708
|
on (event: 'displayRemove', listener: (event: Events.Display.Remove) => void): this
|
|
671
709
|
on (event: 'displayOrient', listener: (event: Events.Display.Orient) => void): this
|
|
@@ -676,6 +714,7 @@ export namespace Sdl {
|
|
|
676
714
|
on (event: '*', listener: (type: string, event: Events.Display.Any) => void): this
|
|
677
715
|
on (event: 'error', listener: (error: Error) => void): this
|
|
678
716
|
|
|
717
|
+
readonly drivers: Drivers
|
|
679
718
|
readonly displays: Display[]
|
|
680
719
|
|
|
681
720
|
readonly windows: Window[]
|
|
@@ -684,11 +723,11 @@ export namespace Sdl {
|
|
|
684
723
|
|
|
685
724
|
createWindow (options?: {
|
|
686
725
|
title?: string
|
|
687
|
-
display?: Display
|
|
688
|
-
x?:
|
|
689
|
-
y?:
|
|
690
|
-
width?:
|
|
691
|
-
height?:
|
|
726
|
+
display?: Display
|
|
727
|
+
x?: Points
|
|
728
|
+
y?: Points
|
|
729
|
+
width?: Points
|
|
730
|
+
height?: Points
|
|
692
731
|
visible?: boolean
|
|
693
732
|
fullscreen?: boolean
|
|
694
733
|
resizable?: boolean
|
|
@@ -700,6 +739,9 @@ export namespace Sdl {
|
|
|
700
739
|
webgpu?: boolean
|
|
701
740
|
}): Window
|
|
702
741
|
|
|
742
|
+
convert (srcSpec: ConversionSrcSpec, srcData: Buffer, dstSpec: ConversionDstSpec, dstData?: undefined): Buffer
|
|
743
|
+
convert (srcSpec: ConversionSrcSpec, srcData: Buffer, dstSpec: ConversionDstSpec, dstData: Buffer): number
|
|
744
|
+
|
|
703
745
|
bytesPerPixel (format: Format | FormatAlias): number
|
|
704
746
|
isYuv (format: Format | FormatAlias): boolean
|
|
705
747
|
isPlanarYuv (format: Format | FormatAlias): boolean
|
|
@@ -871,6 +913,7 @@ export namespace Sdl {
|
|
|
871
913
|
| 'CLEARAGAIN'
|
|
872
914
|
| 'CRSEL'
|
|
873
915
|
| 'EXSEL'
|
|
916
|
+
| 'FRONT'
|
|
874
917
|
| 'KP_00'
|
|
875
918
|
| 'KP_000'
|
|
876
919
|
| 'THOUSANDSSEPARATOR'
|
|
@@ -963,6 +1006,8 @@ export namespace Sdl {
|
|
|
963
1006
|
export type Key = string
|
|
964
1007
|
|
|
965
1008
|
interface Module extends EventEmitter {
|
|
1009
|
+
isAvailable (): boolean
|
|
1010
|
+
|
|
966
1011
|
readonly SCANCODE: { [name in ScancodeNames]: Scancode }
|
|
967
1012
|
|
|
968
1013
|
on (event: 'keymapChange', listener: (event: Events.Keyboard.KeymapChange) => void): this
|
|
@@ -972,7 +1017,7 @@ export namespace Sdl {
|
|
|
972
1017
|
getKey (scancode: Scancode): Key | null
|
|
973
1018
|
getScancode (key: Key): Scancode | null
|
|
974
1019
|
|
|
975
|
-
getState ():
|
|
1020
|
+
getState (): Uint8Array
|
|
976
1021
|
}
|
|
977
1022
|
|
|
978
1023
|
}
|
|
@@ -1011,19 +1056,21 @@ export namespace Sdl {
|
|
|
1011
1056
|
| 'wResize'
|
|
1012
1057
|
|
|
1013
1058
|
interface Module {
|
|
1059
|
+
isAvailable (): boolean
|
|
1060
|
+
|
|
1014
1061
|
readonly BUTTON: { [name in ButtonNames]: number }
|
|
1015
1062
|
|
|
1016
1063
|
getButton (button: number): boolean
|
|
1017
1064
|
|
|
1018
1065
|
readonly position: {
|
|
1019
|
-
x:
|
|
1020
|
-
y:
|
|
1066
|
+
x: Points
|
|
1067
|
+
y: Points
|
|
1021
1068
|
}
|
|
1022
|
-
setPosition (x:
|
|
1069
|
+
setPosition (x: Points, y: Points): void
|
|
1023
1070
|
|
|
1024
1071
|
setCursor (cursor: Cursor): void
|
|
1025
1072
|
resetCursor (): void
|
|
1026
|
-
setCursorImage (width: number, height: number, stride: number, format: Video.Format | Video.FormatAlias, buffer: Buffer, x:
|
|
1073
|
+
setCursorImage (width: number, height: number, stride: number, format: Video.Format | Video.FormatAlias, buffer: Buffer, x: Pixels, y: Pixels): void
|
|
1027
1074
|
|
|
1028
1075
|
showCursor (show?: boolean): void
|
|
1029
1076
|
hideCursor (): void
|
|
@@ -1050,6 +1097,8 @@ export namespace Sdl {
|
|
|
1050
1097
|
}
|
|
1051
1098
|
|
|
1052
1099
|
interface Module {
|
|
1100
|
+
isAvailable (): boolean
|
|
1101
|
+
|
|
1053
1102
|
readonly devices: Device[]
|
|
1054
1103
|
}
|
|
1055
1104
|
|
|
@@ -1130,11 +1179,11 @@ export namespace Sdl {
|
|
|
1130
1179
|
setLed (red: number, green: number, blue: number): void
|
|
1131
1180
|
|
|
1132
1181
|
readonly hasRumble: boolean
|
|
1133
|
-
rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number
|
|
1182
|
+
rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number): void
|
|
1134
1183
|
stopRumble (): void
|
|
1135
1184
|
|
|
1136
1185
|
readonly hasRumbleTriggers: boolean
|
|
1137
|
-
rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number
|
|
1186
|
+
rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number): void
|
|
1138
1187
|
stopRumbleTriggers (): void
|
|
1139
1188
|
|
|
1140
1189
|
readonly closed: boolean
|
|
@@ -1142,6 +1191,8 @@ export namespace Sdl {
|
|
|
1142
1191
|
}
|
|
1143
1192
|
|
|
1144
1193
|
interface Module extends EventEmitter {
|
|
1194
|
+
isAvailable (): boolean
|
|
1195
|
+
|
|
1145
1196
|
on (event: 'deviceAdd', listener: (event: Events.JoystickDevice.Add) => void): this
|
|
1146
1197
|
on (event: 'deviceRemove', listener: (event: Events.JoystickDevice.Remove) => void): this
|
|
1147
1198
|
on (event: '*', listener: (type: string, event: Events.JoystickDevice.Any) => void): this
|
|
@@ -1168,6 +1219,7 @@ export namespace Sdl {
|
|
|
1168
1219
|
| 'nintendoSwitchJoyconRight'
|
|
1169
1220
|
| 'nintendoSwitchJoyconPair'
|
|
1170
1221
|
| 'gamecube'
|
|
1222
|
+
| 'steam'
|
|
1171
1223
|
|
|
1172
1224
|
export type Axis
|
|
1173
1225
|
= 'leftStickX'
|
|
@@ -1262,11 +1314,11 @@ export namespace Sdl {
|
|
|
1262
1314
|
setLed (red: number, green: number, blue: number): void
|
|
1263
1315
|
|
|
1264
1316
|
readonly hasRumble: boolean
|
|
1265
|
-
rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number
|
|
1317
|
+
rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number): void
|
|
1266
1318
|
stopRumble (): void
|
|
1267
1319
|
|
|
1268
1320
|
readonly hasRumbleTriggers: boolean
|
|
1269
|
-
rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number
|
|
1321
|
+
rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number): void
|
|
1270
1322
|
stopRumbleTriggers (): void
|
|
1271
1323
|
|
|
1272
1324
|
readonly closed: boolean
|
|
@@ -1274,6 +1326,8 @@ export namespace Sdl {
|
|
|
1274
1326
|
}
|
|
1275
1327
|
|
|
1276
1328
|
interface Module extends EventEmitter {
|
|
1329
|
+
isAvailable (): boolean
|
|
1330
|
+
|
|
1277
1331
|
on (event: 'deviceAdd', listener: (event: Events.GamepadDevice.Add) => void): this
|
|
1278
1332
|
on (event: 'deviceRemove', listener: (event: Events.GamepadDevice.Remove) => void): this
|
|
1279
1333
|
on (event: '*', listener: (type: string, event: Events.GamepadDevice.Any) => void): this
|
|
@@ -1326,6 +1380,8 @@ export namespace Sdl {
|
|
|
1326
1380
|
}
|
|
1327
1381
|
|
|
1328
1382
|
interface Module {
|
|
1383
|
+
isAvailable (): boolean
|
|
1384
|
+
|
|
1329
1385
|
readonly STANDARD_GRAVITY: 9.80665
|
|
1330
1386
|
|
|
1331
1387
|
readonly devices: Device[]
|
|
@@ -1366,6 +1422,14 @@ export namespace Sdl {
|
|
|
1366
1422
|
readonly frequency?: number
|
|
1367
1423
|
readonly format?: Format | FormatAlias
|
|
1368
1424
|
readonly buffered?: number
|
|
1425
|
+
readonly gain?: number
|
|
1426
|
+
readonly frequencyRatio?: number
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
export interface ConversionSpec {
|
|
1430
|
+
readonly format?: Format | FormatAlias
|
|
1431
|
+
readonly channels?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
|
|
1432
|
+
readonly frequency?: number
|
|
1369
1433
|
}
|
|
1370
1434
|
|
|
1371
1435
|
export interface AudioStream extends EventEmitter {
|
|
@@ -1384,6 +1448,11 @@ export namespace Sdl {
|
|
|
1384
1448
|
play (play?: boolean): void
|
|
1385
1449
|
pause (): void
|
|
1386
1450
|
|
|
1451
|
+
readonly gain: number
|
|
1452
|
+
setGain (gain: number): void
|
|
1453
|
+
readonly frequencyRatio: number
|
|
1454
|
+
setFrequencyRatio (frequencyRatio: number): void
|
|
1455
|
+
|
|
1387
1456
|
clear (): void
|
|
1388
1457
|
|
|
1389
1458
|
readonly bytesPerSample: number
|
|
@@ -1398,11 +1467,21 @@ export namespace Sdl {
|
|
|
1398
1467
|
}
|
|
1399
1468
|
|
|
1400
1469
|
export interface AudioPlaybackStream extends AudioStream {
|
|
1470
|
+
on (event: 'drain', listener: (event: Events.Audio.Drain) => void): this
|
|
1471
|
+
on (event: 'close', listener: (event: Events.Audio.Close) => void): this
|
|
1472
|
+
on (event: '*', listener: (type: string, event: Events.Audio.Any) => void): this
|
|
1473
|
+
on (event: 'error', listener: (error: Error) => void): this
|
|
1474
|
+
|
|
1401
1475
|
readonly queued: number
|
|
1402
1476
|
putData (buffer: Buffer, bytes?: number): void
|
|
1403
1477
|
}
|
|
1404
1478
|
|
|
1405
1479
|
export interface AudioRecordingStream extends AudioStream {
|
|
1480
|
+
on (event: 'readable', listener: (event: Events.Audio.Readable) => void): this
|
|
1481
|
+
on (event: 'close', listener: (event: Events.Audio.Close) => void): this
|
|
1482
|
+
on (event: '*', listener: (type: string, event: Events.Audio.Any) => void): this
|
|
1483
|
+
on (event: 'error', listener: (error: Error) => void): this
|
|
1484
|
+
|
|
1406
1485
|
readonly available: number
|
|
1407
1486
|
getData (buffer: Buffer, bytes?: number): number
|
|
1408
1487
|
}
|
|
@@ -1419,9 +1498,15 @@ export namespace Sdl {
|
|
|
1419
1498
|
}
|
|
1420
1499
|
|
|
1421
1500
|
interface Module {
|
|
1501
|
+
isAvailable (): boolean
|
|
1502
|
+
|
|
1503
|
+
readonly drivers: Drivers
|
|
1422
1504
|
readonly playback: DeviceModule<AudioPlaybackStream>
|
|
1423
1505
|
readonly recording: DeviceModule<AudioRecordingStream>
|
|
1424
1506
|
|
|
1507
|
+
convert (srcSpec: ConversionSpec, srcData: Buffer, dstSpec: ConversionSpec, dstData?: undefined): Buffer
|
|
1508
|
+
convert (srcSpec: ConversionSpec, srcData: Buffer, dstSpec: ConversionSpec, dstData: Buffer): number
|
|
1509
|
+
|
|
1425
1510
|
bytesPerSample (format: Format | FormatAlias): number
|
|
1426
1511
|
minSampleValue (format: Format | FormatAlias): number
|
|
1427
1512
|
maxSampleValue (format: Format | FormatAlias): number
|
|
@@ -1434,6 +1519,8 @@ export namespace Sdl {
|
|
|
1434
1519
|
export namespace Clipboard {
|
|
1435
1520
|
|
|
1436
1521
|
interface Module extends EventEmitter {
|
|
1522
|
+
isAvailable (): boolean
|
|
1523
|
+
|
|
1437
1524
|
on (event: 'update', listener: (event: Events.Clipboard.Update) => void): this
|
|
1438
1525
|
on (event: '*', listener: (type: string, event: Events.Clipboard.Any) => void): this
|
|
1439
1526
|
on (event: 'error', listener: (error: Error) => void): this
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const Globals = require('../globals')
|
|
2
|
-
const Bindings = require('../bindings')
|
|
3
|
-
|
|
4
|
-
const closedFormat = {
|
|
5
|
-
format: null,
|
|
6
|
-
channels: null,
|
|
7
|
-
frequency: null,
|
|
8
|
-
buffered: null,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const make = (device) => ({ ...device, ...closedFormat })
|
|
12
|
-
|
|
13
|
-
const makeDefault = () => make({ id: null, name: null })
|
|
14
|
-
|
|
15
|
-
const update = (device) => {
|
|
16
|
-
let stream = null
|
|
17
|
-
for (const candidate of Globals.audioStreams.values()) {
|
|
18
|
-
if (candidate._device === device) {
|
|
19
|
-
stream = candidate
|
|
20
|
-
break
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!stream) {
|
|
25
|
-
Object.assign(device, closedFormat)
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try { Object.assign(device, Bindings.audio_getDeviceFormat(stream._id)) }
|
|
30
|
-
catch (_) {}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
34
|
-
make,
|
|
35
|
-
makeDefault,
|
|
36
|
-
update,
|
|
37
|
-
}
|