@kmamal/sdl 0.9.5 → 0.9.6-1
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 +111 -103
- package/binding.gyp +25 -5
- package/package.json +7 -4
- package/src/javascript/audio/audio-instance.js +9 -6
- package/src/javascript/cleanup.js +1 -1
- package/src/javascript/clipboard/index.js +2 -1
- package/src/javascript/controller/controller-instance.js +7 -4
- package/src/javascript/enums.js +1 -9
- package/src/javascript/events/index.js +293 -305
- package/src/javascript/index.js +1 -1
- package/src/javascript/joystick/device.js +0 -3
- package/src/javascript/joystick/joystick-instance.js +8 -6
- package/src/javascript/keyboard/index.js +3 -3
- package/src/javascript/keyboard/key-mapping.js +14 -6
- package/src/javascript/mouse/index.js +14 -13
- package/src/javascript/power/index.js +1 -8
- package/src/javascript/sensor/sensor-instance.js +1 -5
- package/src/javascript/video/index.js +0 -5
- package/src/javascript/video/window.js +17 -16
- package/src/native/audio.cpp +178 -0
- package/src/native/audio.h +21 -0
- package/src/native/clipboard.cpp +45 -0
- package/src/native/clipboard.h +13 -0
- package/src/native/cocoa-global.h +8 -0
- package/src/native/cocoa-global.mm +8 -0
- package/src/native/cocoa-window.h +9 -4
- package/src/native/cocoa-window.mm +6 -9
- package/src/native/controller.cpp +160 -0
- package/src/native/controller.h +22 -0
- package/src/native/enums.cpp +339 -0
- package/src/native/enums.h +12 -0
- package/src/native/events.cpp +391 -0
- package/src/native/events.h +70 -0
- package/src/native/global.cpp +361 -0
- package/src/native/global.h +15 -0
- package/src/native/joystick.cpp +394 -0
- package/src/native/joystick.h +29 -0
- package/src/native/keyboard.cpp +51 -0
- package/src/native/keyboard.h +18 -0
- package/src/native/module.cpp +98 -0
- package/src/native/mouse.cpp +186 -0
- package/src/native/mouse.h +21 -0
- package/src/native/power.cpp +23 -0
- package/src/native/power.h +17 -0
- package/src/native/sensor.cpp +124 -0
- package/src/native/sensor.h +21 -0
- package/src/native/video.cpp +95 -0
- package/src/native/video.h +16 -0
- package/src/native/window.cpp +755 -0
- package/src/native/window.h +29 -0
- package/src/types/index.d.ts +91 -49
- package/scripts/test.mjs +0 -12
- package/src/native/asprintf.c +0 -47
- package/src/native/asprintf.h +0 -37
- package/src/native/binding.cpp +0 -1680
- package/src/native/sdl-helpers.cpp +0 -2617
- package/src/native/sdl-helpers.h +0 -182
package/README.md
CHANGED
|
@@ -118,8 +118,8 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
|
|
|
118
118
|
* [sdl.info](#sdlinfo)
|
|
119
119
|
* [sdl.video](#sdlvideo)
|
|
120
120
|
* [Image data](#image-data)
|
|
121
|
+
* [High-DPI](#high-dpi)
|
|
121
122
|
* [Pixel formats](#pixel-formats)
|
|
122
|
-
* [High-DPI](#highdpi)
|
|
123
123
|
* [Event: 'displayAdd'](#event-displayadd)
|
|
124
124
|
* [Event: 'displayRemove'](#event-displayremove)
|
|
125
125
|
* [Event: 'displayOrient'](#event-displayorient)
|
|
@@ -207,21 +207,20 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
|
|
|
207
207
|
* [sdl.keyboard.getScancode(key)](#sdlkeyboardgetscancodekey)
|
|
208
208
|
* [sdl.keyboard.getState()](#sdlkeyboardgetstate)
|
|
209
209
|
* [sdl.mouse](#sdlmouse)
|
|
210
|
-
* [Mouse cursors](#mouse-cursors)
|
|
211
210
|
* [Enum: BUTTON](#enum-button)
|
|
212
211
|
* [sdl.mouse.getButton(button)](#sdlmousegetbuttonbutton)
|
|
213
212
|
* [sdl.mouse.position](#sdlmouseposition)
|
|
214
213
|
* [sdl.mouse.setPosition(x, y)](#sdlmousesetpositionx-y)
|
|
215
214
|
* [sdl.mouse.setCursor(cursor)](#sdlmousesetcursorcursor)
|
|
215
|
+
* [sdl.mouse.resetCursor()](#sdlmouseresetcursor)
|
|
216
216
|
* [sdl.mouse.setCursorImage(width, height, stride, format, buffer, x, y)](#sdlmousesetcursorimagewidth-height-stride-format-buffer-x-y)
|
|
217
217
|
* [sdl.mouse.showCursor([show])](#sdlmouseshowcursorshow)
|
|
218
218
|
* [sdl.mouse.hideCursor()](#sdlmousehidecursor)
|
|
219
|
+
* [sdl.mouse.redrawCursor()](#sdlmouseredrawcursor)
|
|
219
220
|
* [sdl.mouse.capture([capture])](#sdlmousecapturecapture)
|
|
220
221
|
* [sdl.mouse.uncapture()](#sdlmouseuncapture)
|
|
221
222
|
* [sdl.joystick](#sdljoystick)
|
|
222
|
-
* [Joystick types](#joystick-types)
|
|
223
223
|
* [Hat positions](#hat-positions)
|
|
224
|
-
* [Power levels](#power-levels)
|
|
225
224
|
* [Event: 'deviceAdd'](#joystick-event-deviceadd)
|
|
226
225
|
* [Event: 'deviceRemove'](#joystick-event-deviceremove)
|
|
227
226
|
* [sdl.joystick.devices](#sdljoystickdevices)
|
|
@@ -242,6 +241,7 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
|
|
|
242
241
|
* [joystickInstance.hats](#joystickinstancehats)
|
|
243
242
|
* [joystickInstance.power](#joystickinstancepower)
|
|
244
243
|
* [joystickInstance.setPlayer(index)](#joystickinstancesetplayerindex)
|
|
244
|
+
* [joystickInstance.resetPlayer()](#joystickinstanceresetplayer)
|
|
245
245
|
* [joystickInstance.hasLed](#joystickinstancehasled)
|
|
246
246
|
* [joystickInstance.setLed(red, green, blue)](#joystickinstancesetledred-green-blue)
|
|
247
247
|
* [joystickInstance.hasRumble](#joystickinstancehasrumble)
|
|
@@ -271,6 +271,7 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
|
|
|
271
271
|
* [controllerInstance.buttons](#controllerinstancebuttons)
|
|
272
272
|
* [controllerInstance.power](#controllerinstancepower)
|
|
273
273
|
* [controllerInstance.setPlayer(index)](#controllerinstancesetplayerindex)
|
|
274
|
+
* [controllerInstance.resetPlayer()](#controllerinstanceresetplayer)
|
|
274
275
|
* [controllerInstance.hasLed](#controllerinstancehasled)
|
|
275
276
|
* [controllerInstance.setLed(red, green, blue)](#controllerinstancesetledred-green-blue)
|
|
276
277
|
* [controllerInstance.hasRumble](#controllerinstancehasrumble)
|
|
@@ -282,7 +283,7 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
|
|
|
282
283
|
* [controllerInstance.closed](#controllerinstanceclosed)
|
|
283
284
|
* [controllerInstance.close()](#controllerinstanceclose)
|
|
284
285
|
* [sdl.sensor](#sdlsensor)
|
|
285
|
-
* [sdl.sensor.STANDARD_GRAVITY](#
|
|
286
|
+
* [sdl.sensor.STANDARD_GRAVITY](#sdlsensorstandard_gravity)
|
|
286
287
|
* [sdl.sensor.devices](#sdlsensordevices)
|
|
287
288
|
* [sdl.sensor.openDevice(device)](#sdlsensoropendevicedevice)
|
|
288
289
|
* [class SensorInstance](#class-sensorinstance)
|
|
@@ -425,6 +426,14 @@ for (let i = 0; i < height; i++) {
|
|
|
425
426
|
window.render(width, height, stride, 'rgba32', buffer)
|
|
426
427
|
```
|
|
427
428
|
|
|
429
|
+
### High-DPI
|
|
430
|
+
|
|
431
|
+
On a high-dpi display, windows have more pixels that their `width` and `height` would indicate.
|
|
432
|
+
On such systems `width` and `height` (and all other measurements such as `x` and `y`) are in "points".
|
|
433
|
+
Points are abstract and don't have to correspond to pixels.
|
|
434
|
+
If you need to know a window's width and height in pixels, you should use the `pixelWidth` and `pixelHeight` properties.
|
|
435
|
+
You should be doing this always, since you don't know beforehand if your program will be running on a high-dpi system.
|
|
436
|
+
|
|
428
437
|
### Pixel formats
|
|
429
438
|
|
|
430
439
|
String values used to represent how the pixels of an image are stored in a Buffer.
|
|
@@ -469,15 +478,6 @@ String values used to represent how the pixels of an image are stored in a Buffe
|
|
|
469
478
|
| `'nv21'` | `SDL_PIXELFORMAT_NV21` | planar mode: Y + V/U interleaved (2 planes) |
|
|
470
479
|
|
|
471
480
|
|
|
472
|
-
### High-DPI
|
|
473
|
-
|
|
474
|
-
On a high-dpi display, windows have more pixels that their `width` and `height` would indicate.
|
|
475
|
-
On such systems `width` and `height` (and all other measurements such as `x` and `y`) are in "points".
|
|
476
|
-
Points are abstract and don't have to correspond to pixels.
|
|
477
|
-
If you need to know a window's width and height in pixels, you should use the `pixelWidth` and `pixelHeight` properties.
|
|
478
|
-
You should be doing this always, since you don't know beforehand if your program will be running on a high-dpi system.
|
|
479
|
-
|
|
480
|
-
|
|
481
481
|
### Event: 'displayAdd'
|
|
482
482
|
|
|
483
483
|
* `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
@@ -485,7 +485,6 @@ You should be doing this always, since you don't know beforehand if your program
|
|
|
485
485
|
Fired when a display is added to the system.
|
|
486
486
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
487
487
|
|
|
488
|
-
|
|
489
488
|
### Event: 'displayRemove'
|
|
490
489
|
|
|
491
490
|
* `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
@@ -493,7 +492,6 @@ Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
|
493
492
|
Fired when a display is removed from the system.
|
|
494
493
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
495
494
|
|
|
496
|
-
|
|
497
495
|
### Event: 'displayOrient'
|
|
498
496
|
|
|
499
497
|
* `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
@@ -1081,6 +1079,16 @@ Trying to handle text input by manually translating key presses to text is not a
|
|
|
1081
1079
|
It's better to let the OS handle all the text logic, and get the final text by handling the rasulting ([`'textInput'`](#event-textinput)) events.
|
|
1082
1080
|
|
|
1083
1081
|
|
|
1082
|
+
### Virtual keys
|
|
1083
|
+
|
|
1084
|
+
String values used to represent virtual keys in the context of the current keyboard mapping.
|
|
1085
|
+
Note that some keys do not correspond to any virtual key.
|
|
1086
|
+
A Key can be either one of the values below __or__ any unicode character.
|
|
1087
|
+
Keys that produce characters are represented by that character.
|
|
1088
|
+
All others are represented by one of these values:
|
|
1089
|
+
|
|
1090
|
+
`'&&'`, `'+/-'`, `'||'`, `'00'`, `'000'`, `'again'`, `'alt'`, `'altErase'`, `'app1'`, `'app2'`, `'application'`, `'audioFastForward'`, `'audioMute'`, `'audioNext'`, `'audioPlay'`, `'audioPrev'`, `'audioRewind'`, `'audioStop'`, `'back'`, `'backspace'`, `'binary'`, `'bookmarks'`, `'brightnessDown'`, `'brightnessUp'`, `'calculator'`, `'cancel'`, `'capsLock'`, `'clear'`, `'clearEntry'`, `'computer'`, `'copy'`, `'crSel'`, `'ctrl'`, `'currencySubUnit'`, `'currencyUnit'`, `'cut'`, `'decimal'`, `'decimalSeparator'`, `'delete'`, `'displaySwitch'`, `'down'`, `'eject'`, `'end'`, `'enter'`, `'escape'`, `'execute'`, `'exSel'`, `'f1'`, `'f2'`, `'f3'`, `'f4'`, `'f5'`, `'f6'`, `'f7'`, `'f8'`, `'f9'`, `'f10'`, `'f11'`, `'f12'`, `'f13'`, `'f14'`, `'f15'`, `'f16'`, `'f17'`, `'f18'`, `'f19'`, `'f20'`, `'f21'`, `'f22'`, `'f23'`, `'f24'`, `'find'`, `'forward'`, `'gui'`, `'help'`, `'hexadecimal'`, `'home'`, `'illumDown'`, `'illumToggle'`, `'illumUp'`, `'insert'`, `'left'`, `'mail'`, `'mediaSelect'`, `'memAdd'`, `'memClear'`, `'memDivide'`, `'memMultiply'`, `'memRecall'`, `'memStore'`, `'memSubtract'`, `'menu'`, `'modeSwitch'`, `'mute'`, `'numlock'`, `'octal'`, `'oper'`, `'out'`, `'pageDown'`, `'pageUp'`, `'paste'`, `'pause'`, `'power'`, `'printScreen'`, `'prior'`, `'refresh'`, `'return'`, `'right'`, `'scrollLock'`, `'search'`, `'select'`, `'separator'`, `'shift'`, `'sleep'`, `'space'`, `'stop'`, `'sysReq'`, `'tab'`, `'thousandsSeparator'`, `'undo'`, `'up'`, `'volumeDown'`, `'volumeUp'`, `'www'`, `'xor'`.
|
|
1091
|
+
|
|
1084
1092
|
### Enum: SCANCODE
|
|
1085
1093
|
|
|
1086
1094
|
Used to represent physical keys on the keyboard.
|
|
@@ -1092,7 +1100,6 @@ Values are based on the [USB usage page standard](https://www.usb.org/sites/defa
|
|
|
1092
1100
|
|
|
1093
1101
|
| Value | Corresponding `SDL_Scancode` | Comment |
|
|
1094
1102
|
| --- | --- | --- |
|
|
1095
|
-
| `sdl.keyboard.SCANCODE.UNKNOWN` | `SDL_SCANCODE_UNKNOWN` | value `0` |
|
|
1096
1103
|
| `sdl.keyboard.SCANCODE.A` | `SDL_SCANCODE_A` | |
|
|
1097
1104
|
| `sdl.keyboard.SCANCODE.B` | `SDL_SCANCODE_B` | |
|
|
1098
1105
|
| `sdl.keyboard.SCANCODE.C` | `SDL_SCANCODE_C` | |
|
|
@@ -1337,29 +1344,21 @@ Values are based on the [USB usage page standard](https://www.usb.org/sites/defa
|
|
|
1337
1344
|
| `sdl.keyboard.SCANCODE.AUDIOFASTFORWARD` | `SDL_SCANCODE_AUDIOFASTFORWARD` | |
|
|
1338
1345
|
</details>
|
|
1339
1346
|
|
|
1340
|
-
### Virtual keys
|
|
1341
|
-
|
|
1342
|
-
String values used to represent virtual keys in the context of the current keyboard mapping.
|
|
1343
|
-
Note that some keys do not correspond to any virtual key.
|
|
1344
|
-
A Key can be either one of the values below __or__ any unicode character.
|
|
1345
|
-
Keys that produce characters are represented by that character.
|
|
1346
|
-
All others are represented by one of these values:
|
|
1347
|
-
|
|
1348
|
-
`'&&'`, `'+/-'`, `'||'`, `'00'`, `'000'`, `'again'`, `'alt'`, `'altErase'`, `'app1'`, `'app2'`, `'application'`, `'audioFastForward'`, `'audioMute'`, `'audioNext'`, `'audioPlay'`, `'audioPrev'`, `'audioRewind'`, `'audioStop'`, `'back'`, `'backspace'`, `'binary'`, `'bookmarks'`, `'brightnessDown'`, `'brightnessUp'`, `'calculator'`, `'cancel'`, `'capsLock'`, `'clear'`, `'clearEntry'`, `'computer'`, `'copy'`, `'crSel'`, `'ctrl'`, `'currencySubUnit'`, `'currencyUnit'`, `'cut'`, `'decimal'`, `'decimalSeparator'`, `'delete'`, `'displaySwitch'`, `'down'`, `'eject'`, `'end'`, `'enter'`, `'escape'`, `'execute'`, `'exSel'`, `'f1'`, `'f2'`, `'f3'`, `'f4'`, `'f5'`, `'f6'`, `'f7'`, `'f8'`, `'f9'`, `'f10'`, `'f11'`, `'f12'`, `'f13'`, `'f14'`, `'f15'`, `'f16'`, `'f17'`, `'f18'`, `'f19'`, `'f20'`, `'f21'`, `'f22'`, `'f23'`, `'f24'`, `'find'`, `'forward'`, `'gui'`, `'help'`, `'hexadecimal'`, `'home'`, `'illumDown'`, `'illumToggle'`, `'illumUp'`, `'insert'`, `'left'`, `'mail'`, `'mediaSelect'`, `'memAdd'`, `'memClear'`, `'memDivide'`, `'memMultiply'`, `'memRecall'`, `'memStore'`, `'memSubtract'`, `'menu'`, `'modeSwitch'`, `'mute'`, `'numlock'`, `'octal'`, `'oper'`, `'out'`, `'pageDown'`, `'pageUp'`, `'paste'`, `'pause'`, `'power'`, `'printScreen'`, `'prior'`, `'refresh'`, `'return'`, `'right'`, `'scrollLock'`, `'search'`, `'select'`, `'separator'`, `'shift'`, `'sleep'`, `'space'`, `'stop'`, `'sysReq'`, `'tab'`, `'thousandsSeparator'`, `'undo'`, `'up'`, `'volumeDown'`, `'volumeUp'`, `'www'`, `'xor'`.
|
|
1349
|
-
|
|
1350
1347
|
### sdl.keyboard.getKey(scancode)
|
|
1351
1348
|
|
|
1352
1349
|
* `scancode: `[`<Scancode>`](#enum-scancode)
|
|
1353
1350
|
* Returns: [`<Key>`](#virtual-keys)`|<null>`
|
|
1354
1351
|
|
|
1355
1352
|
Maps a scancode to the corresponding key based on the current keyboard mapping.
|
|
1353
|
+
Retuns `null` if the scancode does not currespond to a key in the current mapping.
|
|
1356
1354
|
|
|
1357
1355
|
### sdl.keyboard.getScancode(key)
|
|
1358
1356
|
|
|
1359
1357
|
* `key: `[`<Key>`](#virtual-keys)
|
|
1360
|
-
* Returns: [`<Scancode>`](#enum-scancode)
|
|
1358
|
+
* Returns: [`<Scancode>`](#enum-scancode)`|<null>`
|
|
1361
1359
|
|
|
1362
1360
|
Maps a key to the corresponding scancode based on the current keyboard mapping.
|
|
1361
|
+
Retuns `null` if the key does not currespond to a scancode in the current mapping.
|
|
1363
1362
|
If multiple physical keys produce the same virtual key, then only the first one will be returned.
|
|
1364
1363
|
|
|
1365
1364
|
### sdl.keyboard.getState()
|
|
@@ -1372,25 +1371,6 @@ The values will be `true` for keys that are pressed and `false` otherwise.
|
|
|
1372
1371
|
|
|
1373
1372
|
## sdl.mouse
|
|
1374
1373
|
|
|
1375
|
-
### Mouse cursors
|
|
1376
|
-
|
|
1377
|
-
String values used to represent the types of cursors available on most systems.
|
|
1378
|
-
|
|
1379
|
-
| Value | Corresponding `SDL_SystemCursor` | Description |
|
|
1380
|
-
| --- | --- | --- |
|
|
1381
|
-
| `'arrow'` | `SDL_SYSTEM_CURSOR_ARROW` | arrow |
|
|
1382
|
-
| `'ibeam'` | `SDL_SYSTEM_CURSOR_IBEAM` | i-beam |
|
|
1383
|
-
| `'wait'` | `SDL_SYSTEM_CURSOR_WAIT` | wait |
|
|
1384
|
-
| `'crosshair'` | `SDL_SYSTEM_CURSOR_CROSSHAIR` | crosshair |
|
|
1385
|
-
| `'waitarrow'` | `SDL_SYSTEM_CURSOR_WAITARROW` | small wait cursor (or wait if not available) |
|
|
1386
|
-
| `'sizenwse'` | `SDL_SYSTEM_CURSOR_SIZENWSE` | double arrow pointing northwest and southeast |
|
|
1387
|
-
| `'sizenesw'` | `SDL_SYSTEM_CURSOR_SIZENESW` | double arrow pointing northeast and southwest |
|
|
1388
|
-
| `'sizewe'` | `SDL_SYSTEM_CURSOR_SIZEWE` | double arrow pointing west and east |
|
|
1389
|
-
| `'sizens'` | `SDL_SYSTEM_CURSOR_SIZENS` | double arrow pointing north and south |
|
|
1390
|
-
| `'sizeall'` | `SDL_SYSTEM_CURSOR_SIZEALL` | four pointed arrow pointing north, south, east, and west |
|
|
1391
|
-
| `'no'` | `SDL_SYSTEM_CURSOR_NO` | slashed circle or crossbones |
|
|
1392
|
-
| `'hand'` | `SDL_SYSTEM_CURSOR_HAND` | hand |
|
|
1393
|
-
|
|
1394
1374
|
### Enum: BUTTON
|
|
1395
1375
|
|
|
1396
1376
|
Used to represent the buttons on a mouse.
|
|
@@ -1426,10 +1406,31 @@ Moves the mouse to the specified position.
|
|
|
1426
1406
|
|
|
1427
1407
|
### sdl.mouse.setCursor(cursor)
|
|
1428
1408
|
|
|
1429
|
-
* `cursor:
|
|
1409
|
+
* `cursor: <MouseCursor>` The icon to use for the cursor.
|
|
1430
1410
|
|
|
1431
1411
|
Changes the icon that is displayed for the mouse cursor.
|
|
1432
1412
|
|
|
1413
|
+
Possible values for `cursor` are:
|
|
1414
|
+
|
|
1415
|
+
| Value | Corresponding `SDL_SystemCursor` | Description |
|
|
1416
|
+
| --- | --- | --- |
|
|
1417
|
+
| `'arrow'` | `SDL_SYSTEM_CURSOR_ARROW` | arrow |
|
|
1418
|
+
| `'ibeam'` | `SDL_SYSTEM_CURSOR_IBEAM` | i-beam |
|
|
1419
|
+
| `'wait'` | `SDL_SYSTEM_CURSOR_WAIT` | wait |
|
|
1420
|
+
| `'crosshair'` | `SDL_SYSTEM_CURSOR_CROSSHAIR` | crosshair |
|
|
1421
|
+
| `'waitarrow'` | `SDL_SYSTEM_CURSOR_WAITARROW` | small wait cursor (or wait if not available) |
|
|
1422
|
+
| `'sizenwse'` | `SDL_SYSTEM_CURSOR_SIZENWSE` | double arrow pointing northwest and southeast |
|
|
1423
|
+
| `'sizenesw'` | `SDL_SYSTEM_CURSOR_SIZENESW` | double arrow pointing northeast and southwest |
|
|
1424
|
+
| `'sizewe'` | `SDL_SYSTEM_CURSOR_SIZEWE` | double arrow pointing west and east |
|
|
1425
|
+
| `'sizens'` | `SDL_SYSTEM_CURSOR_SIZENS` | double arrow pointing north and south |
|
|
1426
|
+
| `'sizeall'` | `SDL_SYSTEM_CURSOR_SIZEALL` | four pointed arrow pointing north, south, east, and west |
|
|
1427
|
+
| `'no'` | `SDL_SYSTEM_CURSOR_NO` | slashed circle or crossbones |
|
|
1428
|
+
| `'hand'` | `SDL_SYSTEM_CURSOR_HAND` | hand |
|
|
1429
|
+
|
|
1430
|
+
### sdl.mouse.resetCursor()
|
|
1431
|
+
|
|
1432
|
+
Switched back to the default cursor.
|
|
1433
|
+
|
|
1433
1434
|
### sdl.mouse.setCursorImage(width, height, stride, format, buffer, x, y)
|
|
1434
1435
|
|
|
1435
1436
|
* `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to use as a cursor.
|
|
@@ -1447,7 +1448,11 @@ Changes the visibility of the mouse cursor.
|
|
|
1447
1448
|
|
|
1448
1449
|
### sdl.mouse.hideCursor()
|
|
1449
1450
|
|
|
1450
|
-
Equivalent to [`sdl.mouse.showCursor
|
|
1451
|
+
Equivalent to [`sdl.mouse.showCursor
|
|
1452
|
+
|
|
1453
|
+
### sdl.mouse.redrawCursor()
|
|
1454
|
+
|
|
1455
|
+
Forces a cursor redraw.
|
|
1451
1456
|
|
|
1452
1457
|
### sdl.mouse.capture([capture])
|
|
1453
1458
|
|
|
@@ -1462,28 +1467,11 @@ Equivalent to [`sdl.mouse.capture(false)`](#sdlmousecapturecapture).
|
|
|
1462
1467
|
|
|
1463
1468
|
## sdl.joystick
|
|
1464
1469
|
|
|
1465
|
-
### Joystick types
|
|
1466
|
-
|
|
1467
|
-
String values used to represent the type of a joystick device.
|
|
1468
|
-
|
|
1469
|
-
| Value | Corresponding `SDL_JoystickType` |
|
|
1470
|
-
| --- | --- |
|
|
1471
|
-
| `'unknown'` | `SDL_JOYSTICK_TYPE_UNKNOWN` |
|
|
1472
|
-
| `'gamecontroller'` | `SDL_JOYSTICK_TYPE_GAMECONTROLLER` |
|
|
1473
|
-
| `'wheel'` | `SDL_JOYSTICK_TYPE_WHEEL` |
|
|
1474
|
-
| `'arcadestick'` | `SDL_JOYSTICK_TYPE_ARCADE_STICK` |
|
|
1475
|
-
| `'flightstick'` | `SDL_JOYSTICK_TYPE_FLIGHT_STICK` |
|
|
1476
|
-
| `'dancepad'` | `SDL_JOYSTICK_TYPE_DANCE_PAD` |
|
|
1477
|
-
| `'guitar'` | `SDL_JOYSTICK_TYPE_GUITAR` |
|
|
1478
|
-
| `'drumkit'` | `SDL_JOYSTICK_TYPE_DRUM_KIT` |
|
|
1479
|
-
| `'arcadepad'` | `SDL_JOYSTICK_TYPE_ARCADE_PAD` |
|
|
1480
|
-
| `'throttle'` | `SDL_JOYSTICK_TYPE_THROTTLE` |
|
|
1481
|
-
|
|
1482
1470
|
### Hat positions
|
|
1483
1471
|
|
|
1484
1472
|
String values used to represent the positions of a joystick hat
|
|
1485
1473
|
|
|
1486
|
-
| Value | Corresponding
|
|
1474
|
+
| Value | Corresponding `SDL_HAT_*` |
|
|
1487
1475
|
| --- | --- |
|
|
1488
1476
|
| `'centered'` | `SDL_HAT_CENTERED` |
|
|
1489
1477
|
| `'up'` | `SDL_HAT_UP` |
|
|
@@ -1495,20 +1483,6 @@ String values used to represent the positions of a joystick hat
|
|
|
1495
1483
|
| `'leftup'` | `SDL_HAT_LEFTUP` |
|
|
1496
1484
|
| `'leftdown'` | `SDL_HAT_LEFTDOWN` |
|
|
1497
1485
|
|
|
1498
|
-
### Power levels
|
|
1499
|
-
|
|
1500
|
-
String values used to represent the power level of a joystick device.
|
|
1501
|
-
|
|
1502
|
-
| Value | Corresponding `SDL_JoystickPowerLevel` |
|
|
1503
|
-
| --- | --- |
|
|
1504
|
-
| `'unknown'` | `SDL_JOYSTICK_POWER_UNKNOWN` |
|
|
1505
|
-
| `'empty'` | `SDL_JOYSTICK_POWER_EMPTY` |
|
|
1506
|
-
| `'low'` | `SDL_JOYSTICK_POWER_LOW` |
|
|
1507
|
-
| `'medium'` | `SDL_JOYSTICK_POWER_MEDIUM` |
|
|
1508
|
-
| `'full'` | `SDL_JOYSTICK_POWER_FULL` |
|
|
1509
|
-
| `'wired'` | `SDL_JOYSTICK_POWER_WIRED` |
|
|
1510
|
-
| `'max'` | `SDL_JOYSTICK_POWER_MAX` |
|
|
1511
|
-
|
|
1512
1486
|
<a id="joystick-event-deviceadd"></a>
|
|
1513
1487
|
|
|
1514
1488
|
### Event: 'deviceAdd'
|
|
@@ -1532,16 +1506,31 @@ When this event is emitted, all instances that were opened from the removed devi
|
|
|
1532
1506
|
|
|
1533
1507
|
* `<object>[]`
|
|
1534
1508
|
* `id: <number>` The unique id for the device.
|
|
1535
|
-
* `type
|
|
1509
|
+
* `type: <JoystickType>` The type of the device.
|
|
1536
1510
|
* `name: <string>` The name of the device.
|
|
1537
1511
|
* `path: <string>` The implementation dependent path of the device.
|
|
1538
1512
|
* `guid: <string>` The GUID of the device.
|
|
1539
|
-
* `vendor: <number>` The USB vendor ID of the device.
|
|
1540
|
-
* `product: <number>` The USB product ID of the device.
|
|
1541
|
-
* `version: <number>` The USB product version of the device.
|
|
1542
|
-
* `player: <number>` The player index for the device.
|
|
1513
|
+
* `vendor: <number>|<null>` The USB vendor ID of the device. Will be `null` if it can't be determined.
|
|
1514
|
+
* `product: <number>|<null>` The USB product ID of the device. Will be `null` if it can't be determined.
|
|
1515
|
+
* `version: <number>|<null>` The USB product version of the device. Will be `null` if it can't be determined.
|
|
1516
|
+
* `player: <number>|<null>` The player index for the device. Will be `null` if it can't be determined.
|
|
1543
1517
|
|
|
1544
1518
|
A list of all the detected joystick devices.
|
|
1519
|
+
|
|
1520
|
+
Possible values for `type` are:
|
|
1521
|
+
|
|
1522
|
+
| Value | Corresponding `SDL_JoystickType` |
|
|
1523
|
+
| --- | --- |
|
|
1524
|
+
| `'gamecontroller'` | `SDL_JOYSTICK_TYPE_GAMECONTROLLER` |
|
|
1525
|
+
| `'wheel'` | `SDL_JOYSTICK_TYPE_WHEEL` |
|
|
1526
|
+
| `'arcadestick'` | `SDL_JOYSTICK_TYPE_ARCADE_STICK` |
|
|
1527
|
+
| `'flightstick'` | `SDL_JOYSTICK_TYPE_FLIGHT_STICK` |
|
|
1528
|
+
| `'dancepad'` | `SDL_JOYSTICK_TYPE_DANCE_PAD` |
|
|
1529
|
+
| `'guitar'` | `SDL_JOYSTICK_TYPE_GUITAR` |
|
|
1530
|
+
| `'drumkit'` | `SDL_JOYSTICK_TYPE_DRUM_KIT` |
|
|
1531
|
+
| `'arcadepad'` | `SDL_JOYSTICK_TYPE_ARCADE_PAD` |
|
|
1532
|
+
| `'throttle'` | `SDL_JOYSTICK_TYPE_THROTTLE` |
|
|
1533
|
+
|
|
1545
1534
|
Sample output:
|
|
1546
1535
|
|
|
1547
1536
|
```js
|
|
@@ -1627,9 +1616,9 @@ The [device](#sdljoystickdevices) from which this instance was opened.
|
|
|
1627
1616
|
|
|
1628
1617
|
### joystickInstance.firmwareVersion
|
|
1629
1618
|
|
|
1630
|
-
* `<number>`
|
|
1619
|
+
* `<number>|<null>`
|
|
1631
1620
|
|
|
1632
|
-
The joystick's firmware version
|
|
1621
|
+
The joystick's firmware version, or `null` if it's not available..
|
|
1633
1622
|
|
|
1634
1623
|
### joystickInstance.serialNumber
|
|
1635
1624
|
|
|
@@ -1668,9 +1657,20 @@ An array of values, each corresponding to the position of one of the joystick's
|
|
|
1668
1657
|
|
|
1669
1658
|
### joystickInstance.power
|
|
1670
1659
|
|
|
1671
|
-
*
|
|
1660
|
+
* `<PowerLevel>|<null>`
|
|
1661
|
+
|
|
1662
|
+
The current power level of the joystick device, or `null` if it is unknown.
|
|
1663
|
+
|
|
1664
|
+
Possible values are:
|
|
1672
1665
|
|
|
1673
|
-
|
|
1666
|
+
| Value | Corresponding `SDL_JoystickPowerLevel` |
|
|
1667
|
+
| --- | --- |
|
|
1668
|
+
| `'empty'` | `SDL_JOYSTICK_POWER_EMPTY` |
|
|
1669
|
+
| `'low'` | `SDL_JOYSTICK_POWER_LOW` |
|
|
1670
|
+
| `'medium'` | `SDL_JOYSTICK_POWER_MEDIUM` |
|
|
1671
|
+
| `'full'` | `SDL_JOYSTICK_POWER_FULL` |
|
|
1672
|
+
| `'wired'` | `SDL_JOYSTICK_POWER_WIRED` |
|
|
1673
|
+
| `'max'` | `SDL_JOYSTICK_POWER_MAX` |
|
|
1674
1674
|
|
|
1675
1675
|
### joystickInstance.setPlayer(index)
|
|
1676
1676
|
|
|
@@ -1678,6 +1678,10 @@ The current power level of the joystick device.
|
|
|
1678
1678
|
|
|
1679
1679
|
Sets the player index of this joystick.
|
|
1680
1680
|
|
|
1681
|
+
### joystickInstance.resetPlayer()
|
|
1682
|
+
|
|
1683
|
+
Clears player assignment and player led.
|
|
1684
|
+
|
|
1681
1685
|
### joystickInstance.hasLed
|
|
1682
1686
|
|
|
1683
1687
|
* `<boolean>`
|
|
@@ -1798,10 +1802,10 @@ This can cause already opened controller instances to be [remapped](#event-remap
|
|
|
1798
1802
|
* `name: <string>` The name of the device.
|
|
1799
1803
|
* `path: <string>` The implementation dependent path of the device.
|
|
1800
1804
|
* `guid: <string>` The GUID of the device.
|
|
1801
|
-
* `vendor: <number>` The USB vendor ID of the device.
|
|
1802
|
-
* `product: <number>` The USB product ID of the device.
|
|
1803
|
-
* `version: <number>` The USB product version of the device.
|
|
1804
|
-
* `player: <number>` The player index for the device.
|
|
1805
|
+
* `vendor: <number>|<null>` The USB vendor ID of the device. Will be `null` if it can't be determined.
|
|
1806
|
+
* `product: <number>|<null>` The USB product ID of the device. Will be `null` if it can't be determined.
|
|
1807
|
+
* `version: <number>|<null>` The USB product version of the device. Will be `null` if it can't be determined.
|
|
1808
|
+
* `player: <number>|<null>` The player index for the device. Will be `null` if it can't be determined.
|
|
1805
1809
|
* `mapping: <string>` The axis and button mapping for this device.
|
|
1806
1810
|
|
|
1807
1811
|
A list of all the detected controller devices.
|
|
@@ -1839,7 +1843,7 @@ Instead, objects returned by [`sdl.controller.openDevice()`](#sdlcontrolleropend
|
|
|
1839
1843
|
|
|
1840
1844
|
### Event: 'axisMotion'
|
|
1841
1845
|
|
|
1842
|
-
* `axis
|
|
1846
|
+
* `axis:`[`<Axis>`](#controllerinstanceaxes) The axis that moved.
|
|
1843
1847
|
* `value: <number>` The new axis position.
|
|
1844
1848
|
|
|
1845
1849
|
Fired when one of the controller's axes moves.
|
|
@@ -1848,7 +1852,7 @@ Fired when one of the controller's axes moves.
|
|
|
1848
1852
|
|
|
1849
1853
|
### Event: 'buttonDown'
|
|
1850
1854
|
|
|
1851
|
-
* `button
|
|
1855
|
+
* `button:`[`<Button>`](#controllerinstancebuttons) The button that was pressed.
|
|
1852
1856
|
|
|
1853
1857
|
Fired when one of the controller's buttons is pressed.
|
|
1854
1858
|
|
|
@@ -1942,6 +1946,10 @@ The current power level of the controller device.
|
|
|
1942
1946
|
|
|
1943
1947
|
Sets the player index of this controller.
|
|
1944
1948
|
|
|
1949
|
+
### controllerInstance.resetPlayer()
|
|
1950
|
+
|
|
1951
|
+
Clears player assignment and player led.
|
|
1952
|
+
|
|
1945
1953
|
### controllerInstance.hasLed
|
|
1946
1954
|
|
|
1947
1955
|
* `<boolean>`
|
|
@@ -2014,7 +2022,7 @@ Closes the instance.
|
|
|
2014
2022
|
|
|
2015
2023
|
* `<number>`
|
|
2016
2024
|
|
|
2017
|
-
The readings from accelerometers will include the force of gravity, so a device at rest will have
|
|
2025
|
+
The readings from accelerometers will include the force of gravity, so a device at rest will have a value of `STANDARD_GRAVITY` away from the center of the earth.
|
|
2018
2026
|
Use this constant to correct for that if your application requires it.
|
|
2019
2027
|
|
|
2020
2028
|
### sdl.sensor.devices
|
|
@@ -2022,8 +2030,8 @@ Use this constant to correct for that if your application requires it.
|
|
|
2022
2030
|
* `<object>[]`
|
|
2023
2031
|
* `id: <number>` The unique id of the device.
|
|
2024
2032
|
* `name: <string>` The name of the device.
|
|
2025
|
-
* `type: <string>`
|
|
2026
|
-
* `side: <string
|
|
2033
|
+
* `type: <string>|<null>` Either `'accelerometer'`, `'gyroscope'`. Will be `null` if it can't be determined.
|
|
2034
|
+
* `side: <string>|<null>` Some sensors (such as those on the Joy-Con controller) have a `'left'` or `'right'` side, otherwise this value will be `null`.
|
|
2027
2035
|
|
|
2028
2036
|
A list of all the detected sensor devices.
|
|
2029
2037
|
Sample output:
|
|
@@ -2065,7 +2073,7 @@ The [device](#sdlsensordevices) from which this instance was opened.
|
|
|
2065
2073
|
### sensorInstance.data
|
|
2066
2074
|
|
|
2067
2075
|
* `<object>`
|
|
2068
|
-
* `timestamp: <number
|
|
2076
|
+
* `timestamp: <number>|<null>` The time this measurement was taken **in microseconds**, or `null` if that's not available.
|
|
2069
2077
|
* `x: <number>` X axis value.
|
|
2070
2078
|
* `y: <number>` Y axis value.
|
|
2071
2079
|
* `z: <number>` Z axis value.
|
|
@@ -2517,9 +2525,9 @@ Changes the text contents of the clipboard.
|
|
|
2517
2525
|
### sdl.power.info
|
|
2518
2526
|
|
|
2519
2527
|
* `<object>`
|
|
2520
|
-
* `state: <string
|
|
2521
|
-
* `seconds: <number
|
|
2522
|
-
* `percent: <number
|
|
2528
|
+
* `state: <string>|null` One of `'noBattery'`, `'battery'`, `'charging'`, `'charged'`. Will be `null` if it can't be determinded.
|
|
2529
|
+
* `seconds: <number>|<null>` Seconds of battery life left. Will be `null` if not running on battery, or if it can't be determinded.
|
|
2530
|
+
* `percent: <number>|<null>` Percentage of battery life left. Will be `null` if not running on battery, or if it can't be determinded.
|
|
2523
2531
|
|
|
2524
2532
|
The curent power information of the device.
|
|
2525
2533
|
|
package/binding.gyp
CHANGED
|
@@ -2,10 +2,28 @@
|
|
|
2
2
|
'targets': [{
|
|
3
3
|
'target_name': 'sdl',
|
|
4
4
|
'sources': [
|
|
5
|
-
'src/native/
|
|
6
|
-
'src/native/
|
|
5
|
+
'src/native/module.cpp',
|
|
6
|
+
'src/native/enums.cpp',
|
|
7
|
+
'src/native/global.cpp',
|
|
8
|
+
'src/native/events.cpp',
|
|
9
|
+
'src/native/video.cpp',
|
|
10
|
+
'src/native/window.cpp',
|
|
11
|
+
'src/native/keyboard.cpp',
|
|
12
|
+
'src/native/mouse.cpp',
|
|
13
|
+
'src/native/joystick.cpp',
|
|
14
|
+
'src/native/controller.cpp',
|
|
15
|
+
'src/native/sensor.cpp',
|
|
16
|
+
'src/native/audio.cpp',
|
|
17
|
+
'src/native/clipboard.cpp',
|
|
18
|
+
'src/native/power.cpp',
|
|
19
|
+
],
|
|
20
|
+
'dependencies': [
|
|
21
|
+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
|
22
|
+
],
|
|
23
|
+
'defines': [
|
|
24
|
+
'NAPI_VERSION=<(napi_build_version)',
|
|
25
|
+
'NODE_ADDON_API_DISABLE_DEPRECATED',
|
|
7
26
|
],
|
|
8
|
-
'defines': [ 'NAPI_VERSION=<(napi_build_version)' ],
|
|
9
27
|
'conditions': [
|
|
10
28
|
['OS == "linux"', {
|
|
11
29
|
'cflags': [ '-D_REENTRANT' ],
|
|
@@ -17,7 +35,10 @@
|
|
|
17
35
|
},
|
|
18
36
|
}],
|
|
19
37
|
['OS == "mac"', {
|
|
20
|
-
'sources': [
|
|
38
|
+
'sources': [
|
|
39
|
+
'src/native/cocoa-global.mm',
|
|
40
|
+
'src/native/cocoa-window.mm',
|
|
41
|
+
],
|
|
21
42
|
'cflags': [ '-D_THREAD_SAFE' ],
|
|
22
43
|
'xcode_settings': { 'OTHER_CFLAGS': [ '-std=c++17' ] },
|
|
23
44
|
'include_dirs': [
|
|
@@ -30,7 +51,6 @@
|
|
|
30
51
|
},
|
|
31
52
|
}],
|
|
32
53
|
['OS == "win"', {
|
|
33
|
-
'sources': [ 'src/native/asprintf.c' ],
|
|
34
54
|
'cflags': [ '-D_REENTRANT' ],
|
|
35
55
|
'msvs_settings': {
|
|
36
56
|
'VCCLCompilerTool': {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.9.
|
|
2
|
+
"version": "0.9.6-1",
|
|
3
3
|
"name": "@kmamal/sdl",
|
|
4
4
|
"description": "SDL bindings for Node.js",
|
|
5
5
|
"keywords": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"gypfile": true,
|
|
48
48
|
"scripts": {
|
|
49
|
-
"test": "
|
|
49
|
+
"test": "npx @kmamal/testing",
|
|
50
50
|
"install": "cd scripts && node install.mjs",
|
|
51
51
|
"download-release": "cd scripts && node download-release.mjs",
|
|
52
52
|
"download-sdl": "cd scripts && node download-sdl.mjs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"clean": "cd scripts && node clean.mjs"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"tar": "^6.
|
|
59
|
+
"tar": "^6.2.0"
|
|
60
60
|
},
|
|
61
61
|
"sdl": {
|
|
62
62
|
"owner": "kmamal",
|
|
@@ -64,6 +64,9 @@
|
|
|
64
64
|
"version": "2.26.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@
|
|
67
|
+
"@kmamal/testing": "^0.0.27",
|
|
68
|
+
"@types/node": "^20.11.5",
|
|
69
|
+
"node-addon-api": "^7.1.0",
|
|
70
|
+
"node-gyp": "^10.0.1"
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -19,8 +19,6 @@ class AudioInstance extends EventsViaPoll {
|
|
|
19
19
|
buffered = 4096,
|
|
20
20
|
} = options
|
|
21
21
|
|
|
22
|
-
const _format = Enums.audioFormat[format] ?? null
|
|
23
|
-
|
|
24
22
|
if (name !== undefined && name !== null && typeof name !== 'string') { throw Object.assign(new Error("name must be a string"), { name }) }
|
|
25
23
|
if (typeof type !== 'string') { throw Object.assign(new Error("type must be a string"), { type }) }
|
|
26
24
|
if (type !== 'playback' && type !== 'recording') { throw Object.assign(new Error("type must be either 'playback' or 'recording'"), { type }) }
|
|
@@ -29,11 +27,13 @@ class AudioInstance extends EventsViaPoll {
|
|
|
29
27
|
if (!Number.isFinite(frequency)) { throw Object.assign(new Error("frequency must be a number"), { frequency }) }
|
|
30
28
|
if (frequency <= 0) { throw Object.assign(new Error("invalid frequency"), { frequency }) }
|
|
31
29
|
if (typeof format !== 'string') { throw Object.assign(new Error("format must be a string"), { format }) }
|
|
32
|
-
if (_format === null) { throw Object.assign(new Error("invalid format"), { format }) }
|
|
33
30
|
if (!Number.isFinite(buffered)) { throw Object.assign(new Error("buffered must be a number"), { buffered }) }
|
|
34
31
|
if (buffered !== 2 ** (32 - Math.clz32(buffered) - 1)) { throw Object.assign(new Error("invalid buffered"), { buffered }) }
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
const _format = Enums.audioFormat[format]
|
|
34
|
+
if (_format === undefined) { throw Object.assign(new Error("invalid format"), { format }) }
|
|
35
|
+
|
|
36
|
+
this._id = Bindings.audio_open(name ?? null, type === 'recording', frequency, _format, channels, buffered)
|
|
37
37
|
|
|
38
38
|
this._device = device
|
|
39
39
|
this._name = name
|
|
@@ -42,7 +42,7 @@ class AudioInstance extends EventsViaPoll {
|
|
|
42
42
|
this._format = format
|
|
43
43
|
this._frequency = frequency
|
|
44
44
|
|
|
45
|
-
this._playing =
|
|
45
|
+
this._playing = false
|
|
46
46
|
this._closed = false
|
|
47
47
|
|
|
48
48
|
const helper = AudioFormatHelpers[this._format]
|
|
@@ -90,8 +90,10 @@ class AudioInstance extends EventsViaPoll {
|
|
|
90
90
|
if (this._closed) { throw Object.assign(new Error("instance is closed"), { id: this._id }) }
|
|
91
91
|
|
|
92
92
|
if (typeof play !== 'boolean') { throw Object.assign(new Error("play must be a boolean"), { play }) }
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
Bindings.audio_play(this._id, play)
|
|
95
|
+
|
|
96
|
+
this._playing = play
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
pause () {
|
|
@@ -119,6 +121,7 @@ class AudioInstance extends EventsViaPoll {
|
|
|
119
121
|
this._closed = true
|
|
120
122
|
|
|
121
123
|
Bindings.audio_close(this._id)
|
|
124
|
+
|
|
122
125
|
Globals.audioInstances.delete(this._id)
|
|
123
126
|
}
|
|
124
127
|
}
|
|
@@ -6,9 +6,10 @@ const validEvents = [ 'update' ]
|
|
|
6
6
|
const clipboard = new class extends EventsViaPoll {
|
|
7
7
|
constructor () { super(validEvents) }
|
|
8
8
|
|
|
9
|
-
get text () { return Bindings.clipboard_getText()
|
|
9
|
+
get text () { return Bindings.clipboard_getText() }
|
|
10
10
|
setText (text) {
|
|
11
11
|
if (typeof text !== 'string') { throw Object.assign(new Error("text must be a string"), { text }) }
|
|
12
|
+
|
|
12
13
|
Bindings.clipboard_setText(text)
|
|
13
14
|
}
|
|
14
15
|
}()
|
|
@@ -47,10 +47,7 @@ class ControllerInstance extends EventsViaPoll {
|
|
|
47
47
|
get axes () { return this._axes }
|
|
48
48
|
get buttons () { return this._buttons }
|
|
49
49
|
|
|
50
|
-
get power () {
|
|
51
|
-
const power = Bindings.joystick_getPower(this._device.id)
|
|
52
|
-
return Enums.powerLevelNames[power]
|
|
53
|
-
}
|
|
50
|
+
get power () { return Bindings.joystick_getPower(this._device.id) }
|
|
54
51
|
|
|
55
52
|
setPlayer (player) {
|
|
56
53
|
if (this._closed) { throw Object.assign(new Error("instance is closed"), { id: this._device.id }) }
|
|
@@ -61,6 +58,12 @@ class ControllerInstance extends EventsViaPoll {
|
|
|
61
58
|
Bindings.joystick_setPlayer(this._device.id, player)
|
|
62
59
|
}
|
|
63
60
|
|
|
61
|
+
resetPlayer () {
|
|
62
|
+
if (this._closed) { throw Object.assign(new Error("instance is closed"), { id: this._device.id }) }
|
|
63
|
+
|
|
64
|
+
Bindings.joystick_setPlayer(this._device.id, -1)
|
|
65
|
+
}
|
|
66
|
+
|
|
64
67
|
get hasLed () { return this._hasLed }
|
|
65
68
|
setLed (red, green, blue) {
|
|
66
69
|
if (this._closed) { throw Object.assign(new Error("instance is closed"), { id: this._device.id }) }
|
package/src/javascript/enums.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
const Bindings = require('./bindings')
|
|
2
2
|
|
|
3
|
-
const enums = Bindings.
|
|
4
|
-
|
|
5
|
-
for (const [ key, obj ] of Object.entries(enums)) {
|
|
6
|
-
const names = {}
|
|
7
|
-
for (const [ name, value ] of Object.entries(obj)) {
|
|
8
|
-
names[value] = name
|
|
9
|
-
}
|
|
10
|
-
enums[`${key}Names`] = names
|
|
11
|
-
}
|
|
3
|
+
const enums = Bindings.enums_get()
|
|
12
4
|
|
|
13
5
|
module.exports = enums
|