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