@kmamal/sdl 0.11.10 → 0.11.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -1
- package/README.md +1105 -1031
- package/binding.gyp +1 -0
- package/package.json +14 -10
- package/src/javascript/controller/controller-instance.js +4 -1
- package/src/javascript/events/index.js +47 -0
- package/src/javascript/globals.js +1 -0
- package/src/javascript/index.js +2 -0
- package/src/javascript/joystick/joystick-instance.js +3 -1
- package/src/javascript/keyboard/index.js +11 -6
- package/src/javascript/touch/index.js +15 -0
- package/src/javascript/video/window.js +3 -0
- package/src/native/controller.cpp +15 -5
- package/src/native/controller.h +1 -0
- package/src/native/events.cpp +75 -29
- package/src/native/events.h +8 -0
- package/src/native/global.cpp +14 -0
- package/src/native/joystick.cpp +21 -24
- package/src/native/joystick.h +2 -1
- package/src/native/keyboard.cpp +1 -1
- package/src/native/module.cpp +3 -1
- package/src/native/touch.cpp +46 -0
- package/src/native/touch.h +16 -0
- package/src/types/index.d.ts +108 -20
package/README.md
CHANGED
|
@@ -17,17 +17,16 @@ SDL bindings for Node.js. Provides access to systems that are not normally avail
|
|
|
17
17
|
- 🔋 Battery status
|
|
18
18
|
- 🧭 Sensors
|
|
19
19
|
|
|
20
|
-
Also allows using Canvas2D, WebGL, and WebGPU without a browser:
|
|
20
|
+
Also allows using Canvas2D, WebGL, and WebGPU without a browser, through these libraries:
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
- __Canvas2D:__ [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas). In my experience, this is the fastest library out of the many available on npm.
|
|
23
|
+
- __WebGL:__ [@kmamal/gl](https://github.com/kmamal/headless-gl#readme). This is a fork of [headless-gl](https://github.com/stackgl/headless-gl#readme) that I've modified to render directly to SDL windows.
|
|
24
|
+
- __WebGPU:__ [@kmamal/gpu](https://github.com/kmamal/gpu#readme). This is a fork of [Google Dawn](https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/node/) that I've modified to render directly to SDL windows.
|
|
25
25
|
|
|
26
26
|
Officially supports Linux (x64, arm64), Mac (x64, arm64), and Windows (x64).
|
|
27
|
-
Should
|
|
27
|
+
Should theoretically work on any system supported by both SDL and Node.js, but I haven't tried any others.
|
|
28
28
|
Prebuilt binaries are available for the supported architectures.
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
## Installation
|
|
32
31
|
|
|
33
32
|
This package is self-contained. Just run:
|
|
@@ -40,7 +39,6 @@ You do __not__ have to manually install any other libs or DLLs to your system. A
|
|
|
40
39
|
|
|
41
40
|
(But if the install script fails, have a look at the instructions for [building the package manually](#building-from-source))
|
|
42
41
|
|
|
43
|
-
|
|
44
42
|
## Examples
|
|
45
43
|
|
|
46
44
|
### "Hello, World!"
|
|
@@ -129,267 +127,272 @@ renderer.swap()
|
|
|
129
127
|
|
|
130
128
|
Check the [`examples/`](https://github.com/kmamal/node-sdl/tree/master/examples#readme) folder.
|
|
131
129
|
|
|
132
|
-
|
|
133
130
|
# API Reference
|
|
134
131
|
|
|
135
132
|
## Contents
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
134
|
+
- [sdl](#sdl)
|
|
135
|
+
- [sdl.info](#sdlinfo)
|
|
136
|
+
- [sdl.video](#sdlvideo)
|
|
137
|
+
- [Image data](#image-data)
|
|
138
|
+
- [High-DPI](#high-dpi)
|
|
139
|
+
- [Pixel formats](#pixel-formats)
|
|
140
|
+
- [Event: 'displayAdd'](#event-displayadd)
|
|
141
|
+
- [Event: 'displayRemove'](#event-displayremove)
|
|
142
|
+
- [Event: 'displayOrient'](#event-displayorient)
|
|
143
|
+
- [Event: 'displayMove'](#event-displaymove)
|
|
144
|
+
- [sdl.video.displays](#sdlvideodisplays)
|
|
145
|
+
- [sdl.video.windows](#sdlvideowindows)
|
|
146
|
+
- [sdl.video.focused](#sdlvideofocused)
|
|
147
|
+
- [sdl.video.hovered](#sdlvideohovered)
|
|
148
|
+
- [sdl.video.createWindow([options])](#sdlvideocreatewindowoptions)
|
|
149
|
+
- [class Window](#class-window)
|
|
150
|
+
- [Event: 'show'](#event-show)
|
|
151
|
+
- [Event: 'hide'](#event-hide)
|
|
152
|
+
- [Event: 'expose'](#event-expose)
|
|
153
|
+
- [Event: 'minimize'](#event-minimize)
|
|
154
|
+
- [Event: 'maximize'](#event-maximize)
|
|
155
|
+
- [Event: 'restore'](#event-restore)
|
|
156
|
+
- [Event: 'move'](#event-move)
|
|
157
|
+
- [Event: 'resize'](#event-resize)
|
|
158
|
+
- [Event: 'displayChange'](#event-displaychange)
|
|
159
|
+
- [Event: 'focus'](#event-focus)
|
|
160
|
+
- [Event: 'blur'](#event-blur)
|
|
161
|
+
- [Event: 'hover'](#event-hover)
|
|
162
|
+
- [Event: 'leave'](#event-leave)
|
|
163
|
+
- [Event: 'beforeClose'](#event-beforeclose)
|
|
164
|
+
- [Event: 'close'](#event-close)
|
|
165
|
+
- [Event: 'keyDown'](#event-keydown)
|
|
166
|
+
- [Event: 'keyUp'](#event-keyup)
|
|
167
|
+
- [Event: 'textInput'](#event-textinput)
|
|
168
|
+
- [Event: 'mouseButtonDown'](#event-mousebuttondown)
|
|
169
|
+
- [Event: 'mouseButtonUp'](#event-mousebuttonup)
|
|
170
|
+
- [Event: 'mouseMove'](#event-mousemove)
|
|
171
|
+
- [Event: 'mouseWheel'](#event-mousewheel)
|
|
172
|
+
- [Event: 'fingerDown'](#event-fingerdown)
|
|
173
|
+
- [Event: 'fingerUp'](#event-fingerup)
|
|
174
|
+
- [Event: 'fingerMove'](#event-fingermove)
|
|
175
|
+
- [Event: 'dropBegin'](#event-dropbegin)
|
|
176
|
+
- [Event: 'dropText'](#event-droptext)
|
|
177
|
+
- [Event: 'dropFile'](#event-dropfile)
|
|
178
|
+
- [Event: 'dropComplete'](#event-dropcomplete)
|
|
179
|
+
- [window.id](#windowid)
|
|
180
|
+
- [window.title](#windowtitle)
|
|
181
|
+
- [window.setTitle(title)](#windowsettitletitle)
|
|
182
|
+
- [window.x](#windowx)
|
|
183
|
+
- [window.y](#windowy)
|
|
184
|
+
- [window.setPosition(x, y)](#windowsetpositionx-y)
|
|
185
|
+
- [window.width](#windowwidth)
|
|
186
|
+
- [window.height](#windowheight)
|
|
187
|
+
- [window.pixelWidth](#windowpixelwidth)
|
|
188
|
+
- [window.pixelHeight](#windowpixelheight)
|
|
189
|
+
- [window.setSize(width, height)](#windowsetsizewidth-height)
|
|
190
|
+
- [window.setSizeInPixels(pixelWidth, pixelHeight)](#windowsetsizeinpixelspixelwidth-pixelheight)
|
|
191
|
+
- [window.display](#windowdisplay)
|
|
192
|
+
- [window.visible](#windowvisible)
|
|
193
|
+
- [window.show([show])](#windowshowshow)
|
|
194
|
+
- [window.hide()](#windowhide)
|
|
195
|
+
- [window.fullscreen](#windowfullscreen)
|
|
196
|
+
- [window.setFullscreen(fullscreen)](#windowsetfullscreenfullscreen)
|
|
197
|
+
- [window.resizable](#windowresizable)
|
|
198
|
+
- [window.setResizable(resizable)](#windowsetresizableresizable)
|
|
199
|
+
- [window.borderless](#windowborderless)
|
|
200
|
+
- [window.setBorderless(borderless)](#windowsetborderlessborderless)
|
|
201
|
+
- [window.alwaysOnTop](#windowalwaysontop)
|
|
202
|
+
- [window.accelerated](#windowaccelerated)
|
|
203
|
+
- [window.setAccelerated(accelerated)](#windowsetacceleratedaccelerated)
|
|
204
|
+
- [window.vsync](#windowvsync)
|
|
205
|
+
- [window.setVsync(vsync)](#windowsetvsyncvsync)
|
|
206
|
+
- [window.opengl](#windowopengl)
|
|
207
|
+
- [window.webgpu](#windowwebgpu)
|
|
208
|
+
- [window.native](#windownative)
|
|
209
|
+
- [window.maximized](#windowmaximized)
|
|
210
|
+
- [window.maximize()](#windowmaximize)
|
|
211
|
+
- [window.minimized](#windowminimized)
|
|
212
|
+
- [window.minimize()](#windowminimize)
|
|
213
|
+
- [window.restore()](#windowrestore)
|
|
214
|
+
- [window.focused](#windowfocused)
|
|
215
|
+
- [window.focus()](#windowfocus)
|
|
216
|
+
- [window.hovered](#windowhovered)
|
|
217
|
+
- [window.skipTaskbar](#windowskiptaskbar)
|
|
218
|
+
- [window.popupMenu](#windowpopupmenu)
|
|
219
|
+
- [window.tooltip](#windowtooltip)
|
|
220
|
+
- [window.utility](#windowutility)
|
|
221
|
+
- [window.render(width, height, stride, format, buffer[, options])](#windowrenderwidth-height-stride-format-buffer-options)
|
|
222
|
+
- [window.setIcon(width, height, stride, format, buffer)](#windowseticonwidth-height-stride-format-buffer)
|
|
223
|
+
- [window.flash([untilFocused])](#windowflashuntilfocused)
|
|
224
|
+
- [window.stopFlashing()](#windowstopflashing)
|
|
225
|
+
- [window.destroyed](#windowdestroyed)
|
|
226
|
+
- [window.destroy()](#windowdestroy)
|
|
227
|
+
- [window.destroyGently()](#windowdestroygently)
|
|
228
|
+
- [sdl.keyboard](#sdlkeyboard)
|
|
229
|
+
- [Virtual keys](#virtual-keys)
|
|
230
|
+
- [Enum: SCANCODE](#enum-scancode)
|
|
231
|
+
- [Event: 'keymapChange'](#event-keymapchange)
|
|
232
|
+
- [sdl.keyboard.getKey(scancode)](#sdlkeyboardgetkeyscancode)
|
|
233
|
+
- [sdl.keyboard.getScancode(key)](#sdlkeyboardgetscancodekey)
|
|
234
|
+
- [sdl.keyboard.getState()](#sdlkeyboardgetstate)
|
|
235
|
+
- [sdl.mouse](#sdlmouse)
|
|
236
|
+
- [Enum: BUTTON](#enum-button)
|
|
237
|
+
- [sdl.mouse.getButton(button)](#sdlmousegetbuttonbutton)
|
|
238
|
+
- [sdl.mouse.position](#sdlmouseposition)
|
|
239
|
+
- [sdl.mouse.setPosition(x, y)](#sdlmousesetpositionx-y)
|
|
240
|
+
- [sdl.mouse.setCursor(cursor)](#sdlmousesetcursorcursor)
|
|
241
|
+
- [sdl.mouse.resetCursor()](#sdlmouseresetcursor)
|
|
242
|
+
- [sdl.mouse.setCursorImage(width, height, stride, format, buffer, x, y)](#sdlmousesetcursorimagewidth-height-stride-format-buffer-x-y)
|
|
243
|
+
- [sdl.mouse.showCursor([show])](#sdlmouseshowcursorshow)
|
|
244
|
+
- [sdl.mouse.hideCursor()](#sdlmousehidecursor)
|
|
245
|
+
- [sdl.mouse.redrawCursor()](#sdlmouseredrawcursor)
|
|
246
|
+
- [sdl.mouse.capture([capture])](#sdlmousecapturecapture)
|
|
247
|
+
- [sdl.mouse.uncapture()](#sdlmouseuncapture)
|
|
248
|
+
- [sdl.joystick](#sdljoystick)
|
|
249
|
+
- [Hat positions](#hat-positions)
|
|
250
|
+
- [Power levels](#power-levels)
|
|
251
|
+
- [Event: 'deviceAdd'](#joystick-event-deviceadd)
|
|
252
|
+
- [Event: 'deviceRemove'](#joystick-event-deviceremove)
|
|
253
|
+
- [sdl.joystick.devices](#sdljoystickdevices)
|
|
254
|
+
- [sdl.joystick.openDevice(device)](#sdljoystickopendevicedevice)
|
|
255
|
+
- [class JoystickInstance](#class-joystickinstance)
|
|
256
|
+
- [Event: 'axisMotion'](#joystick-instance-event-axismotion)
|
|
257
|
+
- [Event: 'ballMotion'](#event-ballmotion)
|
|
258
|
+
- [Event: 'buttonDown'](#joystick-instance-event-buttondown)
|
|
259
|
+
- [Event: 'buttonUp'](#joystick-instance-event-buttonup)
|
|
260
|
+
- [Event: 'hatMotion'](#event-hatmotion)
|
|
261
|
+
- [Event: 'powerUpdate'](#joystick-instance-event-power-update)
|
|
262
|
+
- [Event: 'close'](#joystick-instance-event-close)
|
|
263
|
+
- [joystickInstance.device](#joystickinstancedevice)
|
|
264
|
+
- [joystickInstance.firmwareVersion](#joystickinstancefirmwareversion)
|
|
265
|
+
- [joystickInstance.serialNumber](#joystickinstanceserialnumber)
|
|
266
|
+
- [joystickInstance.axes](#joystickinstanceaxes)
|
|
267
|
+
- [joystickInstance.balls](#joystickinstanceballs)
|
|
268
|
+
- [joystickInstance.buttons](#joystickinstancebuttons)
|
|
269
|
+
- [joystickInstance.hats](#joystickinstancehats)
|
|
270
|
+
- [joystickInstance.power](#joystickinstancepower)
|
|
271
|
+
- [joystickInstance.setPlayer(index)](#joystickinstancesetplayerindex)
|
|
272
|
+
- [joystickInstance.resetPlayer()](#joystickinstanceresetplayer)
|
|
273
|
+
- [joystickInstance.hasLed](#joystickinstancehasled)
|
|
274
|
+
- [joystickInstance.setLed(red, green, blue)](#joystickinstancesetledred-green-blue)
|
|
275
|
+
- [joystickInstance.hasRumble](#joystickinstancehasrumble)
|
|
276
|
+
- [joystickInstance.rumble([low[, high[, duration]]])](#joystickinstancerumblelow-high-duration)
|
|
277
|
+
- [joystickInstance.stopRumble()](#joystickinstancestoprumble)
|
|
278
|
+
- [joystickInstance.hasRumbleTriggers](#joystickinstancehasrumbletriggers)
|
|
279
|
+
- [joystickInstance.rumbleTriggers([left[, right[, duration]]])](#joystickinstancerumbletriggersleft-right-duration)
|
|
280
|
+
- [joystickInstance.stopRumbleTriggers()](#joystickinstancestoprumbletriggers)
|
|
281
|
+
- [joystickInstance.closed](#joystickinstanceclosed)
|
|
282
|
+
- [joystickInstance.close()](#joystickinstanceclose)
|
|
283
|
+
- [sdl.controller](#sdlcontroller)
|
|
284
|
+
- [Event: 'deviceAdd'](#controller-event-deviceadd)
|
|
285
|
+
- [Event: 'deviceRemove'](#controller-event-deviceremove)
|
|
286
|
+
- [sdl.controller.addMappings(mappings)](#sdlcontrolleraddmappingsmappings)
|
|
287
|
+
- [sdl.controller.devices](#sdlcontrollerdevices)
|
|
288
|
+
- [sdl.controller.openDevice(device)](#sdlcontrolleropendevicedevice)
|
|
289
|
+
- [class ControllerInstance](#class-controllerinstance)
|
|
290
|
+
- [Event: 'axisMotion'](#controller-instance-event-axismotion)
|
|
291
|
+
- [Event: 'buttonDown'](#controller-instance-event-buttondown)
|
|
292
|
+
- [Event: 'buttonUp'](#controller-instance-event-buttonup)
|
|
293
|
+
- [Event: 'powerUpdate'](#controller-instance-event-power-update)
|
|
294
|
+
- [Event: 'steamHandleUpdate'](#event-steamhandleupdate)
|
|
295
|
+
- [Event: 'remap'](#event-remap)
|
|
296
|
+
- [Event: 'close'](#controller-instance-event-close)
|
|
297
|
+
- [controllerInstance.device](#controllerinstancedevice)
|
|
298
|
+
- [controllerInstance.firmwareVersion](#controllerinstancefirmwareversion)
|
|
299
|
+
- [controllerInstance.serialNumber](#controllerinstanceserialnumber)
|
|
300
|
+
- [controllerInstance.steamHandle](#controllerinstancesteamhandle)
|
|
301
|
+
- [controllerInstance.axes](#controllerinstanceaxes)
|
|
302
|
+
- [controllerInstance.buttons](#controllerinstancebuttons)
|
|
303
|
+
- [controllerInstance.power](#controllerinstancepower)
|
|
304
|
+
- [controllerInstance.setPlayer(index)](#controllerinstancesetplayerindex)
|
|
305
|
+
- [controllerInstance.resetPlayer()](#controllerinstanceresetplayer)
|
|
306
|
+
- [controllerInstance.hasLed](#controllerinstancehasled)
|
|
307
|
+
- [controllerInstance.setLed(red, green, blue)](#controllerinstancesetledred-green-blue)
|
|
308
|
+
- [controllerInstance.hasRumble](#controllerinstancehasrumble)
|
|
309
|
+
- [controllerInstance.rumble([low[, high[, duration]]])](#controllerinstancerumblelow-high-duration)
|
|
310
|
+
- [controllerInstance.stopRumble()](#controllerinstancestoprumble)
|
|
311
|
+
- [controllerInstance.hasRumbleTriggers](#controllerinstancehasrumbletriggers)
|
|
312
|
+
- [controllerInstance.rumbleTriggers([left[, right[, duration]]])](#controllerinstancerumbletriggersleft-right-duration)
|
|
313
|
+
- [controllerInstance.stopRumbleTriggers()](#controllerinstancestoprumbletriggers)
|
|
314
|
+
- [controllerInstance.closed](#controllerinstanceclosed)
|
|
315
|
+
- [controllerInstance.close()](#controllerinstanceclose)
|
|
316
|
+
- [sdl.sensor](#sdlsensor)
|
|
317
|
+
- [sdl.sensor.STANDARD_GRAVITY](#sdlsensorstandard_gravity)
|
|
318
|
+
- [sdl.sensor.devices](#sdlsensordevices)
|
|
319
|
+
- [sdl.sensor.openDevice(device)](#sdlsensoropendevicedevice)
|
|
320
|
+
- [class SensorInstance](#class-sensorinstance)
|
|
321
|
+
- [Event: 'update'](#sensor-instance-event-update)
|
|
322
|
+
- [sensorInstance.device](#sensorinstancedevice)
|
|
323
|
+
- [sensorInstance.data](#sensorinstancedata)
|
|
324
|
+
- [sensorInstance.closed](#sensorinstanceclosed)
|
|
325
|
+
- [sensorInstance.close()](#sensorinstanceclose)
|
|
326
|
+
- [sdl.audio](#sdlaudio)
|
|
327
|
+
- [Audio data](#audio-data)
|
|
328
|
+
- [Sample formats](#sample-formats)
|
|
329
|
+
- [Event: 'deviceAdd'](#audio-event-deviceadd)
|
|
330
|
+
- [Event: 'deviceRemove'](#audio-event-deviceremove)
|
|
331
|
+
- [sdl.audio.bytesPerSample(format)](#sdlaudiobytespersampleformat)
|
|
332
|
+
- [sdl.audio.minSampleValue(format)](#sdlaudiominsamplevalueformat)
|
|
333
|
+
- [sdl.audio.maxSampleValue(format)](#sdlaudiomaxsamplevalueformat)
|
|
334
|
+
- [sdl.audio.zeroSampleValue(format)](#sdlaudiozerosamplevalueformat)
|
|
335
|
+
- [sdl.audio.readSample(format, buffer[, offset])](#sdlaudioreadsampleformat-buffer-offset)
|
|
336
|
+
- [sdl.audio.writeSample(format, buffer, value[, offset])](#sdlaudiowritesampleformat-buffer-value-offset)
|
|
337
|
+
- [sdl.audio.devices](#sdlaudiodevices)
|
|
338
|
+
- [sdl.audio.openDevice(device[, options])](#sdlaudioopendevicedevice-options)
|
|
339
|
+
- [class AudioInstance](#class-audioinstance)
|
|
340
|
+
- [Event: 'close'](#audio-instance-event-close)
|
|
341
|
+
- [audioInstance.id](#audioinstanceid)
|
|
342
|
+
- [audioInstance.channels](#audioinstancechannels)
|
|
343
|
+
- [audioInstance.frequency](#audioinstancefrequency)
|
|
344
|
+
- [audioInstance.format](#audioinstanceformat)
|
|
345
|
+
- [audioInstance.bytesPerSample](#audioinstancebytespersample)
|
|
346
|
+
- [audioInstance.minSampleValue](#audioinstanceminsamplevalue)
|
|
347
|
+
- [audioInstance.maxSampleValue](#audioinstancemaxsamplevalue)
|
|
348
|
+
- [audioInstance.zeroSampleValue](#audioinstancezerosamplevalue)
|
|
349
|
+
- [audioInstance.readSample(buffer[, offset])](#audioinstancereadsamplebuffer-offset)
|
|
350
|
+
- [audioInstance.writeSample(buffer, value[, offset])](#audioinstancewritesamplebuffer-value-offset)
|
|
351
|
+
- [audioInstance.buffered](#audioinstancebuffered)
|
|
352
|
+
- [audioInstance.playing](#audioinstanceplaying)
|
|
353
|
+
- [audioInstance.play([play])](#audioinstanceplayplay)
|
|
354
|
+
- [audioInstance.pause()](#audioinstancepause)
|
|
355
|
+
- [audioInstance.queued](#audioinstancequeued)
|
|
356
|
+
- [audioInstance.clearQueue()](#audioinstanceclearqueue)
|
|
357
|
+
- [audioInstance.closed](#audioinstanceclosed)
|
|
358
|
+
- [audioInstance.close()](#audioinstanceclose)
|
|
359
|
+
- [class AudioPlaybackInstance extends AudioInstance](#class-audioplaybackinstance-extends-audioinstance)
|
|
360
|
+
- [playbackInstance.enqueue(buffer[, bytes])](#playbackinstanceenqueuebuffer-bytes)
|
|
361
|
+
- [class AudioRecordingInstance extends AudioInstance](#class-audiorecordinginstance-extends-audioinstance)
|
|
362
|
+
- [recordingInstance.dequeue(buffer[, bytes])](#recordinginstancedequeuebuffer-bytes)
|
|
363
|
+
- [sdl.clipboard](#sdlclipboard)
|
|
364
|
+
- [Event: 'update'](#clipboard-event-update)
|
|
365
|
+
- [sdl.clipboard.text](#sdlclipboardtext)
|
|
366
|
+
- [sdl.clipboard.setText(text)](#sdlclipboardsettexttext)
|
|
367
|
+
- [sdl.power](#sdlpower)
|
|
368
|
+
- [sdl.power.info](#sdlpowerinfo)
|
|
369
|
+
- [helpers](#helpers)
|
|
367
370
|
|
|
368
371
|
## sdl
|
|
369
372
|
|
|
370
373
|
### sdl.info
|
|
371
374
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
375
|
+
- `<object>`
|
|
376
|
+
- `version: <object>`
|
|
377
|
+
- `compile: <object>` The version of the SDL library that this package was compiled against.
|
|
378
|
+
- `major, minor, patch: <Semver>` The components of the version.
|
|
379
|
+
- `runtime: <object>` The version of the SDL library that was found and loaded at runtime.
|
|
380
|
+
- `major, minor, patch: <Semver>` The components of the version.
|
|
381
|
+
- `platform: <string>` The name of the platform we are running on. Possible values are: `'Linux'`, `'Windows'`, and `'Mac OS X'`.
|
|
382
|
+
- `drivers: <object>`
|
|
383
|
+
- `video: <object>`
|
|
384
|
+
- `all: <string>[]` A list of all video drivers.
|
|
385
|
+
- `current: <string>|<null>` The video driver that is currently selected.
|
|
386
|
+
- `audio: <object>`
|
|
387
|
+
- `all: <string>[]` A list of all audio drivers.
|
|
388
|
+
- `current: <string>|<null>` The audio driver that is currently selected.
|
|
389
|
+
- `initialized: <object>`
|
|
390
|
+
- `video: <boolean>`: Is `true` if the video subsystem was successfully initialized, or `false` otherwise.
|
|
391
|
+
- `audio: <boolean>`: Is `true` if the audio subsystem was successfully initialized, or `false` otherwise.
|
|
392
|
+
- `joystick: <boolean>`: Is `true` if the joystick subsystem was successfully initialized, or `false` otherwise.
|
|
393
|
+
- `controller: <boolean>`: Is `true` if the controller subsystem was successfully initialized, or `false` otherwise.
|
|
394
|
+
- `haptic: <boolean>`: Is `true` if the haptic subsystem was successfully initialized, or `false` otherwise.
|
|
395
|
+
- `sensor: <boolean>`: Is `true` if the sensor subsystem was successfully initialized, or `false` otherwise.
|
|
393
396
|
|
|
394
397
|
The `sdl.info` object is filled with information produced during the initialization of SDL.
|
|
395
398
|
All the values remain constant throughout the execution of the program.
|
|
@@ -429,24 +432,23 @@ Sample data for Ubuntu:
|
|
|
429
432
|
}
|
|
430
433
|
```
|
|
431
434
|
|
|
432
|
-
|
|
433
435
|
## sdl.video
|
|
434
436
|
|
|
435
437
|
### Image data
|
|
436
438
|
|
|
437
439
|
There are 3 places in the API where you must provide an image to the library:
|
|
438
440
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
- [`window.render()`](#windowrenderwidth-height-stride-format-buffer-options)
|
|
442
|
+
- [`window.setIcon()`](#windowseticonwidth-height-stride-format-buffer)
|
|
443
|
+
- [`mouse.setCursorImage()`](#sdlmousesetcursorimagewidth-height-stride-format-buffer-x-y)
|
|
442
444
|
|
|
443
445
|
All three of these functions accept the image as a series of arguments:
|
|
444
446
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
447
|
+
- `width: <number>` The width of the image in pixels.
|
|
448
|
+
- `height: <number>` The height of the image in pixels.
|
|
449
|
+
- `stride: <number>` How many bytes each row of the image takes up in the buffer. Usually equal to `width * bytesPerPixel`, but may be larger if the rows of the buffer are padded to always be some multiple of bytes.
|
|
450
|
+
- `format: `[`<PixelFormat>`](#pixel-formats) The binary representation of the data in the buffer.
|
|
451
|
+
- `buffer: <Buffer>` Holds the actual pixel data for the image, in the format and layout specified by all the above arguments.
|
|
450
452
|
|
|
451
453
|
So, for example, to fill the window with a red+green gradient you could do:
|
|
452
454
|
|
|
@@ -481,100 +483,98 @@ I recommend that in these cases you always use `pixelWidth` and `pixelHeight`, s
|
|
|
481
483
|
|
|
482
484
|
String values used to represent how the pixels of an image are stored in a Buffer.
|
|
483
485
|
|
|
484
|
-
| Value
|
|
485
|
-
| ---
|
|
486
|
-
| `'rgb332'`
|
|
487
|
-
| `'rgb444'`
|
|
488
|
-
| `'rgb555'`
|
|
489
|
-
| `'bgr555'`
|
|
490
|
-
| `'argb4444'`
|
|
491
|
-
| `'rgba4444'`
|
|
492
|
-
| `'abgr4444'`
|
|
493
|
-
| `'bgra4444'`
|
|
494
|
-
| `'argb1555'`
|
|
495
|
-
| `'rgba5551'`
|
|
496
|
-
| `'abgr1555'`
|
|
497
|
-
| `'bgra5551'`
|
|
498
|
-
| `'rgb565'`
|
|
499
|
-
| `'bgr565'`
|
|
500
|
-
| `'rgb24'`
|
|
501
|
-
| `'bgr24'`
|
|
502
|
-
| `'rgb888'`
|
|
503
|
-
| `'rgbx8888'`
|
|
504
|
-
| `'bgr888'`
|
|
505
|
-
| `'bgrx8888'`
|
|
506
|
-
| `'argb8888'`
|
|
507
|
-
| `'rgba8888'`
|
|
508
|
-
| `'abgr8888'`
|
|
509
|
-
| `'bgra8888'`
|
|
510
|
-
| `'argb2101010'` | `SDL_PIXELFORMAT_ARGB2101010`
|
|
511
|
-
| `'rgba32'`
|
|
512
|
-
| `'argb32'`
|
|
513
|
-
| `'bgra32'`
|
|
514
|
-
| `'abgr32'`
|
|
515
|
-
| `'yv12'`
|
|
516
|
-
| `'iyuv'`
|
|
517
|
-
| `'yuy2'`
|
|
518
|
-
| `'uyvy'`
|
|
519
|
-
| `'yvyu'`
|
|
520
|
-
| `'nv12'`
|
|
521
|
-
| `'nv21'`
|
|
522
|
-
|
|
486
|
+
| Value | Corresponding `SDL_PixelFormatEnum` | Comment |
|
|
487
|
+
| --- | --- | --- |
|
|
488
|
+
| `'rgb332'` | `SDL_PIXELFORMAT_RGB332` | |
|
|
489
|
+
| `'rgb444'` | `SDL_PIXELFORMAT_RGB444` | |
|
|
490
|
+
| `'rgb555'` | `SDL_PIXELFORMAT_RGB555` | |
|
|
491
|
+
| `'bgr555'` | `SDL_PIXELFORMAT_BGR555` | |
|
|
492
|
+
| `'argb4444'` | `SDL_PIXELFORMAT_ARGB4444` | |
|
|
493
|
+
| `'rgba4444'` | `SDL_PIXELFORMAT_RGBA4444` | |
|
|
494
|
+
| `'abgr4444'` | `SDL_PIXELFORMAT_ABGR4444` | |
|
|
495
|
+
| `'bgra4444'` | `SDL_PIXELFORMAT_BGRA4444` | |
|
|
496
|
+
| `'argb1555'` | `SDL_PIXELFORMAT_ARGB1555` | |
|
|
497
|
+
| `'rgba5551'` | `SDL_PIXELFORMAT_RGBA5551` | |
|
|
498
|
+
| `'abgr1555'` | `SDL_PIXELFORMAT_ABGR1555` | |
|
|
499
|
+
| `'bgra5551'` | `SDL_PIXELFORMAT_BGRA5551` | |
|
|
500
|
+
| `'rgb565'` | `SDL_PIXELFORMAT_RGB565` | |
|
|
501
|
+
| `'bgr565'` | `SDL_PIXELFORMAT_BGR565` | |
|
|
502
|
+
| `'rgb24'` | `SDL_PIXELFORMAT_RGB24` | |
|
|
503
|
+
| `'bgr24'` | `SDL_PIXELFORMAT_BGR24` | |
|
|
504
|
+
| `'rgb888'` | `SDL_PIXELFORMAT_RGB888` | |
|
|
505
|
+
| `'rgbx8888'` | `SDL_PIXELFORMAT_RGBX8888` | |
|
|
506
|
+
| `'bgr888'` | `SDL_PIXELFORMAT_BGR888` | |
|
|
507
|
+
| `'bgrx8888'` | `SDL_PIXELFORMAT_BGRX8888` | |
|
|
508
|
+
| `'argb8888'` | `SDL_PIXELFORMAT_ARGB8888` | |
|
|
509
|
+
| `'rgba8888'` | `SDL_PIXELFORMAT_RGBA8888` | |
|
|
510
|
+
| `'abgr8888'` | `SDL_PIXELFORMAT_ABGR8888` | |
|
|
511
|
+
| `'bgra8888'` | `SDL_PIXELFORMAT_BGRA8888` | |
|
|
512
|
+
| `'argb2101010'` | `SDL_PIXELFORMAT_ARGB2101010` | |
|
|
513
|
+
| `'rgba32'` | `SDL_PIXELFORMAT_RGBA32` | alias for `'rgba8888'` on big endian machines and for `'abgr8888'` on little endian machines |
|
|
514
|
+
| `'argb32'` | `SDL_PIXELFORMAT_ARGB32` | alias for `'argb8888'` on big endian machines and for `'bgra8888'` on little endian machines |
|
|
515
|
+
| `'bgra32'` | `SDL_PIXELFORMAT_BGRA32` | alias for `'bgra8888'` on big endian machines and for `'argb8888'` on little endian machines |
|
|
516
|
+
| `'abgr32'` | `SDL_PIXELFORMAT_ABGR32` | alias for `'abgr8888'` on big endian machines and for `'rgba8888'` on little endian machines |
|
|
517
|
+
| `'yv12'` | `SDL_PIXELFORMAT_YV12` | planar mode: Y + V + U (3 planes) |
|
|
518
|
+
| `'iyuv'` | `SDL_PIXELFORMAT_IYUV` | planar mode: Y + U + V (3 planes) |
|
|
519
|
+
| `'yuy2'` | `SDL_PIXELFORMAT_YUY2` | packed mode: Y0+U0+Y1+V0 (1 plane) |
|
|
520
|
+
| `'uyvy'` | `SDL_PIXELFORMAT_UYVY` | packed mode: U0+Y0+V0+Y1 (1 plane) |
|
|
521
|
+
| `'yvyu'` | `SDL_PIXELFORMAT_YVYU` | packed mode: Y0+V0+Y1+U0 (1 plane) |
|
|
522
|
+
| `'nv12'` | `SDL_PIXELFORMAT_NV12` | planar mode: Y + U/V interleaved (2 planes) |
|
|
523
|
+
| `'nv21'` | `SDL_PIXELFORMAT_NV21` | planar mode: Y + V/U interleaved (2 planes) |
|
|
523
524
|
|
|
524
525
|
### Event: 'displayAdd'
|
|
525
526
|
|
|
526
|
-
|
|
527
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
527
528
|
|
|
528
529
|
Fired when a display is added to the system.
|
|
529
530
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
530
531
|
|
|
531
532
|
### Event: 'displayRemove'
|
|
532
533
|
|
|
533
|
-
|
|
534
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
534
535
|
|
|
535
536
|
Fired when a display is removed from the system.
|
|
536
537
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
537
538
|
|
|
538
539
|
### Event: 'displayOrient'
|
|
539
540
|
|
|
540
|
-
|
|
541
|
-
|
|
541
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
542
|
+
- `orientation: <string>`: The display's new orientation.
|
|
542
543
|
|
|
543
544
|
Fired when a display changes orientation.
|
|
544
545
|
|
|
545
546
|
### Event: 'displayMove'
|
|
546
547
|
|
|
547
|
-
|
|
548
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
548
549
|
|
|
549
550
|
Fired when a display changes position.
|
|
550
551
|
|
|
551
|
-
|
|
552
552
|
### sdl.video.displays
|
|
553
553
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
554
|
+
- `<object>[]`
|
|
555
|
+
- `name: <string>|<null>` The name of the display, or `null` if it can't be determined.
|
|
556
|
+
- `format: `[`<PixelFormat>`](#pixel-formats) The pixel format of the display.
|
|
557
|
+
- `frequency: <number>` The refresh rate of the display.
|
|
558
|
+
- `geometry: <object>` The desktop region represented by the display.
|
|
559
|
+
- `x, y, width, height: <Rect>` The position and size of the display's geometry.
|
|
560
|
+
- `usable: <object>` Similar to `geometry`, but excludes areas taken up by the OS or window manager such as menus, docks, e.t.c.
|
|
561
|
+
- `x, y, width, height: <Rect>` The position and size of the display's usable region.
|
|
562
|
+
- `dpi: <object>|<null>` Return pixel density for the display in dots/pixels-per-inch units. Might be `null` on some devices if DPI info can't be retrieved.
|
|
563
|
+
- `horizontal: <number>` The horizontal density.
|
|
564
|
+
- `vertical: <number>` The vertical density.
|
|
565
|
+
- `diagonal: <number>` The diagonal density.
|
|
566
|
+
- `orientation: <string>|<null>` The orientation of the display.
|
|
567
567
|
|
|
568
568
|
A list of all detected displays.
|
|
569
569
|
|
|
570
570
|
Possible values for `orientation` are `null` if it is unknown, or one of:
|
|
571
571
|
|
|
572
|
-
| Value
|
|
573
|
-
| ---
|
|
574
|
-
| `'landscape'`
|
|
575
|
-
| `'landscapeFlipped'` | `SDL_ORIENTATION_LANDSCAPE_FLIPPED`
|
|
576
|
-
| `'portrait'`
|
|
577
|
-
| `'portraitFlipped'`
|
|
572
|
+
| Value | Corresponding `SDL_DisplayOrientation` |
|
|
573
|
+
| --- | --- |
|
|
574
|
+
| `'landscape'` | `SDL_ORIENTATION_LANDSCAPE` |
|
|
575
|
+
| `'landscapeFlipped'` | `SDL_ORIENTATION_LANDSCAPE_FLIPPED` |
|
|
576
|
+
| `'portrait'` | `SDL_ORIENTATION_PORTRAIT` |
|
|
577
|
+
| `'portraitFlipped'` | `SDL_ORIENTATION_PORTRAIT_FLIPPED` |
|
|
578
578
|
|
|
579
579
|
Sample output for two side-to-side monitors is below.
|
|
580
580
|
Notice how the geometries don't overlap:
|
|
@@ -602,55 +602,55 @@ Notice how the geometries don't overlap:
|
|
|
602
602
|
|
|
603
603
|
### sdl.video.windows
|
|
604
604
|
|
|
605
|
-
|
|
605
|
+
- [`<Window>`](#class-window)`[]`
|
|
606
606
|
|
|
607
607
|
A list of all open windows.
|
|
608
608
|
|
|
609
609
|
### sdl.video.focused
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
- [`<Window>`](#class-window)`|<null>`
|
|
612
612
|
|
|
613
613
|
The window that has the current keyboard focus, or `null` if no window has the keyboard focus.
|
|
614
614
|
|
|
615
615
|
### sdl.video.hovered
|
|
616
616
|
|
|
617
|
-
|
|
617
|
+
- [`<Window>`](#class-window)`|<null>`
|
|
618
618
|
|
|
619
619
|
The window that the mouse is hovered over, or `null` if the mouse is not over a window.
|
|
620
620
|
|
|
621
621
|
### sdl.video.createWindow([options])
|
|
622
622
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
623
|
+
- `options: <object>`
|
|
624
|
+
- `title: <string>` Appears in the window's title bar. Default: `''`
|
|
625
|
+
- `display: <number>` An object from `sdl.video.displays` to specify in which display the window should appear (if you have multiple displays). Default: `sdl.video.displays[0]`
|
|
626
|
+
- `x: <number>` The x position in which the window should appear relative to the screen, or `null` for centered. Default: `null`
|
|
627
|
+
- `y: <number>` The y position in which the window should appear relative to the screen, or `null` for centered. Default: `null`
|
|
628
|
+
- `width: <number>` The width of the window. Default: `640`
|
|
629
|
+
- `height: <number>` The height of the window. Default: `480`
|
|
630
|
+
- `visible: <boolean>` Set to `false` to create a hidden window that will only be shown when you call [`window.show()`](#windowshowshow). Default: `true`
|
|
631
|
+
- `fullscreen: <boolean>` Set to `true` to create the window in fullscreen mode. Default: `false`
|
|
632
|
+
- `resizable: <boolean>` Set to `true` to allow resizing the window by dragging its borders. Default: `false`
|
|
633
|
+
- `borderless: <boolean>` Set to `true` to completely hide the window's borders and title bar. Default: `false`
|
|
634
|
+
- `alwaysOnTop: <boolean>` Set to `true` to always show the window above others. Default: `false`
|
|
635
|
+
- `accelerated: <boolean>` Set to `false` to disable hardware accelerated rendering. Default: `true`
|
|
636
|
+
- `vsync: <boolean>` Set to `false` to disable frame rate synchronization. Default: `true`
|
|
637
|
+
- `opengl: <boolean>` Set to `true` to create an OpenGL-compatible window (for use with [@kmamal/gl](https://github.com/kmamal/headless-gl#readme)). Default: `false`
|
|
638
|
+
- `webgpu: <boolean>` Set to `true` to create an WebGPU-compatible window (for use with [@kmamal/gpu](https://github.com/kmamal/gpu#readme)). Default: `false`
|
|
639
|
+
- `skipTaskbar: <boolean>` X11 only. Set to `true` to not add the window to the taskbar. Default: `false`
|
|
640
|
+
- `popupMenu: <boolean>` X11 only. Set to `true` to treat the window like a popup menu. Default: `false`
|
|
641
|
+
- `tooltip: <boolean>` X11 only. Set to `true` to treat the window like a tooltip. Default: `false`
|
|
642
|
+
- `utility: <boolean>` X11 only. Set to `true` to treat the window like a utility window. Default: `false`
|
|
643
|
+
- Returns: [`<Window>`](#class-window) an object representing the new window.
|
|
644
644
|
|
|
645
645
|
Creates a new window.
|
|
646
646
|
|
|
647
647
|
The following restrictions apply:
|
|
648
648
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
649
|
+
- The `display` option is mutually exclusive with the `x` and `y` options.
|
|
650
|
+
- The `resizable` and `borderless` options are mutually exclusive.
|
|
651
|
+
- The `opengl` and `webgpu` options are mutually exclusive.
|
|
652
|
+
- The `vsync` option only applies to windows that are also `accelerated`.
|
|
653
|
+
- The `accelerated` and `vsync` options have no effect if either `opengl` or `webgpu` is also specified.
|
|
654
654
|
|
|
655
655
|
If you set the `opengl` or `webgpu` options, then you must use OpenGL/WebGPU calls to render to the window.
|
|
656
656
|
Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) will fail.
|
|
@@ -686,23 +686,23 @@ Fired when the window gets restored.
|
|
|
686
686
|
|
|
687
687
|
### Event: 'move'
|
|
688
688
|
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
- `x: <number>` The window's new x position, relative to the screen.
|
|
690
|
+
- `y: <number>` The window's new y position, relative to the screen.
|
|
691
691
|
|
|
692
692
|
Fired when the window changes position.
|
|
693
693
|
|
|
694
694
|
### Event: 'resize'
|
|
695
695
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
696
|
+
- `width: <number>` The window's new width.
|
|
697
|
+
- `height: <number>` The window's new height.
|
|
698
|
+
- `pixelWidth: <number>` The window's new width in pixels. See [high-dpi](#high-dpi).
|
|
699
|
+
- `pixelHeight: <number>` The window's new height in pixels. See [high-dpi](#high-dpi).
|
|
700
700
|
|
|
701
701
|
Fired when the window changes size.
|
|
702
702
|
|
|
703
703
|
### Event: 'displayChange'
|
|
704
704
|
|
|
705
|
-
|
|
705
|
+
- `display: <object>` An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the window's new display.
|
|
706
706
|
|
|
707
707
|
Fired when the window moves from one display to another.
|
|
708
708
|
|
|
@@ -724,7 +724,7 @@ Fired when the mouse leaves the window.
|
|
|
724
724
|
|
|
725
725
|
### Event: 'beforeClose'
|
|
726
726
|
|
|
727
|
-
|
|
727
|
+
- `prevent: <function (void) => void>` Call this function to prevent the window from closing.
|
|
728
728
|
|
|
729
729
|
Fired to indicate that the user requested that the window should close (usually by clicking the "x" button).
|
|
730
730
|
If you need to display any confirmation dialogs, call `event.prevent()` and afterwards handle destruction manually.
|
|
@@ -737,89 +737,124 @@ Handle any cleanup here.
|
|
|
737
737
|
|
|
738
738
|
### Event: 'keyDown'
|
|
739
739
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
740
|
+
- `scancode: `[`<Scancode>`](#enum-scancode) The scancode of the key that caused the event.
|
|
741
|
+
- `key: `[`<Key>`](#virtual-keys)`|<null>` The virtual key that caused the event, or `null` if the physical key does not correspond to any virtual key.
|
|
742
|
+
- `repeat: <boolean>` Is `true` if the event was generated by holding down a key for a long time.
|
|
743
|
+
- `shift: <boolean>` Is `true` if the Shift key was pressed when the event was generated.
|
|
744
|
+
- `ctrl: <boolean>` Is `true` if the Ctrl key was pressed when the event was generated.
|
|
745
|
+
- `alt: <boolean>` Is `true` if the Alt key was pressed when the event was generated.
|
|
746
|
+
- `super: <boolean>` Is `true` if the "Windows" key was pressed when the event was generated.
|
|
747
|
+
- `altgr: <boolean>` Is `true` if the AltGr key was pressed when the event was generated.
|
|
748
|
+
- `capslock: <boolean>` Is `true` if CapsLock was active when the event was generated.
|
|
749
|
+
- `numlock: <boolean>` Is `true` if NumLock was active when the event was generated.
|
|
750
750
|
|
|
751
751
|
Fired when a key is pressed, and will also be fired repeatedly afterwards if the key is held down.
|
|
752
752
|
|
|
753
753
|
### Event: 'keyUp'
|
|
754
754
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
755
|
+
- `scancode: `[`<Scancode>`](#enum-scancode) The scancode of the key that caused the event.
|
|
756
|
+
- `key: `[`<Key>`](#virtual-keys)`|<null>` The virtual key that caused the event, or `null` if the physical key does not correspond to any virtual key.
|
|
757
|
+
- `shift: <boolean>` Is `true` if the Shift key was pressed when the event was generated.
|
|
758
|
+
- `ctrl: <boolean>` Is `true` if the Ctrl key was pressed when the event was generated.
|
|
759
|
+
- `alt: <boolean>` Is `true` if the Alt key was pressed when the event was generated.
|
|
760
|
+
- `super: <boolean>` Is `true` if the "Windows" key was pressed when the event was generated.
|
|
761
|
+
- `altgr: <boolean>` Is `true` if the AltGr key was pressed when the event was generated.
|
|
762
|
+
- `capslock: <boolean>` Is `true` if CapsLock was active when the event was generated.
|
|
763
|
+
- `numlock: <boolean>` Is `true` if NumLock was active when the event was generated.
|
|
764
764
|
|
|
765
765
|
Fired when a key is released.
|
|
766
766
|
|
|
767
767
|
### Event: 'textInput'
|
|
768
768
|
|
|
769
|
-
|
|
769
|
+
- `text: <string>` The unicode representation of the character that was entered.
|
|
770
770
|
|
|
771
771
|
Fired when text is entered via the keyboard.
|
|
772
772
|
|
|
773
773
|
### Event: 'mouseButtonDown'
|
|
774
774
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
775
|
+
- `x: <number>` The mouse's x position when the event happened, relative to the window.
|
|
776
|
+
- `y: <number>` The mouse's y position when the event happened, relative to the window.
|
|
777
|
+
- `touch: <boolean>` Is `true` if the event was caused by a touch event.
|
|
778
|
+
- `button: `[`<sdl.mouse.BUTTON>`](#enum-button) The button that was pressed.
|
|
779
779
|
|
|
780
780
|
Fired when a mouse button is pressed.
|
|
781
781
|
|
|
782
782
|
### Event: 'mouseButtonUp'
|
|
783
783
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
784
|
+
- `x: <number>` The mouse's x position when the event happened, relative to the window.
|
|
785
|
+
- `y: <number>` The mouse's y position when the event happened, relative to the window.
|
|
786
|
+
- `touch: <boolean>` Is `true` if the event was caused by a touch event.
|
|
787
|
+
- `button: `[`<sdl.mouse.BUTTON>`](#enum-button) The button that was released.
|
|
788
788
|
|
|
789
789
|
Fired when a mouse button is released.
|
|
790
790
|
|
|
791
791
|
### Event: 'mouseMove'
|
|
792
792
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
793
|
+
- `x: <number>` The mouse's x position when the event happened, relative to the window.
|
|
794
|
+
- `y: <number>` The mouse's y position when the event happened, relative to the window.
|
|
795
|
+
- `touch: <boolean>` Is `true` if the event was caused by a touch event.
|
|
796
796
|
|
|
797
797
|
Fired when the mouse moves.
|
|
798
798
|
|
|
799
799
|
### Event: 'mouseWheel'
|
|
800
800
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
801
|
+
- `x: <number>` The mouse's x position when the event happened, relative to the window.
|
|
802
|
+
- `y: <number>` The mouse's y position when the event happened, relative to the window.
|
|
803
|
+
- `touch: <boolean>` Is `true` if the event was caused by a touch event.
|
|
804
|
+
- `dx: <number>` The wheel's x movement, relative to its last position.
|
|
805
|
+
- `dy: <number>` The wheel's y movement, relative to its last position.
|
|
806
|
+
- `flipped: <boolean>` Is `true` if the underlying platform reverses the mouse wheel's scroll direction. Multiply `dx` and `dy` by `-1` to get the correct values.
|
|
807
807
|
|
|
808
808
|
Fired when the mouse wheel is scrolled.
|
|
809
809
|
|
|
810
|
+
### Event: 'fingerDown'
|
|
811
|
+
|
|
812
|
+
- `device: <object>`: An object from [`sdl.touch.devices`](#sdltouchdevices) indicating the touch device that caused the event.
|
|
813
|
+
- `fingerId: <number>` The id of the finger that coused the event.
|
|
814
|
+
- `x: <number>` The finger's x position when the event happened, normalized in the range from `0` to `1`.
|
|
815
|
+
- `y: <number>` The finger's y position when the event happened, normalized in the range from `0` to `1`.
|
|
816
|
+
- `pressure: <number>` The finger's pressure when the event happened, normalized in the range from `0` to `1`.
|
|
817
|
+
- `mouse: <boolean>` Is `true` if the event was caused by a mouse event.
|
|
818
|
+
|
|
819
|
+
Fired when a finger is presed to the touch surface.
|
|
820
|
+
|
|
821
|
+
### Event: 'fingerUp'
|
|
822
|
+
|
|
823
|
+
- `device: <object>`: An object from [`sdl.touch.devices`](#sdltouchdevices) indicating the touch device that caused the event.
|
|
824
|
+
- `fingerId: <number>` The id of the finger that coused the event.
|
|
825
|
+
- `x: <number>` The finger's x position when the event happened, normalized in the range from `0` to `1`.
|
|
826
|
+
- `y: <number>` The finger's y position when the event happened, normalized in the range from `0` to `1`.
|
|
827
|
+
- `pressure: <number>` The finger's pressure when the event happened, normalized in the range from `0` to `1`.
|
|
828
|
+
- `mouse: <boolean>` Is `true` if the event was caused by a mouse event.
|
|
829
|
+
|
|
830
|
+
Fired when a finger is lifted from the touch surface.
|
|
831
|
+
|
|
832
|
+
### Event: 'fingerMove'
|
|
833
|
+
|
|
834
|
+
- `device: <object>`: An object from [`sdl.touch.devices`](#sdltouchdevices) indicating the touch device that caused the event.
|
|
835
|
+
- `fingerId: <number>` The id of the finger that coused the event.
|
|
836
|
+
- `x: <number>` The finger's x position when the event happened, normalized in the range from `0` to `1`.
|
|
837
|
+
- `y: <number>` The finger's y position when the event happened, normalized in the range from `0` to `1`.
|
|
838
|
+
- `dx: <number>` The finger's x position when the event happened, normalized in the range from `-1` to `1`.
|
|
839
|
+
- `dy: <number>` The finger's y position when the event happened, normalized in the range from `-1` to `1`.
|
|
840
|
+
- `pressure: <number>` The finger's pressure when the event happened, normalized in the range from `0` to `1`.
|
|
841
|
+
- `mouse: <boolean>` Is `true` if the event was caused by a mouse event.
|
|
842
|
+
|
|
843
|
+
Fired when a finger moves on the touch surface.
|
|
844
|
+
|
|
810
845
|
### Event: 'dropBegin'
|
|
811
846
|
|
|
812
847
|
When you drop a set of items onto a window, first the [`'dropBegin'`](#event-dropbegin) event is fired, then a number of [`'dropText'`](#event-droptext) and/or [`'dropFile'`](#event-dropfile) events are fired, corresponding to the contents of the drop, then finally the [`'dropComplete'`](#event-dropcomplete) event is fired.
|
|
813
848
|
|
|
814
849
|
### Event: 'dropText'
|
|
815
850
|
|
|
816
|
-
|
|
851
|
+
- `text: <string>`: The text that was dropped onto the window.
|
|
817
852
|
|
|
818
853
|
Fired when one of the drops is a text item.
|
|
819
854
|
|
|
820
855
|
### Event: 'dropFile'
|
|
821
856
|
|
|
822
|
-
|
|
857
|
+
- `file: <string>`: The path to the file that was dropped onto the window.
|
|
823
858
|
|
|
824
859
|
Fired when one of the drops is a file.
|
|
825
860
|
|
|
@@ -829,98 +864,98 @@ Fired after a set of items has been dropped on a window.
|
|
|
829
864
|
|
|
830
865
|
### window.id
|
|
831
866
|
|
|
832
|
-
|
|
867
|
+
- `<number>`
|
|
833
868
|
|
|
834
869
|
A unique identifier for the window.
|
|
835
870
|
|
|
836
871
|
### window.title
|
|
837
872
|
|
|
838
|
-
|
|
873
|
+
- `<string>`
|
|
839
874
|
|
|
840
875
|
The text that appears in the window's title bar.
|
|
841
876
|
|
|
842
877
|
### window.setTitle(title)
|
|
843
878
|
|
|
844
|
-
|
|
879
|
+
- `title: <string>`: The new title.
|
|
845
880
|
|
|
846
881
|
Changes the text that appears in the window's title bar.
|
|
847
882
|
|
|
848
883
|
### window.x
|
|
849
884
|
|
|
850
|
-
|
|
885
|
+
- `<number>`
|
|
851
886
|
|
|
852
887
|
The window's x position, relative to the screen.
|
|
853
888
|
|
|
854
889
|
### window.y
|
|
855
890
|
|
|
856
|
-
|
|
891
|
+
- `<number>`
|
|
857
892
|
|
|
858
893
|
The window's y position, relative to the screen.
|
|
859
894
|
|
|
860
895
|
### window.setPosition(x, y)
|
|
861
896
|
|
|
862
|
-
|
|
863
|
-
|
|
897
|
+
- `x: <number>`: The new x position, relative to the screen.
|
|
898
|
+
- `y: <number>`: The new y position, relative to the screen.
|
|
864
899
|
|
|
865
900
|
Moves the window to a new position on the screen.
|
|
866
901
|
|
|
867
902
|
### window.width
|
|
868
903
|
|
|
869
|
-
|
|
904
|
+
- `<number>`
|
|
870
905
|
|
|
871
906
|
The window's width.
|
|
872
907
|
|
|
873
908
|
### window.height
|
|
874
909
|
|
|
875
|
-
|
|
910
|
+
- `<number>`
|
|
876
911
|
|
|
877
912
|
The window's height.
|
|
878
913
|
|
|
879
914
|
### window.pixelWidth
|
|
880
915
|
|
|
881
|
-
|
|
916
|
+
- `<number>`
|
|
882
917
|
|
|
883
918
|
The window's width in pixels.
|
|
884
919
|
Is larger than [`width`](#windowwidth) on [high-dpi](#high-dpi) displays.
|
|
885
920
|
|
|
886
921
|
### window.pixelHeight
|
|
887
922
|
|
|
888
|
-
|
|
923
|
+
- `<number>`
|
|
889
924
|
|
|
890
925
|
The window's height in pixels.
|
|
891
926
|
Is larger than [`height`](#windowheight) on [high-dpi](#high-dpi) displays.
|
|
892
927
|
|
|
893
928
|
### window.setSize(width, height)
|
|
894
929
|
|
|
895
|
-
|
|
896
|
-
|
|
930
|
+
- `width: <number>`: The new width.
|
|
931
|
+
- `height: <number>`: The new height.
|
|
897
932
|
|
|
898
933
|
Changes the size of the window.
|
|
899
934
|
|
|
900
935
|
### window.setSizeInPixels(pixelWidth, pixelHeight)
|
|
901
936
|
|
|
902
|
-
|
|
903
|
-
|
|
937
|
+
- `pixelWidth: <number>`: The new width in pixels.
|
|
938
|
+
- `pixelHeight: <number>`: The new height in pixels.
|
|
904
939
|
|
|
905
940
|
Changes the size of the window.
|
|
906
941
|
This function only behaves differently from [`window.setSize()`](#windowsetsizewidth-height) for [high-dpi](#high-dpi) displays.
|
|
907
942
|
|
|
908
943
|
### window.display
|
|
909
944
|
|
|
910
|
-
|
|
945
|
+
- `<object>`
|
|
911
946
|
|
|
912
947
|
An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display the window belongs to.
|
|
913
948
|
If the window spans multiple displays, then the display that contains the center of the window is returned.
|
|
914
949
|
|
|
915
950
|
### window.visible
|
|
916
951
|
|
|
917
|
-
|
|
952
|
+
- `<boolean>`
|
|
918
953
|
|
|
919
954
|
Is `true` if the window is visible.
|
|
920
955
|
|
|
921
956
|
### window.show([show])
|
|
922
957
|
|
|
923
|
-
|
|
958
|
+
- `show: <boolean>` Set to `true` to make the window visible, `false` to hide it. Default: `true`
|
|
924
959
|
|
|
925
960
|
Shows or hides the window.
|
|
926
961
|
|
|
@@ -930,59 +965,59 @@ Equivalent to [`window.show(false)`](#windowshowshow).
|
|
|
930
965
|
|
|
931
966
|
### window.fullscreen
|
|
932
967
|
|
|
933
|
-
|
|
968
|
+
- `<boolean>`
|
|
934
969
|
|
|
935
970
|
Is `true` if the window is fullscreen.
|
|
936
971
|
A fullscreen window is displayed over the entire screen.
|
|
937
972
|
|
|
938
973
|
### window.setFullscreen(fullscreen)
|
|
939
974
|
|
|
940
|
-
|
|
975
|
+
- `fullscreen: <boolean>` The new value of the property.
|
|
941
976
|
|
|
942
977
|
Changes the window's fullscreen property.
|
|
943
978
|
|
|
944
979
|
### window.resizable
|
|
945
980
|
|
|
946
|
-
|
|
981
|
+
- `<boolean>`
|
|
947
982
|
|
|
948
983
|
Is `true` if the window is resizable.
|
|
949
984
|
A resizable window can be resized by dragging its borders.
|
|
950
985
|
|
|
951
986
|
### window.setResizable(resizable)
|
|
952
987
|
|
|
953
|
-
|
|
988
|
+
- `resizable: <boolean>` The new value of the property.
|
|
954
989
|
|
|
955
990
|
Changes the window's resizable property.
|
|
956
991
|
|
|
957
992
|
### window.borderless
|
|
958
993
|
|
|
959
|
-
|
|
994
|
+
- `<boolean>`
|
|
960
995
|
|
|
961
996
|
Is `true` if the window is borderless.
|
|
962
997
|
A borderless window has no borders or title bar.
|
|
963
998
|
|
|
964
999
|
### window.setBorderless(borderless)
|
|
965
1000
|
|
|
966
|
-
|
|
1001
|
+
- `borderless: <boolean>` The new value of the property.
|
|
967
1002
|
|
|
968
1003
|
Changes the window's borderless property.
|
|
969
1004
|
|
|
970
1005
|
### window.alwaysOnTop
|
|
971
1006
|
|
|
972
|
-
|
|
1007
|
+
- `<boolean>`
|
|
973
1008
|
|
|
974
1009
|
Is `true` if the window was created with `alwaysOnTop: true`.
|
|
975
1010
|
Such a window is always be shown above other windows.
|
|
976
1011
|
|
|
977
1012
|
### window.accelerated
|
|
978
1013
|
|
|
979
|
-
|
|
1014
|
+
- `<boolean>`
|
|
980
1015
|
|
|
981
1016
|
Is `true` if the window is using hardware accelerated rendering.
|
|
982
1017
|
|
|
983
1018
|
### window.setAccelerated(accelerated)
|
|
984
1019
|
|
|
985
|
-
|
|
1020
|
+
- `accelerated: <boolean>` The new value of the property.
|
|
986
1021
|
|
|
987
1022
|
Changes the window's accelerated property.
|
|
988
1023
|
|
|
@@ -990,7 +1025,7 @@ If you have set the `opengl` or `webgpu` options, then calls to this function wi
|
|
|
990
1025
|
|
|
991
1026
|
### window.vsync
|
|
992
1027
|
|
|
993
|
-
|
|
1028
|
+
- `<boolean>`
|
|
994
1029
|
|
|
995
1030
|
Is `true` if the window is using vsync.
|
|
996
1031
|
Vsync synchronizes the window's frame rate with the display's refresh rate to prevent tearing.
|
|
@@ -998,7 +1033,7 @@ Note that vsync can only be set to `true` if [`accelerated`](#windowaccelerated)
|
|
|
998
1033
|
|
|
999
1034
|
### window.setVsync(vsync)
|
|
1000
1035
|
|
|
1001
|
-
|
|
1036
|
+
- `vsync: <boolean>` The new value of the property.
|
|
1002
1037
|
|
|
1003
1038
|
Changes the window's vsync property.
|
|
1004
1039
|
|
|
@@ -1006,7 +1041,7 @@ If you have set the `opengl` or `webgpu` options, then calls to this function wi
|
|
|
1006
1041
|
|
|
1007
1042
|
### window.opengl
|
|
1008
1043
|
|
|
1009
|
-
|
|
1044
|
+
- `<boolean>`
|
|
1010
1045
|
|
|
1011
1046
|
Is `true` if the window was created in OpenGl mode.
|
|
1012
1047
|
In OpenGL mode, you must use OpenGL calls to render to the window.
|
|
@@ -1014,7 +1049,7 @@ Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) wi
|
|
|
1014
1049
|
|
|
1015
1050
|
### window.webgpu
|
|
1016
1051
|
|
|
1017
|
-
|
|
1052
|
+
- `<boolean>`
|
|
1018
1053
|
|
|
1019
1054
|
Is `true` if the window was created in WebGPU mode.
|
|
1020
1055
|
In WebGPU mode, you must use WebGPU calls to render to the window.
|
|
@@ -1022,8 +1057,8 @@ Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) wi
|
|
|
1022
1057
|
|
|
1023
1058
|
### window.native
|
|
1024
1059
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1060
|
+
- `<object>`
|
|
1061
|
+
- `handle : <Buffer>` The platform-specific handle of the window.
|
|
1027
1062
|
|
|
1028
1063
|
The native type of `handle` is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
|
|
1029
1064
|
It should work exactly like the [`win.getNativeWindowHandle()`](https://www.electronjs.org/docs/latest/api/browser-window#wingetnativewindowhandle) electron method.
|
|
@@ -1034,7 +1069,7 @@ They are used internally for passing to [@kmamal/gl](https://github.com/kmamal/h
|
|
|
1034
1069
|
|
|
1035
1070
|
### window.maximized
|
|
1036
1071
|
|
|
1037
|
-
|
|
1072
|
+
- `<boolean>`
|
|
1038
1073
|
|
|
1039
1074
|
Is `true` if the window is maximized.
|
|
1040
1075
|
|
|
@@ -1044,7 +1079,7 @@ Maximizes the window.
|
|
|
1044
1079
|
|
|
1045
1080
|
### window.minimized
|
|
1046
1081
|
|
|
1047
|
-
|
|
1082
|
+
- `<boolean>`
|
|
1048
1083
|
|
|
1049
1084
|
Is `true` if the window is minimized.
|
|
1050
1085
|
|
|
@@ -1058,7 +1093,7 @@ Restores the window so it is neither minimized nor maximized.
|
|
|
1058
1093
|
|
|
1059
1094
|
### window.focused
|
|
1060
1095
|
|
|
1061
|
-
|
|
1096
|
+
- `<boolean>`
|
|
1062
1097
|
|
|
1063
1098
|
Is `true` if the window has keyboard input.
|
|
1064
1099
|
|
|
@@ -1068,13 +1103,13 @@ Gives the window the keyboard focus.
|
|
|
1068
1103
|
|
|
1069
1104
|
### window.hovered
|
|
1070
1105
|
|
|
1071
|
-
|
|
1106
|
+
- `<boolean>`
|
|
1072
1107
|
|
|
1073
1108
|
Is `true` if the mouse is over the window.
|
|
1074
1109
|
|
|
1075
1110
|
### window.skipTaskbar
|
|
1076
1111
|
|
|
1077
|
-
|
|
1112
|
+
- `<boolean>`
|
|
1078
1113
|
|
|
1079
1114
|
X11 only.
|
|
1080
1115
|
Is `true` if the window was created with `skipTaskbar: true`.
|
|
@@ -1082,7 +1117,7 @@ Such a window is not added to the taskbar.
|
|
|
1082
1117
|
|
|
1083
1118
|
### window.popupMenu
|
|
1084
1119
|
|
|
1085
|
-
|
|
1120
|
+
- `<boolean>`
|
|
1086
1121
|
|
|
1087
1122
|
X11 only.
|
|
1088
1123
|
Is `true` if the window was created with `popupMenu: true`.
|
|
@@ -1090,7 +1125,7 @@ Such a window is always treated as a popup menu.
|
|
|
1090
1125
|
|
|
1091
1126
|
### window.tooltip
|
|
1092
1127
|
|
|
1093
|
-
|
|
1128
|
+
- `<boolean>`
|
|
1094
1129
|
|
|
1095
1130
|
X11 only.
|
|
1096
1131
|
Is `true` if the window was created with `tooltip: true`.
|
|
@@ -1098,7 +1133,7 @@ Such a window is always treated as a tooltip.
|
|
|
1098
1133
|
|
|
1099
1134
|
### window.utility
|
|
1100
1135
|
|
|
1101
|
-
|
|
1136
|
+
- `<boolean>`
|
|
1102
1137
|
|
|
1103
1138
|
X11 only.
|
|
1104
1139
|
Is `true` if the window was created with `utility: true`.
|
|
@@ -1106,11 +1141,11 @@ Such a window is always treated as a utility window.
|
|
|
1106
1141
|
|
|
1107
1142
|
### window.render(width, height, stride, format, buffer[, options])
|
|
1108
1143
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1144
|
+
- `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to display on the window.
|
|
1145
|
+
- `options: <object>`
|
|
1146
|
+
- `scaling: <string>` How to scale the image to match the window size. Default: `'nearest'`
|
|
1147
|
+
- `dstRect: <object>` Where exactly on the window to draw the image. Default: whole window.
|
|
1148
|
+
- `x, y, width, height: <rect>` The components of the rectangle.
|
|
1114
1149
|
|
|
1115
1150
|
Displays an image in the window.
|
|
1116
1151
|
|
|
@@ -1122,24 +1157,24 @@ If the dimensions of the image do not match the dimensions of the area it should
|
|
|
1122
1157
|
The `scaling` argument controls how exactly the scaling is implemented.
|
|
1123
1158
|
Possible values are:
|
|
1124
1159
|
|
|
1125
|
-
| Value
|
|
1126
|
-
| ---
|
|
1127
|
-
| `'nearest'` | `SDL_ScaleModeNearest`
|
|
1128
|
-
| `'linear'`
|
|
1129
|
-
| `'best'`
|
|
1160
|
+
| Value | Corresponding `SDL_ScaleMode` | Description |
|
|
1161
|
+
| --- | --- | --- |
|
|
1162
|
+
| `'nearest'` | `SDL_ScaleModeNearest` | nearest pixel sampling |
|
|
1163
|
+
| `'linear'` | `SDL_ScaleModeLinear` | linear filtering |
|
|
1164
|
+
| `'best'` | `SDL_ScaleModeBest` | anisotropic filtering |
|
|
1130
1165
|
|
|
1131
1166
|
If the window was created with either of the `opengl` or `webgpu` options, then you must use OpenGL/WebGPU calls to render to the window.
|
|
1132
1167
|
Calls to `render()` will fail.
|
|
1133
1168
|
|
|
1134
1169
|
### window.setIcon(width, height, stride, format, buffer)
|
|
1135
1170
|
|
|
1136
|
-
|
|
1171
|
+
- `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to display as the icon of the window.
|
|
1137
1172
|
|
|
1138
1173
|
Set's the window's icon, usually displayed in the title bar and the taskbar.
|
|
1139
1174
|
|
|
1140
1175
|
### window.flash([untilFocused])
|
|
1141
1176
|
|
|
1142
|
-
|
|
1177
|
+
- `untilFocused: <boolean>` Whether to keep flashing the window until the user focuses it. Default: `false`
|
|
1143
1178
|
|
|
1144
1179
|
Flash the window briefly to get attention.
|
|
1145
1180
|
If `untilFocused` is set, the window will continue flashing until the user focuses it.
|
|
@@ -1150,7 +1185,7 @@ Stop the window from flashing.
|
|
|
1150
1185
|
|
|
1151
1186
|
### window.destroyed
|
|
1152
1187
|
|
|
1153
|
-
|
|
1188
|
+
- `<boolean>`
|
|
1154
1189
|
|
|
1155
1190
|
Is `true` if the window is destroyed.
|
|
1156
1191
|
A destroyed window object must not be used any further.
|
|
@@ -1164,7 +1199,6 @@ Destroys the window.
|
|
|
1164
1199
|
Asks before destroying the window.
|
|
1165
1200
|
The difference between this function and [destroy()](#windowdestroy) is that this function first makes the window emit the [`'beforeClose'`](#event-beforeclose) event, giving you a chance to prevent the window from being destroyed.
|
|
1166
1201
|
|
|
1167
|
-
|
|
1168
1202
|
## sdl.keyboard
|
|
1169
1203
|
|
|
1170
1204
|
There are three levels at which you can deal with the keyboard: physical keys ([scancodes](#enum-scancode)), virtual keys ([keys](#virtual-keys)), and text ([`'textInput'`](#event-textinput) events).
|
|
@@ -1190,7 +1224,6 @@ Consider for example what happens when a user on a Greek keyboard layout enters
|
|
|
1190
1224
|
Trying to handle text input by manually translating key presses to text is not a very viable solution.
|
|
1191
1225
|
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.
|
|
1192
1226
|
|
|
1193
|
-
|
|
1194
1227
|
### Virtual keys
|
|
1195
1228
|
|
|
1196
1229
|
String values used to represent virtual keys in the context of the current keyboard mapping.
|
|
@@ -1211,265 +1244,271 @@ Values are based on the [USB usage page standard](https://www.usb.org/sites/defa
|
|
|
1211
1244
|
|
|
1212
1245
|
<summary>Click to expand table</summary>
|
|
1213
1246
|
|
|
1214
|
-
| Value
|
|
1215
|
-
| ---
|
|
1216
|
-
| `sdl.keyboard.SCANCODE.A`
|
|
1217
|
-
| `sdl.keyboard.SCANCODE.B`
|
|
1218
|
-
| `sdl.keyboard.SCANCODE.C`
|
|
1219
|
-
| `sdl.keyboard.SCANCODE.D`
|
|
1220
|
-
| `sdl.keyboard.SCANCODE.E`
|
|
1221
|
-
| `sdl.keyboard.SCANCODE.F`
|
|
1222
|
-
| `sdl.keyboard.SCANCODE.G`
|
|
1223
|
-
| `sdl.keyboard.SCANCODE.H`
|
|
1224
|
-
| `sdl.keyboard.SCANCODE.I`
|
|
1225
|
-
| `sdl.keyboard.SCANCODE.J`
|
|
1226
|
-
| `sdl.keyboard.SCANCODE.K`
|
|
1227
|
-
| `sdl.keyboard.SCANCODE.L`
|
|
1228
|
-
| `sdl.keyboard.SCANCODE.M`
|
|
1229
|
-
| `sdl.keyboard.SCANCODE.N`
|
|
1230
|
-
| `sdl.keyboard.SCANCODE.O`
|
|
1231
|
-
| `sdl.keyboard.SCANCODE.P`
|
|
1232
|
-
| `sdl.keyboard.SCANCODE.Q`
|
|
1233
|
-
| `sdl.keyboard.SCANCODE.R`
|
|
1234
|
-
| `sdl.keyboard.SCANCODE.S`
|
|
1235
|
-
| `sdl.keyboard.SCANCODE.T`
|
|
1236
|
-
| `sdl.keyboard.SCANCODE.U`
|
|
1237
|
-
| `sdl.keyboard.SCANCODE.V`
|
|
1238
|
-
| `sdl.keyboard.SCANCODE.W`
|
|
1239
|
-
| `sdl.keyboard.SCANCODE.X`
|
|
1240
|
-
| `sdl.keyboard.SCANCODE.Y`
|
|
1241
|
-
| `sdl.keyboard.SCANCODE.Z`
|
|
1242
|
-
| `sdl.keyboard.SCANCODE.1`
|
|
1243
|
-
| `sdl.keyboard.SCANCODE.2`
|
|
1244
|
-
| `sdl.keyboard.SCANCODE.3`
|
|
1245
|
-
| `sdl.keyboard.SCANCODE.4`
|
|
1246
|
-
| `sdl.keyboard.SCANCODE.5`
|
|
1247
|
-
| `sdl.keyboard.SCANCODE.6`
|
|
1248
|
-
| `sdl.keyboard.SCANCODE.7`
|
|
1249
|
-
| `sdl.keyboard.SCANCODE.8`
|
|
1250
|
-
| `sdl.keyboard.SCANCODE.9`
|
|
1251
|
-
| `sdl.keyboard.SCANCODE.0`
|
|
1252
|
-
| `sdl.keyboard.SCANCODE.RETURN`
|
|
1253
|
-
| `sdl.keyboard.SCANCODE.ESCAPE`
|
|
1254
|
-
| `sdl.keyboard.SCANCODE.BACKSPACE`
|
|
1255
|
-
| `sdl.keyboard.SCANCODE.TAB`
|
|
1256
|
-
| `sdl.keyboard.SCANCODE.SPACE`
|
|
1257
|
-
| `sdl.keyboard.SCANCODE.MINUS`
|
|
1258
|
-
| `sdl.keyboard.SCANCODE.EQUALS`
|
|
1259
|
-
| `sdl.keyboard.SCANCODE.LEFTBRACKET`
|
|
1260
|
-
| `sdl.keyboard.SCANCODE.RIGHTBRACKET`
|
|
1261
|
-
| `sdl.keyboard.SCANCODE.BACKSLASH`
|
|
1262
|
-
| `sdl.keyboard.SCANCODE.NONUSHASH`
|
|
1263
|
-
| `sdl.keyboard.SCANCODE.SEMICOLON`
|
|
1264
|
-
| `sdl.keyboard.SCANCODE.APOSTROPHE`
|
|
1265
|
-
| `sdl.keyboard.SCANCODE.GRAVE`
|
|
1266
|
-
| `sdl.keyboard.SCANCODE.COMMA`
|
|
1267
|
-
| `sdl.keyboard.SCANCODE.PERIOD`
|
|
1268
|
-
| `sdl.keyboard.SCANCODE.SLASH`
|
|
1269
|
-
| `sdl.keyboard.SCANCODE.CAPSLOCK`
|
|
1270
|
-
| `sdl.keyboard.SCANCODE.F1`
|
|
1271
|
-
| `sdl.keyboard.SCANCODE.F2`
|
|
1272
|
-
| `sdl.keyboard.SCANCODE.F3`
|
|
1273
|
-
| `sdl.keyboard.SCANCODE.F4`
|
|
1274
|
-
| `sdl.keyboard.SCANCODE.F5`
|
|
1275
|
-
| `sdl.keyboard.SCANCODE.F6`
|
|
1276
|
-
| `sdl.keyboard.SCANCODE.F7`
|
|
1277
|
-
| `sdl.keyboard.SCANCODE.F8`
|
|
1278
|
-
| `sdl.keyboard.SCANCODE.F9`
|
|
1279
|
-
| `sdl.keyboard.SCANCODE.F10`
|
|
1280
|
-
| `sdl.keyboard.SCANCODE.F11`
|
|
1281
|
-
| `sdl.keyboard.SCANCODE.F12`
|
|
1282
|
-
| `sdl.keyboard.SCANCODE.PRINTSCREEN`
|
|
1283
|
-
| `sdl.keyboard.SCANCODE.SCROLLLOCK`
|
|
1284
|
-
| `sdl.keyboard.SCANCODE.PAUSE`
|
|
1285
|
-
| `sdl.keyboard.SCANCODE.INSERT`
|
|
1286
|
-
| `sdl.keyboard.SCANCODE.HOME`
|
|
1287
|
-
| `sdl.keyboard.SCANCODE.PAGEUP`
|
|
1288
|
-
| `sdl.keyboard.SCANCODE.DELETE`
|
|
1289
|
-
| `sdl.keyboard.SCANCODE.END`
|
|
1290
|
-
| `sdl.keyboard.SCANCODE.PAGEDOWN`
|
|
1291
|
-
| `sdl.keyboard.SCANCODE.RIGHT`
|
|
1292
|
-
| `sdl.keyboard.SCANCODE.LEFT`
|
|
1293
|
-
| `sdl.keyboard.SCANCODE.DOWN`
|
|
1294
|
-
| `sdl.keyboard.SCANCODE.UP`
|
|
1295
|
-
| `sdl.keyboard.SCANCODE.NUMLOCKCLEAR`
|
|
1296
|
-
| `sdl.keyboard.SCANCODE.KP_DIVIDE`
|
|
1297
|
-
| `sdl.keyboard.SCANCODE.KP_MULTIPLY`
|
|
1298
|
-
| `sdl.keyboard.SCANCODE.KP_MINUS`
|
|
1299
|
-
| `sdl.keyboard.SCANCODE.KP_PLUS`
|
|
1300
|
-
| `sdl.keyboard.SCANCODE.KP_ENTER`
|
|
1301
|
-
| `sdl.keyboard.SCANCODE.KP_1`
|
|
1302
|
-
| `sdl.keyboard.SCANCODE.KP_2`
|
|
1303
|
-
| `sdl.keyboard.SCANCODE.KP_3`
|
|
1304
|
-
| `sdl.keyboard.SCANCODE.KP_4`
|
|
1305
|
-
| `sdl.keyboard.SCANCODE.KP_5`
|
|
1306
|
-
| `sdl.keyboard.SCANCODE.KP_6`
|
|
1307
|
-
| `sdl.keyboard.SCANCODE.KP_7`
|
|
1308
|
-
| `sdl.keyboard.SCANCODE.KP_8`
|
|
1309
|
-
| `sdl.keyboard.SCANCODE.KP_9`
|
|
1310
|
-
| `sdl.keyboard.SCANCODE.KP_0`
|
|
1311
|
-
| `sdl.keyboard.SCANCODE.KP_PERIOD`
|
|
1312
|
-
| `sdl.keyboard.SCANCODE.NONUSBACKSLASH`
|
|
1313
|
-
| `sdl.keyboard.SCANCODE.APPLICATION`
|
|
1314
|
-
| `sdl.keyboard.SCANCODE.POWER`
|
|
1315
|
-
| `sdl.keyboard.SCANCODE.KP_EQUALS`
|
|
1316
|
-
| `sdl.keyboard.SCANCODE.F13`
|
|
1317
|
-
| `sdl.keyboard.SCANCODE.F14`
|
|
1318
|
-
| `sdl.keyboard.SCANCODE.F15`
|
|
1319
|
-
| `sdl.keyboard.SCANCODE.F16`
|
|
1320
|
-
| `sdl.keyboard.SCANCODE.F17`
|
|
1321
|
-
| `sdl.keyboard.SCANCODE.F18`
|
|
1322
|
-
| `sdl.keyboard.SCANCODE.F19`
|
|
1323
|
-
| `sdl.keyboard.SCANCODE.F20`
|
|
1324
|
-
| `sdl.keyboard.SCANCODE.F21`
|
|
1325
|
-
| `sdl.keyboard.SCANCODE.F22`
|
|
1326
|
-
| `sdl.keyboard.SCANCODE.F23`
|
|
1327
|
-
| `sdl.keyboard.SCANCODE.F24`
|
|
1328
|
-
| `sdl.keyboard.SCANCODE.EXECUTE`
|
|
1329
|
-
| `sdl.keyboard.SCANCODE.HELP`
|
|
1330
|
-
| `sdl.keyboard.SCANCODE.MENU`
|
|
1331
|
-
| `sdl.keyboard.SCANCODE.SELECT`
|
|
1332
|
-
| `sdl.keyboard.SCANCODE.STOP`
|
|
1333
|
-
| `sdl.keyboard.SCANCODE.AGAIN`
|
|
1334
|
-
| `sdl.keyboard.SCANCODE.UNDO`
|
|
1335
|
-
| `sdl.keyboard.SCANCODE.CUT`
|
|
1336
|
-
| `sdl.keyboard.SCANCODE.COPY`
|
|
1337
|
-
| `sdl.keyboard.SCANCODE.PASTE`
|
|
1338
|
-
| `sdl.keyboard.SCANCODE.FIND`
|
|
1339
|
-
| `sdl.keyboard.SCANCODE.MUTE`
|
|
1340
|
-
| `sdl.keyboard.SCANCODE.VOLUMEUP`
|
|
1341
|
-
| `sdl.keyboard.SCANCODE.VOLUMEDOWN`
|
|
1342
|
-
| `sdl.keyboard.SCANCODE.KP_COMMA`
|
|
1343
|
-
| `sdl.keyboard.SCANCODE.KP_EQUALSAS400`
|
|
1344
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL1`
|
|
1345
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL2`
|
|
1346
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL3`
|
|
1347
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL4`
|
|
1348
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL5`
|
|
1349
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL6`
|
|
1350
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL7`
|
|
1351
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL8`
|
|
1352
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL9`
|
|
1353
|
-
| `sdl.keyboard.SCANCODE.LANG1`
|
|
1354
|
-
| `sdl.keyboard.SCANCODE.LANG2`
|
|
1355
|
-
| `sdl.keyboard.SCANCODE.LANG3`
|
|
1356
|
-
| `sdl.keyboard.SCANCODE.LANG4`
|
|
1357
|
-
| `sdl.keyboard.SCANCODE.LANG5`
|
|
1358
|
-
| `sdl.keyboard.SCANCODE.LANG6`
|
|
1359
|
-
| `sdl.keyboard.SCANCODE.LANG7`
|
|
1360
|
-
| `sdl.keyboard.SCANCODE.LANG8`
|
|
1361
|
-
| `sdl.keyboard.SCANCODE.LANG9`
|
|
1362
|
-
| `sdl.keyboard.SCANCODE.ALTERASE`
|
|
1363
|
-
| `sdl.keyboard.SCANCODE.SYSREQ`
|
|
1364
|
-
| `sdl.keyboard.SCANCODE.CANCEL`
|
|
1365
|
-
| `sdl.keyboard.SCANCODE.CLEAR`
|
|
1366
|
-
| `sdl.keyboard.SCANCODE.PRIOR`
|
|
1367
|
-
| `sdl.keyboard.SCANCODE.RETURN2`
|
|
1368
|
-
| `sdl.keyboard.SCANCODE.SEPARATOR`
|
|
1369
|
-
| `sdl.keyboard.SCANCODE.OUT`
|
|
1370
|
-
| `sdl.keyboard.SCANCODE.OPER`
|
|
1371
|
-
| `sdl.keyboard.SCANCODE.CLEARAGAIN`
|
|
1372
|
-
| `sdl.keyboard.SCANCODE.CRSEL`
|
|
1373
|
-
| `sdl.keyboard.SCANCODE.EXSEL`
|
|
1374
|
-
| `sdl.keyboard.SCANCODE.KP_00`
|
|
1375
|
-
| `sdl.keyboard.SCANCODE.KP_000`
|
|
1376
|
-
| `sdl.keyboard.SCANCODE.THOUSANDSSEPARATOR` | `SDL_SCANCODE_THOUSANDSSEPARATOR` |
|
|
1377
|
-
| `sdl.keyboard.SCANCODE.DECIMALSEPARATOR`
|
|
1378
|
-
| `sdl.keyboard.SCANCODE.CURRENCYUNIT`
|
|
1379
|
-
| `sdl.keyboard.SCANCODE.CURRENCYSUBUNIT`
|
|
1380
|
-
| `sdl.keyboard.SCANCODE.KP_LEFTPAREN`
|
|
1381
|
-
| `sdl.keyboard.SCANCODE.KP_RIGHTPAREN`
|
|
1382
|
-
| `sdl.keyboard.SCANCODE.KP_LEFTBRACE`
|
|
1383
|
-
| `sdl.keyboard.SCANCODE.KP_RIGHTBRACE`
|
|
1384
|
-
| `sdl.keyboard.SCANCODE.KP_TAB`
|
|
1385
|
-
| `sdl.keyboard.SCANCODE.KP_BACKSPACE`
|
|
1386
|
-
| `sdl.keyboard.SCANCODE.KP_A`
|
|
1387
|
-
| `sdl.keyboard.SCANCODE.KP_B`
|
|
1388
|
-
| `sdl.keyboard.SCANCODE.KP_C`
|
|
1389
|
-
| `sdl.keyboard.SCANCODE.KP_D`
|
|
1390
|
-
| `sdl.keyboard.SCANCODE.KP_E`
|
|
1391
|
-
| `sdl.keyboard.SCANCODE.KP_F`
|
|
1392
|
-
| `sdl.keyboard.SCANCODE.KP_XOR`
|
|
1393
|
-
| `sdl.keyboard.SCANCODE.KP_POWER`
|
|
1394
|
-
| `sdl.keyboard.SCANCODE.KP_PERCENT`
|
|
1395
|
-
| `sdl.keyboard.SCANCODE.KP_LESS`
|
|
1396
|
-
| `sdl.keyboard.SCANCODE.KP_GREATER`
|
|
1397
|
-
| `sdl.keyboard.SCANCODE.KP_AMPERSAND`
|
|
1398
|
-
| `sdl.keyboard.SCANCODE.KP_DBLAMPERSAND`
|
|
1399
|
-
| `sdl.keyboard.SCANCODE.KP_VERTICALBAR`
|
|
1400
|
-
| `sdl.keyboard.SCANCODE.KP_DBLVERTICALBAR`
|
|
1401
|
-
| `sdl.keyboard.SCANCODE.KP_COLON`
|
|
1402
|
-
| `sdl.keyboard.SCANCODE.KP_HASH`
|
|
1403
|
-
| `sdl.keyboard.SCANCODE.KP_SPACE`
|
|
1404
|
-
| `sdl.keyboard.SCANCODE.KP_AT`
|
|
1405
|
-
| `sdl.keyboard.SCANCODE.KP_EXCLAM`
|
|
1406
|
-
| `sdl.keyboard.SCANCODE.KP_MEMSTORE`
|
|
1407
|
-
| `sdl.keyboard.SCANCODE.KP_MEMRECALL`
|
|
1408
|
-
| `sdl.keyboard.SCANCODE.KP_MEMCLEAR`
|
|
1409
|
-
| `sdl.keyboard.SCANCODE.KP_MEMADD`
|
|
1410
|
-
| `sdl.keyboard.SCANCODE.KP_MEMSUBTRACT`
|
|
1411
|
-
| `sdl.keyboard.SCANCODE.KP_MEMMULTIPLY`
|
|
1412
|
-
| `sdl.keyboard.SCANCODE.KP_MEMDIVIDE`
|
|
1413
|
-
| `sdl.keyboard.SCANCODE.KP_PLUSMINUS`
|
|
1414
|
-
| `sdl.keyboard.SCANCODE.KP_CLEAR`
|
|
1415
|
-
| `sdl.keyboard.SCANCODE.KP_CLEARENTRY`
|
|
1416
|
-
| `sdl.keyboard.SCANCODE.KP_BINARY`
|
|
1417
|
-
| `sdl.keyboard.SCANCODE.KP_OCTAL`
|
|
1418
|
-
| `sdl.keyboard.SCANCODE.KP_DECIMAL`
|
|
1419
|
-
| `sdl.keyboard.SCANCODE.KP_HEXADECIMAL`
|
|
1420
|
-
| `sdl.keyboard.SCANCODE.LCTRL`
|
|
1421
|
-
| `sdl.keyboard.SCANCODE.LSHIFT`
|
|
1422
|
-
| `sdl.keyboard.SCANCODE.LALT`
|
|
1423
|
-
| `sdl.keyboard.SCANCODE.LGUI`
|
|
1424
|
-
| `sdl.keyboard.SCANCODE.RCTRL`
|
|
1425
|
-
| `sdl.keyboard.SCANCODE.RSHIFT`
|
|
1426
|
-
| `sdl.keyboard.SCANCODE.RALT`
|
|
1427
|
-
| `sdl.keyboard.SCANCODE.RGUI`
|
|
1428
|
-
| `sdl.keyboard.SCANCODE.MODE`
|
|
1429
|
-
| `sdl.keyboard.SCANCODE.AUDIONEXT`
|
|
1430
|
-
| `sdl.keyboard.SCANCODE.AUDIOPREV`
|
|
1431
|
-
| `sdl.keyboard.SCANCODE.AUDIOSTOP`
|
|
1432
|
-
| `sdl.keyboard.SCANCODE.AUDIOPLAY`
|
|
1433
|
-
| `sdl.keyboard.SCANCODE.AUDIOMUTE`
|
|
1434
|
-
| `sdl.keyboard.SCANCODE.MEDIASELECT`
|
|
1435
|
-
| `sdl.keyboard.SCANCODE.WWW`
|
|
1436
|
-
| `sdl.keyboard.SCANCODE.MAIL`
|
|
1437
|
-
| `sdl.keyboard.SCANCODE.CALCULATOR`
|
|
1438
|
-
| `sdl.keyboard.SCANCODE.COMPUTER`
|
|
1439
|
-
| `sdl.keyboard.SCANCODE.AC_SEARCH`
|
|
1440
|
-
| `sdl.keyboard.SCANCODE.AC_HOME`
|
|
1441
|
-
| `sdl.keyboard.SCANCODE.AC_BACK`
|
|
1442
|
-
| `sdl.keyboard.SCANCODE.AC_FORWARD`
|
|
1443
|
-
| `sdl.keyboard.SCANCODE.AC_STOP`
|
|
1444
|
-
| `sdl.keyboard.SCANCODE.AC_REFRESH`
|
|
1445
|
-
| `sdl.keyboard.SCANCODE.AC_BOOKMARKS`
|
|
1446
|
-
| `sdl.keyboard.SCANCODE.BRIGHTNESSDOWN`
|
|
1447
|
-
| `sdl.keyboard.SCANCODE.BRIGHTNESSUP`
|
|
1448
|
-
| `sdl.keyboard.SCANCODE.DISPLAYSWITCH`
|
|
1449
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMTOGGLE`
|
|
1450
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMDOWN`
|
|
1451
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMUP`
|
|
1452
|
-
| `sdl.keyboard.SCANCODE.EJECT`
|
|
1453
|
-
| `sdl.keyboard.SCANCODE.SLEEP`
|
|
1454
|
-
| `sdl.keyboard.SCANCODE.APP1`
|
|
1455
|
-
| `sdl.keyboard.SCANCODE.APP2`
|
|
1456
|
-
| `sdl.keyboard.SCANCODE.AUDIOREWIND`
|
|
1457
|
-
| `sdl.keyboard.SCANCODE.AUDIOFASTFORWARD`
|
|
1247
|
+
| Value | Corresponding `SDL_Scancode` | Comment |
|
|
1248
|
+
| --- | --- | --- |
|
|
1249
|
+
| `sdl.keyboard.SCANCODE.A` | `SDL_SCANCODE_A` | |
|
|
1250
|
+
| `sdl.keyboard.SCANCODE.B` | `SDL_SCANCODE_B` | |
|
|
1251
|
+
| `sdl.keyboard.SCANCODE.C` | `SDL_SCANCODE_C` | |
|
|
1252
|
+
| `sdl.keyboard.SCANCODE.D` | `SDL_SCANCODE_D` | |
|
|
1253
|
+
| `sdl.keyboard.SCANCODE.E` | `SDL_SCANCODE_E` | |
|
|
1254
|
+
| `sdl.keyboard.SCANCODE.F` | `SDL_SCANCODE_F` | |
|
|
1255
|
+
| `sdl.keyboard.SCANCODE.G` | `SDL_SCANCODE_G` | |
|
|
1256
|
+
| `sdl.keyboard.SCANCODE.H` | `SDL_SCANCODE_H` | |
|
|
1257
|
+
| `sdl.keyboard.SCANCODE.I` | `SDL_SCANCODE_I` | |
|
|
1258
|
+
| `sdl.keyboard.SCANCODE.J` | `SDL_SCANCODE_J` | |
|
|
1259
|
+
| `sdl.keyboard.SCANCODE.K` | `SDL_SCANCODE_K` | |
|
|
1260
|
+
| `sdl.keyboard.SCANCODE.L` | `SDL_SCANCODE_L` | |
|
|
1261
|
+
| `sdl.keyboard.SCANCODE.M` | `SDL_SCANCODE_M` | |
|
|
1262
|
+
| `sdl.keyboard.SCANCODE.N` | `SDL_SCANCODE_N` | |
|
|
1263
|
+
| `sdl.keyboard.SCANCODE.O` | `SDL_SCANCODE_O` | |
|
|
1264
|
+
| `sdl.keyboard.SCANCODE.P` | `SDL_SCANCODE_P` | |
|
|
1265
|
+
| `sdl.keyboard.SCANCODE.Q` | `SDL_SCANCODE_Q` | |
|
|
1266
|
+
| `sdl.keyboard.SCANCODE.R` | `SDL_SCANCODE_R` | |
|
|
1267
|
+
| `sdl.keyboard.SCANCODE.S` | `SDL_SCANCODE_S` | |
|
|
1268
|
+
| `sdl.keyboard.SCANCODE.T` | `SDL_SCANCODE_T` | |
|
|
1269
|
+
| `sdl.keyboard.SCANCODE.U` | `SDL_SCANCODE_U` | |
|
|
1270
|
+
| `sdl.keyboard.SCANCODE.V` | `SDL_SCANCODE_V` | |
|
|
1271
|
+
| `sdl.keyboard.SCANCODE.W` | `SDL_SCANCODE_W` | |
|
|
1272
|
+
| `sdl.keyboard.SCANCODE.X` | `SDL_SCANCODE_X` | |
|
|
1273
|
+
| `sdl.keyboard.SCANCODE.Y` | `SDL_SCANCODE_Y` | |
|
|
1274
|
+
| `sdl.keyboard.SCANCODE.Z` | `SDL_SCANCODE_Z` | |
|
|
1275
|
+
| `sdl.keyboard.SCANCODE.1` | `SDL_SCANCODE_1` | |
|
|
1276
|
+
| `sdl.keyboard.SCANCODE.2` | `SDL_SCANCODE_2` | |
|
|
1277
|
+
| `sdl.keyboard.SCANCODE.3` | `SDL_SCANCODE_3` | |
|
|
1278
|
+
| `sdl.keyboard.SCANCODE.4` | `SDL_SCANCODE_4` | |
|
|
1279
|
+
| `sdl.keyboard.SCANCODE.5` | `SDL_SCANCODE_5` | |
|
|
1280
|
+
| `sdl.keyboard.SCANCODE.6` | `SDL_SCANCODE_6` | |
|
|
1281
|
+
| `sdl.keyboard.SCANCODE.7` | `SDL_SCANCODE_7` | |
|
|
1282
|
+
| `sdl.keyboard.SCANCODE.8` | `SDL_SCANCODE_8` | |
|
|
1283
|
+
| `sdl.keyboard.SCANCODE.9` | `SDL_SCANCODE_9` | |
|
|
1284
|
+
| `sdl.keyboard.SCANCODE.0` | `SDL_SCANCODE_0` | |
|
|
1285
|
+
| `sdl.keyboard.SCANCODE.RETURN` | `SDL_SCANCODE_RETURN` | |
|
|
1286
|
+
| `sdl.keyboard.SCANCODE.ESCAPE` | `SDL_SCANCODE_ESCAPE` | |
|
|
1287
|
+
| `sdl.keyboard.SCANCODE.BACKSPACE` | `SDL_SCANCODE_BACKSPACE` | |
|
|
1288
|
+
| `sdl.keyboard.SCANCODE.TAB` | `SDL_SCANCODE_TAB` | |
|
|
1289
|
+
| `sdl.keyboard.SCANCODE.SPACE` | `SDL_SCANCODE_SPACE` | |
|
|
1290
|
+
| `sdl.keyboard.SCANCODE.MINUS` | `SDL_SCANCODE_MINUS` | |
|
|
1291
|
+
| `sdl.keyboard.SCANCODE.EQUALS` | `SDL_SCANCODE_EQUALS` | |
|
|
1292
|
+
| `sdl.keyboard.SCANCODE.LEFTBRACKET` | `SDL_SCANCODE_LEFTBRACKET` | |
|
|
1293
|
+
| `sdl.keyboard.SCANCODE.RIGHTBRACKET` | `SDL_SCANCODE_RIGHTBRACKET` | |
|
|
1294
|
+
| `sdl.keyboard.SCANCODE.BACKSLASH` | `SDL_SCANCODE_BACKSLASH` | Located at the lower left of the return key on ISO keyboards and at the right end of the QWERTY row on ANSI keyboards. Produces REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US layout, REVERSE SOLIDUS and VERTICAL LINE in a UK Mac layout, NUMBER SIGN and TILDE in a UK Windows layout, DOLLAR SIGN and POUND SIGN in a Swiss German layout, NUMBER SIGN and APOSTROPHE in a German layout, GRAVE ACCENT and POUND SIGN in a French Mac layout, and ASTERISK and MICRO SIGN in a French Windows layout. |
|
|
1295
|
+
| `sdl.keyboard.SCANCODE.NONUSHASH` | `SDL_SCANCODE_NONUSHASH` | ISO USB keyboards actually use this code instead of 49 for the same key, but all OSes I've seen treat the two codes identically. So, as an implementor, unless your keyboard generates both of those codes and your OS treats them differently, you should generate SDL_SCANCODE_BACKSLASH instead of this code. As a user, you should not rely on this code because SDL will never generate it with most (all?) keyboards. |
|
|
1296
|
+
| `sdl.keyboard.SCANCODE.SEMICOLON` | `SDL_SCANCODE_SEMICOLON` | |
|
|
1297
|
+
| `sdl.keyboard.SCANCODE.APOSTROPHE` | `SDL_SCANCODE_APOSTROPHE` | |
|
|
1298
|
+
| `sdl.keyboard.SCANCODE.GRAVE` | `SDL_SCANCODE_GRAVE` | Located in the top left corner (on both ANSI and ISO keyboards). Produces GRAVE ACCENT and TILDE in a US Windows layout and in US and UK Mac layouts on ANSI keyboards, GRAVE ACCENT and NOT SIGN in a UK Windows layout, SECTION SIGN and PLUS-MINUS SIGN in US and UK Mac layouts on ISO keyboards, SECTION SIGN and DEGREE SIGN in a Swiss German layout (Mac: only on ISO keyboards), CIRCUMFLEX ACCENT and DEGREE SIGN in a German layout (Mac: only on ISO keyboards), SUPERSCRIPT TWO and TILDE in a French Windows layout, COMMERCIAL AT and NUMBER SIGN in a French Mac layout on ISO keyboards, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French Mac layout on ANSI keyboards. |
|
|
1299
|
+
| `sdl.keyboard.SCANCODE.COMMA` | `SDL_SCANCODE_COMMA` | |
|
|
1300
|
+
| `sdl.keyboard.SCANCODE.PERIOD` | `SDL_SCANCODE_PERIOD` | |
|
|
1301
|
+
| `sdl.keyboard.SCANCODE.SLASH` | `SDL_SCANCODE_SLASH` | |
|
|
1302
|
+
| `sdl.keyboard.SCANCODE.CAPSLOCK` | `SDL_SCANCODE_CAPSLOCK` | |
|
|
1303
|
+
| `sdl.keyboard.SCANCODE.F1` | `SDL_SCANCODE_F1` | |
|
|
1304
|
+
| `sdl.keyboard.SCANCODE.F2` | `SDL_SCANCODE_F2` | |
|
|
1305
|
+
| `sdl.keyboard.SCANCODE.F3` | `SDL_SCANCODE_F3` | |
|
|
1306
|
+
| `sdl.keyboard.SCANCODE.F4` | `SDL_SCANCODE_F4` | |
|
|
1307
|
+
| `sdl.keyboard.SCANCODE.F5` | `SDL_SCANCODE_F5` | |
|
|
1308
|
+
| `sdl.keyboard.SCANCODE.F6` | `SDL_SCANCODE_F6` | |
|
|
1309
|
+
| `sdl.keyboard.SCANCODE.F7` | `SDL_SCANCODE_F7` | |
|
|
1310
|
+
| `sdl.keyboard.SCANCODE.F8` | `SDL_SCANCODE_F8` | |
|
|
1311
|
+
| `sdl.keyboard.SCANCODE.F9` | `SDL_SCANCODE_F9` | |
|
|
1312
|
+
| `sdl.keyboard.SCANCODE.F10` | `SDL_SCANCODE_F10` | |
|
|
1313
|
+
| `sdl.keyboard.SCANCODE.F11` | `SDL_SCANCODE_F11` | |
|
|
1314
|
+
| `sdl.keyboard.SCANCODE.F12` | `SDL_SCANCODE_F12` | |
|
|
1315
|
+
| `sdl.keyboard.SCANCODE.PRINTSCREEN` | `SDL_SCANCODE_PRINTSCREEN` | |
|
|
1316
|
+
| `sdl.keyboard.SCANCODE.SCROLLLOCK` | `SDL_SCANCODE_SCROLLLOCK` | |
|
|
1317
|
+
| `sdl.keyboard.SCANCODE.PAUSE` | `SDL_SCANCODE_PAUSE` | |
|
|
1318
|
+
| `sdl.keyboard.SCANCODE.INSERT` | `SDL_SCANCODE_INSERT` | insert on PC, help on some Mac keyboards |
|
|
1319
|
+
| `sdl.keyboard.SCANCODE.HOME` | `SDL_SCANCODE_HOME` | |
|
|
1320
|
+
| `sdl.keyboard.SCANCODE.PAGEUP` | `SDL_SCANCODE_PAGEUP` | |
|
|
1321
|
+
| `sdl.keyboard.SCANCODE.DELETE` | `SDL_SCANCODE_DELETE` | |
|
|
1322
|
+
| `sdl.keyboard.SCANCODE.END` | `SDL_SCANCODE_END` | |
|
|
1323
|
+
| `sdl.keyboard.SCANCODE.PAGEDOWN` | `SDL_SCANCODE_PAGEDOWN` | |
|
|
1324
|
+
| `sdl.keyboard.SCANCODE.RIGHT` | `SDL_SCANCODE_RIGHT` | |
|
|
1325
|
+
| `sdl.keyboard.SCANCODE.LEFT` | `SDL_SCANCODE_LEFT` | |
|
|
1326
|
+
| `sdl.keyboard.SCANCODE.DOWN` | `SDL_SCANCODE_DOWN` | |
|
|
1327
|
+
| `sdl.keyboard.SCANCODE.UP` | `SDL_SCANCODE_UP` | |
|
|
1328
|
+
| `sdl.keyboard.SCANCODE.NUMLOCKCLEAR` | `SDL_SCANCODE_NUMLOCKCLEAR` | num lock on PC, clear on Mac keyboards |
|
|
1329
|
+
| `sdl.keyboard.SCANCODE.KP_DIVIDE` | `SDL_SCANCODE_KP_DIVIDE` | |
|
|
1330
|
+
| `sdl.keyboard.SCANCODE.KP_MULTIPLY` | `SDL_SCANCODE_KP_MULTIPLY` | |
|
|
1331
|
+
| `sdl.keyboard.SCANCODE.KP_MINUS` | `SDL_SCANCODE_KP_MINUS` | |
|
|
1332
|
+
| `sdl.keyboard.SCANCODE.KP_PLUS` | `SDL_SCANCODE_KP_PLUS` | |
|
|
1333
|
+
| `sdl.keyboard.SCANCODE.KP_ENTER` | `SDL_SCANCODE_KP_ENTER` | |
|
|
1334
|
+
| `sdl.keyboard.SCANCODE.KP_1` | `SDL_SCANCODE_KP_1` | |
|
|
1335
|
+
| `sdl.keyboard.SCANCODE.KP_2` | `SDL_SCANCODE_KP_2` | |
|
|
1336
|
+
| `sdl.keyboard.SCANCODE.KP_3` | `SDL_SCANCODE_KP_3` | |
|
|
1337
|
+
| `sdl.keyboard.SCANCODE.KP_4` | `SDL_SCANCODE_KP_4` | |
|
|
1338
|
+
| `sdl.keyboard.SCANCODE.KP_5` | `SDL_SCANCODE_KP_5` | |
|
|
1339
|
+
| `sdl.keyboard.SCANCODE.KP_6` | `SDL_SCANCODE_KP_6` | |
|
|
1340
|
+
| `sdl.keyboard.SCANCODE.KP_7` | `SDL_SCANCODE_KP_7` | |
|
|
1341
|
+
| `sdl.keyboard.SCANCODE.KP_8` | `SDL_SCANCODE_KP_8` | |
|
|
1342
|
+
| `sdl.keyboard.SCANCODE.KP_9` | `SDL_SCANCODE_KP_9` | |
|
|
1343
|
+
| `sdl.keyboard.SCANCODE.KP_0` | `SDL_SCANCODE_KP_0` | |
|
|
1344
|
+
| `sdl.keyboard.SCANCODE.KP_PERIOD` | `SDL_SCANCODE_KP_PERIOD` | |
|
|
1345
|
+
| `sdl.keyboard.SCANCODE.NONUSBACKSLASH` | `SDL_SCANCODE_NONUSBACKSLASH` | This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Y. Produces GRAVE ACCENT and TILDE in a US or UK Mac layout, REVERSE SOLIDUS (backslash) and VERTICAL LINE in a US or UK Windows layout, and LESS-THAN SIGN and GREATER-THAN SIGN in a Swiss German, German, or French layout. |
|
|
1346
|
+
| `sdl.keyboard.SCANCODE.APPLICATION` | `SDL_SCANCODE_APPLICATION` | windows contextual menu, compose |
|
|
1347
|
+
| `sdl.keyboard.SCANCODE.POWER` | `SDL_SCANCODE_POWER` | The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key. |
|
|
1348
|
+
| `sdl.keyboard.SCANCODE.KP_EQUALS` | `SDL_SCANCODE_KP_EQUALS` | |
|
|
1349
|
+
| `sdl.keyboard.SCANCODE.F13` | `SDL_SCANCODE_F13` | |
|
|
1350
|
+
| `sdl.keyboard.SCANCODE.F14` | `SDL_SCANCODE_F14` | |
|
|
1351
|
+
| `sdl.keyboard.SCANCODE.F15` | `SDL_SCANCODE_F15` | |
|
|
1352
|
+
| `sdl.keyboard.SCANCODE.F16` | `SDL_SCANCODE_F16` | |
|
|
1353
|
+
| `sdl.keyboard.SCANCODE.F17` | `SDL_SCANCODE_F17` | |
|
|
1354
|
+
| `sdl.keyboard.SCANCODE.F18` | `SDL_SCANCODE_F18` | |
|
|
1355
|
+
| `sdl.keyboard.SCANCODE.F19` | `SDL_SCANCODE_F19` | |
|
|
1356
|
+
| `sdl.keyboard.SCANCODE.F20` | `SDL_SCANCODE_F20` | |
|
|
1357
|
+
| `sdl.keyboard.SCANCODE.F21` | `SDL_SCANCODE_F21` | |
|
|
1358
|
+
| `sdl.keyboard.SCANCODE.F22` | `SDL_SCANCODE_F22` | |
|
|
1359
|
+
| `sdl.keyboard.SCANCODE.F23` | `SDL_SCANCODE_F23` | |
|
|
1360
|
+
| `sdl.keyboard.SCANCODE.F24` | `SDL_SCANCODE_F24` | |
|
|
1361
|
+
| `sdl.keyboard.SCANCODE.EXECUTE` | `SDL_SCANCODE_EXECUTE` | |
|
|
1362
|
+
| `sdl.keyboard.SCANCODE.HELP` | `SDL_SCANCODE_HELP` | |
|
|
1363
|
+
| `sdl.keyboard.SCANCODE.MENU` | `SDL_SCANCODE_MENU` | |
|
|
1364
|
+
| `sdl.keyboard.SCANCODE.SELECT` | `SDL_SCANCODE_SELECT` | |
|
|
1365
|
+
| `sdl.keyboard.SCANCODE.STOP` | `SDL_SCANCODE_STOP` | |
|
|
1366
|
+
| `sdl.keyboard.SCANCODE.AGAIN` | `SDL_SCANCODE_AGAIN` | redo |
|
|
1367
|
+
| `sdl.keyboard.SCANCODE.UNDO` | `SDL_SCANCODE_UNDO` | |
|
|
1368
|
+
| `sdl.keyboard.SCANCODE.CUT` | `SDL_SCANCODE_CUT` | |
|
|
1369
|
+
| `sdl.keyboard.SCANCODE.COPY` | `SDL_SCANCODE_COPY` | |
|
|
1370
|
+
| `sdl.keyboard.SCANCODE.PASTE` | `SDL_SCANCODE_PASTE` | |
|
|
1371
|
+
| `sdl.keyboard.SCANCODE.FIND` | `SDL_SCANCODE_FIND` | |
|
|
1372
|
+
| `sdl.keyboard.SCANCODE.MUTE` | `SDL_SCANCODE_MUTE` | |
|
|
1373
|
+
| `sdl.keyboard.SCANCODE.VOLUMEUP` | `SDL_SCANCODE_VOLUMEUP` | |
|
|
1374
|
+
| `sdl.keyboard.SCANCODE.VOLUMEDOWN` | `SDL_SCANCODE_VOLUMEDOWN` | |
|
|
1375
|
+
| `sdl.keyboard.SCANCODE.KP_COMMA` | `SDL_SCANCODE_KP_COMMA` | |
|
|
1376
|
+
| `sdl.keyboard.SCANCODE.KP_EQUALSAS400` | `SDL_SCANCODE_KP_EQUALSAS400` | |
|
|
1377
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL1` | `SDL_SCANCODE_INTERNATIONAL1` | used on Asian keyboards, see footnotes in USB doc |
|
|
1378
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL2` | `SDL_SCANCODE_INTERNATIONAL2` | |
|
|
1379
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL3` | `SDL_SCANCODE_INTERNATIONAL3` | Yen |
|
|
1380
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL4` | `SDL_SCANCODE_INTERNATIONAL4` | |
|
|
1381
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL5` | `SDL_SCANCODE_INTERNATIONAL5` | |
|
|
1382
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL6` | `SDL_SCANCODE_INTERNATIONAL6` | |
|
|
1383
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL7` | `SDL_SCANCODE_INTERNATIONAL7` | |
|
|
1384
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL8` | `SDL_SCANCODE_INTERNATIONAL8` | |
|
|
1385
|
+
| `sdl.keyboard.SCANCODE.INTERNATIONAL9` | `SDL_SCANCODE_INTERNATIONAL9` | |
|
|
1386
|
+
| `sdl.keyboard.SCANCODE.LANG1` | `SDL_SCANCODE_LANG1` | Hangul/English toggle |
|
|
1387
|
+
| `sdl.keyboard.SCANCODE.LANG2` | `SDL_SCANCODE_LANG2` | Hanja conversion |
|
|
1388
|
+
| `sdl.keyboard.SCANCODE.LANG3` | `SDL_SCANCODE_LANG3` | Katakana |
|
|
1389
|
+
| `sdl.keyboard.SCANCODE.LANG4` | `SDL_SCANCODE_LANG4` | Hiragana |
|
|
1390
|
+
| `sdl.keyboard.SCANCODE.LANG5` | `SDL_SCANCODE_LANG5` | Zenkaku/Hankaku |
|
|
1391
|
+
| `sdl.keyboard.SCANCODE.LANG6` | `SDL_SCANCODE_LANG6` | |
|
|
1392
|
+
| `sdl.keyboard.SCANCODE.LANG7` | `SDL_SCANCODE_LANG7` | |
|
|
1393
|
+
| `sdl.keyboard.SCANCODE.LANG8` | `SDL_SCANCODE_LANG8` | |
|
|
1394
|
+
| `sdl.keyboard.SCANCODE.LANG9` | `SDL_SCANCODE_LANG9` | |
|
|
1395
|
+
| `sdl.keyboard.SCANCODE.ALTERASE` | `SDL_SCANCODE_ALTERASE` | Erase-Eaze |
|
|
1396
|
+
| `sdl.keyboard.SCANCODE.SYSREQ` | `SDL_SCANCODE_SYSREQ` | |
|
|
1397
|
+
| `sdl.keyboard.SCANCODE.CANCEL` | `SDL_SCANCODE_CANCEL` | |
|
|
1398
|
+
| `sdl.keyboard.SCANCODE.CLEAR` | `SDL_SCANCODE_CLEAR` | |
|
|
1399
|
+
| `sdl.keyboard.SCANCODE.PRIOR` | `SDL_SCANCODE_PRIOR` | |
|
|
1400
|
+
| `sdl.keyboard.SCANCODE.RETURN2` | `SDL_SCANCODE_RETURN2` | |
|
|
1401
|
+
| `sdl.keyboard.SCANCODE.SEPARATOR` | `SDL_SCANCODE_SEPARATOR` | |
|
|
1402
|
+
| `sdl.keyboard.SCANCODE.OUT` | `SDL_SCANCODE_OUT` | |
|
|
1403
|
+
| `sdl.keyboard.SCANCODE.OPER` | `SDL_SCANCODE_OPER` | |
|
|
1404
|
+
| `sdl.keyboard.SCANCODE.CLEARAGAIN` | `SDL_SCANCODE_CLEARAGAIN` | |
|
|
1405
|
+
| `sdl.keyboard.SCANCODE.CRSEL` | `SDL_SCANCODE_CRSEL` | |
|
|
1406
|
+
| `sdl.keyboard.SCANCODE.EXSEL` | `SDL_SCANCODE_EXSEL` | |
|
|
1407
|
+
| `sdl.keyboard.SCANCODE.KP_00` | `SDL_SCANCODE_KP_00` | |
|
|
1408
|
+
| `sdl.keyboard.SCANCODE.KP_000` | `SDL_SCANCODE_KP_000` | |
|
|
1409
|
+
| `sdl.keyboard.SCANCODE.THOUSANDSSEPARATOR` | `SDL_SCANCODE_THOUSANDSSEPARATOR` | |
|
|
1410
|
+
| `sdl.keyboard.SCANCODE.DECIMALSEPARATOR` | `SDL_SCANCODE_DECIMALSEPARATOR` | |
|
|
1411
|
+
| `sdl.keyboard.SCANCODE.CURRENCYUNIT` | `SDL_SCANCODE_CURRENCYUNIT` | |
|
|
1412
|
+
| `sdl.keyboard.SCANCODE.CURRENCYSUBUNIT` | `SDL_SCANCODE_CURRENCYSUBUNIT` | |
|
|
1413
|
+
| `sdl.keyboard.SCANCODE.KP_LEFTPAREN` | `SDL_SCANCODE_KP_LEFTPAREN` | |
|
|
1414
|
+
| `sdl.keyboard.SCANCODE.KP_RIGHTPAREN` | `SDL_SCANCODE_KP_RIGHTPAREN` | |
|
|
1415
|
+
| `sdl.keyboard.SCANCODE.KP_LEFTBRACE` | `SDL_SCANCODE_KP_LEFTBRACE` | |
|
|
1416
|
+
| `sdl.keyboard.SCANCODE.KP_RIGHTBRACE` | `SDL_SCANCODE_KP_RIGHTBRACE` | |
|
|
1417
|
+
| `sdl.keyboard.SCANCODE.KP_TAB` | `SDL_SCANCODE_KP_TAB` | |
|
|
1418
|
+
| `sdl.keyboard.SCANCODE.KP_BACKSPACE` | `SDL_SCANCODE_KP_BACKSPACE` | |
|
|
1419
|
+
| `sdl.keyboard.SCANCODE.KP_A` | `SDL_SCANCODE_KP_A` | |
|
|
1420
|
+
| `sdl.keyboard.SCANCODE.KP_B` | `SDL_SCANCODE_KP_B` | |
|
|
1421
|
+
| `sdl.keyboard.SCANCODE.KP_C` | `SDL_SCANCODE_KP_C` | |
|
|
1422
|
+
| `sdl.keyboard.SCANCODE.KP_D` | `SDL_SCANCODE_KP_D` | |
|
|
1423
|
+
| `sdl.keyboard.SCANCODE.KP_E` | `SDL_SCANCODE_KP_E` | |
|
|
1424
|
+
| `sdl.keyboard.SCANCODE.KP_F` | `SDL_SCANCODE_KP_F` | |
|
|
1425
|
+
| `sdl.keyboard.SCANCODE.KP_XOR` | `SDL_SCANCODE_KP_XOR` | |
|
|
1426
|
+
| `sdl.keyboard.SCANCODE.KP_POWER` | `SDL_SCANCODE_KP_POWER` | |
|
|
1427
|
+
| `sdl.keyboard.SCANCODE.KP_PERCENT` | `SDL_SCANCODE_KP_PERCENT` | |
|
|
1428
|
+
| `sdl.keyboard.SCANCODE.KP_LESS` | `SDL_SCANCODE_KP_LESS` | |
|
|
1429
|
+
| `sdl.keyboard.SCANCODE.KP_GREATER` | `SDL_SCANCODE_KP_GREATER` | |
|
|
1430
|
+
| `sdl.keyboard.SCANCODE.KP_AMPERSAND` | `SDL_SCANCODE_KP_AMPERSAND` | |
|
|
1431
|
+
| `sdl.keyboard.SCANCODE.KP_DBLAMPERSAND` | `SDL_SCANCODE_KP_DBLAMPERSAND` | |
|
|
1432
|
+
| `sdl.keyboard.SCANCODE.KP_VERTICALBAR` | `SDL_SCANCODE_KP_VERTICALBAR` | |
|
|
1433
|
+
| `sdl.keyboard.SCANCODE.KP_DBLVERTICALBAR` | `SDL_SCANCODE_KP_DBLVERTICALBAR` | |
|
|
1434
|
+
| `sdl.keyboard.SCANCODE.KP_COLON` | `SDL_SCANCODE_KP_COLON` | |
|
|
1435
|
+
| `sdl.keyboard.SCANCODE.KP_HASH` | `SDL_SCANCODE_KP_HASH` | |
|
|
1436
|
+
| `sdl.keyboard.SCANCODE.KP_SPACE` | `SDL_SCANCODE_KP_SPACE` | |
|
|
1437
|
+
| `sdl.keyboard.SCANCODE.KP_AT` | `SDL_SCANCODE_KP_AT` | |
|
|
1438
|
+
| `sdl.keyboard.SCANCODE.KP_EXCLAM` | `SDL_SCANCODE_KP_EXCLAM` | |
|
|
1439
|
+
| `sdl.keyboard.SCANCODE.KP_MEMSTORE` | `SDL_SCANCODE_KP_MEMSTORE` | |
|
|
1440
|
+
| `sdl.keyboard.SCANCODE.KP_MEMRECALL` | `SDL_SCANCODE_KP_MEMRECALL` | |
|
|
1441
|
+
| `sdl.keyboard.SCANCODE.KP_MEMCLEAR` | `SDL_SCANCODE_KP_MEMCLEAR` | |
|
|
1442
|
+
| `sdl.keyboard.SCANCODE.KP_MEMADD` | `SDL_SCANCODE_KP_MEMADD` | |
|
|
1443
|
+
| `sdl.keyboard.SCANCODE.KP_MEMSUBTRACT` | `SDL_SCANCODE_KP_MEMSUBTRACT` | |
|
|
1444
|
+
| `sdl.keyboard.SCANCODE.KP_MEMMULTIPLY` | `SDL_SCANCODE_KP_MEMMULTIPLY` | |
|
|
1445
|
+
| `sdl.keyboard.SCANCODE.KP_MEMDIVIDE` | `SDL_SCANCODE_KP_MEMDIVIDE` | |
|
|
1446
|
+
| `sdl.keyboard.SCANCODE.KP_PLUSMINUS` | `SDL_SCANCODE_KP_PLUSMINUS` | |
|
|
1447
|
+
| `sdl.keyboard.SCANCODE.KP_CLEAR` | `SDL_SCANCODE_KP_CLEAR` | |
|
|
1448
|
+
| `sdl.keyboard.SCANCODE.KP_CLEARENTRY` | `SDL_SCANCODE_KP_CLEARENTRY` | |
|
|
1449
|
+
| `sdl.keyboard.SCANCODE.KP_BINARY` | `SDL_SCANCODE_KP_BINARY` | |
|
|
1450
|
+
| `sdl.keyboard.SCANCODE.KP_OCTAL` | `SDL_SCANCODE_KP_OCTAL` | |
|
|
1451
|
+
| `sdl.keyboard.SCANCODE.KP_DECIMAL` | `SDL_SCANCODE_KP_DECIMAL` | |
|
|
1452
|
+
| `sdl.keyboard.SCANCODE.KP_HEXADECIMAL` | `SDL_SCANCODE_KP_HEXADECIMAL` | |
|
|
1453
|
+
| `sdl.keyboard.SCANCODE.LCTRL` | `SDL_SCANCODE_LCTRL` | |
|
|
1454
|
+
| `sdl.keyboard.SCANCODE.LSHIFT` | `SDL_SCANCODE_LSHIFT` | |
|
|
1455
|
+
| `sdl.keyboard.SCANCODE.LALT` | `SDL_SCANCODE_LALT` | alt, option |
|
|
1456
|
+
| `sdl.keyboard.SCANCODE.LGUI` | `SDL_SCANCODE_LGUI` | windows, command (apple), meta |
|
|
1457
|
+
| `sdl.keyboard.SCANCODE.RCTRL` | `SDL_SCANCODE_RCTRL` | |
|
|
1458
|
+
| `sdl.keyboard.SCANCODE.RSHIFT` | `SDL_SCANCODE_RSHIFT` | |
|
|
1459
|
+
| `sdl.keyboard.SCANCODE.RALT` | `SDL_SCANCODE_RALT` | alt gr, option |
|
|
1460
|
+
| `sdl.keyboard.SCANCODE.RGUI` | `SDL_SCANCODE_RGUI` | windows, command (apple), meta |
|
|
1461
|
+
| `sdl.keyboard.SCANCODE.MODE` | `SDL_SCANCODE_MODE` | |
|
|
1462
|
+
| `sdl.keyboard.SCANCODE.AUDIONEXT` | `SDL_SCANCODE_AUDIONEXT` | |
|
|
1463
|
+
| `sdl.keyboard.SCANCODE.AUDIOPREV` | `SDL_SCANCODE_AUDIOPREV` | |
|
|
1464
|
+
| `sdl.keyboard.SCANCODE.AUDIOSTOP` | `SDL_SCANCODE_AUDIOSTOP` | |
|
|
1465
|
+
| `sdl.keyboard.SCANCODE.AUDIOPLAY` | `SDL_SCANCODE_AUDIOPLAY` | |
|
|
1466
|
+
| `sdl.keyboard.SCANCODE.AUDIOMUTE` | `SDL_SCANCODE_AUDIOMUTE` | |
|
|
1467
|
+
| `sdl.keyboard.SCANCODE.MEDIASELECT` | `SDL_SCANCODE_MEDIASELECT` | |
|
|
1468
|
+
| `sdl.keyboard.SCANCODE.WWW` | `SDL_SCANCODE_WWW` | |
|
|
1469
|
+
| `sdl.keyboard.SCANCODE.MAIL` | `SDL_SCANCODE_MAIL` | |
|
|
1470
|
+
| `sdl.keyboard.SCANCODE.CALCULATOR` | `SDL_SCANCODE_CALCULATOR` | |
|
|
1471
|
+
| `sdl.keyboard.SCANCODE.COMPUTER` | `SDL_SCANCODE_COMPUTER` | |
|
|
1472
|
+
| `sdl.keyboard.SCANCODE.AC_SEARCH` | `SDL_SCANCODE_AC_SEARCH` | |
|
|
1473
|
+
| `sdl.keyboard.SCANCODE.AC_HOME` | `SDL_SCANCODE_AC_HOME` | |
|
|
1474
|
+
| `sdl.keyboard.SCANCODE.AC_BACK` | `SDL_SCANCODE_AC_BACK` | |
|
|
1475
|
+
| `sdl.keyboard.SCANCODE.AC_FORWARD` | `SDL_SCANCODE_AC_FORWARD` | |
|
|
1476
|
+
| `sdl.keyboard.SCANCODE.AC_STOP` | `SDL_SCANCODE_AC_STOP` | |
|
|
1477
|
+
| `sdl.keyboard.SCANCODE.AC_REFRESH` | `SDL_SCANCODE_AC_REFRESH` | |
|
|
1478
|
+
| `sdl.keyboard.SCANCODE.AC_BOOKMARKS` | `SDL_SCANCODE_AC_BOOKMARKS` | |
|
|
1479
|
+
| `sdl.keyboard.SCANCODE.BRIGHTNESSDOWN` | `SDL_SCANCODE_BRIGHTNESSDOWN` | |
|
|
1480
|
+
| `sdl.keyboard.SCANCODE.BRIGHTNESSUP` | `SDL_SCANCODE_BRIGHTNESSUP` | |
|
|
1481
|
+
| `sdl.keyboard.SCANCODE.DISPLAYSWITCH` | `SDL_SCANCODE_DISPLAYSWITCH` | display mirroring/dual display switch, video mode switch |
|
|
1482
|
+
| `sdl.keyboard.SCANCODE.KBDILLUMTOGGLE` | `SDL_SCANCODE_KBDILLUMTOGGLE` | |
|
|
1483
|
+
| `sdl.keyboard.SCANCODE.KBDILLUMDOWN` | `SDL_SCANCODE_KBDILLUMDOWN` | |
|
|
1484
|
+
| `sdl.keyboard.SCANCODE.KBDILLUMUP` | `SDL_SCANCODE_KBDILLUMUP` | |
|
|
1485
|
+
| `sdl.keyboard.SCANCODE.EJECT` | `SDL_SCANCODE_EJECT` | |
|
|
1486
|
+
| `sdl.keyboard.SCANCODE.SLEEP` | `SDL_SCANCODE_SLEEP` | |
|
|
1487
|
+
| `sdl.keyboard.SCANCODE.APP1` | `SDL_SCANCODE_APP1` | |
|
|
1488
|
+
| `sdl.keyboard.SCANCODE.APP2` | `SDL_SCANCODE_APP2` | |
|
|
1489
|
+
| `sdl.keyboard.SCANCODE.AUDIOREWIND` | `SDL_SCANCODE_AUDIOREWIND` | |
|
|
1490
|
+
| `sdl.keyboard.SCANCODE.AUDIOFASTFORWARD` | `SDL_SCANCODE_AUDIOFASTFORWARD` | |
|
|
1458
1491
|
|
|
1459
1492
|
</details>
|
|
1460
1493
|
|
|
1494
|
+
### Event: 'keymapChange'
|
|
1495
|
+
|
|
1496
|
+
Fired when the keymap changes due to a system event such as an input language or keyboard layout change.
|
|
1497
|
+
After this event, the correspondance between physical and logical keys might have changed.
|
|
1498
|
+
You should assume that any previous result you have gotten from [`getKey()`](#sdlkeyboardgetkeyscancode) or [`getScancode()`](#sdlkeyboardgetscancodekey) are not invalid.
|
|
1499
|
+
|
|
1461
1500
|
### sdl.keyboard.getKey(scancode)
|
|
1462
1501
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1502
|
+
- `scancode: `[`<Scancode>`](#enum-scancode)
|
|
1503
|
+
- Returns: [`<Key>`](#virtual-keys)`|<null>`
|
|
1465
1504
|
|
|
1466
1505
|
Maps a scancode to the corresponding key based on the current keyboard mapping.
|
|
1467
1506
|
Retuns `null` if the scancode does not currespond to a key in the current mapping.
|
|
1468
1507
|
|
|
1469
1508
|
### sdl.keyboard.getScancode(key)
|
|
1470
1509
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1510
|
+
- `key: `[`<Key>`](#virtual-keys)
|
|
1511
|
+
- Returns: [`<Scancode>`](#enum-scancode)`|<null>`
|
|
1473
1512
|
|
|
1474
1513
|
Maps a key to the corresponding scancode based on the current keyboard mapping.
|
|
1475
1514
|
Retuns `null` if the key does not currespond to a scancode in the current mapping.
|
|
@@ -1477,12 +1516,11 @@ If multiple physical keys produce the same virtual key, then only the first one
|
|
|
1477
1516
|
|
|
1478
1517
|
### sdl.keyboard.getState()
|
|
1479
1518
|
|
|
1480
|
-
|
|
1519
|
+
- Returns: `<boolean[]>` an array representing the state of each key.
|
|
1481
1520
|
|
|
1482
1521
|
The returned array can be indexed with [`Scancode`](#enum-scancode) values.
|
|
1483
1522
|
Each value in the array is either `true` if the corresponding key is pressed, or `false` otherwise.
|
|
1484
1523
|
|
|
1485
|
-
|
|
1486
1524
|
## sdl.mouse
|
|
1487
1525
|
|
|
1488
1526
|
### Enum: BUTTON
|
|
@@ -1490,56 +1528,56 @@ Each value in the array is either `true` if the corresponding key is pressed, or
|
|
|
1490
1528
|
Used to represent the buttons on a mouse.
|
|
1491
1529
|
A mouse can have many buttons, but the values for the three most common ones are represented in this enum.
|
|
1492
1530
|
|
|
1493
|
-
| Value
|
|
1494
|
-
| ---
|
|
1495
|
-
| `sdl.mouse.BUTTON.LEFT`
|
|
1496
|
-
| `sdl.mouse.BUTTON.MIDDLE` | `SDL_BUTTON_MIDDLE`
|
|
1497
|
-
| `sdl.mouse.BUTTON.RIGHT`
|
|
1531
|
+
| Value | Corresponding `SDL_BUTTON_*` |
|
|
1532
|
+
| --- | --- |
|
|
1533
|
+
| `sdl.mouse.BUTTON.LEFT` | `SDL_BUTTON_LEFT` |
|
|
1534
|
+
| `sdl.mouse.BUTTON.MIDDLE` | `SDL_BUTTON_MIDDLE` |
|
|
1535
|
+
| `sdl.mouse.BUTTON.RIGHT` | `SDL_BUTTON_RIGHT` |
|
|
1498
1536
|
|
|
1499
1537
|
### sdl.mouse.getButton(button)
|
|
1500
1538
|
|
|
1501
|
-
|
|
1502
|
-
|
|
1539
|
+
- `button: <number>` The index of the button.
|
|
1540
|
+
- Returns: `<boolean>` Is `true` if the button is pressed.
|
|
1503
1541
|
|
|
1504
1542
|
Queries the state of a single mouse button.
|
|
1505
1543
|
|
|
1506
1544
|
### sdl.mouse.position
|
|
1507
1545
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1546
|
+
- `<object>`
|
|
1547
|
+
- `x: <number>` The x position of the mouse, relative to the screen.
|
|
1548
|
+
- `y: <number>` The y position of the mouse, relative to the screen.
|
|
1511
1549
|
|
|
1512
1550
|
The position of the mouse on the screen.
|
|
1513
1551
|
|
|
1514
1552
|
### sdl.mouse.setPosition(x, y)
|
|
1515
1553
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1554
|
+
- `x: <number>` The new x position of the mouse, relative to the screen.
|
|
1555
|
+
- `y: <number>` The new y position of the mouse, relative to the screen.
|
|
1518
1556
|
|
|
1519
1557
|
Moves the mouse to the specified position.
|
|
1520
1558
|
|
|
1521
1559
|
### sdl.mouse.setCursor(cursor)
|
|
1522
1560
|
|
|
1523
|
-
|
|
1561
|
+
- `cursor: <MouseCursor>` The icon to use for the cursor.
|
|
1524
1562
|
|
|
1525
1563
|
Changes the icon that is displayed for the mouse cursor.
|
|
1526
1564
|
|
|
1527
1565
|
Possible values for `cursor` are:
|
|
1528
1566
|
|
|
1529
|
-
| Value
|
|
1530
|
-
| ---
|
|
1531
|
-
| `'arrow'`
|
|
1532
|
-
| `'ibeam'`
|
|
1533
|
-
| `'wait'`
|
|
1534
|
-
| `'crosshair'` | `SDL_SYSTEM_CURSOR_CROSSHAIR`
|
|
1535
|
-
| `'waitarrow'` | `SDL_SYSTEM_CURSOR_WAITARROW`
|
|
1536
|
-
| `'sizenwse'`
|
|
1537
|
-
| `'sizenesw'`
|
|
1538
|
-
| `'sizewe'`
|
|
1539
|
-
| `'sizens'`
|
|
1540
|
-
| `'sizeall'`
|
|
1541
|
-
| `'no'`
|
|
1542
|
-
| `'hand'`
|
|
1567
|
+
| Value | Corresponding `SDL_SystemCursor` | Description |
|
|
1568
|
+
| --- | --- | --- |
|
|
1569
|
+
| `'arrow'` | `SDL_SYSTEM_CURSOR_ARROW` | arrow |
|
|
1570
|
+
| `'ibeam'` | `SDL_SYSTEM_CURSOR_IBEAM` | i-beam |
|
|
1571
|
+
| `'wait'` | `SDL_SYSTEM_CURSOR_WAIT` | wait |
|
|
1572
|
+
| `'crosshair'` | `SDL_SYSTEM_CURSOR_CROSSHAIR` | crosshair |
|
|
1573
|
+
| `'waitarrow'` | `SDL_SYSTEM_CURSOR_WAITARROW` | small wait cursor (or wait if not available) |
|
|
1574
|
+
| `'sizenwse'` | `SDL_SYSTEM_CURSOR_SIZENWSE` | double arrow pointing northwest and southeast |
|
|
1575
|
+
| `'sizenesw'` | `SDL_SYSTEM_CURSOR_SIZENESW` | double arrow pointing northeast and southwest |
|
|
1576
|
+
| `'sizewe'` | `SDL_SYSTEM_CURSOR_SIZEWE` | double arrow pointing west and east |
|
|
1577
|
+
| `'sizens'` | `SDL_SYSTEM_CURSOR_SIZENS` | double arrow pointing north and south |
|
|
1578
|
+
| `'sizeall'` | `SDL_SYSTEM_CURSOR_SIZEALL` | four pointed arrow pointing north, south, east, and west |
|
|
1579
|
+
| `'no'` | `SDL_SYSTEM_CURSOR_NO` | slashed circle or crossbones |
|
|
1580
|
+
| `'hand'` | `SDL_SYSTEM_CURSOR_HAND` | hand |
|
|
1543
1581
|
|
|
1544
1582
|
### sdl.mouse.resetCursor()
|
|
1545
1583
|
|
|
@@ -1547,16 +1585,16 @@ Switched back to the default cursor.
|
|
|
1547
1585
|
|
|
1548
1586
|
### sdl.mouse.setCursorImage(width, height, stride, format, buffer, x, y)
|
|
1549
1587
|
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1588
|
+
- `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to use as a cursor.
|
|
1589
|
+
- `x: <number>` The x position of the cursor image's hotspot.
|
|
1590
|
+
- `y: <number>` The y position of the cursor image's hotspot.
|
|
1553
1591
|
|
|
1554
1592
|
Sets a image to be the mouse cursor.
|
|
1555
1593
|
The hotspot represents the pixel that is considered to be under the mouse.
|
|
1556
1594
|
|
|
1557
1595
|
### sdl.mouse.showCursor([show])
|
|
1558
1596
|
|
|
1559
|
-
|
|
1597
|
+
- `show: <boolean>` If `true` then the mouse cursor is made visible. Default: `true`
|
|
1560
1598
|
|
|
1561
1599
|
Changes the visibility of the mouse cursor.
|
|
1562
1600
|
|
|
@@ -1570,7 +1608,7 @@ Forces a cursor redraw.
|
|
|
1570
1608
|
|
|
1571
1609
|
### sdl.mouse.capture([capture])
|
|
1572
1610
|
|
|
1573
|
-
|
|
1611
|
+
- `capture: <boolean>` If `true` the mouse is to be captured by the current window. Default: `true`
|
|
1574
1612
|
|
|
1575
1613
|
When the mouse has been captured you will continue receiving mouse events even if the mouse is not over a window.
|
|
1576
1614
|
|
|
@@ -1578,6 +1616,29 @@ When the mouse has been captured you will continue receiving mouse events even i
|
|
|
1578
1616
|
|
|
1579
1617
|
Equivalent to [`sdl.mouse.capture(false)`](#sdlmousecapturecapture).
|
|
1580
1618
|
|
|
1619
|
+
## sdl.touch
|
|
1620
|
+
|
|
1621
|
+
### sdl.touch.devices
|
|
1622
|
+
|
|
1623
|
+
- `<object>[]`
|
|
1624
|
+
- `id: <number>` The unique id for the device.
|
|
1625
|
+
- `name: <string>|<null>` The name of the device, or `null` if it can't be determined.
|
|
1626
|
+
- `type: <TouchDeviceType>|<null>` The type of the device, or `null` if it can't be determined.
|
|
1627
|
+
|
|
1628
|
+
A list of all the detected touch devices.
|
|
1629
|
+
On some platforms SDL only sees the touch device after it has actually been used.
|
|
1630
|
+
Therefore the returned list might be empty, although devices are available.
|
|
1631
|
+
After using all devices at least once the number will be correct.
|
|
1632
|
+
|
|
1633
|
+
Possible values for `type` are `null` if it is unknown, or one of:
|
|
1634
|
+
|
|
1635
|
+
| Value | Corresponding `SDL_TouchDeviceType` |
|
|
1636
|
+
| --- | --- |
|
|
1637
|
+
| `'direct'` | `SDL_TOUCH_DEVICE_DIRECT` |
|
|
1638
|
+
| `'indirectAbsolute'` | `SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE` |
|
|
1639
|
+
| `'indirectRelative'` | `SDL_TOUCH_DEVICE_INDIRECT_RELATIVE` |
|
|
1640
|
+
|
|
1641
|
+
// TODO Sample output
|
|
1581
1642
|
|
|
1582
1643
|
## sdl.joystick
|
|
1583
1644
|
|
|
@@ -1585,36 +1646,36 @@ Equivalent to [`sdl.mouse.capture(false)`](#sdlmousecapturecapture).
|
|
|
1585
1646
|
|
|
1586
1647
|
String values used to represent the positions of a joystick hat
|
|
1587
1648
|
|
|
1588
|
-
| Value
|
|
1589
|
-
| ---
|
|
1590
|
-
| `'centered'`
|
|
1591
|
-
| `'up'`
|
|
1592
|
-
| `'right'`
|
|
1593
|
-
| `'down'`
|
|
1594
|
-
| `'left'`
|
|
1595
|
-
| `'rightup'`
|
|
1596
|
-
| `'rightdown'` | `SDL_HAT_RIGHTDOWN`
|
|
1597
|
-
| `'leftup'`
|
|
1598
|
-
| `'leftdown'`
|
|
1649
|
+
| Value | Corresponding `SDL_HAT_*` |
|
|
1650
|
+
| --- | --- |
|
|
1651
|
+
| `'centered'` | `SDL_HAT_CENTERED` |
|
|
1652
|
+
| `'up'` | `SDL_HAT_UP` |
|
|
1653
|
+
| `'right'` | `SDL_HAT_RIGHT` |
|
|
1654
|
+
| `'down'` | `SDL_HAT_DOWN` |
|
|
1655
|
+
| `'left'` | `SDL_HAT_LEFT` |
|
|
1656
|
+
| `'rightup'` | `SDL_HAT_RIGHTUP` |
|
|
1657
|
+
| `'rightdown'` | `SDL_HAT_RIGHTDOWN` |
|
|
1658
|
+
| `'leftup'` | `SDL_HAT_LEFTUP` |
|
|
1659
|
+
| `'leftdown'` | `SDL_HAT_LEFTDOWN` |
|
|
1599
1660
|
|
|
1600
1661
|
### Power levels
|
|
1601
1662
|
|
|
1602
1663
|
String values used to represent the power level of a joystick or controller
|
|
1603
1664
|
|
|
1604
|
-
| Value
|
|
1605
|
-
| ---
|
|
1606
|
-
| `'empty'`
|
|
1607
|
-
| `'low'`
|
|
1608
|
-
| `'medium'` | `SDL_JOYSTICK_POWER_MEDIUM`
|
|
1609
|
-
| `'full'`
|
|
1610
|
-
| `'wired'`
|
|
1611
|
-
| `'max'`
|
|
1665
|
+
| Value | Corresponding `SDL_JoystickPowerLevel` |
|
|
1666
|
+
| --- | --- |
|
|
1667
|
+
| `'empty'` | `SDL_JOYSTICK_POWER_EMPTY` |
|
|
1668
|
+
| `'low'` | `SDL_JOYSTICK_POWER_LOW` |
|
|
1669
|
+
| `'medium'` | `SDL_JOYSTICK_POWER_MEDIUM` |
|
|
1670
|
+
| `'full'` | `SDL_JOYSTICK_POWER_FULL` |
|
|
1671
|
+
| `'wired'` | `SDL_JOYSTICK_POWER_WIRED` |
|
|
1672
|
+
| `'max'` | `SDL_JOYSTICK_POWER_MAX` |
|
|
1612
1673
|
|
|
1613
1674
|
<a id="joystick-event-deviceadd"></a>
|
|
1614
1675
|
|
|
1615
1676
|
### Event: 'deviceAdd'
|
|
1616
1677
|
|
|
1617
|
-
|
|
1678
|
+
- `device: <object>`: An object from [`sdl.joystick.devices`](#sdljoystickdevices) indicating the device that caused the event.
|
|
1618
1679
|
|
|
1619
1680
|
Fired when a new joystick device becomes available.
|
|
1620
1681
|
Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joystick devices.
|
|
@@ -1623,7 +1684,7 @@ Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joyst
|
|
|
1623
1684
|
|
|
1624
1685
|
### Event: 'deviceRemove'
|
|
1625
1686
|
|
|
1626
|
-
|
|
1687
|
+
- `device: <object>`: An object from [`sdl.joystick.devices`](#sdljoystickdevices) indicating the device that caused the event.
|
|
1627
1688
|
|
|
1628
1689
|
Fired when an existing joystick device is removed.
|
|
1629
1690
|
Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joystick devices.
|
|
@@ -1631,32 +1692,32 @@ When this event is emitted, all instances that were opened from the removed devi
|
|
|
1631
1692
|
|
|
1632
1693
|
### sdl.joystick.devices
|
|
1633
1694
|
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1695
|
+
- `<object>[]`
|
|
1696
|
+
- `id: <number>` The unique id for the device.
|
|
1697
|
+
- `name: <string>|<null>` The name of the device.
|
|
1698
|
+
- `path: <string>|<null>` The implementation dependent path of the device, or `null` if it can't be determined.
|
|
1699
|
+
- `type: <JoystickType>|<null>` The type of the device, or `null` if it can't be determined.
|
|
1700
|
+
- `guid: <string>|<null>` The GUID of the device, or `null` if it can't be determined.
|
|
1701
|
+
- `vendor: <number>|<null>` The USB vendor ID of the device, or `null` if it can't be determined.
|
|
1702
|
+
- `product: <number>|<null>` The USB product ID of the device, or `null` if it can't be determined.
|
|
1703
|
+
- `version: <number>|<null>` The USB product version of the device, or `null` if it can't be determined.
|
|
1704
|
+
- `player: <number>|<null>` The player index for the device, or `null` if it can't be determined.
|
|
1644
1705
|
|
|
1645
1706
|
A list of all the detected joystick devices.
|
|
1646
1707
|
|
|
1647
1708
|
Possible values for `type` are `null` if it is unknown, or one of:
|
|
1648
1709
|
|
|
1649
|
-
| Value
|
|
1650
|
-
| ---
|
|
1710
|
+
| Value | Corresponding `SDL_JoystickType` |
|
|
1711
|
+
| --- | --- |
|
|
1651
1712
|
| `'gamecontroller'` | `SDL_JOYSTICK_TYPE_GAMECONTROLLER` |
|
|
1652
|
-
| `'wheel'`
|
|
1653
|
-
| `'arcadestick'`
|
|
1654
|
-
| `'flightstick'`
|
|
1655
|
-
| `'dancepad'`
|
|
1656
|
-
| `'guitar'`
|
|
1657
|
-
| `'drumkit'`
|
|
1658
|
-
| `'arcadepad'`
|
|
1659
|
-
| `'throttle'`
|
|
1713
|
+
| `'wheel'` | `SDL_JOYSTICK_TYPE_WHEEL` |
|
|
1714
|
+
| `'arcadestick'` | `SDL_JOYSTICK_TYPE_ARCADE_STICK` |
|
|
1715
|
+
| `'flightstick'` | `SDL_JOYSTICK_TYPE_FLIGHT_STICK` |
|
|
1716
|
+
| `'dancepad'` | `SDL_JOYSTICK_TYPE_DANCE_PAD` |
|
|
1717
|
+
| `'guitar'` | `SDL_JOYSTICK_TYPE_GUITAR` |
|
|
1718
|
+
| `'drumkit'` | `SDL_JOYSTICK_TYPE_DRUM_KIT` |
|
|
1719
|
+
| `'arcadepad'` | `SDL_JOYSTICK_TYPE_ARCADE_PAD` |
|
|
1720
|
+
| `'throttle'` | `SDL_JOYSTICK_TYPE_THROTTLE` |
|
|
1660
1721
|
|
|
1661
1722
|
Sample output:
|
|
1662
1723
|
|
|
@@ -1678,8 +1739,8 @@ Sample output:
|
|
|
1678
1739
|
|
|
1679
1740
|
### sdl.joystick.openDevice(device)
|
|
1680
1741
|
|
|
1681
|
-
|
|
1682
|
-
|
|
1742
|
+
- `device: <object>` An object from [`sdl.joystick.devices`](#sdljoystickdevices) that is to be opened.
|
|
1743
|
+
- Returns: [`<joystickInstance>`](#class-joystickinstance) an object representing the opened joystick device instance.
|
|
1683
1744
|
|
|
1684
1745
|
Initializes a joystick device and returns a corresponding instance.
|
|
1685
1746
|
|
|
@@ -1692,16 +1753,16 @@ Instead, objects returned by [`sdl.joystick.openDevice()`](#sdljoystickopendevic
|
|
|
1692
1753
|
|
|
1693
1754
|
### Event: 'axisMotion'
|
|
1694
1755
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1756
|
+
- `axis: <number>` The index of the axis that moved.
|
|
1757
|
+
- `value: <number>` The new axis position.
|
|
1697
1758
|
|
|
1698
1759
|
Fired when one of the joystick's axes moves.
|
|
1699
1760
|
|
|
1700
1761
|
### Event: 'ballMotion'
|
|
1701
1762
|
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1763
|
+
- `ball: <number>` The index of the ball that moved.
|
|
1764
|
+
- `x: <number>` The new x-position of the ball.
|
|
1765
|
+
- `y: <number>` The new y-position of the ball.
|
|
1705
1766
|
|
|
1706
1767
|
Fired when one of the joystick's balls moves.
|
|
1707
1768
|
|
|
@@ -1709,7 +1770,7 @@ Fired when one of the joystick's balls moves.
|
|
|
1709
1770
|
|
|
1710
1771
|
### Event: 'buttonDown'
|
|
1711
1772
|
|
|
1712
|
-
|
|
1773
|
+
- `button: <number>` The index of the button that was pressed.
|
|
1713
1774
|
|
|
1714
1775
|
Fired when one of the joystick's buttons is pressed.
|
|
1715
1776
|
|
|
@@ -1717,17 +1778,25 @@ Fired when one of the joystick's buttons is pressed.
|
|
|
1717
1778
|
|
|
1718
1779
|
### Event: 'buttonUp'
|
|
1719
1780
|
|
|
1720
|
-
|
|
1781
|
+
- `button: <number>` The index of the button that was released.
|
|
1721
1782
|
|
|
1722
1783
|
Fired when one of the joystick's buttons is released.
|
|
1723
1784
|
|
|
1724
1785
|
### Event: 'hatMotion'
|
|
1725
1786
|
|
|
1726
|
-
|
|
1727
|
-
|
|
1787
|
+
- `hat: <number>` The index of the hat that was moved.
|
|
1788
|
+
- `value: `[`<HatPosition>`](#hat-positions) The new hat position.
|
|
1728
1789
|
|
|
1729
1790
|
Fired when one of the joystick's hats is moved.
|
|
1730
1791
|
|
|
1792
|
+
<a id="joystick-instance-event-power-update"></a>
|
|
1793
|
+
|
|
1794
|
+
### Event: 'powerUpdate'
|
|
1795
|
+
|
|
1796
|
+
- `power: `[`<PowerLevel>`](#power-levels)`|<null>` The new power level.
|
|
1797
|
+
|
|
1798
|
+
Fired when the joystick's [power level](#controllerinstancepower) changes.
|
|
1799
|
+
|
|
1731
1800
|
<a id="joystick-instance-event-close"></a>
|
|
1732
1801
|
|
|
1733
1802
|
### Event: 'close'
|
|
@@ -1737,60 +1806,60 @@ Handle cleanup here.
|
|
|
1737
1806
|
|
|
1738
1807
|
### joystickInstance.device
|
|
1739
1808
|
|
|
1740
|
-
|
|
1809
|
+
- `<object>`
|
|
1741
1810
|
|
|
1742
1811
|
The [device](#sdljoystickdevices) from which the instance was opened.
|
|
1743
1812
|
|
|
1744
1813
|
### joystickInstance.firmwareVersion
|
|
1745
1814
|
|
|
1746
|
-
|
|
1815
|
+
- `<number>|<null>`
|
|
1747
1816
|
|
|
1748
1817
|
The joystick's firmware version, or `null` if it is not available.
|
|
1749
1818
|
|
|
1750
1819
|
### joystickInstance.serialNumber
|
|
1751
1820
|
|
|
1752
|
-
|
|
1821
|
+
- `<string>|<null>`
|
|
1753
1822
|
|
|
1754
1823
|
The joystick's serial number, or `null` if it is not available.
|
|
1755
1824
|
|
|
1756
1825
|
### joystickInstance.axes
|
|
1757
1826
|
|
|
1758
|
-
|
|
1827
|
+
- `<number>[]`
|
|
1759
1828
|
|
|
1760
1829
|
An array of values, each corresponding to the position of one of the joystick's axes.
|
|
1761
|
-
The values are normalized from `-1` to `+1`.
|
|
1830
|
+
The values are normalized in the range from `-1` to `+1`.
|
|
1762
1831
|
It may be necessary to impose certain tolerances on these values to account for jitter.
|
|
1763
1832
|
|
|
1764
1833
|
### joystickInstance.balls
|
|
1765
1834
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1835
|
+
- `<object>[]`
|
|
1836
|
+
- `x: <number>` The horizontal position of the joystick's ball.
|
|
1837
|
+
- `y: <number>` The vertical position of the joystick's ball.
|
|
1769
1838
|
|
|
1770
1839
|
An array of values, each corresponding to the position of one of the joystick's balls.
|
|
1771
1840
|
|
|
1772
1841
|
### joystickInstance.buttons
|
|
1773
1842
|
|
|
1774
|
-
|
|
1843
|
+
- `<boolean>[]`
|
|
1775
1844
|
|
|
1776
1845
|
An array of values, each corresponding to the state of one of the joystick's buttons.
|
|
1777
1846
|
Each value in the object isarray is either `true` if the corresponding button is pressed, or `false` otherwise.
|
|
1778
1847
|
|
|
1779
1848
|
### joystickInstance.hats
|
|
1780
1849
|
|
|
1781
|
-
|
|
1850
|
+
- [`<HatPosition>`](#hat-positions)`[]`
|
|
1782
1851
|
|
|
1783
1852
|
An array of values, each corresponding to the position of one of the joystick's hats.
|
|
1784
1853
|
|
|
1785
1854
|
### joystickInstance.power
|
|
1786
1855
|
|
|
1787
|
-
|
|
1856
|
+
- [`<PowerLevel>`](#power-levels)`|<null>`
|
|
1788
1857
|
|
|
1789
1858
|
The current power level of the joystick device, or `null` if it is unknown.
|
|
1790
1859
|
|
|
1791
1860
|
### joystickInstance.setPlayer(index)
|
|
1792
1861
|
|
|
1793
|
-
|
|
1862
|
+
- `index: <number>` The player index to assign to the joystick.
|
|
1794
1863
|
|
|
1795
1864
|
Sets the player index of the joystick.
|
|
1796
1865
|
|
|
@@ -1800,29 +1869,29 @@ Clears player assignment and player led.
|
|
|
1800
1869
|
|
|
1801
1870
|
### joystickInstance.hasLed
|
|
1802
1871
|
|
|
1803
|
-
|
|
1872
|
+
- `<boolean>`
|
|
1804
1873
|
|
|
1805
1874
|
Is `true` if the joystick has a LED light whose color can be controlled.
|
|
1806
1875
|
|
|
1807
1876
|
### joystickInstance.setLed(red, green, blue)
|
|
1808
1877
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1878
|
+
- `red: <number>` The red component of the led color, from `0` to `1`.
|
|
1879
|
+
- `green: <number>` The green component of the led color, from `0` to `1`.
|
|
1880
|
+
- `blue: <number>` The blue component of the led color, from `0` to `1`.
|
|
1812
1881
|
|
|
1813
1882
|
Sets the color of the LED light on the joystick.
|
|
1814
1883
|
|
|
1815
1884
|
### joystickInstance.hasRumble
|
|
1816
1885
|
|
|
1817
|
-
|
|
1886
|
+
- `<boolean>`
|
|
1818
1887
|
|
|
1819
1888
|
Is `true` if the joystick has rumble motors.
|
|
1820
1889
|
|
|
1821
1890
|
### joystickInstance.rumble([low[, high[, duration]]])
|
|
1822
1891
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1892
|
+
- `low: <number>` The intensity of the low frequency rumble motor, from `0` to `1`. Default: `1`
|
|
1893
|
+
- `high: <number>` The intensity of the high frequency rumble motor, from `0` to `1`. Default: `1`
|
|
1894
|
+
- `duration: <number>` The duration of the rumble, in ms. Default: `1e3`
|
|
1826
1895
|
|
|
1827
1896
|
Makes the joystick rumble for a set `duration`.
|
|
1828
1897
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -1834,15 +1903,15 @@ Equivalent to [`joystickInstance.rumble(0, 0)`](#joystickinstancerumblelow-high-
|
|
|
1834
1903
|
|
|
1835
1904
|
### joystickInstance.hasRumbleTriggers
|
|
1836
1905
|
|
|
1837
|
-
|
|
1906
|
+
- `<boolean>`
|
|
1838
1907
|
|
|
1839
1908
|
Is `true` if the joystick has rumble motors on the triggers.
|
|
1840
1909
|
|
|
1841
1910
|
### joystickInstance.rumbleTriggers([left[, right[, duration]]])
|
|
1842
1911
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1912
|
+
- `left: <number>` The intensity of the left trigger rumble motor, from `0` to `1`. Default: `1`
|
|
1913
|
+
- `right: <number>` The intensity of the right trigger rumble motor, from `0` to `1`. Default: `1`
|
|
1914
|
+
- `duration: <number>` The duration of the rumble, in ms. Default: `1e3`
|
|
1846
1915
|
|
|
1847
1916
|
Makes the joystick triggers rumble for a set `duration`.
|
|
1848
1917
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -1854,7 +1923,7 @@ Equivalent to [`joystickInstance.rumbleTriggers(0, 0)`](#joystickinstancerumblet
|
|
|
1854
1923
|
|
|
1855
1924
|
### joystickInstance.closed
|
|
1856
1925
|
|
|
1857
|
-
|
|
1926
|
+
- `<boolean>`
|
|
1858
1927
|
|
|
1859
1928
|
Is `true` if the instance is closed.
|
|
1860
1929
|
A closed instance object must not be used any further.
|
|
@@ -1863,7 +1932,6 @@ A closed instance object must not be used any further.
|
|
|
1863
1932
|
|
|
1864
1933
|
Closes the instance.
|
|
1865
1934
|
|
|
1866
|
-
|
|
1867
1935
|
## sdl.controller
|
|
1868
1936
|
|
|
1869
1937
|
An SDL controller is an abstraction over [`joysticks`](#sdljoystick) based on the xbox360 controller: They have a dpad, two analog sticks, 4 buttons on the right (called A, B, X, Y), shoulder buttons (two of which might be axes) and 3 buttons in the middle ("Start", "Back" and usually some kind of logo-button called "Guide").
|
|
@@ -1875,7 +1943,7 @@ Because controllers are an abstraction over joysticks, they operate on the same
|
|
|
1875
1943
|
For a joystick device to also be available as a controller device it needs a "mapping".
|
|
1876
1944
|
A mapping is a string that consists of the device's GUID, its name, and a series of pairings between one joystick axis/button and the corresponding controller axis/button name.
|
|
1877
1945
|
See the sample output [`here`](#sdlcontrollerdevices) for an example.
|
|
1878
|
-
SDL has pretty good default controller mappings, but if you need more, there's a community sourced database available on https://github.com/gabomdq/SDL_GameControllerDB.
|
|
1946
|
+
SDL has pretty good default controller mappings, but if you need more, there's a community sourced database available on [gabomdq/SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB).
|
|
1879
1947
|
Add them via:
|
|
1880
1948
|
|
|
1881
1949
|
```js
|
|
@@ -1890,7 +1958,7 @@ sdl.controller.addMappings(mappings)
|
|
|
1890
1958
|
|
|
1891
1959
|
### Event: 'deviceAdd'
|
|
1892
1960
|
|
|
1893
|
-
|
|
1961
|
+
- `device: <object>`: An object from [`sdl.controller.devices`](#sdlcontrollerdevices) indicating the device that caused the event.
|
|
1894
1962
|
|
|
1895
1963
|
Fired when a new controller device becomes available.
|
|
1896
1964
|
Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of controller devices.
|
|
@@ -1899,7 +1967,7 @@ Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of c
|
|
|
1899
1967
|
|
|
1900
1968
|
### Event: 'deviceRemove'
|
|
1901
1969
|
|
|
1902
|
-
|
|
1970
|
+
- `device: <object>`: An object from [`sdl.controller.devices`](#sdlcontrollerdevices) indicating the device that caused the event.
|
|
1903
1971
|
|
|
1904
1972
|
Fired when an existing controller device is removed.
|
|
1905
1973
|
Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of controller devices.
|
|
@@ -1907,44 +1975,44 @@ When this event is emitted, all instances that were opened from the removed devi
|
|
|
1907
1975
|
|
|
1908
1976
|
### sdl.controller.addMappings(mappings)
|
|
1909
1977
|
|
|
1910
|
-
|
|
1978
|
+
- `mappings: <string>[]` An array of mappings to register.
|
|
1911
1979
|
|
|
1912
1980
|
Registers new mappings for controllers.
|
|
1913
1981
|
This may cause already opened controller instances to be [remapped](#event-remap).
|
|
1914
1982
|
|
|
1915
1983
|
### sdl.controller.devices
|
|
1916
1984
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1985
|
+
- `<object>[]`
|
|
1986
|
+
- `id: <number>` The unique id for the device.
|
|
1987
|
+
- `name: <string>|<null>` The name of the device.
|
|
1988
|
+
- `path: <string>|<null>` The implementation dependent path of the device, or `null` if it can't be determined.
|
|
1989
|
+
- `type: <string>|<null>` The type of the device, or `null` if it can't be determined.
|
|
1990
|
+
- `guid: <string>|<null>` The GUID of the device, or `null` if it can't be determined.
|
|
1991
|
+
- `vendor: <number>|<null>` The USB vendor ID of the device, or `null` if it can't be determined.
|
|
1992
|
+
- `product: <number>|<null>` The USB product ID of the device, or `null` if it can't be determined.
|
|
1993
|
+
- `version: <number>|<null>` The USB product version of the device, or `null` if it can't be determined.
|
|
1994
|
+
- `player: <number>|<null>` The player index for the device, or `null` if it can't be determined.
|
|
1995
|
+
- `mapping: <string>|<null>` The axis and button mapping for the device, or `null` if it can't be determined.
|
|
1928
1996
|
|
|
1929
1997
|
A list of all the detected controller devices.
|
|
1930
1998
|
|
|
1931
1999
|
Possible values for `type` are `null` if it is unknown, or one of:
|
|
1932
2000
|
|
|
1933
|
-
| Value
|
|
1934
|
-
| ---
|
|
1935
|
-
| `'xbox360'`
|
|
1936
|
-
| `'xboxOne'`
|
|
1937
|
-
| `'ps3'`
|
|
1938
|
-
| `'ps4'`
|
|
1939
|
-
| `'nintendoSwitchPro'`
|
|
1940
|
-
| `'virtual'`
|
|
1941
|
-
| `'ps5'`
|
|
1942
|
-
| `'amazonLuna'`
|
|
1943
|
-
| `'googleStadia'`
|
|
1944
|
-
| `'nvidiaShield'`
|
|
1945
|
-
| `'nintendoSwitchJoyconLeft'`
|
|
2001
|
+
| Value | Corresponding `SDL_GameControllerType` |
|
|
2002
|
+
| --- | --- |
|
|
2003
|
+
| `'xbox360'` | SDL_CONTROLLER_TYPE_XBOX360 |
|
|
2004
|
+
| `'xboxOne'` | SDL_CONTROLLER_TYPE_XBOXONE |
|
|
2005
|
+
| `'ps3'` | SDL_CONTROLLER_TYPE_PS3 |
|
|
2006
|
+
| `'ps4'` | SDL_CONTROLLER_TYPE_PS4 |
|
|
2007
|
+
| `'nintendoSwitchPro'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO |
|
|
2008
|
+
| `'virtual'` | SDL_CONTROLLER_TYPE_VIRTUAL |
|
|
2009
|
+
| `'ps5'` | SDL_CONTROLLER_TYPE_PS5 |
|
|
2010
|
+
| `'amazonLuna'` | SDL_CONTROLLER_TYPE_AMAZON_LUNA |
|
|
2011
|
+
| `'googleStadia'` | SDL_CONTROLLER_TYPE_GOOGLE_STADIA |
|
|
2012
|
+
| `'nvidiaShield'` | SDL_CONTROLLER_TYPE_NVIDIA_SHIELD |
|
|
2013
|
+
| `'nintendoSwitchJoyconLeft'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT |
|
|
1946
2014
|
| `'nintendoSwitchJoyconRight'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT |
|
|
1947
|
-
| `'nintendoSwitchJoyconPair'`
|
|
2015
|
+
| `'nintendoSwitchJoyconPair'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR |
|
|
1948
2016
|
|
|
1949
2017
|
Sample output:
|
|
1950
2018
|
|
|
@@ -1967,8 +2035,8 @@ Sample output:
|
|
|
1967
2035
|
|
|
1968
2036
|
### sdl.controller.openDevice(device)
|
|
1969
2037
|
|
|
1970
|
-
|
|
1971
|
-
|
|
2038
|
+
- `device: <object>` An object from [`sdl.controller.devices`](#sdlcontrollerdevices) that is to be opened.
|
|
2039
|
+
- Returns: [`<ControllerInstance>`](#class-controllerinstance) an object representing the opened controller device instance.
|
|
1972
2040
|
|
|
1973
2041
|
Initializes an controller device and returns a corresponding instance.
|
|
1974
2042
|
|
|
@@ -1981,8 +2049,8 @@ Instead, objects returned by [`sdl.controller.openDevice()`](#sdlcontrolleropend
|
|
|
1981
2049
|
|
|
1982
2050
|
### Event: 'axisMotion'
|
|
1983
2051
|
|
|
1984
|
-
|
|
1985
|
-
|
|
2052
|
+
- `axis:`[`<Axis>`](#controllerinstanceaxes) The axis that moved.
|
|
2053
|
+
- `value: <number>` The new axis position.
|
|
1986
2054
|
|
|
1987
2055
|
Fired when one of the controller's axes moves.
|
|
1988
2056
|
|
|
@@ -1990,7 +2058,7 @@ Fired when one of the controller's axes moves.
|
|
|
1990
2058
|
|
|
1991
2059
|
### Event: 'buttonDown'
|
|
1992
2060
|
|
|
1993
|
-
|
|
2061
|
+
- `button:`[`<Button>`](#controllerinstancebuttons) The button that was pressed.
|
|
1994
2062
|
|
|
1995
2063
|
Fired when one of the controller's buttons is pressed.
|
|
1996
2064
|
|
|
@@ -1998,10 +2066,24 @@ Fired when one of the controller's buttons is pressed.
|
|
|
1998
2066
|
|
|
1999
2067
|
### Event: 'buttonUp'
|
|
2000
2068
|
|
|
2001
|
-
|
|
2069
|
+
- `button: <number>` The index of the button that was released.
|
|
2002
2070
|
|
|
2003
2071
|
Fired when one of the controller's buttons is released.
|
|
2004
2072
|
|
|
2073
|
+
<a id="controller-instance-event-power-update"></a>
|
|
2074
|
+
|
|
2075
|
+
### Event: 'powerUpdate'
|
|
2076
|
+
|
|
2077
|
+
- `power: `[`<PowerLevel>`](#power-levels)`|<null>` The new power level.
|
|
2078
|
+
|
|
2079
|
+
Fired when the controller's [power level](#controllerinstancepowerlevel) changes.
|
|
2080
|
+
|
|
2081
|
+
### Event: 'steamHandleUpdate'
|
|
2082
|
+
|
|
2083
|
+
- `steamHandle: <Buffer>|<null>` The new steam handle.
|
|
2084
|
+
|
|
2085
|
+
Fired when the controller's [`steamHandle`](#controllerinstancesteamhandle) changes.
|
|
2086
|
+
|
|
2005
2087
|
### Event: 'remap'
|
|
2006
2088
|
|
|
2007
2089
|
Fired when a new mapping for the controller is applied (usually via [`sdl.controller.addMappings()`](#sdlcontrolleraddmappingsmappings)).
|
|
@@ -2016,78 +2098,78 @@ Handle cleanup here.
|
|
|
2016
2098
|
|
|
2017
2099
|
### controllerInstance.device
|
|
2018
2100
|
|
|
2019
|
-
|
|
2101
|
+
- `<object>`
|
|
2020
2102
|
|
|
2021
2103
|
The [device](#sdlcontrollerdevices) from which the instance was opened.
|
|
2022
2104
|
|
|
2023
2105
|
### controllerInstance.firmwareVersion
|
|
2024
2106
|
|
|
2025
|
-
|
|
2107
|
+
- `<number>`
|
|
2026
2108
|
|
|
2027
2109
|
The controller's firmware version.
|
|
2028
2110
|
|
|
2029
2111
|
### controllerInstance.serialNumber
|
|
2030
2112
|
|
|
2031
|
-
|
|
2113
|
+
- `<string>|<null>`
|
|
2032
2114
|
|
|
2033
2115
|
The controller's serial number, or `null` if it is not available.
|
|
2034
2116
|
|
|
2035
2117
|
### controllerInstance.steamHandle
|
|
2036
2118
|
|
|
2037
|
-
|
|
2119
|
+
- `<Buffer>|<null>`
|
|
2038
2120
|
|
|
2039
2121
|
The controller's steam handle, or `null` if it is not available.
|
|
2040
2122
|
The `Buffer` contains an `InputHandle_t` for the controller that can be used with the [Steam Input API](https://partner.steamgames.com/doc/api/ISteamInput)
|
|
2041
2123
|
|
|
2042
2124
|
### controllerInstance.axes
|
|
2043
2125
|
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2126
|
+
- `<object>`
|
|
2127
|
+
- `leftStickX: <number>` Left stick horizontal position
|
|
2128
|
+
- `leftStickY: <number>` Left stick vertical position
|
|
2129
|
+
- `rightStickX: <number>` Right stick horizontal position
|
|
2130
|
+
- `rightStickY: <number>` Right stick vertical position
|
|
2131
|
+
- `leftTrigger: <number>` Left trigger position
|
|
2132
|
+
- `rightTrigger: <number>` Right trigger position
|
|
2051
2133
|
|
|
2052
2134
|
An object mapping each axis of the controller's axes to its position.
|
|
2053
|
-
The values are normalized from `-1` to `+1`.
|
|
2135
|
+
The values are normalized in the range from `-1` to `+1`.
|
|
2054
2136
|
It may be necessary to impose certain tolerances on these values to account for jitter.
|
|
2055
2137
|
|
|
2056
2138
|
### controllerInstance.buttons
|
|
2057
2139
|
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2140
|
+
- `<object>`
|
|
2141
|
+
- `dpadLeft: <boolean>` D-Pad left pressed
|
|
2142
|
+
- `dpadRight: <boolean>` D-Pad right pressed
|
|
2143
|
+
- `dpadUp: <boolean>` D-Pad up pressed
|
|
2144
|
+
- `dpadDown: <boolean>` D-Pad down pressed
|
|
2145
|
+
- `a: <boolean>` A button pressed
|
|
2146
|
+
- `b: <boolean>` B button pressed
|
|
2147
|
+
- `x: <boolean>` X button pressed
|
|
2148
|
+
- `y: <boolean>` Y button pressed
|
|
2149
|
+
- `guide: <boolean>` Middle button pressed
|
|
2150
|
+
- `back: <boolean>` Back button pressed
|
|
2151
|
+
- `start: <boolean>` Start button pressed
|
|
2152
|
+
- `leftStick: <boolean>` Left stick pressed
|
|
2153
|
+
- `rightStick: <boolean>` Right stick pressed
|
|
2154
|
+
- `leftShoulder: <boolean>` Left shoulder button pressed
|
|
2155
|
+
- `rightShoulder: <boolean>` Right shoulder button pressed
|
|
2156
|
+
- `paddle1: <boolean>` Paddle 1 pressed
|
|
2157
|
+
- `paddle2: <boolean>` Paddle 2 pressed
|
|
2158
|
+
- `paddle3: <boolean>` Paddle 3 pressed
|
|
2159
|
+
- `paddle4: <boolean>` Paddle 4 pressed
|
|
2078
2160
|
|
|
2079
2161
|
An object mapping each of the controller's buttons to a boolean value.
|
|
2080
2162
|
Each value in the object is either `true` if the corresponding button is pressed, or `false` otherwise.
|
|
2081
2163
|
|
|
2082
2164
|
### controllerInstance.power
|
|
2083
2165
|
|
|
2084
|
-
|
|
2166
|
+
- [`<PowerLevel>`](#power-levels)`|<null>`
|
|
2085
2167
|
|
|
2086
2168
|
The current power level of the joystick device, or `null` if it is unknown.
|
|
2087
2169
|
|
|
2088
2170
|
### controllerInstance.setPlayer(index)
|
|
2089
2171
|
|
|
2090
|
-
|
|
2172
|
+
- `index: <number>` The player index to assign to the controller.
|
|
2091
2173
|
|
|
2092
2174
|
Sets the player index of the controller.
|
|
2093
2175
|
|
|
@@ -2097,29 +2179,29 @@ Clears player assignment and player led.
|
|
|
2097
2179
|
|
|
2098
2180
|
### controllerInstance.hasLed
|
|
2099
2181
|
|
|
2100
|
-
|
|
2182
|
+
- `<boolean>`
|
|
2101
2183
|
|
|
2102
2184
|
Is `true` if the controller has a LED light whose color can be controlled.
|
|
2103
2185
|
|
|
2104
2186
|
### controllerInstance.setLed(red, green, blue)
|
|
2105
2187
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2188
|
+
- `red: <number>` The red component of the led color, from `0` to `1`.
|
|
2189
|
+
- `green: <number>` The green component of the led color, from `0` to `1`.
|
|
2190
|
+
- `blue: <number>` The blue component of the led color, from `0` to `1`.
|
|
2109
2191
|
|
|
2110
2192
|
Sets the color of the LED light on the controller.
|
|
2111
2193
|
|
|
2112
2194
|
### controllerInstance.hasRumble
|
|
2113
2195
|
|
|
2114
|
-
|
|
2196
|
+
- `<boolean>`
|
|
2115
2197
|
|
|
2116
2198
|
Is `true` if the controller has rumble motors.
|
|
2117
2199
|
|
|
2118
2200
|
### controllerInstance.rumble([low[, high[, duration]]])
|
|
2119
2201
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2202
|
+
- `low: <number>` The intensity of the low frequency rumble motor, from `0` to `1`. Default: `1`
|
|
2203
|
+
- `high: <number>` The intensity of the high frequency rumble motor, from `0` to `1`. Default: `1`
|
|
2204
|
+
- `duration: <number>` The duration of the rumble, in ms. Default: `1e3`
|
|
2123
2205
|
|
|
2124
2206
|
Makes the controller rumble for a set `duration`.
|
|
2125
2207
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -2131,15 +2213,15 @@ Equivalent to [`controllerInstance.rumble(0, 0)`](#controllerinstancerumblelow-h
|
|
|
2131
2213
|
|
|
2132
2214
|
### controllerInstance.hasRumbleTriggers
|
|
2133
2215
|
|
|
2134
|
-
|
|
2216
|
+
- `<boolean>`
|
|
2135
2217
|
|
|
2136
2218
|
Is `true` if the controller has rumble motors on the triggers.
|
|
2137
2219
|
|
|
2138
2220
|
### controllerInstance.rumbleTriggers([left[, right[, duration]]])
|
|
2139
2221
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2222
|
+
- `left: <number>` The intensity of the left trigger rumble motor, from `0` to `1`. Default: `1`
|
|
2223
|
+
- `right: <number>` The intensity of the right trigger rumble motor, from `0` to `1`. Default: `1`
|
|
2224
|
+
- `duration: <number>` The duration of the rumble, in ms. Default: `1e3`
|
|
2143
2225
|
|
|
2144
2226
|
Makes the controller triggers rumble for a set `duration`.
|
|
2145
2227
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -2151,7 +2233,7 @@ Equivalent to [`controllerInstance.rumbleTriggers(0, 0)`](#controllerinstancerum
|
|
|
2151
2233
|
|
|
2152
2234
|
### controllerInstance.closed
|
|
2153
2235
|
|
|
2154
|
-
|
|
2236
|
+
- `<boolean>`
|
|
2155
2237
|
|
|
2156
2238
|
Is `true` if the instance is closed.
|
|
2157
2239
|
A closed instance object must not be used any further.
|
|
@@ -2160,12 +2242,11 @@ A closed instance object must not be used any further.
|
|
|
2160
2242
|
|
|
2161
2243
|
Closes the instance.
|
|
2162
2244
|
|
|
2163
|
-
|
|
2164
2245
|
## sdl.sensor
|
|
2165
2246
|
|
|
2166
2247
|
### sdl.sensor.STANDARD_GRAVITY
|
|
2167
2248
|
|
|
2168
|
-
|
|
2249
|
+
- `<number>`
|
|
2169
2250
|
|
|
2170
2251
|
Accelerometers are affected by the force of gravity:
|
|
2171
2252
|
even if the device is completely at rest, it will still indicata an acceleration with a magnitude of [`sdl.sensor.STANDARD_GRAVITY`](#sdlsensorstandard_gravity) away from the center of the earth.
|
|
@@ -2173,11 +2254,11 @@ Use the `sdl.sensor.STANDARD_GRAVITY` constant to correct for gravitational acce
|
|
|
2173
2254
|
|
|
2174
2255
|
### sdl.sensor.devices
|
|
2175
2256
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2257
|
+
- `<object>[]`
|
|
2258
|
+
- `id: <number>` The unique id of the device.
|
|
2259
|
+
- `name: <string>` The name of the device.
|
|
2260
|
+
- `type: <string>|<null>` Either `'accelerometer'` or `'gyroscope'`. Is `null` if it can't be determined.
|
|
2261
|
+
- `side: <string>|<null>` Either `'left'` or `'right'`. Is `null` if the sensor does not have a side, or the value can't be determined.
|
|
2181
2262
|
|
|
2182
2263
|
A list of all the detected sensor devices.
|
|
2183
2264
|
|
|
@@ -2190,8 +2271,8 @@ Sample output:
|
|
|
2190
2271
|
|
|
2191
2272
|
### sdl.sensor.openDevice(device)
|
|
2192
2273
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2274
|
+
- `device: <object>` An object from [`sdl.sensor.devices`](#sdlsensordevices) that is to be opened.
|
|
2275
|
+
- Returns: [`<SensorInstance>`](#class-sensorinstance) an object representing the opened sensor device instance.
|
|
2195
2276
|
|
|
2196
2277
|
Initializes a sensor device and returns a corresponding instance.
|
|
2197
2278
|
|
|
@@ -2216,17 +2297,17 @@ Handle cleanup here.
|
|
|
2216
2297
|
|
|
2217
2298
|
### sensorInstance.device
|
|
2218
2299
|
|
|
2219
|
-
|
|
2300
|
+
- `<object>`
|
|
2220
2301
|
|
|
2221
2302
|
The [device](#sdlsensordevices) from which the `sensorInstance` was opened.
|
|
2222
2303
|
|
|
2223
2304
|
### sensorInstance.data
|
|
2224
2305
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2306
|
+
- `<object>`
|
|
2307
|
+
- `timestamp: <number>|<null>` The time the latest measurement was taken __in microseconds__, or `null` if it can't be determined.
|
|
2308
|
+
- `x: <number>` X axis value.
|
|
2309
|
+
- `y: <number>` Y axis value.
|
|
2310
|
+
- `z: <number>` Z axis value.
|
|
2230
2311
|
|
|
2231
2312
|
An object reporting the latest measurement from the sensor.
|
|
2232
2313
|
|
|
@@ -2238,13 +2319,14 @@ For gyroscopes, the `x`, `y`, and `z` values correspond to the current rate of r
|
|
|
2238
2319
|
The rotation is positive in the counter-clockwise direction, meaning that an observer looking from a positive location on one of the axes would see positive rotation on that axis when it appeared to be rotating counter-clockwise.
|
|
2239
2320
|
|
|
2240
2321
|
For phones held in portrait mode and game controllers held in front of you, the axes are defined as follows:
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2322
|
+
|
|
2323
|
+
- -X ... +X : left ... right
|
|
2324
|
+
- -Y ... +Y : bottom ... top
|
|
2325
|
+
- -Z ... +Z : farther ... closer
|
|
2244
2326
|
|
|
2245
2327
|
### sensorInstance.closed
|
|
2246
2328
|
|
|
2247
|
-
|
|
2329
|
+
- `<boolean>`
|
|
2248
2330
|
|
|
2249
2331
|
Is `true` if the instance is closed.
|
|
2250
2332
|
A closed instance object must not be used any further.
|
|
@@ -2253,7 +2335,6 @@ A closed instance object must not be used any further.
|
|
|
2253
2335
|
|
|
2254
2336
|
Closes the instance.
|
|
2255
2337
|
|
|
2256
|
-
|
|
2257
2338
|
## sdl.audio
|
|
2258
2339
|
|
|
2259
2340
|
### Audio data
|
|
@@ -2266,10 +2347,10 @@ A _sample_ is a single number representing the intensity of an audio channel at
|
|
|
2266
2347
|
For audio with multiple channels, each point in time is represented by multiple samples (one per channel) that together make up a _frame_.
|
|
2267
2348
|
The samples in a frame are arranged as follows:
|
|
2268
2349
|
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2350
|
+
- For 1 channel (mono) a frame contains just the one sample.
|
|
2351
|
+
- For 2 channels (stereo) the frame contains two samples and the layout is: left, right. This means that the first sample corresponds to the left channel and the second sample corresponds to the right channel.
|
|
2352
|
+
- For 4 channels (quad) the layout is front-left, front-right, rear-left, rear-right.
|
|
2353
|
+
- For 6 channels (5.1) the layout is front-left, front-right, center, low-freq, rear-left, rear-right.
|
|
2273
2354
|
|
|
2274
2355
|
So for example, to play 3 seconds of a 440Hz sine wave, you could do:
|
|
2275
2356
|
|
|
@@ -2316,32 +2397,32 @@ playbackInstance.play()
|
|
|
2316
2397
|
|
|
2317
2398
|
String values used to represent how audio samples are stored in a Buffer.
|
|
2318
2399
|
|
|
2319
|
-
| Value
|
|
2320
|
-
| ---
|
|
2321
|
-
| `'s8'`
|
|
2322
|
-
| `'u8'`
|
|
2323
|
-
| `'s16lsb'` | `AUDIO_S16LSB`
|
|
2324
|
-
| `'s16msb'` | `AUDIO_S16MSB`
|
|
2325
|
-
| `'s16sys'` | `AUDIO_S16SYS`
|
|
2326
|
-
| `'s16'`
|
|
2327
|
-
| `'u16lsb'` | `AUDIO_U16LSB`
|
|
2328
|
-
| `'u16msb'` | `AUDIO_U16MSB`
|
|
2329
|
-
| `'u16sys'` | `AUDIO_U16SYS`
|
|
2330
|
-
| `'u16'`
|
|
2331
|
-
| `'s32lsb'` | `AUDIO_S32LSB`
|
|
2332
|
-
| `'s32msb'` | `AUDIO_S32MSB`
|
|
2333
|
-
| `'s32sys'` | `AUDIO_S32SYS`
|
|
2334
|
-
| `'s32'`
|
|
2335
|
-
| `'f32lsb'` | `AUDIO_F32LSB`
|
|
2336
|
-
| `'f32msb'` | `AUDIO_F32MSB`
|
|
2337
|
-
| `'f32sys'` | `AUDIO_F32SYS`
|
|
2338
|
-
| `'f32'`
|
|
2400
|
+
| Value | Corresponding `SDL_AudioFormat` | Comment |
|
|
2401
|
+
| --- | --- | --- |
|
|
2402
|
+
| `'s8'` | `AUDIO_S8` | signed 8-bit samples |
|
|
2403
|
+
| `'u8'` | `AUDIO_U8` | unsigned 8-bit samples |
|
|
2404
|
+
| `'s16lsb'` | `AUDIO_S16LSB` | signed 16-bit samples in little-endian byte order |
|
|
2405
|
+
| `'s16msb'` | `AUDIO_S16MSB` | signed 16-bit samples in big-endian byte order |
|
|
2406
|
+
| `'s16sys'` | `AUDIO_S16SYS` | signed 16-bit samples in native byte order |
|
|
2407
|
+
| `'s16'` | `AUDIO_S16` | alias for `'s16lsb'` |
|
|
2408
|
+
| `'u16lsb'` | `AUDIO_U16LSB` | unsigned 16-bit samples in little-endian byte order |
|
|
2409
|
+
| `'u16msb'` | `AUDIO_U16MSB` | unsigned 16-bit samples in big-endian byte order |
|
|
2410
|
+
| `'u16sys'` | `AUDIO_U16SYS` | unsigned 16-bit samples in native byte order |
|
|
2411
|
+
| `'u16'` | `AUDIO_U16` | alias for `'u16lsb'` |
|
|
2412
|
+
| `'s32lsb'` | `AUDIO_S32LSB` | 32-bit integer samples in little-endian byte order |
|
|
2413
|
+
| `'s32msb'` | `AUDIO_S32MSB` | 32-bit integer samples in big-endian byte order |
|
|
2414
|
+
| `'s32sys'` | `AUDIO_S32SYS` | 32-bit integer samples in native byte order |
|
|
2415
|
+
| `'s32'` | `AUDIO_S32` | alias for `'s32lsb'` |
|
|
2416
|
+
| `'f32lsb'` | `AUDIO_F32LSB` | 32-bit floating point samples in little-endian byte order |
|
|
2417
|
+
| `'f32msb'` | `AUDIO_F32MSB` | 32-bit floating point samples in big-endian byte order |
|
|
2418
|
+
| `'f32sys'` | `AUDIO_F32SYS` | 32-bit floating point samples in native byte order |
|
|
2419
|
+
| `'f32'` | `AUDIO_F32` | alias for `'f32lsb'` |
|
|
2339
2420
|
|
|
2340
2421
|
<a id="audio-event-deviceadd"></a>
|
|
2341
2422
|
|
|
2342
2423
|
### Event: 'deviceAdd'
|
|
2343
2424
|
|
|
2344
|
-
|
|
2425
|
+
- `device: <object>`: An object from [`sdl.audio.devices`](#sdlaudiodevices) indicating the device that caused the event.
|
|
2345
2426
|
|
|
2346
2427
|
Fired when a new audio device becomes available.
|
|
2347
2428
|
Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devices.
|
|
@@ -2350,7 +2431,7 @@ Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devic
|
|
|
2350
2431
|
|
|
2351
2432
|
### Event: 'deviceRemove'
|
|
2352
2433
|
|
|
2353
|
-
|
|
2434
|
+
- `device: <object>`: An object from [`sdl.audio.devices`](#sdlaudiodevices) indicating the device that caused the event.
|
|
2354
2435
|
|
|
2355
2436
|
Fired when an existing audio device is removed.
|
|
2356
2437
|
Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devices.
|
|
@@ -2358,8 +2439,8 @@ When the `'deviceRemove'` event is emitted, all instances that were opened from
|
|
|
2358
2439
|
|
|
2359
2440
|
### sdl.audio.bytesPerSample(format)
|
|
2360
2441
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2442
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2443
|
+
- Returns: `<number>` The number of bytes.
|
|
2363
2444
|
|
|
2364
2445
|
Helper function which maps each sample format to the corresponding number of bytes its samples take up.
|
|
2365
2446
|
|
|
@@ -2367,8 +2448,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2367
2448
|
|
|
2368
2449
|
### sdl.audio.minSampleValue(format)
|
|
2369
2450
|
|
|
2370
|
-
|
|
2371
|
-
|
|
2451
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2452
|
+
- Returns: `<number>` The minimum sample value.
|
|
2372
2453
|
|
|
2373
2454
|
Helper function which maps each sample format to the corresponding minimum value its samples can take.
|
|
2374
2455
|
|
|
@@ -2376,8 +2457,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2376
2457
|
|
|
2377
2458
|
### sdl.audio.maxSampleValue(format)
|
|
2378
2459
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2460
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2461
|
+
- Returns: `<number>` The maximum sample value.
|
|
2381
2462
|
|
|
2382
2463
|
Helper function which maps each sample format to the corresponding maximum value its samples can take.
|
|
2383
2464
|
|
|
@@ -2385,8 +2466,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2385
2466
|
|
|
2386
2467
|
### sdl.audio.zeroSampleValue(format)
|
|
2387
2468
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2469
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2470
|
+
- Returns: `<number>` The zero sample value.
|
|
2390
2471
|
|
|
2391
2472
|
Helper function which maps each sample format to the sample value that corresponds to silence.
|
|
2392
2473
|
|
|
@@ -2394,10 +2475,10 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2394
2475
|
|
|
2395
2476
|
### sdl.audio.readSample(format, buffer[, offset])
|
|
2396
2477
|
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2478
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2479
|
+
- `buffer: <Buffer>` The buffer to read the sample from.
|
|
2480
|
+
- `offset: <number>` The position from which to read the sample. Default: `0`
|
|
2481
|
+
- Returns: `<number>` The value of the sample read.
|
|
2401
2482
|
|
|
2402
2483
|
Helper function which calls the appropriate `read*` method of `Buffer` based on the format argument.
|
|
2403
2484
|
For example, a call to `sdl.audio.readSample('f32', buffer, offset)` would be equivalent to `buffer.readFloatLE(offset)`.
|
|
@@ -2406,11 +2487,11 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2406
2487
|
|
|
2407
2488
|
### sdl.audio.writeSample(format, buffer, value[, offset])
|
|
2408
2489
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2490
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2491
|
+
- `buffer: <Buffer>` The buffer to write the sample to.
|
|
2492
|
+
- `value: <number>` The value of the sample to write.
|
|
2493
|
+
- `offset: <number>` The position at which to write the sample. Default: `0`
|
|
2494
|
+
- Returns: `<number>` The updated `offset`.
|
|
2414
2495
|
|
|
2415
2496
|
Helper function which calls the appropriate `write*` method of `Buffer` based on the format argument.
|
|
2416
2497
|
For example, a call to `sdl.audio.writeSample('f32', buffer, value, offset)` would be equivalent to `buffer.writeFloatLE(value, offset)`.
|
|
@@ -2419,9 +2500,9 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2419
2500
|
|
|
2420
2501
|
### sdl.audio.devices
|
|
2421
2502
|
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2503
|
+
- `<object>[]`
|
|
2504
|
+
- `type: <string>` Either `'playback'` or `'recording'`.
|
|
2505
|
+
- `name: <string>` The name of the device.
|
|
2425
2506
|
|
|
2426
2507
|
A list of all the detected audio devices.
|
|
2427
2508
|
Sample output for PulseAudio:
|
|
@@ -2442,15 +2523,15 @@ const playbackInstance = sdl.audio.openDevice({ type: 'playback' })
|
|
|
2442
2523
|
|
|
2443
2524
|
### sdl.audio.openDevice(device[, options])
|
|
2444
2525
|
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2526
|
+
- `device: <object>` An object from [`sdl.audio.devices`](#sdlaudiodevices), or a custom device.
|
|
2527
|
+
- `type: <string>`: Either `'playback'` or `'recording'`.
|
|
2528
|
+
- `name: <string>|<null>`: The name of the device. Optional.
|
|
2529
|
+
- `options: <object>`
|
|
2530
|
+
- `channels: <number>`: Number of audio channels. Valid values: `1`, `2`, `4`, `6`. Default: `1`
|
|
2531
|
+
- `frequency: <number>`: The sampling frequency in frames per second. Default: `48e3`
|
|
2532
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The binary format for each sample. Default: `'f32'`
|
|
2533
|
+
- `buffered: <number>`: Number of frames buffered by the driver. Must be a power of `2`. Default: `4096`
|
|
2534
|
+
- Returns: [`<AudioInstance>`](#class-audioinstance) an object representing the opened audio device instance.
|
|
2454
2535
|
|
|
2455
2536
|
Initializes an audio device for playback/recording and returns a corresponding instance.
|
|
2456
2537
|
If the opened device is a playback device, then it returns an [`AudioPlaybackInstance`](#class-audioplaybackinstance-extends-audioinstance), otherwise it returns an [`AudioRecordingInstance`](#class-audiorecordinginstance-extends-audioinstance).
|
|
@@ -2478,7 +2559,6 @@ The `buffered` option specifies the "delay" between the application and the audi
|
|
|
2478
2559
|
With smaller values you have smaller delays, but you also have to read/write data from/to the driver more frequently.
|
|
2479
2560
|
Applications such as virtual instruments that need to play audio in reaction to user input should set `buffered` to a lower value.
|
|
2480
2561
|
|
|
2481
|
-
|
|
2482
2562
|
## class AudioInstance
|
|
2483
2563
|
|
|
2484
2564
|
The `AudioInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2493,92 +2573,92 @@ Handle cleanup here.
|
|
|
2493
2573
|
|
|
2494
2574
|
### audioInstance.id
|
|
2495
2575
|
|
|
2496
|
-
|
|
2576
|
+
- `<number>`
|
|
2497
2577
|
|
|
2498
2578
|
A unique identifier for the instance.
|
|
2499
2579
|
|
|
2500
2580
|
### audioInstance.device
|
|
2501
2581
|
|
|
2502
|
-
|
|
2582
|
+
- `<object>`
|
|
2503
2583
|
|
|
2504
2584
|
The device passed to [`sdl.audio.openDevice()`](#sdlaudioopendevicedevice-options) when the `audioInstance` was opened.
|
|
2505
2585
|
|
|
2506
2586
|
### audioInstance.channels
|
|
2507
2587
|
|
|
2508
|
-
|
|
2588
|
+
- `<number>`
|
|
2509
2589
|
|
|
2510
2590
|
The number of channels the instance was opened with.
|
|
2511
2591
|
|
|
2512
2592
|
### audioInstance.frequency
|
|
2513
2593
|
|
|
2514
|
-
|
|
2594
|
+
- `<number>`
|
|
2515
2595
|
|
|
2516
2596
|
The sampling frequency (in frames per second) the instance was opened with.
|
|
2517
2597
|
|
|
2518
2598
|
### audioInstance.format
|
|
2519
2599
|
|
|
2520
|
-
|
|
2600
|
+
- [`<SampleFormat>`](#sample-formats)
|
|
2521
2601
|
|
|
2522
2602
|
The audio sample format the instance was opened with.
|
|
2523
2603
|
|
|
2524
2604
|
### audioInstance.bytesPerSample
|
|
2525
2605
|
|
|
2526
|
-
|
|
2606
|
+
- `<number>`
|
|
2527
2607
|
|
|
2528
2608
|
The number of bytes that make up a single audio sample, based on the format the instance was opened with.
|
|
2529
2609
|
|
|
2530
2610
|
### audioInstance.minSampleValue
|
|
2531
2611
|
|
|
2532
|
-
|
|
2612
|
+
- `<number>`
|
|
2533
2613
|
|
|
2534
2614
|
The minimum value a sample can take, based on the format the instance was opened with.
|
|
2535
2615
|
|
|
2536
2616
|
### audioInstance.maxSampleValue
|
|
2537
2617
|
|
|
2538
|
-
|
|
2618
|
+
- `<number>`
|
|
2539
2619
|
|
|
2540
2620
|
The maximum value a sample can take, based on the format the instance was opened with.
|
|
2541
2621
|
|
|
2542
2622
|
### audioInstance.zeroSampleValue
|
|
2543
2623
|
|
|
2544
|
-
|
|
2624
|
+
- `<number>`
|
|
2545
2625
|
|
|
2546
2626
|
The sample value that corresponds to silence, based on the format the instance was opened with.
|
|
2547
2627
|
|
|
2548
2628
|
### audioInstance.readSample(buffer[, offset])
|
|
2549
2629
|
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2630
|
+
- `buffer: <Buffer>` The buffer to read the sample from.
|
|
2631
|
+
- `offset: <number>` The position from which to read the sample. Default: `0`
|
|
2632
|
+
- Returns: `<number>` The value of the sample read.
|
|
2553
2633
|
|
|
2554
2634
|
Helper function which calls the appropriate `read*` method of `Buffer` based on the format the instance was opened with.
|
|
2555
2635
|
For example, for an instance opened with the `'f32'` sample format, a call to `audioinstance.readSample(buffer, offset)` would be equivalent to `buffer.readFloatLE(offset)`.
|
|
2556
2636
|
|
|
2557
2637
|
### audioInstance.writeSample(buffer, value[, offset])
|
|
2558
2638
|
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2639
|
+
- `buffer: <Buffer>` The buffer to write the sample to.
|
|
2640
|
+
- `value: <number>` The value of the sample to write.
|
|
2641
|
+
- `offset: <number>` The position at which to write the sample. Default: `0`
|
|
2642
|
+
- Returns: `<number>` The updated `offset`.
|
|
2563
2643
|
|
|
2564
2644
|
Helper function which calls the appropriate `write*` method of `Buffer` based on the format the instance was opened with.
|
|
2565
2645
|
For example, for an instance opened with the `'f32'` sample format, a call to `audioinstance.writeSample(buffer, value, offset)` would be equivalent to `buffer.writeFloatLE(value, offset)`.
|
|
2566
2646
|
|
|
2567
2647
|
### audioInstance.buffered
|
|
2568
2648
|
|
|
2569
|
-
|
|
2649
|
+
- `<number>`
|
|
2570
2650
|
|
|
2571
2651
|
The buffer size (in frames) the instance was opened with.
|
|
2572
2652
|
|
|
2573
2653
|
### audioInstance.playing
|
|
2574
2654
|
|
|
2575
|
-
|
|
2655
|
+
- `<boolean>`
|
|
2576
2656
|
|
|
2577
2657
|
Is `true` if the instance is currently playing.
|
|
2578
2658
|
|
|
2579
2659
|
### audioInstance.play([play])
|
|
2580
2660
|
|
|
2581
|
-
|
|
2661
|
+
- `show: <boolean>` Set to `true` to start the instance, `false` to stop. Default: `true`
|
|
2582
2662
|
|
|
2583
2663
|
Starts or stops the instance.
|
|
2584
2664
|
|
|
@@ -2588,7 +2668,7 @@ Equivalent to [`audioInstance.play(false)`](#audioinstanceplayplay)
|
|
|
2588
2668
|
|
|
2589
2669
|
### audioInstance.queued
|
|
2590
2670
|
|
|
2591
|
-
|
|
2671
|
+
- `<number>`
|
|
2592
2672
|
|
|
2593
2673
|
The number of bytes that are currently queued up, waiting to be either played by the system or dequeued by the user.
|
|
2594
2674
|
|
|
@@ -2598,7 +2678,7 @@ Clears the queued data.
|
|
|
2598
2678
|
|
|
2599
2679
|
### audioInstance.closed
|
|
2600
2680
|
|
|
2601
|
-
|
|
2681
|
+
- `<boolean>`
|
|
2602
2682
|
|
|
2603
2683
|
Is `true` if the instance is closed.
|
|
2604
2684
|
A closed instance object must not be used any further.
|
|
@@ -2607,7 +2687,6 @@ A closed instance object must not be used any further.
|
|
|
2607
2687
|
|
|
2608
2688
|
Closes the instance.
|
|
2609
2689
|
|
|
2610
|
-
|
|
2611
2690
|
## class AudioPlaybackInstance extends AudioInstance
|
|
2612
2691
|
|
|
2613
2692
|
The `AudioPlaybackInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2615,12 +2694,11 @@ Instead, objects returned by [`sdl.audio.openDevice()`](#sdlaudioopendevicedevic
|
|
|
2615
2694
|
|
|
2616
2695
|
### playbackInstance.enqueue(buffer[, bytes])
|
|
2617
2696
|
|
|
2618
|
-
|
|
2619
|
-
|
|
2697
|
+
- `buffer: <Buffer>` The buffer to read data from.
|
|
2698
|
+
- `bytes: <number>` The number of bytes to read from the buffer. Default: `buffer.length`
|
|
2620
2699
|
|
|
2621
2700
|
Takes the audio data that you have written to the buffer, and writes it to the queue, from where it will be played back as audio.
|
|
2622
2701
|
|
|
2623
|
-
|
|
2624
2702
|
## class AudioRecordingInstance extends AudioInstance
|
|
2625
2703
|
|
|
2626
2704
|
The `AudioRecordingInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2628,13 +2706,12 @@ Instead, objects returned by [`sdl.audio.openDevice()`](#sdlaudioopendevicedevic
|
|
|
2628
2706
|
|
|
2629
2707
|
### recordingInstance.dequeue(buffer[, bytes])
|
|
2630
2708
|
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2709
|
+
- `buffer: <Buffer>` The buffer to write data to.
|
|
2710
|
+
- `bytes: <number>` The number of bytes to write to the buffer. Default: `buffer.length`
|
|
2711
|
+
- Returns: `<number>` The actual number of bytes read.
|
|
2634
2712
|
|
|
2635
2713
|
Takes recorded audio data that has is waiting on the queue, and writes it to the provided buffer.
|
|
2636
2714
|
|
|
2637
|
-
|
|
2638
2715
|
## sdl.clipboard
|
|
2639
2716
|
|
|
2640
2717
|
<a id="clipboard-event-update"></a>
|
|
@@ -2646,29 +2723,27 @@ Check [`sdl.clipboard.text`](#sdlclipboardtext) to get the new contents of the c
|
|
|
2646
2723
|
|
|
2647
2724
|
### sdl.clipboard.text
|
|
2648
2725
|
|
|
2649
|
-
|
|
2726
|
+
- `<string>`
|
|
2650
2727
|
|
|
2651
2728
|
The current text value on the clipboard.
|
|
2652
2729
|
|
|
2653
2730
|
### sdl.clipboard.setText(text)
|
|
2654
2731
|
|
|
2655
|
-
|
|
2732
|
+
- `text: <string>` The new value to save on the clipboard.
|
|
2656
2733
|
|
|
2657
2734
|
Changes the text contents of the clipboard.
|
|
2658
2735
|
|
|
2659
|
-
|
|
2660
2736
|
## sdl.power
|
|
2661
2737
|
|
|
2662
2738
|
### sdl.power.info
|
|
2663
2739
|
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2740
|
+
- `<object>`
|
|
2741
|
+
- `state: <string>|<null>` One of `'noBattery'`, `'battery'`, `'charging'`, `'charged'`. Is `null` if it can't be determinded.
|
|
2742
|
+
- `seconds: <number>|<null>` Seconds of battery life left, or `null` if not running on battery or if it can't be determinded.
|
|
2743
|
+
- `percent: <number>|<null>` Percentage of battery life left, or `null` if not running on battery or if it can't be determinded.
|
|
2668
2744
|
|
|
2669
2745
|
The curent power information of the device.
|
|
2670
2746
|
|
|
2671
|
-
|
|
2672
2747
|
## Helpers
|
|
2673
2748
|
|
|
2674
2749
|
The `@kmamal/sdl` library must only be imported from the main thread.
|
|
@@ -2686,13 +2761,12 @@ For an example of their use see [this example](https://github.com/kmamal/node-sd
|
|
|
2686
2761
|
|
|
2687
2762
|
The functions included in `@kmamal/sdl/helpers` are:
|
|
2688
2763
|
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2764
|
+
- [`sdl.audio.bytesPerSample`](#sdlaudiobytespersampleformat)
|
|
2765
|
+
- [`sdl.audio.minSampleValue`](#sdlaudiominsamplevalueformat)
|
|
2766
|
+
- [`sdl.audio.maxSampleValue`](#sdlaudiomaxsamplevalueformat)
|
|
2767
|
+
- [`sdl.audio.zeroSampleValue`](#sdlaudiozerosamplevalueformat)
|
|
2768
|
+
- [`sdl.audio.readSample`](#sdlaudioreadsampleformat-buffer-offset)
|
|
2769
|
+
- [`sdl.audio.writeSample`](#sdlaudiowritesampleformat-buffer-value-offset)
|
|
2696
2770
|
|
|
2697
2771
|
## Building from source
|
|
2698
2772
|
|
|
@@ -2714,11 +2788,11 @@ You need to have `cmake` installed for that to work.
|
|
|
2714
2788
|
You could also have found your way to the "Building from source" section because you are trying to contribute to this package.
|
|
2715
2789
|
There are some npm scripts in `package.json` that could be of use to you:
|
|
2716
2790
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2791
|
+
- `npm run clean` deletes all folders that are created during the build, as well as `node_modules`.
|
|
2792
|
+
- `npm run download-release` downloads the prebuilt binaries. This is the first thing the install script tries to do.
|
|
2793
|
+
- `npm run download-sdl` downloads the SDL headers and libraries from `@kmamal/build-sdl` so you can compile against them in later steps. This is the second step in the install script, after `download-release` has failed.
|
|
2794
|
+
- `npm run build` prepares the environment variables and calls `node-gyp` to build the package.
|
|
2795
|
+
- `NODE_SDL_FROM_SOURCE=1 npm install` runs the install script normally, but skips the inital attempt to download the binaries, and goes straight to building from source.
|
|
2722
2796
|
|
|
2723
2797
|
The SDL headers and libs get downloaded to `sdl/`, the build happens in `build/`, and the final binaries get collected into `dist/`.
|
|
2724
2798
|
|