@kmamal/sdl 0.8.0 → 0.8.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
7
  SDL bindings for Node.js.
8
- Provides window management, input events (keyboard, mouse, joystick, controller), audio playback and recording, and clipboard manipulation.
8
+ Provides window management, input events (keyboard, mouse, joystick, controller), audio playback and recording, clipboard manipulation, and battery status.
9
9
 
10
10
  It should work on Linux, Mac, and Windows.
11
11
  Prebuilt binaries are available for x64 architectures, arm-based Macs, and Raspberry Pi.
@@ -88,6 +88,9 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
88
88
  * [Image data](#image-data)
89
89
  * [Pixel formats](#pixel-formats)
90
90
  * [High-DPI](#highdpi)
91
+ * [Event: 'displayAdd'](#event-displayadd)
92
+ * [Event: 'displayRemove'](#event-displayremove)
93
+ * [Event: 'displayOrient'](#event-displayorient)
91
94
  * [sdl.video.displays](#sdlvideodisplays)
92
95
  * [sdl.video.windows](#sdlvideowindows)
93
96
  * [sdl.video.focused](#sdlvideofocused)
@@ -184,8 +187,8 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
184
187
  * [Joystick types](#joystick-types)
185
188
  * [Hat positions](#hat-positions)
186
189
  * [Power levels](#power-levels)
187
- * [Event: 'deviceAdd'](#joystick-event-device-add)
188
- * [Event: 'deviceRemove'](#joystick-event-device-remove)
190
+ * [Event: 'deviceAdd'](#joystick-event-deviceadd)
191
+ * [Event: 'deviceRemove'](#joystick-event-deviceremove)
189
192
  * [sdl.joystick.devices](#sdljoystickdevices)
190
193
  * [sdl.joystick.openDevice(device)](#sdljoystickopendevicedevice)
191
194
  * [class JoystickInstance](#class-joystickinstance)
@@ -215,8 +218,8 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
215
218
  * [joystickInstance.closed](#joystickinstanceclosed)
216
219
  * [joystickInstance.close()](#joystickinstanceclose)
217
220
  * [sdl.controller](#sdlcontroller)
218
- * [Event: 'deviceAdd'](#controller-event-device-add)
219
- * [Event: 'deviceRemove'](#controller-event-device-remove)
221
+ * [Event: 'deviceAdd'](#controller-event-deviceadd)
222
+ * [Event: 'deviceRemove'](#controller-event-deviceremove)
220
223
  * [sdl.controller.addMappings(mappings)](#sdlcontrolleraddmappingsmappings)
221
224
  * [sdl.controller.devices](#sdlcontrollerdevices)
222
225
  * [sdl.controller.openDevice(device)](#sdlcontrolleropendevicedevice)
@@ -246,8 +249,8 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
246
249
  * [sdl.audio](#sdlaudio)
247
250
  * [Audio data](#audio-data)
248
251
  * [Sample formats](#sample-formats)
249
- * [Event: 'deviceAdd'](#audio-event-device-add)
250
- * [Event: 'deviceRemove'](#audio-event-device-remove)
252
+ * [Event: 'deviceAdd'](#audio-event-deviceadd)
253
+ * [Event: 'deviceRemove'](#audio-event-deviceremove)
251
254
  * [sdl.audio.bytesPerSample(format)](#sdlaudiobytespersampleformat)
252
255
  * [sdl.audio.minSampleValue(format)](#sdlaudiominsamplevalueformat)
253
256
  * [sdl.audio.maxSampleValue(format)](#sdlaudiomaxsamplevalueformat)
@@ -288,6 +291,8 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
288
291
  * [Event: 'update'](#event-update)
289
292
  * [sdl.clipboard.text](#sdlclipboardtext)
290
293
  * [sdl.clipboard.setText(text)](#sdlclipboardsettexttext)
294
+ * [sdl.power](#sdlpower)
295
+ * [sdl.power.info](#sdlpowerinfo)
291
296
 
292
297
 
293
298
  ## sdl
@@ -428,6 +433,30 @@ If you need to know a window's width and height in pixels, you should use the `p
428
433
  You should be doing this always, since you don't know beforehand if your program will be running on a high-dpi system.
429
434
 
430
435
 
436
+ ### Event: 'displayAdd'
437
+
438
+ * `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
439
+
440
+ Fired when a display is added to the system.
441
+ Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
442
+
443
+
444
+ ### Event: 'displayRemove'
445
+
446
+ * `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
447
+
448
+ Fired when a display is removed from the system.
449
+ Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
450
+
451
+
452
+ ### Event: 'displayOrient'
453
+
454
+ * `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
455
+
456
+ Fired when a display changes orientation.
457
+ Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
458
+
459
+
431
460
  ### sdl.video.displays
432
461
 
433
462
  * `<object>[]`
@@ -1409,7 +1438,7 @@ String values used to represent the power level of a joystick device.
1409
1438
  | `'wired'` | `SDL_JOYSTICK_POWER_WIRED` |
1410
1439
  | `'max'` | `SDL_JOYSTICK_POWER_MAX` |
1411
1440
 
1412
- <a id="joystick-event-device-add"></a>
1441
+ <a id="joystick-event-deviceadd"></a>
1413
1442
 
1414
1443
  ### Event: 'deviceAdd'
1415
1444
 
@@ -1418,7 +1447,7 @@ String values used to represent the power level of a joystick device.
1418
1447
  Fired when a new joystick device becomes available.
1419
1448
  Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joystick devices.
1420
1449
 
1421
- <a id="joystick-event-device-remove"></a>
1450
+ <a id="joystick-event-deviceremove"></a>
1422
1451
 
1423
1452
  ### Event: 'deviceRemove'
1424
1453
 
@@ -1665,7 +1694,7 @@ const mappings = text.split('\n')
1665
1694
  sdl.controller.addMappings(mappings)
1666
1695
  ```
1667
1696
 
1668
- <a id="controller-event-device-add"></a>
1697
+ <a id="controller-event-deviceadd"></a>
1669
1698
 
1670
1699
  ### Event: 'deviceAdd'
1671
1700
 
@@ -1674,7 +1703,7 @@ sdl.controller.addMappings(mappings)
1674
1703
  Fired when a new controller device becomes available.
1675
1704
  Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of controller devices.
1676
1705
 
1677
- <a id="controller-event-device-remove"></a>
1706
+ <a id="controller-event-deviceremove"></a>
1678
1707
 
1679
1708
  ### Event: 'deviceRemove'
1680
1709
 
@@ -1989,7 +2018,7 @@ String values used to represent how audio samples are stored in a Buffer.
1989
2018
  | `'f32sys'` | `AUDIO_F32SYS` | 32-bit floating point samples in native byte order |
1990
2019
  | `'f32'` | `AUDIO_F32` | alias for `'f32lsb'` |
1991
2020
 
1992
- <a id="audio-event-device-add"></a>
2021
+ <a id="audio-event-deviceadd"></a>
1993
2022
 
1994
2023
  ### Event: 'deviceAdd'
1995
2024
 
@@ -1998,7 +2027,7 @@ String values used to represent how audio samples are stored in a Buffer.
1998
2027
  Fired when a new audio device becomes available.
1999
2028
  Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devices.
2000
2029
 
2001
- <a id="audio-event-device-remove"></a>
2030
+ <a id="audio-event-deviceremove"></a>
2002
2031
 
2003
2032
  ### Event: 'deviceRemove'
2004
2033
 
@@ -2323,6 +2352,18 @@ The current text value on the clipboard.
2323
2352
  Changes the text contents of the clipboard.
2324
2353
 
2325
2354
 
2355
+ ## sdl.power
2356
+
2357
+ ### sdl.power.info
2358
+
2359
+ * `<object>`
2360
+ * `state: <string>` One of `'unknown'`, `'noBattery'`, `'battery'`, `'charging'`, `'changed'`.
2361
+ * `seconds: <number | null>` Seconds of battery life left. Will be `null` if not running on battery, or if it can't be determinded.
2362
+ * `percent: <number | null>` Percentage of battery life left. Will be `null` if not running on battery, or if it can't be determinded.
2363
+
2364
+ The curent power state of the device.
2365
+
2366
+
2326
2367
  ## Building from source
2327
2368
 
2328
2369
  If there are no prebuilt binaries available for your platform, `@kmamal/sdl` will try to compile itself during installation.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.0",
2
+ "version": "0.8.3",
3
3
  "name": "@kmamal/sdl",
4
4
  "description": "SDL bindings for Node.js",
5
5
  "keywords": [
@@ -27,6 +27,8 @@
27
27
  "microphone",
28
28
  "mic",
29
29
  "clipboard",
30
+ "power",
31
+ "battery",
30
32
  "game"
31
33
  ],
32
34
  "license": "MIT",
@@ -7,7 +7,7 @@ const {
7
7
  const { EventsViaPoll } = require('../events/events-via-poll')
8
8
  const { ControllerInstance } = require('./controller-instance')
9
9
 
10
- Globals.controllerDevices = Bindings.joystick_getDevices(false)
10
+ Globals.controllerDevices = Bindings.joystick_getDevices()
11
11
  .filter(filterControllerDevice)
12
12
  for (const controllerDevice of Globals.controllerDevices) {
13
13
  makeControllerDevice(controllerDevice)
@@ -1,6 +1,7 @@
1
1
  const Bindings = require('../bindings')
2
2
  const Globals = require('../globals')
3
3
  const Enums = require('../enums')
4
+ const { video: videoModule } = require('../video')
4
5
  const { mapping } = require('../keyboard/key-mapping')
5
6
  const { joystick: joystickModule } = require('../joystick')
6
7
  const { controller: controllerModule } = require('../controller')
@@ -77,6 +78,24 @@ const poll = () => {
77
78
  event.type = Enums.eventTypeNames[type]
78
79
 
79
80
  switch (family) {
81
+ case Enums.eventFamily.display: {
82
+ const { displayIndex } = event
83
+ delete event.displayIndex
84
+
85
+ const oldDisplays = Globals.displays
86
+ Globals.displays = Bindings.video_getDisplays()
87
+ for (const display of Globals.displays) {
88
+ display.format = Enums.pixelFormatNames[display.format]
89
+ }
90
+ const newDisplays = Globals.displays
91
+
92
+ event.display = event.type === Enums.eventType.displayRemove
93
+ ? oldDisplays[displayIndex]
94
+ : newDisplays[displayIndex]
95
+
96
+ videoModule.emit(event.type, event)
97
+ } break
98
+
80
99
  case Enums.eventFamily.window: {
81
100
  const { windowId } = event
82
101
  delete event.windowId
@@ -1,5 +1,6 @@
1
1
 
2
2
  module.exports = {
3
+ displays: [],
3
4
  windows: {
4
5
  all: new Map(),
5
6
  focused: null,
@@ -12,6 +12,7 @@ const { joystick } = require('./joystick')
12
12
  const { controller } = require('./controller')
13
13
  const { audio } = require('./audio')
14
14
  const { clipboard } = require('./clipboard')
15
+ const { power } = require('./power')
15
16
 
16
17
  require('./events')
17
18
  require('./cleanup')
@@ -25,4 +26,5 @@ module.exports = {
25
26
  controller,
26
27
  audio,
27
28
  clipboard,
29
+ power,
28
30
  }
@@ -4,7 +4,7 @@ const { make: makeJoystickDevice } = require('./device')
4
4
  const { EventsViaPoll } = require('../events/events-via-poll')
5
5
  const { JoystickInstance } = require('./joystick-instance')
6
6
 
7
- Globals.joystickDevices = Bindings.joystick_getDevices(false)
7
+ Globals.joystickDevices = Bindings.joystick_getDevices()
8
8
  for (const joystickDevice of Globals.joystickDevices) {
9
9
  makeJoystickDevice(joystickDevice)
10
10
  }
@@ -0,0 +1,14 @@
1
+ const Bindings = require('../bindings')
2
+ const Enums = require('../enums')
3
+
4
+ const power = {
5
+ get info () {
6
+ const info = Bindings.power_getInfo()
7
+ if (info.seconds === -1) { info.seconds = null }
8
+ if (info.percent === -1) { info.percent = null }
9
+ info.state = Enums.powerStateNames[info.state]
10
+ return info
11
+ },
12
+ }
13
+
14
+ module.exports = { power }
@@ -1,22 +1,27 @@
1
1
  const Bindings = require('../bindings')
2
2
  const Globals = require('../globals')
3
3
  const Enums = require('../enums')
4
+ const { EventsViaPoll } = require('../events/events-via-poll')
4
5
  const { Window } = require('./window')
5
6
 
6
- const video = {
7
- get displays () {
8
- const displays = Bindings.video_getDisplays()
9
- for (const display of displays) {
10
- display.format = Enums.pixelFormatNames[display.format]
11
- }
12
- return displays
13
- },
7
+ Globals.displays = Bindings.video_getDisplays()
8
+ for (const display of Globals.displays) {
9
+ display.format = Enums.pixelFormatNames[display.format]
10
+ }
14
11
 
15
- get windows () { return [ ...Globals.windows.all.values() ] },
16
- get focused () { return Globals.windows.focused },
17
- get hovered () { return Globals.windows.hovered },
18
12
 
19
- createWindow: (options) => new Window(options),
20
- }
13
+ const validEvents = [ 'displayAdd', 'displayRemove', 'displayOrient' ]
14
+
15
+ const video = new class extends EventsViaPoll {
16
+ constructor () { super(validEvents) }
17
+
18
+ get displays () { return Globals.displays }
19
+
20
+ get windows () { return [ ...Globals.windows.all.values() ] }
21
+ get focused () { return Globals.windows.focused }
22
+ get hovered () { return Globals.windows.hovered }
23
+
24
+ createWindow (options) { return new Window(options) }
25
+ }()
21
26
 
22
27
  module.exports = { video }
@@ -221,6 +221,15 @@ getEnums(napi_env env, napi_callback_info info)
221
221
  CALL_NAPI(napi_set_property, result, key, value);
222
222
  }
223
223
 
224
+ {
225
+ SdlHelpers::Variant power_states;
226
+ CALL_SDL_HELPER(enum_getPowerStates, power_states);
227
+
228
+ CALL_NAPI(fromVariant, power_states, &value);
229
+ CALL_NAPI(napi_create_string_latin1, "powerState", 10, &key);
230
+ CALL_NAPI(napi_set_property, result, key, value);
231
+ }
232
+
224
233
  cleanup:
225
234
  return result;
226
235
  }
@@ -1469,6 +1478,21 @@ clipboard_setText(napi_env env, napi_callback_info info)
1469
1478
  }
1470
1479
 
1471
1480
 
1481
+ napi_value
1482
+ power_getInfo(napi_env env, napi_callback_info info)
1483
+ {
1484
+ napi_value result = nullptr;
1485
+
1486
+ SdlHelpers::Variant power;
1487
+ CALL_SDL_HELPER(power_getInfo, power);
1488
+
1489
+ CALL_NAPI(fromVariant, power, &result);
1490
+
1491
+ cleanup:
1492
+ return result;
1493
+ }
1494
+
1495
+
1472
1496
  napi_value
1473
1497
  cleanup(napi_env env, napi_callback_info info)
1474
1498
  {
@@ -1536,10 +1560,11 @@ init (napi_env env, napi_value exports)
1536
1560
  { "audio_clearQueue", NULL, audio_clearQueue, NULL, NULL, NULL, napi_enumerable, NULL },
1537
1561
  { "clipboard_getText", NULL, clipboard_getText, NULL, NULL, NULL, napi_enumerable, NULL },
1538
1562
  { "clipboard_setText", NULL, clipboard_setText, NULL, NULL, NULL, napi_enumerable, NULL },
1563
+ { "power_getInfo", NULL, power_getInfo, NULL, NULL, NULL, napi_enumerable, NULL },
1539
1564
  { "cleanup", NULL, cleanup, NULL, NULL, NULL, napi_enumerable, NULL }
1540
1565
  };
1541
1566
 
1542
- CALL_NAPI(napi_define_properties, exports, 54, desc);
1567
+ CALL_NAPI(napi_define_properties, exports, 55, desc);
1543
1568
 
1544
1569
  cleanup:
1545
1570
  return exports;
@@ -120,6 +120,7 @@ ErrorMessage::
120
120
 
121
121
 
122
122
  enum class EventFamily {
123
+ DISPLAY,
123
124
  WINDOW,
124
125
  KEYBOARD,
125
126
  MOUSE,
@@ -137,6 +138,7 @@ enum_getEventFamilies (Variant & families)
137
138
  {
138
139
  MAKE_MAP(families);
139
140
 
141
+ SET_NUM(families, "display", (int) EventFamily::DISPLAY);
140
142
  SET_NUM(families, "window", (int) EventFamily::WINDOW);
141
143
  SET_NUM(families, "keyboard", (int) EventFamily::KEYBOARD);
142
144
  SET_NUM(families, "mouse", (int) EventFamily::MOUSE);
@@ -154,6 +156,9 @@ enum_getEventFamilies (Variant & families)
154
156
 
155
157
  enum class EventType {
156
158
  QUIT,
159
+ DISPLAY_ADD,
160
+ DISPLAY_REMOVE,
161
+ DISPLAY_ORIENT,
157
162
  SHOW,
158
163
  HIDE,
159
164
  EXPOSE,
@@ -195,6 +200,9 @@ enum_getEventTypes (Variant & types)
195
200
  MAKE_MAP(types);
196
201
 
197
202
  SET_NUM(types, "quit", (int) EventType::QUIT);
203
+ SET_NUM(types, "displayAdd", (int) EventType::DISPLAY_ADD);
204
+ SET_NUM(types, "displayRemove", (int) EventType::DISPLAY_REMOVE);
205
+ SET_NUM(types, "displayOrient", (int) EventType::DISPLAY_ORIENT);
198
206
  SET_NUM(types, "show", (int) EventType::SHOW);
199
207
  SET_NUM(types, "hide", (int) EventType::HIDE);
200
208
  SET_NUM(types, "expose", (int) EventType::EXPOSE);
@@ -686,6 +694,21 @@ enum_getControllerButtons (Variant & buttons)
686
694
  return nullptr;
687
695
  }
688
696
 
697
+ ErrorMessage *
698
+ enum_getPowerStates (Variant & states)
699
+ {
700
+ MAKE_MAP(states);
701
+
702
+ SET_NUM(states, "unknown", SDL_POWERSTATE_UNKNOWN);
703
+ SET_NUM(states, "noBattery", SDL_POWERSTATE_NO_BATTERY);
704
+ SET_NUM(states, "battery", SDL_POWERSTATE_ON_BATTERY);
705
+ SET_NUM(states, "charging", SDL_POWERSTATE_CHARGING);
706
+ SET_NUM(states, "charged", SDL_POWERSTATE_CHARGED);
707
+
708
+ return nullptr;
709
+ }
710
+
711
+
689
712
 
690
713
  ErrorMessage *
691
714
  initialize (Variant & object)
@@ -990,6 +1013,18 @@ packageEvent (const SDL_Event & event, Variant & object)
990
1013
 
991
1014
  Variant value;
992
1015
  switch (event.type) {
1016
+ case SDL_DISPLAYEVENT: {
1017
+ SET_NUM(object, "family", (int) EventFamily::DISPLAY);
1018
+ SET_NUM(object, "displayIndex", event.display.display);
1019
+
1020
+ switch (event.display.event) {
1021
+ case SDL_DISPLAYEVENT_CONNECTED: { SET_NUM(object, "type", (int) EventType::DISPLAY_ADD); break; }
1022
+ case SDL_DISPLAYEVENT_DISCONNECTED: { SET_NUM(object, "type", (int) EventType::DISPLAY_REMOVE); break; }
1023
+ case SDL_DISPLAYEVENT_ORIENTATION: { SET_NUM(object, "type", (int) EventType::DISPLAY_ORIENT); break; }
1024
+ }
1025
+ break;
1026
+ }
1027
+
993
1028
  case SDL_WINDOWEVENT: {
994
1029
  SET_NUM(object, "family", (int) EventFamily::WINDOW);
995
1030
  SET_NUM(object, "windowId", event.window.windowID);
@@ -2414,6 +2449,22 @@ clipboard_setText (const char * text)
2414
2449
  }
2415
2450
 
2416
2451
 
2452
+ ErrorMessage *
2453
+ power_getInfo (Variant & info)
2454
+ {
2455
+ int seconds, percent;
2456
+ SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
2457
+
2458
+ MAKE_MAP(info);
2459
+
2460
+ SET_NUM(info, "state", (int) state);
2461
+ SET_NUM(info, "seconds", seconds);
2462
+ SET_NUM(info, "percent", percent);
2463
+
2464
+ return nullptr;
2465
+ }
2466
+
2467
+
2417
2468
  ErrorMessage *
2418
2469
  cleanup ()
2419
2470
  {
@@ -44,6 +44,7 @@ ErrorMessage * enum_getPowerLevels (Variant & object);
44
44
  ErrorMessage * enum_getJoystickTypes (Variant & object);
45
45
  ErrorMessage * enum_getControllerAxes (Variant & object);
46
46
  ErrorMessage * enum_getControllerButtons (Variant & object);
47
+ ErrorMessage * enum_getPowerStates (Variant & object);
47
48
 
48
49
  ErrorMessage * initialize (Variant & object);
49
50
  ErrorMessage * cleanup ();
@@ -166,6 +167,8 @@ ErrorMessage * audio_dequeue (int audio_id, void * dst, int size, int * num);
166
167
  ErrorMessage * clipboard_getText (const char ** text);
167
168
  ErrorMessage * clipboard_setText (const char * text);
168
169
 
170
+ ErrorMessage * power_getInfo (Variant & info);
171
+
169
172
  } // namespace
170
173
 
171
174
  #endif // _SDL_H_
@@ -5,6 +5,20 @@ export namespace Events {
5
5
 
6
6
  type PreventCallback = () => void
7
7
 
8
+ namespace Display {
9
+
10
+ interface DisplayEvent extends BaseEvent {
11
+ readonly display: Sdl.Video.Display
12
+ }
13
+
14
+ interface Add extends DisplayEvent { readonly type: 'deviceAdd' }
15
+ interface Remove extends DisplayEvent { readonly type: 'deviceRemove' }
16
+ interface Orient extends DisplayEvent { readonly type: 'deviceOrient' }
17
+
18
+ type Any = Add | Remove | Orient
19
+
20
+ }
21
+
8
22
  namespace Window {
9
23
 
10
24
  interface WindowEvent extends BaseEvent {}
@@ -119,6 +133,7 @@ export namespace Events {
119
133
  | DropText
120
134
  | DropFile
121
135
  | DropComplete
136
+
122
137
  }
123
138
 
124
139
  namespace Joystick {
@@ -435,6 +450,11 @@ export namespace Sdl {
435
450
  }
436
451
 
437
452
  interface Module {
453
+ on (event: 'displayAdd', listener: (event: Events.Display.Add) => void): this
454
+ on (event: 'displayRemove', listener: (event: Events.Display.Remove) => void): this
455
+ on (event: 'displayOrient', listener: (event: Events.Display.Orient) => void): this
456
+ on (event: '*', listener: (event: Events.Display.Any) => void): this
457
+
438
458
  readonly displays: Display[]
439
459
 
440
460
  readonly windows: Window[]
@@ -1060,6 +1080,27 @@ export namespace Sdl {
1060
1080
 
1061
1081
  }
1062
1082
 
1083
+ namespace Power {
1084
+
1085
+ type PowerState
1086
+ = 'unknown'
1087
+ | 'noBattery'
1088
+ | 'battery'
1089
+ | 'charging'
1090
+ | 'charged'
1091
+
1092
+ interface PowerInfo {
1093
+ state: PowerState
1094
+ seconds: number | null
1095
+ percent: number | null
1096
+ }
1097
+
1098
+ interface Module {
1099
+ readonly info: PowerInfo
1100
+ }
1101
+
1102
+ }
1103
+
1063
1104
  interface Module {
1064
1105
  readonly info: Info
1065
1106
  readonly video: Video.Module
@@ -1069,7 +1110,9 @@ export namespace Sdl {
1069
1110
  readonly controller: Controller.Module
1070
1111
  readonly audio: Audio.Module
1071
1112
  readonly clipboard: Clipboard.Module
1113
+ readonly power: Power.Module
1072
1114
  }
1115
+
1073
1116
  }
1074
1117
 
1075
1118
  declare const sdl: Sdl.Module