@kmamal/sdl 0.11.13 → 1.0.0-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.
Files changed (86) hide show
  1. package/CHANGELOG.md +113 -1
  2. package/README.md +26 -2685
  3. package/binding.gyp +82 -65
  4. package/package.json +17 -11
  5. package/scripts/build-sdl.mjs +15 -7
  6. package/scripts/build.mjs +30 -15
  7. package/scripts/download-release.mjs +9 -6
  8. package/scripts/download-sdl.mjs +9 -6
  9. package/scripts/install.mjs +13 -5
  10. package/scripts/util/common.js +9 -1
  11. package/src/javascript/audio/audio-playback-stream.js +50 -0
  12. package/src/javascript/audio/audio-recording-stream.js +32 -0
  13. package/src/javascript/audio/{audio-instance.js → audio-stream.js} +40 -34
  14. package/src/javascript/audio/device.js +34 -6
  15. package/src/javascript/audio/format-helpers.js +29 -34
  16. package/src/javascript/audio/index.js +37 -26
  17. package/src/javascript/audio/prevent-exit.js +19 -9
  18. package/src/javascript/cleanup.js +19 -10
  19. package/src/javascript/enums.js +5 -0
  20. package/src/javascript/events/events-via-poll.js +25 -7
  21. package/src/javascript/events/index.js +280 -174
  22. package/src/javascript/gamepad/device.js +23 -0
  23. package/src/javascript/gamepad/gamepad-instance.js +211 -0
  24. package/src/javascript/gamepad/index.js +51 -0
  25. package/src/javascript/globals.js +8 -5
  26. package/src/javascript/helpers.js +41 -7
  27. package/src/javascript/index.js +5 -3
  28. package/src/javascript/joystick/device.js +5 -10
  29. package/src/javascript/joystick/index.js +7 -7
  30. package/src/javascript/joystick/joystick-instance.js +81 -42
  31. package/src/javascript/joystick/shared.js +90 -0
  32. package/src/javascript/keyboard/index.js +6 -4
  33. package/src/javascript/keyboard/key-mapping.js +70 -28
  34. package/src/javascript/mouse/index.js +21 -10
  35. package/src/javascript/sensor/devices.js +17 -0
  36. package/src/javascript/sensor/index.js +2 -16
  37. package/src/javascript/sensor/sensor-instance.js +22 -6
  38. package/src/javascript/touch/devices.js +17 -0
  39. package/src/javascript/touch/index.js +3 -7
  40. package/src/javascript/video/format-helpers.js +117 -0
  41. package/src/javascript/video/index.js +44 -5
  42. package/src/javascript/video/window.js +289 -133
  43. package/src/native/audio.cpp +182 -58
  44. package/src/native/audio.h +10 -5
  45. package/src/native/clipboard.cpp +22 -5
  46. package/src/native/cocoa-window.h +1 -0
  47. package/src/native/cocoa-window.mm +1 -1
  48. package/src/native/enums.cpp +91 -58
  49. package/src/native/events.cpp +437 -284
  50. package/src/native/events.h +18 -12
  51. package/src/native/gamepad.cpp +185 -0
  52. package/src/native/gamepad.h +27 -0
  53. package/src/native/global.cpp +173 -167
  54. package/src/native/global.h +0 -2
  55. package/src/native/joystick.cpp +287 -225
  56. package/src/native/joystick.h +7 -6
  57. package/src/native/keyboard.cpp +28 -8
  58. package/src/native/keyboard.h +4 -2
  59. package/src/native/module.cpp +14 -8
  60. package/src/native/mouse.cpp +54 -34
  61. package/src/native/mouse.h +0 -1
  62. package/src/native/power.cpp +10 -4
  63. package/src/native/power.h +1 -1
  64. package/src/native/sensor.cpp +52 -52
  65. package/src/native/sensor.h +1 -1
  66. package/src/native/touch.cpp +45 -24
  67. package/src/native/touch.h +1 -1
  68. package/src/native/video.cpp +115 -75
  69. package/src/native/video.h +5 -2
  70. package/src/native/window.cpp +409 -321
  71. package/src/native/window.h +3 -1
  72. package/src/types/helpers.d.ts +45 -19
  73. package/src/types/index.d.ts +366 -273
  74. package/scripts/util/fetch.js +0 -85
  75. package/src/javascript/audio/audio-playback-instance.js +0 -23
  76. package/src/javascript/audio/audio-recording-instance.js +0 -17
  77. package/src/javascript/controller/controller-instance.js +0 -160
  78. package/src/javascript/controller/device.js +0 -26
  79. package/src/javascript/controller/index.js +0 -33
  80. package/src/javascript/events/reconcile-audio-devices.js +0 -16
  81. package/src/javascript/events/reconcile-displays.js +0 -17
  82. package/src/javascript/events/reconcile-joystick-and-controller-devices.js +0 -40
  83. package/src/javascript/events/reconcile.js +0 -61
  84. package/src/javascript/video/display.js +0 -4
  85. package/src/native/controller.cpp +0 -192
  86. package/src/native/controller.h +0 -26
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from 'node:events'
1
2
 
2
3
  export namespace Events {
3
4
 
@@ -8,28 +9,37 @@ export namespace Events {
8
9
  export namespace Display {
9
10
 
10
11
  interface DisplayEvent extends BaseEvent {
11
- readonly display: Sdl.Video.Display
12
+ readonly device: Sdl.Video.Display
12
13
  }
13
14
 
14
15
  export interface Add extends DisplayEvent {
15
- readonly type: 'deviceAdd'
16
- readonly device: Sdl.Video.Display
16
+ readonly type: 'displayAdd'
17
17
  }
18
18
  export interface Remove extends DisplayEvent {
19
- readonly type: 'deviceRemove'
20
- readonly device: Sdl.Video.Display
19
+ readonly type: 'displayRemove'
21
20
  }
22
21
  export interface Orient extends DisplayEvent {
23
- readonly type: 'deviceOrient'
24
- readonly device: Sdl.Video.Display
25
- readonly orientation: Sdl.Video.Orientation
22
+ readonly type: 'displayOrient'
23
+ readonly orientation: Sdl.Video.Orientation | null
26
24
  }
27
25
  export interface Move extends DisplayEvent {
28
- readonly type: 'deviceMove'
29
- readonly device: Sdl.Video.Display
26
+ readonly type: 'displayMove'
27
+ }
28
+ export interface Scale extends DisplayEvent {
29
+ readonly type: 'displayScaleChange'
30
+ readonly scale: number | null
31
+ }
32
+ export interface Mode extends DisplayEvent {
33
+ readonly type: 'displayModeChange'
34
+ readonly format: Sdl.Video.Format | null
35
+ readonly frequency: number | null
36
+ readonly geometry: Sdl.Video.Display['geometry']
37
+ }
38
+ export interface Usable extends DisplayEvent {
39
+ readonly type: 'displayUsableChange'
30
40
  }
31
41
 
32
- export type Any = Add | Remove | Orient | Move
42
+ export type Any = Add | Remove | Orient | Move | Scale | Mode | Usable
33
43
 
34
44
  }
35
45
 
@@ -40,18 +50,18 @@ export namespace Events {
40
50
  interface KeyEvent extends WindowEvent {
41
51
  readonly scancode: Sdl.Keyboard.Scancode
42
52
  readonly key: Sdl.Keyboard.Key | null
43
- readonly shift: number
44
- readonly ctrl: number
45
- readonly alt: number
46
- readonly super: number
47
- readonly altgr: number
48
- readonly capslock: number
49
- readonly numlock: number
53
+ readonly shift: boolean
54
+ readonly ctrl: boolean
55
+ readonly alt: boolean
56
+ readonly super: boolean
57
+ readonly altgr: boolean
58
+ readonly capslock: boolean
59
+ readonly numlock: boolean
50
60
  }
51
61
 
52
62
  export interface KeyDown extends KeyEvent {
53
63
  readonly type: 'keyDown'
54
- readonly repeat: number
64
+ readonly repeat: boolean
55
65
  }
56
66
  export interface KeyUp extends KeyEvent { readonly type: 'keyUp' }
57
67
 
@@ -64,9 +74,14 @@ export namespace Events {
64
74
  readonly x: number
65
75
  readonly y: number
66
76
  readonly touch: boolean
77
+ readonly pen: boolean
67
78
  }
68
79
 
69
- export interface MouseMove extends MouseEvent { readonly type: 'mouseMove' }
80
+ export interface MouseMove extends MouseEvent {
81
+ readonly type: 'mouseMove'
82
+ readonly dx: number
83
+ readonly dy: number
84
+ }
70
85
 
71
86
  interface MouseButtonEvent extends MouseEvent {
72
87
  readonly button: number
@@ -82,12 +97,11 @@ export namespace Events {
82
97
  readonly flipped: boolean
83
98
  }
84
99
 
85
- export interface MouseMove extends MouseEvent { readonly type: 'mouseMove' }
86
-
87
100
  interface FingerEvent extends WindowEvent {
88
- readonly device: Sdl.Touch.Device
89
- readonly fingerId: number
101
+ readonly device: Sdl.Touch.Device | null
102
+ readonly fingerId: bigint
90
103
  readonly mouse: boolean
104
+ readonly pen: boolean
91
105
  readonly x: number
92
106
  readonly y: number
93
107
  readonly pressure: number
@@ -95,6 +109,7 @@ export namespace Events {
95
109
 
96
110
  export interface FingerDown extends FingerEvent { readonly type: 'fingerDown' }
97
111
  export interface FingerUp extends FingerEvent { readonly type: 'fingerUp' }
112
+ export interface FingerCancel extends FingerEvent { readonly type: 'fingerCancel' }
98
113
 
99
114
  export interface FingerMove extends FingerEvent {
100
115
  readonly type: 'fingerMove'
@@ -122,7 +137,7 @@ export namespace Events {
122
137
  }
123
138
  export interface DisplayChange extends WindowEvent {
124
139
  readonly type: 'displayChange'
125
- readonly display: Sdl.Video.Display
140
+ readonly display: Sdl.Video.Display | null
126
141
  }
127
142
  export interface Focus extends WindowEvent { readonly type: 'focus' }
128
143
  export interface Blur extends WindowEvent { readonly type: 'blur' }
@@ -156,6 +171,7 @@ export namespace Events {
156
171
  | FingerDown
157
172
  | FingerUp
158
173
  | FingerMove
174
+ | FingerCancel
159
175
  | Show
160
176
  | Hide
161
177
  | Expose
@@ -204,6 +220,8 @@ export namespace Events {
204
220
  readonly ball: number
205
221
  readonly x: number
206
222
  readonly y: number
223
+ readonly dx: number
224
+ readonly dy: number
207
225
  }
208
226
 
209
227
  interface ButtonEvent extends JoystickEvent {
@@ -216,12 +234,12 @@ export namespace Events {
216
234
  export interface HatMotion extends JoystickEvent {
217
235
  readonly type: 'hatMotion'
218
236
  readonly hat: number
219
- readonly value: Sdl.Joystick.HatPosition
237
+ readonly value: Sdl.Joystick.HatPosition | null
220
238
  }
221
239
 
222
240
  export interface PowerUpdate extends JoystickEvent {
223
241
  readonly type: 'powerUpdate'
224
- readonly power: Sdl.Joystick.PowerLevel | null
242
+ readonly power: Sdl.Joystick.PowerInfo
225
243
  }
226
244
 
227
245
  export interface Close extends JoystickEvent { readonly type: 'close' }
@@ -252,36 +270,36 @@ export namespace Events {
252
270
 
253
271
  }
254
272
 
255
- export namespace Controller {
273
+ export namespace Gamepad {
256
274
 
257
- interface ControllerEvent extends BaseEvent {}
275
+ interface GamepadEvent extends BaseEvent {}
258
276
 
259
- export interface AxisMotion extends ControllerEvent {
277
+ export interface AxisMotion extends GamepadEvent {
260
278
  readonly type: 'axisMotion'
261
- readonly axis: Sdl.Controller.Axis
279
+ readonly axis: Sdl.Gamepad.Axis
262
280
  readonly value: number
263
281
  }
264
282
 
265
- interface ButtonEvent extends ControllerEvent {
266
- readonly button: Sdl.Controller.Button
283
+ interface ButtonEvent extends GamepadEvent {
284
+ readonly button: Sdl.Gamepad.Button
267
285
  }
268
286
 
269
287
  export interface ButtonDown extends ButtonEvent { readonly type: 'buttonDown' }
270
288
  export interface ButtonUp extends ButtonEvent { readonly type: 'buttonUp' }
271
289
 
272
- export interface PowerUpdate extends ControllerEvent {
290
+ export interface PowerUpdate extends GamepadEvent {
273
291
  readonly type: 'powerUpdate'
274
- readonly power: Sdl.Joystick.PowerLevel | null
292
+ readonly power: Sdl.Joystick.PowerInfo
275
293
  }
276
294
 
277
- export interface SteamHandleUpdate extends ControllerEvent {
295
+ export interface SteamHandleUpdate extends GamepadEvent {
278
296
  readonly type: 'steamHandleUpdate'
279
- readonly steamHandle: Buffer | null
297
+ readonly steamHandle: bigint | null
280
298
  }
281
299
 
282
- export interface Remap extends ControllerEvent { readonly type: 'remap' }
300
+ export interface Remap extends GamepadEvent { readonly type: 'remap' }
283
301
 
284
- export interface Close extends ControllerEvent { readonly type: 'close' }
302
+ export interface Close extends GamepadEvent { readonly type: 'close' }
285
303
 
286
304
  export type Any
287
305
  = AxisMotion
@@ -310,10 +328,10 @@ export namespace Events {
310
328
 
311
329
  }
312
330
 
313
- export namespace ControllerDevice {
331
+ export namespace GamepadDevice {
314
332
 
315
333
  interface DeviceEvent extends BaseEvent {
316
- readonly device: Sdl.Controller.Device
334
+ readonly device: Sdl.Gamepad.Device
317
335
  }
318
336
 
319
337
  export interface Add extends DeviceEvent { readonly type: 'deviceAdd' }
@@ -377,22 +395,55 @@ export namespace Sdl {
377
395
  readonly patch: number
378
396
  }
379
397
  }
380
- readonly platform: 'Linux' | 'Windows' | 'Mac OS X'
398
+ readonly platform:
399
+ | 'AIX'
400
+ | 'Android'
401
+ | 'Atari MiNT'
402
+ | 'BSDI'
403
+ | 'Emscripten'
404
+ | 'FreeBSD'
405
+ | 'GNU/Hurd'
406
+ | 'HP-UX'
407
+ | 'Haiku'
408
+ | 'Irix'
409
+ | 'Linux'
410
+ | 'Managarm'
411
+ | 'NetBSD'
412
+ | 'Nintendo 3DS'
413
+ | 'Nokia N-Gage'
414
+ | 'OS/2'
415
+ | 'OSF/1'
416
+ | 'OpenBSD'
417
+ | 'PlayStation 2'
418
+ | 'PlayStation Portable'
419
+ | 'PlayStation Vita'
420
+ | 'QNX Neutrino'
421
+ | 'RISC OS'
422
+ | 'Solaris'
423
+ | 'WinGDK'
424
+ | 'Windows'
425
+ | 'Xbox One'
426
+ | 'Xbox Series X|S'
427
+ | 'iOS'
428
+ | 'macOS'
429
+ | 'tvOS'
430
+ | 'visionOS'
431
+ | null
381
432
  readonly drivers: {
382
433
  readonly video: {
383
434
  readonly all: string[]
384
- readonly current: string
435
+ readonly current: string | null
385
436
  }
386
437
  readonly audio: {
387
438
  readonly all: string[]
388
- readonly current: string
439
+ readonly current: string | null
389
440
  }
390
441
  }
391
442
  readonly initialized: {
392
443
  readonly video: boolean
393
444
  readonly audio: boolean
394
445
  readonly joystick: boolean
395
- readonly controller: boolean
446
+ readonly gamepad: boolean
396
447
  readonly haptic: boolean
397
448
  readonly sensor: boolean
398
449
  }
@@ -408,9 +459,10 @@ export namespace Sdl {
408
459
 
409
460
  export type Format
410
461
  = 'rgb332'
411
- | 'rgb444'
412
- | 'rgb555'
413
- | 'bgr555'
462
+ | 'xrgb4444'
463
+ | 'xbgr4444'
464
+ | 'xrgb1555'
465
+ | 'xbgr1555'
414
466
  | 'argb4444'
415
467
  | 'rgba4444'
416
468
  | 'abgr4444'
@@ -423,19 +475,36 @@ export namespace Sdl {
423
475
  | 'bgr565'
424
476
  | 'rgb24'
425
477
  | 'bgr24'
426
- | 'rgb888'
478
+ | 'xrgb8888'
427
479
  | 'rgbx8888'
428
- | 'bgr888'
480
+ | 'xbgr8888'
429
481
  | 'bgrx8888'
430
482
  | 'argb8888'
431
483
  | 'rgba8888'
432
484
  | 'abgr8888'
433
485
  | 'bgra8888'
434
486
  | 'argb2101010'
435
- | 'rgba32'
436
- | 'argb32'
437
- | 'bgra32'
438
- | 'abgr32'
487
+ | 'xrgb2101010'
488
+ | 'xbgr2101010'
489
+ | 'abgr2101010'
490
+ | 'rgb48'
491
+ | 'bgr48'
492
+ | 'rgba64'
493
+ | 'argb64'
494
+ | 'bgra64'
495
+ | 'abgr64'
496
+ | 'rgb48f'
497
+ | 'bgr48f'
498
+ | 'rgba64f'
499
+ | 'argb64f'
500
+ | 'bgra64f'
501
+ | 'abgr64f'
502
+ | 'rgb96f'
503
+ | 'bgr96f'
504
+ | 'rgba128f'
505
+ | 'argb128f'
506
+ | 'bgra128f'
507
+ | 'abgr128f'
439
508
  | 'yv12'
440
509
  | 'iyuv'
441
510
  | 'yuy2'
@@ -443,16 +512,27 @@ export namespace Sdl {
443
512
  | 'yvyu'
444
513
  | 'nv12'
445
514
  | 'nv21'
515
+ | 'p010'
516
+
517
+ export type FormatAlias
518
+ = 'rgba32'
519
+ | 'argb32'
520
+ | 'bgra32'
521
+ | 'abgr32'
522
+ | 'rgbx32'
523
+ | 'xrgb32'
524
+ | 'bgrx32'
525
+ | 'xbgr32'
446
526
 
447
527
  export type Scaling
448
528
  = 'nearest'
449
529
  | 'linear'
450
- | 'best'
451
530
 
452
531
  export interface Display {
532
+ readonly id: number
453
533
  readonly name: string | null
454
- readonly format: Format
455
- readonly frequency: number
534
+ readonly format: Format | null
535
+ readonly frequency: number | null
456
536
  readonly geometry: {
457
537
  readonly x: number
458
538
  readonly y: number
@@ -465,15 +545,11 @@ export namespace Sdl {
465
545
  readonly width: number
466
546
  readonly height: number
467
547
  }
468
- readonly dpi: {
469
- readonly horizontal: number
470
- readonly vertical: number
471
- readonly diagonal: number
472
- } | null
548
+ readonly scale: number | null
473
549
  readonly orientation: Orientation | null
474
550
  }
475
551
 
476
- export class Window {
552
+ export interface Window extends EventEmitter {
477
553
  on (event: 'show', listener: (event: Events.Window.Show) => void): this
478
554
  on (event: 'hide', listener: (event: Events.Window.Hide) => void): this
479
555
  on (event: 'expose', listener: (event: Events.Window.Expose) => void): this
@@ -499,11 +575,13 @@ export namespace Sdl {
499
575
  on (event: 'fingerDown', listener: (event: Events.Window.FingerDown) => void): this
500
576
  on (event: 'fingerUp', listener: (event: Events.Window.FingerUp) => void): this
501
577
  on (event: 'fingerMove', listener: (event: Events.Window.FingerMove) => void): this
578
+ on (event: 'fingerCancel', listener: (event: Events.Window.FingerCancel) => void): this
502
579
  on (event: 'dropBegin', listener: (event: Events.Window.DropBegin) => void): this
503
580
  on (event: 'dropText', listener: (event: Events.Window.DropText) => void): this
504
581
  on (event: 'dropFile', listener: (event: Events.Window.DropFile) => void): this
505
582
  on (event: 'dropComplete', listener: (event: Events.Window.DropComplete) => void): this
506
583
  on (event: '*', listener: (type: string, event: Events.Window.Any) => void): this
584
+ on (event: 'error', listener: (error: Error) => void): this
507
585
 
508
586
  readonly id: number
509
587
 
@@ -522,7 +600,7 @@ export namespace Sdl {
522
600
  readonly pixelHeight: number
523
601
  setSizeInPixels (pixelWidth: number, pixelHeight: number): void
524
602
 
525
- readonly display: Display
603
+ readonly display: Display | null
526
604
 
527
605
  readonly visible: boolean
528
606
  show (show?: boolean): void
@@ -539,15 +617,18 @@ export namespace Sdl {
539
617
 
540
618
  readonly alwaysOnTop: boolean
541
619
 
542
- readonly accelerated: boolean
620
+ readonly accelerated: boolean | null
543
621
  setAccelerated (accelerated: boolean): void
544
622
 
545
- readonly vsync: boolean
546
- setVsync (vsync: boolean): void
623
+ readonly vsync: number | null
624
+ setVsync (vsync: number): void
547
625
 
548
626
  readonly opengl: boolean
549
627
  readonly webgpu: boolean
550
- readonly native: { handle: Buffer | null }
628
+ readonly native: {
629
+ readonly handle: Buffer | null,
630
+ readonly subsystem: 'x11' | 'wayland' | null,
631
+ }
551
632
 
552
633
  readonly maximized: boolean
553
634
  maximize (): void
@@ -561,23 +642,23 @@ export namespace Sdl {
561
642
  focus (): void
562
643
 
563
644
  readonly hovered: boolean
645
+ readonly mouseCaptured: boolean
564
646
 
565
- readonly skipTaskbar: boolean
566
- readonly popupMenu: boolean
567
- readonly tooltip: boolean
568
- readonly utility: boolean
647
+ readonly relativeMouseMode: boolean
648
+ setRelativeMouseMode (relative?: boolean): void
649
+ unsetRelativeMouseMode (): void
569
650
 
570
- render (width: number, height: number, stride: number, format: Format, buffer: Buffer, options?: {
651
+ render (width: number, height: number, stride: number, format: Format | FormatAlias, buffer: Buffer, options?: {
571
652
  scaling?: Scaling,
572
653
  dstRect?: {
573
654
  x: number,
574
655
  y: number,
575
656
  width: number,
576
657
  height: number,
577
- }
658
+ } | null
578
659
  }): void
579
660
 
580
- setIcon (width: number, height: number, stride: number, format: Format, buffer: Buffer): void
661
+ setIcon (width: number, height: number, stride: number, format: Format | FormatAlias, buffer: Buffer): void
581
662
 
582
663
  flash (untilFocused?: boolean): void
583
664
  stopFlashing (): void
@@ -587,40 +668,46 @@ export namespace Sdl {
587
668
  destroyGently (): void
588
669
  }
589
670
 
590
- interface Module {
671
+ interface Module extends EventEmitter {
591
672
  on (event: 'displayAdd', listener: (event: Events.Display.Add) => void): this
592
673
  on (event: 'displayRemove', listener: (event: Events.Display.Remove) => void): this
593
674
  on (event: 'displayOrient', listener: (event: Events.Display.Orient) => void): this
594
675
  on (event: 'displayMove', listener: (event: Events.Display.Move) => void): this
676
+ on (event: 'displayScaleChange', listener: (event: Events.Display.Scale) => void): this
677
+ on (event: 'displayModeChange', listener: (event: Events.Display.Mode) => void): this
678
+ on (event: 'displayUsableChange', listener: (event: Events.Display.Usable) => void): this
595
679
  on (event: '*', listener: (type: string, event: Events.Display.Any) => void): this
680
+ on (event: 'error', listener: (error: Error) => void): this
596
681
 
597
682
  readonly displays: Display[]
598
683
 
599
684
  readonly windows: Window[]
600
- readonly focused: Window
601
- readonly hovered: Window
685
+ readonly focused: Window | null
686
+ readonly hovered: Window | null
602
687
 
603
688
  createWindow (options?: {
604
689
  title?: string
605
- display?: Display
606
- x?: number
607
- y?: number
608
- width?: number
609
- height?: number
690
+ display?: Display | null
691
+ x?: number | null
692
+ y?: number | null
693
+ width?: number | null
694
+ height?: number | null
610
695
  visible?: boolean
611
696
  fullscreen?: boolean
612
697
  resizable?: boolean
613
698
  borderless?: boolean
614
699
  alwaysOnTop?: boolean
615
700
  accelerated?: boolean
616
- vsync?: boolean
701
+ vsync?: number
617
702
  opengl?: boolean
618
703
  webgpu?: boolean
619
- skipTaskbar?: boolean
620
- popupMenu?: boolean
621
- tooltip?: boolean
622
- utility?: boolean
623
704
  }): Window
705
+
706
+ bytesPerPixel (format: Format | FormatAlias): number
707
+ isYuv (format: Format | FormatAlias): boolean
708
+ isPlanarYuv (format: Format | FormatAlias): boolean
709
+ minStride (format: Format | FormatAlias, width: number): number
710
+ minBufferSize (format: Format | FormatAlias, stride: number, height: number): number
624
711
  }
625
712
  }
626
713
 
@@ -842,16 +929,11 @@ export namespace Sdl {
842
929
  | 'RALT'
843
930
  | 'RGUI'
844
931
  | 'MODE'
845
- | 'AUDIONEXT'
846
- | 'AUDIOPREV'
847
- | 'AUDIOSTOP'
848
- | 'AUDIOPLAY'
849
- | 'AUDIOMUTE'
850
- | 'MEDIASELECT'
851
- | 'WWW'
852
- | 'MAIL'
853
- | 'CALCULATOR'
854
- | 'COMPUTER'
932
+ | 'MEDIA_NEXT_TRACK'
933
+ | 'MEDIA_PREVIOUS_TRACK'
934
+ | 'MEDIA_STOP'
935
+ | 'MEDIA_PLAY'
936
+ | 'MEDIA_SELECT'
855
937
  | 'AC_SEARCH'
856
938
  | 'AC_HOME'
857
939
  | 'AC_BACK'
@@ -859,25 +941,36 @@ export namespace Sdl {
859
941
  | 'AC_STOP'
860
942
  | 'AC_REFRESH'
861
943
  | 'AC_BOOKMARKS'
862
- | 'BRIGHTNESSDOWN'
863
- | 'BRIGHTNESSUP'
864
- | 'DISPLAYSWITCH'
865
- | 'KBDILLUMTOGGLE'
866
- | 'KBDILLUMDOWN'
867
- | 'KBDILLUMUP'
868
- | 'EJECT'
944
+ | 'MEDIA_EJECT'
869
945
  | 'SLEEP'
870
- | 'APP1'
871
- | 'APP2'
872
- | 'AUDIOREWIND'
873
- | 'AUDIOFASTFORWARD'
946
+ | 'WAKE'
947
+ | 'CHANNEL_INCREMENT'
948
+ | 'CHANNEL_DECREMENT'
949
+ | 'MEDIA_PAUSE'
950
+ | 'MEDIA_RECORD'
951
+ | 'MEDIA_PLAY_PAUSE'
952
+ | 'MEDIA_REWIND'
953
+ | 'MEDIA_FAST_FORWARD'
954
+ | 'AC_NEW'
955
+ | 'AC_OPEN'
956
+ | 'AC_CLOSE'
957
+ | 'AC_EXIT'
958
+ | 'AC_SAVE'
959
+ | 'AC_PRINT'
960
+ | 'AC_PROPERTIES'
961
+ | 'SOFTLEFT'
962
+ | 'SOFTRIGHT'
963
+ | 'CALL'
964
+ | 'ENDCALL'
874
965
 
875
966
  export type Key = string
876
967
 
877
- interface Module {
968
+ interface Module extends EventEmitter {
878
969
  readonly SCANCODE: { [name in ScancodeNames]: Scancode }
879
970
 
880
971
  on (event: 'keymapChange', listener: (event: Events.Keyboard.KeymapChange) => void): this
972
+ on (event: '*', listener: (type: string, event: Events.Keyboard.Any) => void): this
973
+ on (event: 'error', listener: (error: Error) => void): this
881
974
 
882
975
  getKey (scancode: Scancode): Key | null
883
976
  getScancode (key: Key): Scancode | null
@@ -895,20 +988,30 @@ export namespace Sdl {
895
988
  = 'LEFT'
896
989
  | 'MIDDLE'
897
990
  | 'RIGHT'
991
+ | 'X1'
992
+ | 'X2'
898
993
 
899
994
  export type Cursor
900
- = 'arrow'
901
- | 'ibeam'
995
+ = 'default'
996
+ | 'text'
902
997
  | 'wait'
903
998
  | 'crosshair'
904
- | 'waitarrow'
905
- | 'sizenwse'
906
- | 'sizenesw'
907
- | 'sizewe'
908
- | 'sizens'
909
- | 'sizeall'
910
- | 'no'
911
- | 'hand'
999
+ | 'progress'
1000
+ | 'nwseResize'
1001
+ | 'neswResize'
1002
+ | 'ewResize'
1003
+ | 'nsResize'
1004
+ | 'move'
1005
+ | 'notAllowed'
1006
+ | 'pointer'
1007
+ | 'nwResize'
1008
+ | 'nResize'
1009
+ | 'neResize'
1010
+ | 'eResize'
1011
+ | 'seResize'
1012
+ | 'sResize'
1013
+ | 'swResize'
1014
+ | 'wResize'
912
1015
 
913
1016
  interface Module {
914
1017
  readonly BUTTON: { [name in ButtonNames]: number }
@@ -923,13 +1026,14 @@ export namespace Sdl {
923
1026
 
924
1027
  setCursor (cursor: Cursor): void
925
1028
  resetCursor (): void
926
- setCursorImage (width: number, height: number, stride: number, format: Video.Format, buffer: Buffer): void
1029
+ setCursorImage (width: number, height: number, stride: number, format: Video.Format | Video.FormatAlias, buffer: Buffer, x: number, y: number): void
927
1030
 
928
1031
  showCursor (show?: boolean): void
929
1032
  hideCursor (): void
930
1033
  redrawCursor (): void
931
1034
 
932
- capture (): void
1035
+ readonly captured: boolean
1036
+ capture (capture?: boolean): void
933
1037
  uncapture (): void
934
1038
  }
935
1039
 
@@ -943,7 +1047,7 @@ export namespace Sdl {
943
1047
  | 'indirectRelative'
944
1048
 
945
1049
  export interface Device {
946
- readonly id: number
1050
+ readonly id: bigint
947
1051
  readonly name: string | null
948
1052
  readonly type: DeviceType | null
949
1053
  }
@@ -962,15 +1066,14 @@ export namespace Sdl {
962
1066
  }
963
1067
 
964
1068
  export type JoystickType
965
- = null
966
- | 'gamecontroller'
1069
+ = 'gamepad'
967
1070
  | 'wheel'
968
- | 'arcadestick'
969
- | 'flightstick'
970
- | 'dancepad'
1071
+ | 'arcadeStick'
1072
+ | 'flightStick'
1073
+ | 'dancePad'
971
1074
  | 'guitar'
972
- | 'drumkit'
973
- | 'arcadepad'
1075
+ | 'drumKit'
1076
+ | 'arcadePad'
974
1077
  | 'throttle'
975
1078
 
976
1079
  export type HatPosition
@@ -979,18 +1082,15 @@ export namespace Sdl {
979
1082
  | 'right'
980
1083
  | 'down'
981
1084
  | 'left'
982
- | 'rightup'
983
- | 'rightdown'
984
- | 'leftup'
985
- | 'leftdown'
986
-
987
- export type PowerLevel
988
- = 'empty'
989
- | 'low'
990
- | 'medium'
991
- | 'full'
992
- | 'wired'
993
- | 'max'
1085
+ | 'rightUp'
1086
+ | 'rightDown'
1087
+ | 'leftUp'
1088
+ | 'leftDown'
1089
+
1090
+ export interface PowerInfo {
1091
+ readonly state: Sdl.Power.PowerState | null
1092
+ readonly percent: number | null
1093
+ }
994
1094
 
995
1095
  export interface Device {
996
1096
  readonly id: number
@@ -1004,7 +1104,7 @@ export namespace Sdl {
1004
1104
  readonly player: number | null
1005
1105
  }
1006
1106
 
1007
- export class JoystickInstance {
1107
+ export interface JoystickInstance extends EventEmitter {
1008
1108
  on (event: 'axisMotion', listener: (event: Events.Joystick.AxisMotion) => void): this
1009
1109
  on (event: 'ballMotion', listener: (event: Events.Joystick.BallMotion) => void): this
1010
1110
  on (event: 'buttonDown', listener: (event: Events.Joystick.ButtonDown) => void): this
@@ -1013,40 +1113,42 @@ export namespace Sdl {
1013
1113
  on (event: 'powerUpdate', listener: (event: Events.Joystick.PowerUpdate) => void): this
1014
1114
  on (event: 'close', listener: (event: Events.Joystick.Close) => void): this
1015
1115
  on (event: '*', listener: (type: string, event: Events.Joystick.Any) => void): this
1116
+ on (event: 'error', listener: (error: Error) => void): this
1016
1117
 
1017
1118
  readonly device: Device
1018
- readonly firmwareVersion: number
1019
- readonly serialNumber: string
1119
+ readonly firmwareVersion: number | null
1120
+ readonly serialNumber: string | null
1020
1121
 
1021
1122
  readonly axes: number[]
1022
1123
  readonly balls: BallPosition[]
1023
- readonly hats: HatPosition[]
1124
+ readonly hats: (HatPosition | null)[]
1024
1125
  readonly buttons: boolean[]
1025
1126
 
1026
- readonly power: PowerLevel | null
1127
+ readonly power: PowerInfo
1027
1128
 
1028
- setPlayer (index: number): void
1129
+ setPlayer (player: number): void
1029
1130
  resetPlayer (): void
1030
1131
 
1031
1132
  readonly hasLed: boolean
1032
1133
  setLed (red: number, green: number, blue: number): void
1033
1134
 
1034
1135
  readonly hasRumble: boolean
1035
- rumble (lowFreqRumble: number, highFreqRumble: number, duration: number): void
1136
+ rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number | null): void
1036
1137
  stopRumble (): void
1037
1138
 
1038
1139
  readonly hasRumbleTriggers: boolean
1039
- rumbleTriggers (leftRumble: number, rightRumble: number, duration: number): void
1140
+ rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number | null): void
1040
1141
  stopRumbleTriggers (): void
1041
1142
 
1042
1143
  readonly closed: boolean
1043
1144
  close (): void
1044
1145
  }
1045
1146
 
1046
- interface Module {
1147
+ interface Module extends EventEmitter {
1047
1148
  on (event: 'deviceAdd', listener: (event: Events.JoystickDevice.Add) => void): this
1048
1149
  on (event: 'deviceRemove', listener: (event: Events.JoystickDevice.Remove) => void): this
1049
1150
  on (event: '*', listener: (type: string, event: Events.JoystickDevice.Any) => void): this
1151
+ on (event: 'error', listener: (error: Error) => void): this
1050
1152
 
1051
1153
  readonly devices: Device[]
1052
1154
 
@@ -1055,23 +1157,20 @@ export namespace Sdl {
1055
1157
 
1056
1158
  }
1057
1159
 
1058
- export namespace Controller {
1160
+ export namespace Gamepad {
1059
1161
 
1060
- export type ControllerType
1061
- = null
1162
+ export type GamepadType
1163
+ = 'standard'
1062
1164
  | 'xbox360'
1063
1165
  | 'xboxOne'
1064
1166
  | 'ps3'
1065
1167
  | 'ps4'
1066
- | 'nintendoSwitchPro'
1067
- | 'virtual'
1068
1168
  | 'ps5'
1069
- | 'amazonLuna'
1070
- | 'googleStadia'
1071
- | 'nvidiaShield'
1169
+ | 'nintendoSwitchPro'
1072
1170
  | 'nintendoSwitchJoyconLeft'
1073
1171
  | 'nintendoSwitchJoyconRight'
1074
1172
  | 'nintendoSwitchJoyconPair'
1173
+ | 'gamecube'
1075
1174
 
1076
1175
  export type Axis
1077
1176
  = 'leftStickX'
@@ -1086,10 +1185,10 @@ export namespace Sdl {
1086
1185
  | 'dpadRight'
1087
1186
  | 'dpadUp'
1088
1187
  | 'dpadDown'
1089
- | 'a'
1090
- | 'b'
1091
- | 'x'
1092
- | 'y'
1188
+ | 'south'
1189
+ | 'east'
1190
+ | 'west'
1191
+ | 'north'
1093
1192
  | 'guide'
1094
1193
  | 'back'
1095
1194
  | 'start'
@@ -1097,16 +1196,33 @@ export namespace Sdl {
1097
1196
  | 'rightStick'
1098
1197
  | 'leftShoulder'
1099
1198
  | 'rightShoulder'
1100
- | 'paddle1'
1101
- | 'paddle2'
1102
- | 'paddle3'
1103
- | 'paddle4'
1199
+ | 'rightPaddle1'
1200
+ | 'leftPaddle1'
1201
+ | 'rightPaddle2'
1202
+ | 'leftPaddle2'
1203
+ | 'misc1'
1204
+ | 'misc2'
1205
+ | 'misc3'
1206
+ | 'misc4'
1207
+ | 'misc5'
1208
+ | 'misc6'
1209
+ | 'touchpad'
1210
+
1211
+ export type ButtonLabel
1212
+ = 'a'
1213
+ | 'b'
1214
+ | 'x'
1215
+ | 'y'
1216
+ | 'cross'
1217
+ | 'circle'
1218
+ | 'square'
1219
+ | 'triangle'
1104
1220
 
1105
1221
  export interface Device {
1106
1222
  readonly id: number
1107
- readonly name: string
1223
+ readonly name: string | null
1108
1224
  readonly path: string | null
1109
- readonly type: ControllerType | null
1225
+ readonly type: GamepadType | null
1110
1226
  readonly guid: string | null
1111
1227
  readonly vendor: number | null
1112
1228
  readonly product: number | null
@@ -1115,82 +1231,62 @@ export namespace Sdl {
1115
1231
  readonly mapping: string | null
1116
1232
  }
1117
1233
 
1118
- export class ControllerInstance {
1119
- on (event: 'axisMotion', listener: (event: Events.Controller.AxisMotion) => void): this
1120
- on (event: 'buttonDown', listener: (event: Events.Controller.ButtonDown) => void): this
1121
- on (event: 'buttonUp', listener: (event: Events.Controller.ButtonUp) => void): this
1122
- on (event: 'powerUpdate', listener: (event: Events.Controller.PowerUpdate) => void): this
1123
- on (event: 'steamHandleUpdate', listener: (event: Events.Controller.SteamHandleUpdate) => void): this
1124
- on (event: 'remap', listener: (event: Events.Controller.Remap) => void): this
1125
- on (event: 'close', listener: (event: Events.Controller.Close) => void): this
1126
- on (event: '*', listener: (type: string, event: Events.Controller.Any) => void): this
1234
+ export interface GamepadInstance extends EventEmitter {
1235
+ on (event: 'axisMotion', listener: (event: Events.Gamepad.AxisMotion) => void): this
1236
+ on (event: 'buttonDown', listener: (event: Events.Gamepad.ButtonDown) => void): this
1237
+ on (event: 'buttonUp', listener: (event: Events.Gamepad.ButtonUp) => void): this
1238
+ on (event: 'powerUpdate', listener: (event: Events.Gamepad.PowerUpdate) => void): this
1239
+ on (event: 'steamHandleUpdate', listener: (event: Events.Gamepad.SteamHandleUpdate) => void): this
1240
+ on (event: 'remap', listener: (event: Events.Gamepad.Remap) => void): this
1241
+ on (event: 'close', listener: (event: Events.Gamepad.Close) => void): this
1242
+ on (event: '*', listener: (type: string, event: Events.Gamepad.Any) => void): this
1243
+ on (event: 'error', listener: (error: Error) => void): this
1127
1244
 
1128
1245
  readonly device: Device
1129
- readonly firmwareVersion: number
1130
- readonly serialNumber: string
1131
- readonly steamHandle: Buffer | null
1132
-
1133
- readonly axes: {
1134
- readonly leftStickX: number
1135
- readonly leftStickY: number
1136
- readonly rightStickX: number
1137
- readonly rightStickY: number
1138
- readonly leftTrigger: number
1139
- readonly rightTrigger: number
1140
- }
1141
-
1142
- readonly buttons: {
1143
- readonly dpadLeft: boolean
1144
- readonly dpadRight: boolean
1145
- readonly dpadUp: boolean
1146
- readonly dpadDown: boolean
1147
- readonly a: boolean
1148
- readonly b: boolean
1149
- readonly x: boolean
1150
- readonly y: boolean
1151
- readonly guide: boolean
1152
- readonly back: boolean
1153
- readonly start: boolean
1154
- readonly leftStick: boolean
1155
- readonly rightStick: boolean
1156
- readonly leftShoulder: boolean
1157
- readonly rightShoulder: boolean
1158
- readonly paddle1: boolean
1159
- readonly paddle2: boolean
1160
- readonly paddle3: boolean
1161
- readonly paddle4: boolean
1246
+ readonly firmwareVersion: number | null
1247
+ readonly serialNumber: string | null
1248
+ readonly steamHandle: bigint | null
1249
+
1250
+ readonly axes: { readonly [axis in Axis]: number }
1251
+ readonly buttons: { readonly [button in Button]: boolean }
1252
+ readonly buttonLabels: {
1253
+ readonly south: ButtonLabel | null
1254
+ readonly east: ButtonLabel | null
1255
+ readonly west: ButtonLabel | null
1256
+ readonly north: ButtonLabel | null
1162
1257
  }
1163
1258
 
1164
- readonly power: Joystick.PowerLevel
1259
+ readonly power: Joystick.PowerInfo
1165
1260
 
1166
- setPlayer (index: number): void
1261
+ setPlayer (player: number): void
1167
1262
  resetPlayer (): void
1168
1263
 
1169
1264
  readonly hasLed: boolean
1170
1265
  setLed (red: number, green: number, blue: number): void
1171
1266
 
1172
1267
  readonly hasRumble: boolean
1173
- rumble (lowFreqRumble: number, highFreqRumble: number, duration: number): void
1268
+ rumble (lowFreqRumble?: number, highFreqRumble?: number, duration?: number | null): void
1174
1269
  stopRumble (): void
1175
1270
 
1176
1271
  readonly hasRumbleTriggers: boolean
1177
- rumbleTriggers (leftRumble: number, rightRumble: number, duration: number): void
1272
+ rumbleTriggers (leftRumble?: number, rightRumble?: number, duration?: number | null): void
1178
1273
  stopRumbleTriggers (): void
1179
1274
 
1180
1275
  readonly closed: boolean
1181
1276
  close (): void
1182
1277
  }
1183
1278
 
1184
- interface Module {
1185
- on (event: 'deviceAdd', listener: (event: Events.ControllerDevice.Add) => void): this
1186
- on (event: 'deviceRemove', listener: (event: Events.ControllerDevice.Remove) => void): this
1187
- on (event: '*', listener: (type: string, event: Events.ControllerDevice.Any) => void): this
1279
+ interface Module extends EventEmitter {
1280
+ on (event: 'deviceAdd', listener: (event: Events.GamepadDevice.Add) => void): this
1281
+ on (event: 'deviceRemove', listener: (event: Events.GamepadDevice.Remove) => void): this
1282
+ on (event: '*', listener: (type: string, event: Events.GamepadDevice.Any) => void): this
1283
+ on (event: 'error', listener: (error: Error) => void): this
1188
1284
 
1189
1285
  addMappings (mappings: string[]): void
1190
1286
 
1191
1287
  readonly devices: Device[]
1192
1288
 
1193
- openDevice (device: Device): ControllerInstance
1289
+ openDevice (device: Device): GamepadInstance
1194
1290
  }
1195
1291
 
1196
1292
  }
@@ -1198,8 +1294,7 @@ export namespace Sdl {
1198
1294
  export namespace Sensor {
1199
1295
 
1200
1296
  export type Type
1201
- = 'unknown'
1202
- | 'accelerometer'
1297
+ = 'accelerometer'
1203
1298
  | 'gyroscope'
1204
1299
 
1205
1300
  export type Side
@@ -1208,22 +1303,22 @@ export namespace Sdl {
1208
1303
 
1209
1304
  export interface Device {
1210
1305
  readonly id: number
1211
- readonly name: string
1306
+ readonly name: string | null
1212
1307
  readonly type: Type | null
1213
1308
  readonly side: Side | null
1214
1309
  }
1215
1310
 
1216
1311
  export interface Data {
1217
- readonly timestamp: number | null
1218
1312
  readonly x: number
1219
1313
  readonly y: number
1220
1314
  readonly z: number
1221
1315
  }
1222
1316
 
1223
- export class SensorInstance {
1317
+ export interface SensorInstance extends EventEmitter {
1224
1318
  on (event: 'update', listener: (event: Events.Sensor.Update) => void): this
1225
1319
  on (event: 'close', listener: (event: Events.Sensor.Close) => void): this
1226
1320
  on (event: '*', listener: (type: string, event: Events.Sensor.Any) => void): this
1321
+ on (event: 'error', listener: (error: Error) => void): this
1227
1322
 
1228
1323
  readonly device: Device
1229
1324
 
@@ -1248,39 +1343,38 @@ export namespace Sdl {
1248
1343
  export type Format
1249
1344
  = 's8'
1250
1345
  | 'u8'
1251
- | 's16lsb'
1252
- | 's16msb'
1253
- | 's16sys'
1254
- | 's16'
1255
- | 'u16lsb'
1256
- | 'u16msb'
1257
- | 'u16sys'
1258
- | 'u16'
1259
- | 's32lsb'
1260
- | 's32msb'
1261
- | 's32sys'
1346
+ | 's16le'
1347
+ | 's16be'
1348
+ | 's32le'
1349
+ | 's32be'
1350
+ | 'f32le'
1351
+ | 'f32be'
1352
+
1353
+ export type FormatAlias
1354
+ = 's16'
1262
1355
  | 's32'
1263
- | 'f32lsb'
1264
- | 'f32msb'
1265
- | 'f32sys'
1266
1356
  | 'f32'
1267
1357
 
1268
1358
  export interface Device {
1269
- readonly type: "recording"|"playback"
1270
- readonly name?: string
1271
- }
1272
-
1273
- export interface PlaybackDevice extends Device {
1274
- readonly type: "playback"
1359
+ readonly id: number | null
1360
+ readonly name: string | null
1361
+ readonly format: Format | null
1362
+ readonly channels: number | null
1363
+ readonly frequency: number | null
1364
+ readonly buffered: number | null
1275
1365
  }
1276
1366
 
1277
- export interface RecordingDevice extends Device {
1278
- readonly type: "recording"
1367
+ export interface StreamOptions {
1368
+ readonly channels?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
1369
+ readonly frequency?: number
1370
+ readonly format?: Format | FormatAlias
1371
+ readonly buffered?: number
1279
1372
  }
1280
1373
 
1281
- export class AudioInstance {
1374
+ export interface AudioStream extends EventEmitter {
1282
1375
  on (event: 'close', listener: (event: Events.Audio.Close) => void): this
1283
1376
  on (event: '*', listener: (type: string, event: Events.Audio.Any) => void): this
1377
+ on (event: 'error', listener: (error: Error) => void): this
1284
1378
 
1285
1379
  readonly id: number
1286
1380
  readonly device: Device
@@ -1288,14 +1382,12 @@ export namespace Sdl {
1288
1382
  readonly channels: number
1289
1383
  readonly frequency: number
1290
1384
  readonly format: Format
1291
- readonly buffered: number
1292
1385
 
1293
1386
  readonly playing: boolean
1294
1387
  play (play?: boolean): void
1295
1388
  pause (): void
1296
1389
 
1297
- readonly queued: number
1298
- clearQueue (): void
1390
+ clear (): void
1299
1391
 
1300
1392
  readonly bytesPerSample: number
1301
1393
  readonly minSampleValue: number
@@ -1308,45 +1400,46 @@ export namespace Sdl {
1308
1400
  close (): void
1309
1401
  }
1310
1402
 
1311
- export class AudioPlaybackInstance extends AudioInstance {
1312
- enqueue (buffer: Buffer, bytes?: number): void
1403
+ export interface AudioPlaybackStream extends AudioStream {
1404
+ readonly queued: number
1405
+ putData (buffer: Buffer, bytes?: number): void
1313
1406
  }
1314
1407
 
1315
- export class AudioRecordingInstance extends AudioInstance {
1316
- dequeue (buffer: Buffer, bytes?: number): number
1408
+ export interface AudioRecordingStream extends AudioStream {
1409
+ readonly available: number
1410
+ getData (buffer: Buffer, bytes?: number): number
1317
1411
  }
1318
1412
 
1319
- export interface AudioOptions {
1320
- readonly channels?: 1 | 2 | 4 | 6
1321
- readonly frequency?: number
1322
- readonly format?: Format
1323
- readonly buffered?: number
1324
- }
1325
-
1326
- interface Module {
1413
+ interface DeviceModule<Stream extends AudioStream> extends EventEmitter {
1327
1414
  on (event: 'deviceAdd', listener: (event: Events.AudioDevice.Add) => void): this
1328
1415
  on (event: 'deviceRemove', listener: (event: Events.AudioDevice.Remove) => void): this
1329
1416
  on (event: '*', listener: (type: string, event: Events.AudioDevice.Any) => void): this
1417
+ on (event: 'error', listener: (error: Error) => void): this
1330
1418
 
1331
1419
  readonly devices: Device[]
1332
1420
 
1333
- openDevice (device: PlaybackDevice, options?: AudioOptions): AudioPlaybackInstance
1334
- openDevice (device: RecordingDevice, options?: AudioOptions): AudioRecordingInstance
1421
+ openDevice (device?: Device | null, options?: StreamOptions): Stream
1422
+ }
1335
1423
 
1336
- bytesPerSample (format: Format): number
1337
- minSampleValue (format: Format): number
1338
- maxSampleValue (format: Format): number
1339
- zeroSampleValue (format: Format): number
1340
- readSample (format: Format, buffer: Buffer, offset?: number): number
1341
- writeSample (format: Format, buffer: Buffer, value: number, offset?: number): number
1424
+ interface Module {
1425
+ readonly playback: DeviceModule<AudioPlaybackStream>
1426
+ readonly recording: DeviceModule<AudioRecordingStream>
1427
+
1428
+ bytesPerSample (format: Format | FormatAlias): number
1429
+ minSampleValue (format: Format | FormatAlias): number
1430
+ maxSampleValue (format: Format | FormatAlias): number
1431
+ zeroSampleValue (format: Format | FormatAlias): number
1432
+ readSample (format: Format | FormatAlias, buffer: Buffer, offset?: number): number
1433
+ writeSample (format: Format | FormatAlias, buffer: Buffer, value: number, offset?: number): number
1342
1434
  }
1343
1435
  }
1344
1436
 
1345
1437
  export namespace Clipboard {
1346
1438
 
1347
- interface Module {
1439
+ interface Module extends EventEmitter {
1348
1440
  on (event: 'update', listener: (event: Events.Clipboard.Update) => void): this
1349
1441
  on (event: '*', listener: (type: string, event: Events.Clipboard.Any) => void): this
1442
+ on (event: 'error', listener: (error: Error) => void): this
1350
1443
 
1351
1444
  readonly text: string
1352
1445
  setText (text: string): void
@@ -1382,7 +1475,7 @@ export const keyboard: Sdl.Keyboard.Module
1382
1475
  export const mouse: Sdl.Mouse.Module
1383
1476
  export const touch: Sdl.Touch.Module
1384
1477
  export const joystick: Sdl.Joystick.Module
1385
- export const controller: Sdl.Controller.Module
1478
+ export const gamepad: Sdl.Gamepad.Module
1386
1479
  export const sensor: Sdl.Sensor.Module
1387
1480
  export const audio: Sdl.Audio.Module
1388
1481
  export const clipboard: Sdl.Clipboard.Module