@kmamal/sdl 0.11.10 → 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 +10 -1
- package/README.md +1042 -1030
- package/package.json +4 -4
- 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 +4 -0
- 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 +34 -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,267 +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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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.
|
|
393
393
|
|
|
394
394
|
The `sdl.info` object is filled with information produced during the initialization of SDL.
|
|
395
395
|
All the values remain constant throughout the execution of the program.
|
|
@@ -429,24 +429,23 @@ Sample data for Ubuntu:
|
|
|
429
429
|
}
|
|
430
430
|
```
|
|
431
431
|
|
|
432
|
-
|
|
433
432
|
## sdl.video
|
|
434
433
|
|
|
435
434
|
### Image data
|
|
436
435
|
|
|
437
436
|
There are 3 places in the API where you must provide an image to the library:
|
|
438
437
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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)
|
|
442
441
|
|
|
443
442
|
All three of these functions accept the image as a series of arguments:
|
|
444
443
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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.
|
|
450
449
|
|
|
451
450
|
So, for example, to fill the window with a red+green gradient you could do:
|
|
452
451
|
|
|
@@ -481,100 +480,98 @@ I recommend that in these cases you always use `pixelWidth` and `pixelHeight`, s
|
|
|
481
480
|
|
|
482
481
|
String values used to represent how the pixels of an image are stored in a Buffer.
|
|
483
482
|
|
|
484
|
-
| Value
|
|
485
|
-
| ---
|
|
486
|
-
| `'rgb332'`
|
|
487
|
-
| `'rgb444'`
|
|
488
|
-
| `'rgb555'`
|
|
489
|
-
| `'bgr555'`
|
|
490
|
-
| `'argb4444'`
|
|
491
|
-
| `'rgba4444'`
|
|
492
|
-
| `'abgr4444'`
|
|
493
|
-
| `'bgra4444'`
|
|
494
|
-
| `'argb1555'`
|
|
495
|
-
| `'rgba5551'`
|
|
496
|
-
| `'abgr1555'`
|
|
497
|
-
| `'bgra5551'`
|
|
498
|
-
| `'rgb565'`
|
|
499
|
-
| `'bgr565'`
|
|
500
|
-
| `'rgb24'`
|
|
501
|
-
| `'bgr24'`
|
|
502
|
-
| `'rgb888'`
|
|
503
|
-
| `'rgbx8888'`
|
|
504
|
-
| `'bgr888'`
|
|
505
|
-
| `'bgrx8888'`
|
|
506
|
-
| `'argb8888'`
|
|
507
|
-
| `'rgba8888'`
|
|
508
|
-
| `'abgr8888'`
|
|
509
|
-
| `'bgra8888'`
|
|
510
|
-
| `'argb2101010'` | `SDL_PIXELFORMAT_ARGB2101010`
|
|
511
|
-
| `'rgba32'`
|
|
512
|
-
| `'argb32'`
|
|
513
|
-
| `'bgra32'`
|
|
514
|
-
| `'abgr32'`
|
|
515
|
-
| `'yv12'`
|
|
516
|
-
| `'iyuv'`
|
|
517
|
-
| `'yuy2'`
|
|
518
|
-
| `'uyvy'`
|
|
519
|
-
| `'yvyu'`
|
|
520
|
-
| `'nv12'`
|
|
521
|
-
| `'nv21'`
|
|
522
|
-
|
|
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) |
|
|
523
521
|
|
|
524
522
|
### Event: 'displayAdd'
|
|
525
523
|
|
|
526
|
-
|
|
524
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
527
525
|
|
|
528
526
|
Fired when a display is added to the system.
|
|
529
527
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
530
528
|
|
|
531
529
|
### Event: 'displayRemove'
|
|
532
530
|
|
|
533
|
-
|
|
531
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
534
532
|
|
|
535
533
|
Fired when a display is removed from the system.
|
|
536
534
|
Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
537
535
|
|
|
538
536
|
### Event: 'displayOrient'
|
|
539
537
|
|
|
540
|
-
|
|
541
|
-
|
|
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.
|
|
542
540
|
|
|
543
541
|
Fired when a display changes orientation.
|
|
544
542
|
|
|
545
543
|
### Event: 'displayMove'
|
|
546
544
|
|
|
547
|
-
|
|
545
|
+
- `device: <object>`: An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display that caused the event.
|
|
548
546
|
|
|
549
547
|
Fired when a display changes position.
|
|
550
548
|
|
|
551
|
-
|
|
552
549
|
### sdl.video.displays
|
|
553
550
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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.
|
|
567
564
|
|
|
568
565
|
A list of all detected displays.
|
|
569
566
|
|
|
570
567
|
Possible values for `orientation` are `null` if it is unknown, or one of:
|
|
571
568
|
|
|
572
|
-
| Value
|
|
573
|
-
| ---
|
|
574
|
-
| `'landscape'`
|
|
575
|
-
| `'landscapeFlipped'` | `SDL_ORIENTATION_LANDSCAPE_FLIPPED`
|
|
576
|
-
| `'portrait'`
|
|
577
|
-
| `'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` |
|
|
578
575
|
|
|
579
576
|
Sample output for two side-to-side monitors is below.
|
|
580
577
|
Notice how the geometries don't overlap:
|
|
@@ -602,55 +599,55 @@ Notice how the geometries don't overlap:
|
|
|
602
599
|
|
|
603
600
|
### sdl.video.windows
|
|
604
601
|
|
|
605
|
-
|
|
602
|
+
- [`<Window>`](#class-window)`[]`
|
|
606
603
|
|
|
607
604
|
A list of all open windows.
|
|
608
605
|
|
|
609
606
|
### sdl.video.focused
|
|
610
607
|
|
|
611
|
-
|
|
608
|
+
- [`<Window>`](#class-window)`|<null>`
|
|
612
609
|
|
|
613
610
|
The window that has the current keyboard focus, or `null` if no window has the keyboard focus.
|
|
614
611
|
|
|
615
612
|
### sdl.video.hovered
|
|
616
613
|
|
|
617
|
-
|
|
614
|
+
- [`<Window>`](#class-window)`|<null>`
|
|
618
615
|
|
|
619
616
|
The window that the mouse is hovered over, or `null` if the mouse is not over a window.
|
|
620
617
|
|
|
621
618
|
### sdl.video.createWindow([options])
|
|
622
619
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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.
|
|
644
641
|
|
|
645
642
|
Creates a new window.
|
|
646
643
|
|
|
647
644
|
The following restrictions apply:
|
|
648
645
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
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.
|
|
654
651
|
|
|
655
652
|
If you set the `opengl` or `webgpu` options, then you must use OpenGL/WebGPU calls to render to the window.
|
|
656
653
|
Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) will fail.
|
|
@@ -686,23 +683,23 @@ Fired when the window gets restored.
|
|
|
686
683
|
|
|
687
684
|
### Event: 'move'
|
|
688
685
|
|
|
689
|
-
|
|
690
|
-
|
|
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.
|
|
691
688
|
|
|
692
689
|
Fired when the window changes position.
|
|
693
690
|
|
|
694
691
|
### Event: 'resize'
|
|
695
692
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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).
|
|
700
697
|
|
|
701
698
|
Fired when the window changes size.
|
|
702
699
|
|
|
703
700
|
### Event: 'displayChange'
|
|
704
701
|
|
|
705
|
-
|
|
702
|
+
- `display: <object>` An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the window's new display.
|
|
706
703
|
|
|
707
704
|
Fired when the window moves from one display to another.
|
|
708
705
|
|
|
@@ -724,7 +721,7 @@ Fired when the mouse leaves the window.
|
|
|
724
721
|
|
|
725
722
|
### Event: 'beforeClose'
|
|
726
723
|
|
|
727
|
-
|
|
724
|
+
- `prevent: <function (void) => void>` Call this function to prevent the window from closing.
|
|
728
725
|
|
|
729
726
|
Fired to indicate that the user requested that the window should close (usually by clicking the "x" button).
|
|
730
727
|
If you need to display any confirmation dialogs, call `event.prevent()` and afterwards handle destruction manually.
|
|
@@ -737,73 +734,73 @@ Handle any cleanup here.
|
|
|
737
734
|
|
|
738
735
|
### Event: 'keyDown'
|
|
739
736
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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.
|
|
750
747
|
|
|
751
748
|
Fired when a key is pressed, and will also be fired repeatedly afterwards if the key is held down.
|
|
752
749
|
|
|
753
750
|
### Event: 'keyUp'
|
|
754
751
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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.
|
|
764
761
|
|
|
765
762
|
Fired when a key is released.
|
|
766
763
|
|
|
767
764
|
### Event: 'textInput'
|
|
768
765
|
|
|
769
|
-
|
|
766
|
+
- `text: <string>` The unicode representation of the character that was entered.
|
|
770
767
|
|
|
771
768
|
Fired when text is entered via the keyboard.
|
|
772
769
|
|
|
773
770
|
### Event: 'mouseButtonDown'
|
|
774
771
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
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.
|
|
779
776
|
|
|
780
777
|
Fired when a mouse button is pressed.
|
|
781
778
|
|
|
782
779
|
### Event: 'mouseButtonUp'
|
|
783
780
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
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.
|
|
788
785
|
|
|
789
786
|
Fired when a mouse button is released.
|
|
790
787
|
|
|
791
788
|
### Event: 'mouseMove'
|
|
792
789
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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.
|
|
796
793
|
|
|
797
794
|
Fired when the mouse moves.
|
|
798
795
|
|
|
799
796
|
### Event: 'mouseWheel'
|
|
800
797
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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.
|
|
807
804
|
|
|
808
805
|
Fired when the mouse wheel is scrolled.
|
|
809
806
|
|
|
@@ -813,13 +810,13 @@ When you drop a set of items onto a window, first the [`'dropBegin'`](#event-dro
|
|
|
813
810
|
|
|
814
811
|
### Event: 'dropText'
|
|
815
812
|
|
|
816
|
-
|
|
813
|
+
- `text: <string>`: The text that was dropped onto the window.
|
|
817
814
|
|
|
818
815
|
Fired when one of the drops is a text item.
|
|
819
816
|
|
|
820
817
|
### Event: 'dropFile'
|
|
821
818
|
|
|
822
|
-
|
|
819
|
+
- `file: <string>`: The path to the file that was dropped onto the window.
|
|
823
820
|
|
|
824
821
|
Fired when one of the drops is a file.
|
|
825
822
|
|
|
@@ -829,98 +826,98 @@ Fired after a set of items has been dropped on a window.
|
|
|
829
826
|
|
|
830
827
|
### window.id
|
|
831
828
|
|
|
832
|
-
|
|
829
|
+
- `<number>`
|
|
833
830
|
|
|
834
831
|
A unique identifier for the window.
|
|
835
832
|
|
|
836
833
|
### window.title
|
|
837
834
|
|
|
838
|
-
|
|
835
|
+
- `<string>`
|
|
839
836
|
|
|
840
837
|
The text that appears in the window's title bar.
|
|
841
838
|
|
|
842
839
|
### window.setTitle(title)
|
|
843
840
|
|
|
844
|
-
|
|
841
|
+
- `title: <string>`: The new title.
|
|
845
842
|
|
|
846
843
|
Changes the text that appears in the window's title bar.
|
|
847
844
|
|
|
848
845
|
### window.x
|
|
849
846
|
|
|
850
|
-
|
|
847
|
+
- `<number>`
|
|
851
848
|
|
|
852
849
|
The window's x position, relative to the screen.
|
|
853
850
|
|
|
854
851
|
### window.y
|
|
855
852
|
|
|
856
|
-
|
|
853
|
+
- `<number>`
|
|
857
854
|
|
|
858
855
|
The window's y position, relative to the screen.
|
|
859
856
|
|
|
860
857
|
### window.setPosition(x, y)
|
|
861
858
|
|
|
862
|
-
|
|
863
|
-
|
|
859
|
+
- `x: <number>`: The new x position, relative to the screen.
|
|
860
|
+
- `y: <number>`: The new y position, relative to the screen.
|
|
864
861
|
|
|
865
862
|
Moves the window to a new position on the screen.
|
|
866
863
|
|
|
867
864
|
### window.width
|
|
868
865
|
|
|
869
|
-
|
|
866
|
+
- `<number>`
|
|
870
867
|
|
|
871
868
|
The window's width.
|
|
872
869
|
|
|
873
870
|
### window.height
|
|
874
871
|
|
|
875
|
-
|
|
872
|
+
- `<number>`
|
|
876
873
|
|
|
877
874
|
The window's height.
|
|
878
875
|
|
|
879
876
|
### window.pixelWidth
|
|
880
877
|
|
|
881
|
-
|
|
878
|
+
- `<number>`
|
|
882
879
|
|
|
883
880
|
The window's width in pixels.
|
|
884
881
|
Is larger than [`width`](#windowwidth) on [high-dpi](#high-dpi) displays.
|
|
885
882
|
|
|
886
883
|
### window.pixelHeight
|
|
887
884
|
|
|
888
|
-
|
|
885
|
+
- `<number>`
|
|
889
886
|
|
|
890
887
|
The window's height in pixels.
|
|
891
888
|
Is larger than [`height`](#windowheight) on [high-dpi](#high-dpi) displays.
|
|
892
889
|
|
|
893
890
|
### window.setSize(width, height)
|
|
894
891
|
|
|
895
|
-
|
|
896
|
-
|
|
892
|
+
- `width: <number>`: The new width.
|
|
893
|
+
- `height: <number>`: The new height.
|
|
897
894
|
|
|
898
895
|
Changes the size of the window.
|
|
899
896
|
|
|
900
897
|
### window.setSizeInPixels(pixelWidth, pixelHeight)
|
|
901
898
|
|
|
902
|
-
|
|
903
|
-
|
|
899
|
+
- `pixelWidth: <number>`: The new width in pixels.
|
|
900
|
+
- `pixelHeight: <number>`: The new height in pixels.
|
|
904
901
|
|
|
905
902
|
Changes the size of the window.
|
|
906
903
|
This function only behaves differently from [`window.setSize()`](#windowsetsizewidth-height) for [high-dpi](#high-dpi) displays.
|
|
907
904
|
|
|
908
905
|
### window.display
|
|
909
906
|
|
|
910
|
-
|
|
907
|
+
- `<object>`
|
|
911
908
|
|
|
912
909
|
An object from [`sdl.video.displays`](#sdlvideodisplays) indicating the display the window belongs to.
|
|
913
910
|
If the window spans multiple displays, then the display that contains the center of the window is returned.
|
|
914
911
|
|
|
915
912
|
### window.visible
|
|
916
913
|
|
|
917
|
-
|
|
914
|
+
- `<boolean>`
|
|
918
915
|
|
|
919
916
|
Is `true` if the window is visible.
|
|
920
917
|
|
|
921
918
|
### window.show([show])
|
|
922
919
|
|
|
923
|
-
|
|
920
|
+
- `show: <boolean>` Set to `true` to make the window visible, `false` to hide it. Default: `true`
|
|
924
921
|
|
|
925
922
|
Shows or hides the window.
|
|
926
923
|
|
|
@@ -930,59 +927,59 @@ Equivalent to [`window.show(false)`](#windowshowshow).
|
|
|
930
927
|
|
|
931
928
|
### window.fullscreen
|
|
932
929
|
|
|
933
|
-
|
|
930
|
+
- `<boolean>`
|
|
934
931
|
|
|
935
932
|
Is `true` if the window is fullscreen.
|
|
936
933
|
A fullscreen window is displayed over the entire screen.
|
|
937
934
|
|
|
938
935
|
### window.setFullscreen(fullscreen)
|
|
939
936
|
|
|
940
|
-
|
|
937
|
+
- `fullscreen: <boolean>` The new value of the property.
|
|
941
938
|
|
|
942
939
|
Changes the window's fullscreen property.
|
|
943
940
|
|
|
944
941
|
### window.resizable
|
|
945
942
|
|
|
946
|
-
|
|
943
|
+
- `<boolean>`
|
|
947
944
|
|
|
948
945
|
Is `true` if the window is resizable.
|
|
949
946
|
A resizable window can be resized by dragging its borders.
|
|
950
947
|
|
|
951
948
|
### window.setResizable(resizable)
|
|
952
949
|
|
|
953
|
-
|
|
950
|
+
- `resizable: <boolean>` The new value of the property.
|
|
954
951
|
|
|
955
952
|
Changes the window's resizable property.
|
|
956
953
|
|
|
957
954
|
### window.borderless
|
|
958
955
|
|
|
959
|
-
|
|
956
|
+
- `<boolean>`
|
|
960
957
|
|
|
961
958
|
Is `true` if the window is borderless.
|
|
962
959
|
A borderless window has no borders or title bar.
|
|
963
960
|
|
|
964
961
|
### window.setBorderless(borderless)
|
|
965
962
|
|
|
966
|
-
|
|
963
|
+
- `borderless: <boolean>` The new value of the property.
|
|
967
964
|
|
|
968
965
|
Changes the window's borderless property.
|
|
969
966
|
|
|
970
967
|
### window.alwaysOnTop
|
|
971
968
|
|
|
972
|
-
|
|
969
|
+
- `<boolean>`
|
|
973
970
|
|
|
974
971
|
Is `true` if the window was created with `alwaysOnTop: true`.
|
|
975
972
|
Such a window is always be shown above other windows.
|
|
976
973
|
|
|
977
974
|
### window.accelerated
|
|
978
975
|
|
|
979
|
-
|
|
976
|
+
- `<boolean>`
|
|
980
977
|
|
|
981
978
|
Is `true` if the window is using hardware accelerated rendering.
|
|
982
979
|
|
|
983
980
|
### window.setAccelerated(accelerated)
|
|
984
981
|
|
|
985
|
-
|
|
982
|
+
- `accelerated: <boolean>` The new value of the property.
|
|
986
983
|
|
|
987
984
|
Changes the window's accelerated property.
|
|
988
985
|
|
|
@@ -990,7 +987,7 @@ If you have set the `opengl` or `webgpu` options, then calls to this function wi
|
|
|
990
987
|
|
|
991
988
|
### window.vsync
|
|
992
989
|
|
|
993
|
-
|
|
990
|
+
- `<boolean>`
|
|
994
991
|
|
|
995
992
|
Is `true` if the window is using vsync.
|
|
996
993
|
Vsync synchronizes the window's frame rate with the display's refresh rate to prevent tearing.
|
|
@@ -998,7 +995,7 @@ Note that vsync can only be set to `true` if [`accelerated`](#windowaccelerated)
|
|
|
998
995
|
|
|
999
996
|
### window.setVsync(vsync)
|
|
1000
997
|
|
|
1001
|
-
|
|
998
|
+
- `vsync: <boolean>` The new value of the property.
|
|
1002
999
|
|
|
1003
1000
|
Changes the window's vsync property.
|
|
1004
1001
|
|
|
@@ -1006,7 +1003,7 @@ If you have set the `opengl` or `webgpu` options, then calls to this function wi
|
|
|
1006
1003
|
|
|
1007
1004
|
### window.opengl
|
|
1008
1005
|
|
|
1009
|
-
|
|
1006
|
+
- `<boolean>`
|
|
1010
1007
|
|
|
1011
1008
|
Is `true` if the window was created in OpenGl mode.
|
|
1012
1009
|
In OpenGL mode, you must use OpenGL calls to render to the window.
|
|
@@ -1014,7 +1011,7 @@ Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) wi
|
|
|
1014
1011
|
|
|
1015
1012
|
### window.webgpu
|
|
1016
1013
|
|
|
1017
|
-
|
|
1014
|
+
- `<boolean>`
|
|
1018
1015
|
|
|
1019
1016
|
Is `true` if the window was created in WebGPU mode.
|
|
1020
1017
|
In WebGPU mode, you must use WebGPU calls to render to the window.
|
|
@@ -1022,8 +1019,8 @@ Calls to [`render()`](#windowrenderwidth-height-stride-format-buffer-options) wi
|
|
|
1022
1019
|
|
|
1023
1020
|
### window.native
|
|
1024
1021
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1022
|
+
- `<object>`
|
|
1023
|
+
- `handle : <Buffer>` The platform-specific handle of the window.
|
|
1027
1024
|
|
|
1028
1025
|
The native type of `handle` is HWND on Windows, NSView* on macOS, and Window (unsigned long) on Linux.
|
|
1029
1026
|
It should work exactly like the [`win.getNativeWindowHandle()`](https://www.electronjs.org/docs/latest/api/browser-window#wingetnativewindowhandle) electron method.
|
|
@@ -1034,7 +1031,7 @@ They are used internally for passing to [@kmamal/gl](https://github.com/kmamal/h
|
|
|
1034
1031
|
|
|
1035
1032
|
### window.maximized
|
|
1036
1033
|
|
|
1037
|
-
|
|
1034
|
+
- `<boolean>`
|
|
1038
1035
|
|
|
1039
1036
|
Is `true` if the window is maximized.
|
|
1040
1037
|
|
|
@@ -1044,7 +1041,7 @@ Maximizes the window.
|
|
|
1044
1041
|
|
|
1045
1042
|
### window.minimized
|
|
1046
1043
|
|
|
1047
|
-
|
|
1044
|
+
- `<boolean>`
|
|
1048
1045
|
|
|
1049
1046
|
Is `true` if the window is minimized.
|
|
1050
1047
|
|
|
@@ -1058,7 +1055,7 @@ Restores the window so it is neither minimized nor maximized.
|
|
|
1058
1055
|
|
|
1059
1056
|
### window.focused
|
|
1060
1057
|
|
|
1061
|
-
|
|
1058
|
+
- `<boolean>`
|
|
1062
1059
|
|
|
1063
1060
|
Is `true` if the window has keyboard input.
|
|
1064
1061
|
|
|
@@ -1068,13 +1065,13 @@ Gives the window the keyboard focus.
|
|
|
1068
1065
|
|
|
1069
1066
|
### window.hovered
|
|
1070
1067
|
|
|
1071
|
-
|
|
1068
|
+
- `<boolean>`
|
|
1072
1069
|
|
|
1073
1070
|
Is `true` if the mouse is over the window.
|
|
1074
1071
|
|
|
1075
1072
|
### window.skipTaskbar
|
|
1076
1073
|
|
|
1077
|
-
|
|
1074
|
+
- `<boolean>`
|
|
1078
1075
|
|
|
1079
1076
|
X11 only.
|
|
1080
1077
|
Is `true` if the window was created with `skipTaskbar: true`.
|
|
@@ -1082,7 +1079,7 @@ Such a window is not added to the taskbar.
|
|
|
1082
1079
|
|
|
1083
1080
|
### window.popupMenu
|
|
1084
1081
|
|
|
1085
|
-
|
|
1082
|
+
- `<boolean>`
|
|
1086
1083
|
|
|
1087
1084
|
X11 only.
|
|
1088
1085
|
Is `true` if the window was created with `popupMenu: true`.
|
|
@@ -1090,7 +1087,7 @@ Such a window is always treated as a popup menu.
|
|
|
1090
1087
|
|
|
1091
1088
|
### window.tooltip
|
|
1092
1089
|
|
|
1093
|
-
|
|
1090
|
+
- `<boolean>`
|
|
1094
1091
|
|
|
1095
1092
|
X11 only.
|
|
1096
1093
|
Is `true` if the window was created with `tooltip: true`.
|
|
@@ -1098,7 +1095,7 @@ Such a window is always treated as a tooltip.
|
|
|
1098
1095
|
|
|
1099
1096
|
### window.utility
|
|
1100
1097
|
|
|
1101
|
-
|
|
1098
|
+
- `<boolean>`
|
|
1102
1099
|
|
|
1103
1100
|
X11 only.
|
|
1104
1101
|
Is `true` if the window was created with `utility: true`.
|
|
@@ -1106,11 +1103,11 @@ Such a window is always treated as a utility window.
|
|
|
1106
1103
|
|
|
1107
1104
|
### window.render(width, height, stride, format, buffer[, options])
|
|
1108
1105
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
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.
|
|
1114
1111
|
|
|
1115
1112
|
Displays an image in the window.
|
|
1116
1113
|
|
|
@@ -1122,24 +1119,24 @@ If the dimensions of the image do not match the dimensions of the area it should
|
|
|
1122
1119
|
The `scaling` argument controls how exactly the scaling is implemented.
|
|
1123
1120
|
Possible values are:
|
|
1124
1121
|
|
|
1125
|
-
| Value
|
|
1126
|
-
| ---
|
|
1127
|
-
| `'nearest'` | `SDL_ScaleModeNearest`
|
|
1128
|
-
| `'linear'`
|
|
1129
|
-
| `'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 |
|
|
1130
1127
|
|
|
1131
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.
|
|
1132
1129
|
Calls to `render()` will fail.
|
|
1133
1130
|
|
|
1134
1131
|
### window.setIcon(width, height, stride, format, buffer)
|
|
1135
1132
|
|
|
1136
|
-
|
|
1133
|
+
- `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to display as the icon of the window.
|
|
1137
1134
|
|
|
1138
1135
|
Set's the window's icon, usually displayed in the title bar and the taskbar.
|
|
1139
1136
|
|
|
1140
1137
|
### window.flash([untilFocused])
|
|
1141
1138
|
|
|
1142
|
-
|
|
1139
|
+
- `untilFocused: <boolean>` Whether to keep flashing the window until the user focuses it. Default: `false`
|
|
1143
1140
|
|
|
1144
1141
|
Flash the window briefly to get attention.
|
|
1145
1142
|
If `untilFocused` is set, the window will continue flashing until the user focuses it.
|
|
@@ -1150,7 +1147,7 @@ Stop the window from flashing.
|
|
|
1150
1147
|
|
|
1151
1148
|
### window.destroyed
|
|
1152
1149
|
|
|
1153
|
-
|
|
1150
|
+
- `<boolean>`
|
|
1154
1151
|
|
|
1155
1152
|
Is `true` if the window is destroyed.
|
|
1156
1153
|
A destroyed window object must not be used any further.
|
|
@@ -1164,7 +1161,6 @@ Destroys the window.
|
|
|
1164
1161
|
Asks before destroying the window.
|
|
1165
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.
|
|
1166
1163
|
|
|
1167
|
-
|
|
1168
1164
|
## sdl.keyboard
|
|
1169
1165
|
|
|
1170
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).
|
|
@@ -1190,7 +1186,6 @@ Consider for example what happens when a user on a Greek keyboard layout enters
|
|
|
1190
1186
|
Trying to handle text input by manually translating key presses to text is not a very viable solution.
|
|
1191
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.
|
|
1192
1188
|
|
|
1193
|
-
|
|
1194
1189
|
### Virtual keys
|
|
1195
1190
|
|
|
1196
1191
|
String values used to represent virtual keys in the context of the current keyboard mapping.
|
|
@@ -1211,265 +1206,271 @@ Values are based on the [USB usage page standard](https://www.usb.org/sites/defa
|
|
|
1211
1206
|
|
|
1212
1207
|
<summary>Click to expand table</summary>
|
|
1213
1208
|
|
|
1214
|
-
| Value
|
|
1215
|
-
| ---
|
|
1216
|
-
| `sdl.keyboard.SCANCODE.A`
|
|
1217
|
-
| `sdl.keyboard.SCANCODE.B`
|
|
1218
|
-
| `sdl.keyboard.SCANCODE.C`
|
|
1219
|
-
| `sdl.keyboard.SCANCODE.D`
|
|
1220
|
-
| `sdl.keyboard.SCANCODE.E`
|
|
1221
|
-
| `sdl.keyboard.SCANCODE.F`
|
|
1222
|
-
| `sdl.keyboard.SCANCODE.G`
|
|
1223
|
-
| `sdl.keyboard.SCANCODE.H`
|
|
1224
|
-
| `sdl.keyboard.SCANCODE.I`
|
|
1225
|
-
| `sdl.keyboard.SCANCODE.J`
|
|
1226
|
-
| `sdl.keyboard.SCANCODE.K`
|
|
1227
|
-
| `sdl.keyboard.SCANCODE.L`
|
|
1228
|
-
| `sdl.keyboard.SCANCODE.M`
|
|
1229
|
-
| `sdl.keyboard.SCANCODE.N`
|
|
1230
|
-
| `sdl.keyboard.SCANCODE.O`
|
|
1231
|
-
| `sdl.keyboard.SCANCODE.P`
|
|
1232
|
-
| `sdl.keyboard.SCANCODE.Q`
|
|
1233
|
-
| `sdl.keyboard.SCANCODE.R`
|
|
1234
|
-
| `sdl.keyboard.SCANCODE.S`
|
|
1235
|
-
| `sdl.keyboard.SCANCODE.T`
|
|
1236
|
-
| `sdl.keyboard.SCANCODE.U`
|
|
1237
|
-
| `sdl.keyboard.SCANCODE.V`
|
|
1238
|
-
| `sdl.keyboard.SCANCODE.W`
|
|
1239
|
-
| `sdl.keyboard.SCANCODE.X`
|
|
1240
|
-
| `sdl.keyboard.SCANCODE.Y`
|
|
1241
|
-
| `sdl.keyboard.SCANCODE.Z`
|
|
1242
|
-
| `sdl.keyboard.SCANCODE.1`
|
|
1243
|
-
| `sdl.keyboard.SCANCODE.2`
|
|
1244
|
-
| `sdl.keyboard.SCANCODE.3`
|
|
1245
|
-
| `sdl.keyboard.SCANCODE.4`
|
|
1246
|
-
| `sdl.keyboard.SCANCODE.5`
|
|
1247
|
-
| `sdl.keyboard.SCANCODE.6`
|
|
1248
|
-
| `sdl.keyboard.SCANCODE.7`
|
|
1249
|
-
| `sdl.keyboard.SCANCODE.8`
|
|
1250
|
-
| `sdl.keyboard.SCANCODE.9`
|
|
1251
|
-
| `sdl.keyboard.SCANCODE.0`
|
|
1252
|
-
| `sdl.keyboard.SCANCODE.RETURN`
|
|
1253
|
-
| `sdl.keyboard.SCANCODE.ESCAPE`
|
|
1254
|
-
| `sdl.keyboard.SCANCODE.BACKSPACE`
|
|
1255
|
-
| `sdl.keyboard.SCANCODE.TAB`
|
|
1256
|
-
| `sdl.keyboard.SCANCODE.SPACE`
|
|
1257
|
-
| `sdl.keyboard.SCANCODE.MINUS`
|
|
1258
|
-
| `sdl.keyboard.SCANCODE.EQUALS`
|
|
1259
|
-
| `sdl.keyboard.SCANCODE.LEFTBRACKET`
|
|
1260
|
-
| `sdl.keyboard.SCANCODE.RIGHTBRACKET`
|
|
1261
|
-
| `sdl.keyboard.SCANCODE.BACKSLASH`
|
|
1262
|
-
| `sdl.keyboard.SCANCODE.NONUSHASH`
|
|
1263
|
-
| `sdl.keyboard.SCANCODE.SEMICOLON`
|
|
1264
|
-
| `sdl.keyboard.SCANCODE.APOSTROPHE`
|
|
1265
|
-
| `sdl.keyboard.SCANCODE.GRAVE`
|
|
1266
|
-
| `sdl.keyboard.SCANCODE.COMMA`
|
|
1267
|
-
| `sdl.keyboard.SCANCODE.PERIOD`
|
|
1268
|
-
| `sdl.keyboard.SCANCODE.SLASH`
|
|
1269
|
-
| `sdl.keyboard.SCANCODE.CAPSLOCK`
|
|
1270
|
-
| `sdl.keyboard.SCANCODE.F1`
|
|
1271
|
-
| `sdl.keyboard.SCANCODE.F2`
|
|
1272
|
-
| `sdl.keyboard.SCANCODE.F3`
|
|
1273
|
-
| `sdl.keyboard.SCANCODE.F4`
|
|
1274
|
-
| `sdl.keyboard.SCANCODE.F5`
|
|
1275
|
-
| `sdl.keyboard.SCANCODE.F6`
|
|
1276
|
-
| `sdl.keyboard.SCANCODE.F7`
|
|
1277
|
-
| `sdl.keyboard.SCANCODE.F8`
|
|
1278
|
-
| `sdl.keyboard.SCANCODE.F9`
|
|
1279
|
-
| `sdl.keyboard.SCANCODE.F10`
|
|
1280
|
-
| `sdl.keyboard.SCANCODE.F11`
|
|
1281
|
-
| `sdl.keyboard.SCANCODE.F12`
|
|
1282
|
-
| `sdl.keyboard.SCANCODE.PRINTSCREEN`
|
|
1283
|
-
| `sdl.keyboard.SCANCODE.SCROLLLOCK`
|
|
1284
|
-
| `sdl.keyboard.SCANCODE.PAUSE`
|
|
1285
|
-
| `sdl.keyboard.SCANCODE.INSERT`
|
|
1286
|
-
| `sdl.keyboard.SCANCODE.HOME`
|
|
1287
|
-
| `sdl.keyboard.SCANCODE.PAGEUP`
|
|
1288
|
-
| `sdl.keyboard.SCANCODE.DELETE`
|
|
1289
|
-
| `sdl.keyboard.SCANCODE.END`
|
|
1290
|
-
| `sdl.keyboard.SCANCODE.PAGEDOWN`
|
|
1291
|
-
| `sdl.keyboard.SCANCODE.RIGHT`
|
|
1292
|
-
| `sdl.keyboard.SCANCODE.LEFT`
|
|
1293
|
-
| `sdl.keyboard.SCANCODE.DOWN`
|
|
1294
|
-
| `sdl.keyboard.SCANCODE.UP`
|
|
1295
|
-
| `sdl.keyboard.SCANCODE.NUMLOCKCLEAR`
|
|
1296
|
-
| `sdl.keyboard.SCANCODE.KP_DIVIDE`
|
|
1297
|
-
| `sdl.keyboard.SCANCODE.KP_MULTIPLY`
|
|
1298
|
-
| `sdl.keyboard.SCANCODE.KP_MINUS`
|
|
1299
|
-
| `sdl.keyboard.SCANCODE.KP_PLUS`
|
|
1300
|
-
| `sdl.keyboard.SCANCODE.KP_ENTER`
|
|
1301
|
-
| `sdl.keyboard.SCANCODE.KP_1`
|
|
1302
|
-
| `sdl.keyboard.SCANCODE.KP_2`
|
|
1303
|
-
| `sdl.keyboard.SCANCODE.KP_3`
|
|
1304
|
-
| `sdl.keyboard.SCANCODE.KP_4`
|
|
1305
|
-
| `sdl.keyboard.SCANCODE.KP_5`
|
|
1306
|
-
| `sdl.keyboard.SCANCODE.KP_6`
|
|
1307
|
-
| `sdl.keyboard.SCANCODE.KP_7`
|
|
1308
|
-
| `sdl.keyboard.SCANCODE.KP_8`
|
|
1309
|
-
| `sdl.keyboard.SCANCODE.KP_9`
|
|
1310
|
-
| `sdl.keyboard.SCANCODE.KP_0`
|
|
1311
|
-
| `sdl.keyboard.SCANCODE.KP_PERIOD`
|
|
1312
|
-
| `sdl.keyboard.SCANCODE.NONUSBACKSLASH`
|
|
1313
|
-
| `sdl.keyboard.SCANCODE.APPLICATION`
|
|
1314
|
-
| `sdl.keyboard.SCANCODE.POWER`
|
|
1315
|
-
| `sdl.keyboard.SCANCODE.KP_EQUALS`
|
|
1316
|
-
| `sdl.keyboard.SCANCODE.F13`
|
|
1317
|
-
| `sdl.keyboard.SCANCODE.F14`
|
|
1318
|
-
| `sdl.keyboard.SCANCODE.F15`
|
|
1319
|
-
| `sdl.keyboard.SCANCODE.F16`
|
|
1320
|
-
| `sdl.keyboard.SCANCODE.F17`
|
|
1321
|
-
| `sdl.keyboard.SCANCODE.F18`
|
|
1322
|
-
| `sdl.keyboard.SCANCODE.F19`
|
|
1323
|
-
| `sdl.keyboard.SCANCODE.F20`
|
|
1324
|
-
| `sdl.keyboard.SCANCODE.F21`
|
|
1325
|
-
| `sdl.keyboard.SCANCODE.F22`
|
|
1326
|
-
| `sdl.keyboard.SCANCODE.F23`
|
|
1327
|
-
| `sdl.keyboard.SCANCODE.F24`
|
|
1328
|
-
| `sdl.keyboard.SCANCODE.EXECUTE`
|
|
1329
|
-
| `sdl.keyboard.SCANCODE.HELP`
|
|
1330
|
-
| `sdl.keyboard.SCANCODE.MENU`
|
|
1331
|
-
| `sdl.keyboard.SCANCODE.SELECT`
|
|
1332
|
-
| `sdl.keyboard.SCANCODE.STOP`
|
|
1333
|
-
| `sdl.keyboard.SCANCODE.AGAIN`
|
|
1334
|
-
| `sdl.keyboard.SCANCODE.UNDO`
|
|
1335
|
-
| `sdl.keyboard.SCANCODE.CUT`
|
|
1336
|
-
| `sdl.keyboard.SCANCODE.COPY`
|
|
1337
|
-
| `sdl.keyboard.SCANCODE.PASTE`
|
|
1338
|
-
| `sdl.keyboard.SCANCODE.FIND`
|
|
1339
|
-
| `sdl.keyboard.SCANCODE.MUTE`
|
|
1340
|
-
| `sdl.keyboard.SCANCODE.VOLUMEUP`
|
|
1341
|
-
| `sdl.keyboard.SCANCODE.VOLUMEDOWN`
|
|
1342
|
-
| `sdl.keyboard.SCANCODE.KP_COMMA`
|
|
1343
|
-
| `sdl.keyboard.SCANCODE.KP_EQUALSAS400`
|
|
1344
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL1`
|
|
1345
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL2`
|
|
1346
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL3`
|
|
1347
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL4`
|
|
1348
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL5`
|
|
1349
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL6`
|
|
1350
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL7`
|
|
1351
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL8`
|
|
1352
|
-
| `sdl.keyboard.SCANCODE.INTERNATIONAL9`
|
|
1353
|
-
| `sdl.keyboard.SCANCODE.LANG1`
|
|
1354
|
-
| `sdl.keyboard.SCANCODE.LANG2`
|
|
1355
|
-
| `sdl.keyboard.SCANCODE.LANG3`
|
|
1356
|
-
| `sdl.keyboard.SCANCODE.LANG4`
|
|
1357
|
-
| `sdl.keyboard.SCANCODE.LANG5`
|
|
1358
|
-
| `sdl.keyboard.SCANCODE.LANG6`
|
|
1359
|
-
| `sdl.keyboard.SCANCODE.LANG7`
|
|
1360
|
-
| `sdl.keyboard.SCANCODE.LANG8`
|
|
1361
|
-
| `sdl.keyboard.SCANCODE.LANG9`
|
|
1362
|
-
| `sdl.keyboard.SCANCODE.ALTERASE`
|
|
1363
|
-
| `sdl.keyboard.SCANCODE.SYSREQ`
|
|
1364
|
-
| `sdl.keyboard.SCANCODE.CANCEL`
|
|
1365
|
-
| `sdl.keyboard.SCANCODE.CLEAR`
|
|
1366
|
-
| `sdl.keyboard.SCANCODE.PRIOR`
|
|
1367
|
-
| `sdl.keyboard.SCANCODE.RETURN2`
|
|
1368
|
-
| `sdl.keyboard.SCANCODE.SEPARATOR`
|
|
1369
|
-
| `sdl.keyboard.SCANCODE.OUT`
|
|
1370
|
-
| `sdl.keyboard.SCANCODE.OPER`
|
|
1371
|
-
| `sdl.keyboard.SCANCODE.CLEARAGAIN`
|
|
1372
|
-
| `sdl.keyboard.SCANCODE.CRSEL`
|
|
1373
|
-
| `sdl.keyboard.SCANCODE.EXSEL`
|
|
1374
|
-
| `sdl.keyboard.SCANCODE.KP_00`
|
|
1375
|
-
| `sdl.keyboard.SCANCODE.KP_000`
|
|
1376
|
-
| `sdl.keyboard.SCANCODE.THOUSANDSSEPARATOR` | `SDL_SCANCODE_THOUSANDSSEPARATOR` |
|
|
1377
|
-
| `sdl.keyboard.SCANCODE.DECIMALSEPARATOR`
|
|
1378
|
-
| `sdl.keyboard.SCANCODE.CURRENCYUNIT`
|
|
1379
|
-
| `sdl.keyboard.SCANCODE.CURRENCYSUBUNIT`
|
|
1380
|
-
| `sdl.keyboard.SCANCODE.KP_LEFTPAREN`
|
|
1381
|
-
| `sdl.keyboard.SCANCODE.KP_RIGHTPAREN`
|
|
1382
|
-
| `sdl.keyboard.SCANCODE.KP_LEFTBRACE`
|
|
1383
|
-
| `sdl.keyboard.SCANCODE.KP_RIGHTBRACE`
|
|
1384
|
-
| `sdl.keyboard.SCANCODE.KP_TAB`
|
|
1385
|
-
| `sdl.keyboard.SCANCODE.KP_BACKSPACE`
|
|
1386
|
-
| `sdl.keyboard.SCANCODE.KP_A`
|
|
1387
|
-
| `sdl.keyboard.SCANCODE.KP_B`
|
|
1388
|
-
| `sdl.keyboard.SCANCODE.KP_C`
|
|
1389
|
-
| `sdl.keyboard.SCANCODE.KP_D`
|
|
1390
|
-
| `sdl.keyboard.SCANCODE.KP_E`
|
|
1391
|
-
| `sdl.keyboard.SCANCODE.KP_F`
|
|
1392
|
-
| `sdl.keyboard.SCANCODE.KP_XOR`
|
|
1393
|
-
| `sdl.keyboard.SCANCODE.KP_POWER`
|
|
1394
|
-
| `sdl.keyboard.SCANCODE.KP_PERCENT`
|
|
1395
|
-
| `sdl.keyboard.SCANCODE.KP_LESS`
|
|
1396
|
-
| `sdl.keyboard.SCANCODE.KP_GREATER`
|
|
1397
|
-
| `sdl.keyboard.SCANCODE.KP_AMPERSAND`
|
|
1398
|
-
| `sdl.keyboard.SCANCODE.KP_DBLAMPERSAND`
|
|
1399
|
-
| `sdl.keyboard.SCANCODE.KP_VERTICALBAR`
|
|
1400
|
-
| `sdl.keyboard.SCANCODE.KP_DBLVERTICALBAR`
|
|
1401
|
-
| `sdl.keyboard.SCANCODE.KP_COLON`
|
|
1402
|
-
| `sdl.keyboard.SCANCODE.KP_HASH`
|
|
1403
|
-
| `sdl.keyboard.SCANCODE.KP_SPACE`
|
|
1404
|
-
| `sdl.keyboard.SCANCODE.KP_AT`
|
|
1405
|
-
| `sdl.keyboard.SCANCODE.KP_EXCLAM`
|
|
1406
|
-
| `sdl.keyboard.SCANCODE.KP_MEMSTORE`
|
|
1407
|
-
| `sdl.keyboard.SCANCODE.KP_MEMRECALL`
|
|
1408
|
-
| `sdl.keyboard.SCANCODE.KP_MEMCLEAR`
|
|
1409
|
-
| `sdl.keyboard.SCANCODE.KP_MEMADD`
|
|
1410
|
-
| `sdl.keyboard.SCANCODE.KP_MEMSUBTRACT`
|
|
1411
|
-
| `sdl.keyboard.SCANCODE.KP_MEMMULTIPLY`
|
|
1412
|
-
| `sdl.keyboard.SCANCODE.KP_MEMDIVIDE`
|
|
1413
|
-
| `sdl.keyboard.SCANCODE.KP_PLUSMINUS`
|
|
1414
|
-
| `sdl.keyboard.SCANCODE.KP_CLEAR`
|
|
1415
|
-
| `sdl.keyboard.SCANCODE.KP_CLEARENTRY`
|
|
1416
|
-
| `sdl.keyboard.SCANCODE.KP_BINARY`
|
|
1417
|
-
| `sdl.keyboard.SCANCODE.KP_OCTAL`
|
|
1418
|
-
| `sdl.keyboard.SCANCODE.KP_DECIMAL`
|
|
1419
|
-
| `sdl.keyboard.SCANCODE.KP_HEXADECIMAL`
|
|
1420
|
-
| `sdl.keyboard.SCANCODE.LCTRL`
|
|
1421
|
-
| `sdl.keyboard.SCANCODE.LSHIFT`
|
|
1422
|
-
| `sdl.keyboard.SCANCODE.LALT`
|
|
1423
|
-
| `sdl.keyboard.SCANCODE.LGUI`
|
|
1424
|
-
| `sdl.keyboard.SCANCODE.RCTRL`
|
|
1425
|
-
| `sdl.keyboard.SCANCODE.RSHIFT`
|
|
1426
|
-
| `sdl.keyboard.SCANCODE.RALT`
|
|
1427
|
-
| `sdl.keyboard.SCANCODE.RGUI`
|
|
1428
|
-
| `sdl.keyboard.SCANCODE.MODE`
|
|
1429
|
-
| `sdl.keyboard.SCANCODE.AUDIONEXT`
|
|
1430
|
-
| `sdl.keyboard.SCANCODE.AUDIOPREV`
|
|
1431
|
-
| `sdl.keyboard.SCANCODE.AUDIOSTOP`
|
|
1432
|
-
| `sdl.keyboard.SCANCODE.AUDIOPLAY`
|
|
1433
|
-
| `sdl.keyboard.SCANCODE.AUDIOMUTE`
|
|
1434
|
-
| `sdl.keyboard.SCANCODE.MEDIASELECT`
|
|
1435
|
-
| `sdl.keyboard.SCANCODE.WWW`
|
|
1436
|
-
| `sdl.keyboard.SCANCODE.MAIL`
|
|
1437
|
-
| `sdl.keyboard.SCANCODE.CALCULATOR`
|
|
1438
|
-
| `sdl.keyboard.SCANCODE.COMPUTER`
|
|
1439
|
-
| `sdl.keyboard.SCANCODE.AC_SEARCH`
|
|
1440
|
-
| `sdl.keyboard.SCANCODE.AC_HOME`
|
|
1441
|
-
| `sdl.keyboard.SCANCODE.AC_BACK`
|
|
1442
|
-
| `sdl.keyboard.SCANCODE.AC_FORWARD`
|
|
1443
|
-
| `sdl.keyboard.SCANCODE.AC_STOP`
|
|
1444
|
-
| `sdl.keyboard.SCANCODE.AC_REFRESH`
|
|
1445
|
-
| `sdl.keyboard.SCANCODE.AC_BOOKMARKS`
|
|
1446
|
-
| `sdl.keyboard.SCANCODE.BRIGHTNESSDOWN`
|
|
1447
|
-
| `sdl.keyboard.SCANCODE.BRIGHTNESSUP`
|
|
1448
|
-
| `sdl.keyboard.SCANCODE.DISPLAYSWITCH`
|
|
1449
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMTOGGLE`
|
|
1450
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMDOWN`
|
|
1451
|
-
| `sdl.keyboard.SCANCODE.KBDILLUMUP`
|
|
1452
|
-
| `sdl.keyboard.SCANCODE.EJECT`
|
|
1453
|
-
| `sdl.keyboard.SCANCODE.SLEEP`
|
|
1454
|
-
| `sdl.keyboard.SCANCODE.APP1`
|
|
1455
|
-
| `sdl.keyboard.SCANCODE.APP2`
|
|
1456
|
-
| `sdl.keyboard.SCANCODE.AUDIOREWIND`
|
|
1457
|
-
| `sdl.keyboard.SCANCODE.AUDIOFASTFORWARD`
|
|
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` | |
|
|
1458
1453
|
|
|
1459
1454
|
</details>
|
|
1460
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
|
+
|
|
1461
1462
|
### sdl.keyboard.getKey(scancode)
|
|
1462
1463
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1464
|
+
- `scancode: `[`<Scancode>`](#enum-scancode)
|
|
1465
|
+
- Returns: [`<Key>`](#virtual-keys)`|<null>`
|
|
1465
1466
|
|
|
1466
1467
|
Maps a scancode to the corresponding key based on the current keyboard mapping.
|
|
1467
1468
|
Retuns `null` if the scancode does not currespond to a key in the current mapping.
|
|
1468
1469
|
|
|
1469
1470
|
### sdl.keyboard.getScancode(key)
|
|
1470
1471
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1472
|
+
- `key: `[`<Key>`](#virtual-keys)
|
|
1473
|
+
- Returns: [`<Scancode>`](#enum-scancode)`|<null>`
|
|
1473
1474
|
|
|
1474
1475
|
Maps a key to the corresponding scancode based on the current keyboard mapping.
|
|
1475
1476
|
Retuns `null` if the key does not currespond to a scancode in the current mapping.
|
|
@@ -1477,12 +1478,11 @@ If multiple physical keys produce the same virtual key, then only the first one
|
|
|
1477
1478
|
|
|
1478
1479
|
### sdl.keyboard.getState()
|
|
1479
1480
|
|
|
1480
|
-
|
|
1481
|
+
- Returns: `<boolean[]>` an array representing the state of each key.
|
|
1481
1482
|
|
|
1482
1483
|
The returned array can be indexed with [`Scancode`](#enum-scancode) values.
|
|
1483
1484
|
Each value in the array is either `true` if the corresponding key is pressed, or `false` otherwise.
|
|
1484
1485
|
|
|
1485
|
-
|
|
1486
1486
|
## sdl.mouse
|
|
1487
1487
|
|
|
1488
1488
|
### Enum: BUTTON
|
|
@@ -1490,56 +1490,56 @@ Each value in the array is either `true` if the corresponding key is pressed, or
|
|
|
1490
1490
|
Used to represent the buttons on a mouse.
|
|
1491
1491
|
A mouse can have many buttons, but the values for the three most common ones are represented in this enum.
|
|
1492
1492
|
|
|
1493
|
-
| Value
|
|
1494
|
-
| ---
|
|
1495
|
-
| `sdl.mouse.BUTTON.LEFT`
|
|
1496
|
-
| `sdl.mouse.BUTTON.MIDDLE` | `SDL_BUTTON_MIDDLE`
|
|
1497
|
-
| `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` |
|
|
1498
1498
|
|
|
1499
1499
|
### sdl.mouse.getButton(button)
|
|
1500
1500
|
|
|
1501
|
-
|
|
1502
|
-
|
|
1501
|
+
- `button: <number>` The index of the button.
|
|
1502
|
+
- Returns: `<boolean>` Is `true` if the button is pressed.
|
|
1503
1503
|
|
|
1504
1504
|
Queries the state of a single mouse button.
|
|
1505
1505
|
|
|
1506
1506
|
### sdl.mouse.position
|
|
1507
1507
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
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.
|
|
1511
1511
|
|
|
1512
1512
|
The position of the mouse on the screen.
|
|
1513
1513
|
|
|
1514
1514
|
### sdl.mouse.setPosition(x, y)
|
|
1515
1515
|
|
|
1516
|
-
|
|
1517
|
-
|
|
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.
|
|
1518
1518
|
|
|
1519
1519
|
Moves the mouse to the specified position.
|
|
1520
1520
|
|
|
1521
1521
|
### sdl.mouse.setCursor(cursor)
|
|
1522
1522
|
|
|
1523
|
-
|
|
1523
|
+
- `cursor: <MouseCursor>` The icon to use for the cursor.
|
|
1524
1524
|
|
|
1525
1525
|
Changes the icon that is displayed for the mouse cursor.
|
|
1526
1526
|
|
|
1527
1527
|
Possible values for `cursor` are:
|
|
1528
1528
|
|
|
1529
|
-
| Value
|
|
1530
|
-
| ---
|
|
1531
|
-
| `'arrow'`
|
|
1532
|
-
| `'ibeam'`
|
|
1533
|
-
| `'wait'`
|
|
1534
|
-
| `'crosshair'` | `SDL_SYSTEM_CURSOR_CROSSHAIR`
|
|
1535
|
-
| `'waitarrow'` | `SDL_SYSTEM_CURSOR_WAITARROW`
|
|
1536
|
-
| `'sizenwse'`
|
|
1537
|
-
| `'sizenesw'`
|
|
1538
|
-
| `'sizewe'`
|
|
1539
|
-
| `'sizens'`
|
|
1540
|
-
| `'sizeall'`
|
|
1541
|
-
| `'no'`
|
|
1542
|
-
| `'hand'`
|
|
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 |
|
|
1543
1543
|
|
|
1544
1544
|
### sdl.mouse.resetCursor()
|
|
1545
1545
|
|
|
@@ -1547,16 +1547,16 @@ Switched back to the default cursor.
|
|
|
1547
1547
|
|
|
1548
1548
|
### sdl.mouse.setCursorImage(width, height, stride, format, buffer, x, y)
|
|
1549
1549
|
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
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.
|
|
1553
1553
|
|
|
1554
1554
|
Sets a image to be the mouse cursor.
|
|
1555
1555
|
The hotspot represents the pixel that is considered to be under the mouse.
|
|
1556
1556
|
|
|
1557
1557
|
### sdl.mouse.showCursor([show])
|
|
1558
1558
|
|
|
1559
|
-
|
|
1559
|
+
- `show: <boolean>` If `true` then the mouse cursor is made visible. Default: `true`
|
|
1560
1560
|
|
|
1561
1561
|
Changes the visibility of the mouse cursor.
|
|
1562
1562
|
|
|
@@ -1570,7 +1570,7 @@ Forces a cursor redraw.
|
|
|
1570
1570
|
|
|
1571
1571
|
### sdl.mouse.capture([capture])
|
|
1572
1572
|
|
|
1573
|
-
|
|
1573
|
+
- `capture: <boolean>` If `true` the mouse is to be captured by the current window. Default: `true`
|
|
1574
1574
|
|
|
1575
1575
|
When the mouse has been captured you will continue receiving mouse events even if the mouse is not over a window.
|
|
1576
1576
|
|
|
@@ -1578,43 +1578,42 @@ When the mouse has been captured you will continue receiving mouse events even i
|
|
|
1578
1578
|
|
|
1579
1579
|
Equivalent to [`sdl.mouse.capture(false)`](#sdlmousecapturecapture).
|
|
1580
1580
|
|
|
1581
|
-
|
|
1582
1581
|
## sdl.joystick
|
|
1583
1582
|
|
|
1584
1583
|
### Hat positions
|
|
1585
1584
|
|
|
1586
1585
|
String values used to represent the positions of a joystick hat
|
|
1587
1586
|
|
|
1588
|
-
| Value
|
|
1589
|
-
| ---
|
|
1590
|
-
| `'centered'`
|
|
1591
|
-
| `'up'`
|
|
1592
|
-
| `'right'`
|
|
1593
|
-
| `'down'`
|
|
1594
|
-
| `'left'`
|
|
1595
|
-
| `'rightup'`
|
|
1596
|
-
| `'rightdown'` | `SDL_HAT_RIGHTDOWN`
|
|
1597
|
-
| `'leftup'`
|
|
1598
|
-
| `'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` |
|
|
1599
1598
|
|
|
1600
1599
|
### Power levels
|
|
1601
1600
|
|
|
1602
1601
|
String values used to represent the power level of a joystick or controller
|
|
1603
1602
|
|
|
1604
|
-
| Value
|
|
1605
|
-
| ---
|
|
1606
|
-
| `'empty'`
|
|
1607
|
-
| `'low'`
|
|
1608
|
-
| `'medium'` | `SDL_JOYSTICK_POWER_MEDIUM`
|
|
1609
|
-
| `'full'`
|
|
1610
|
-
| `'wired'`
|
|
1611
|
-
| `'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` |
|
|
1612
1611
|
|
|
1613
1612
|
<a id="joystick-event-deviceadd"></a>
|
|
1614
1613
|
|
|
1615
1614
|
### Event: 'deviceAdd'
|
|
1616
1615
|
|
|
1617
|
-
|
|
1616
|
+
- `device: <object>`: An object from [`sdl.joystick.devices`](#sdljoystickdevices) indicating the device that caused the event.
|
|
1618
1617
|
|
|
1619
1618
|
Fired when a new joystick device becomes available.
|
|
1620
1619
|
Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joystick devices.
|
|
@@ -1623,7 +1622,7 @@ Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joyst
|
|
|
1623
1622
|
|
|
1624
1623
|
### Event: 'deviceRemove'
|
|
1625
1624
|
|
|
1626
|
-
|
|
1625
|
+
- `device: <object>`: An object from [`sdl.joystick.devices`](#sdljoystickdevices) indicating the device that caused the event.
|
|
1627
1626
|
|
|
1628
1627
|
Fired when an existing joystick device is removed.
|
|
1629
1628
|
Check [`sdl.joystick.devices`](#sdljoystickdevices) to get the new list of joystick devices.
|
|
@@ -1631,32 +1630,32 @@ When this event is emitted, all instances that were opened from the removed devi
|
|
|
1631
1630
|
|
|
1632
1631
|
### sdl.joystick.devices
|
|
1633
1632
|
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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.
|
|
1644
1643
|
|
|
1645
1644
|
A list of all the detected joystick devices.
|
|
1646
1645
|
|
|
1647
1646
|
Possible values for `type` are `null` if it is unknown, or one of:
|
|
1648
1647
|
|
|
1649
|
-
| Value
|
|
1650
|
-
| ---
|
|
1648
|
+
| Value | Corresponding `SDL_JoystickType` |
|
|
1649
|
+
| --- | --- |
|
|
1651
1650
|
| `'gamecontroller'` | `SDL_JOYSTICK_TYPE_GAMECONTROLLER` |
|
|
1652
|
-
| `'wheel'`
|
|
1653
|
-
| `'arcadestick'`
|
|
1654
|
-
| `'flightstick'`
|
|
1655
|
-
| `'dancepad'`
|
|
1656
|
-
| `'guitar'`
|
|
1657
|
-
| `'drumkit'`
|
|
1658
|
-
| `'arcadepad'`
|
|
1659
|
-
| `'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` |
|
|
1660
1659
|
|
|
1661
1660
|
Sample output:
|
|
1662
1661
|
|
|
@@ -1678,8 +1677,8 @@ Sample output:
|
|
|
1678
1677
|
|
|
1679
1678
|
### sdl.joystick.openDevice(device)
|
|
1680
1679
|
|
|
1681
|
-
|
|
1682
|
-
|
|
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.
|
|
1683
1682
|
|
|
1684
1683
|
Initializes a joystick device and returns a corresponding instance.
|
|
1685
1684
|
|
|
@@ -1692,16 +1691,16 @@ Instead, objects returned by [`sdl.joystick.openDevice()`](#sdljoystickopendevic
|
|
|
1692
1691
|
|
|
1693
1692
|
### Event: 'axisMotion'
|
|
1694
1693
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1694
|
+
- `axis: <number>` The index of the axis that moved.
|
|
1695
|
+
- `value: <number>` The new axis position.
|
|
1697
1696
|
|
|
1698
1697
|
Fired when one of the joystick's axes moves.
|
|
1699
1698
|
|
|
1700
1699
|
### Event: 'ballMotion'
|
|
1701
1700
|
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
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.
|
|
1705
1704
|
|
|
1706
1705
|
Fired when one of the joystick's balls moves.
|
|
1707
1706
|
|
|
@@ -1709,7 +1708,7 @@ Fired when one of the joystick's balls moves.
|
|
|
1709
1708
|
|
|
1710
1709
|
### Event: 'buttonDown'
|
|
1711
1710
|
|
|
1712
|
-
|
|
1711
|
+
- `button: <number>` The index of the button that was pressed.
|
|
1713
1712
|
|
|
1714
1713
|
Fired when one of the joystick's buttons is pressed.
|
|
1715
1714
|
|
|
@@ -1717,17 +1716,25 @@ Fired when one of the joystick's buttons is pressed.
|
|
|
1717
1716
|
|
|
1718
1717
|
### Event: 'buttonUp'
|
|
1719
1718
|
|
|
1720
|
-
|
|
1719
|
+
- `button: <number>` The index of the button that was released.
|
|
1721
1720
|
|
|
1722
1721
|
Fired when one of the joystick's buttons is released.
|
|
1723
1722
|
|
|
1724
1723
|
### Event: 'hatMotion'
|
|
1725
1724
|
|
|
1726
|
-
|
|
1727
|
-
|
|
1725
|
+
- `hat: <number>` The index of the hat that was moved.
|
|
1726
|
+
- `value: `[`<HatPosition>`](#hat-positions) The new hat position.
|
|
1728
1727
|
|
|
1729
1728
|
Fired when one of the joystick's hats is moved.
|
|
1730
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
|
+
|
|
1731
1738
|
<a id="joystick-instance-event-close"></a>
|
|
1732
1739
|
|
|
1733
1740
|
### Event: 'close'
|
|
@@ -1737,25 +1744,25 @@ Handle cleanup here.
|
|
|
1737
1744
|
|
|
1738
1745
|
### joystickInstance.device
|
|
1739
1746
|
|
|
1740
|
-
|
|
1747
|
+
- `<object>`
|
|
1741
1748
|
|
|
1742
1749
|
The [device](#sdljoystickdevices) from which the instance was opened.
|
|
1743
1750
|
|
|
1744
1751
|
### joystickInstance.firmwareVersion
|
|
1745
1752
|
|
|
1746
|
-
|
|
1753
|
+
- `<number>|<null>`
|
|
1747
1754
|
|
|
1748
1755
|
The joystick's firmware version, or `null` if it is not available.
|
|
1749
1756
|
|
|
1750
1757
|
### joystickInstance.serialNumber
|
|
1751
1758
|
|
|
1752
|
-
|
|
1759
|
+
- `<string>|<null>`
|
|
1753
1760
|
|
|
1754
1761
|
The joystick's serial number, or `null` if it is not available.
|
|
1755
1762
|
|
|
1756
1763
|
### joystickInstance.axes
|
|
1757
1764
|
|
|
1758
|
-
|
|
1765
|
+
- `<number>[]`
|
|
1759
1766
|
|
|
1760
1767
|
An array of values, each corresponding to the position of one of the joystick's axes.
|
|
1761
1768
|
The values are normalized from `-1` to `+1`.
|
|
@@ -1763,34 +1770,34 @@ It may be necessary to impose certain tolerances on these values to account for
|
|
|
1763
1770
|
|
|
1764
1771
|
### joystickInstance.balls
|
|
1765
1772
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1773
|
+
- `<object>[]`
|
|
1774
|
+
- `x: <number>` The horizontal position of the joystick's ball.
|
|
1775
|
+
- `y: <number>` The vertical position of the joystick's ball.
|
|
1769
1776
|
|
|
1770
1777
|
An array of values, each corresponding to the position of one of the joystick's balls.
|
|
1771
1778
|
|
|
1772
1779
|
### joystickInstance.buttons
|
|
1773
1780
|
|
|
1774
|
-
|
|
1781
|
+
- `<boolean>[]`
|
|
1775
1782
|
|
|
1776
1783
|
An array of values, each corresponding to the state of one of the joystick's buttons.
|
|
1777
1784
|
Each value in the object isarray is either `true` if the corresponding button is pressed, or `false` otherwise.
|
|
1778
1785
|
|
|
1779
1786
|
### joystickInstance.hats
|
|
1780
1787
|
|
|
1781
|
-
|
|
1788
|
+
- [`<HatPosition>`](#hat-positions)`[]`
|
|
1782
1789
|
|
|
1783
1790
|
An array of values, each corresponding to the position of one of the joystick's hats.
|
|
1784
1791
|
|
|
1785
1792
|
### joystickInstance.power
|
|
1786
1793
|
|
|
1787
|
-
|
|
1794
|
+
- [`<PowerLevel>`](#power-levels)`|<null>`
|
|
1788
1795
|
|
|
1789
1796
|
The current power level of the joystick device, or `null` if it is unknown.
|
|
1790
1797
|
|
|
1791
1798
|
### joystickInstance.setPlayer(index)
|
|
1792
1799
|
|
|
1793
|
-
|
|
1800
|
+
- `index: <number>` The player index to assign to the joystick.
|
|
1794
1801
|
|
|
1795
1802
|
Sets the player index of the joystick.
|
|
1796
1803
|
|
|
@@ -1800,29 +1807,29 @@ Clears player assignment and player led.
|
|
|
1800
1807
|
|
|
1801
1808
|
### joystickInstance.hasLed
|
|
1802
1809
|
|
|
1803
|
-
|
|
1810
|
+
- `<boolean>`
|
|
1804
1811
|
|
|
1805
1812
|
Is `true` if the joystick has a LED light whose color can be controlled.
|
|
1806
1813
|
|
|
1807
1814
|
### joystickInstance.setLed(red, green, blue)
|
|
1808
1815
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
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`.
|
|
1812
1819
|
|
|
1813
1820
|
Sets the color of the LED light on the joystick.
|
|
1814
1821
|
|
|
1815
1822
|
### joystickInstance.hasRumble
|
|
1816
1823
|
|
|
1817
|
-
|
|
1824
|
+
- `<boolean>`
|
|
1818
1825
|
|
|
1819
1826
|
Is `true` if the joystick has rumble motors.
|
|
1820
1827
|
|
|
1821
1828
|
### joystickInstance.rumble([low[, high[, duration]]])
|
|
1822
1829
|
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
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`
|
|
1826
1833
|
|
|
1827
1834
|
Makes the joystick rumble for a set `duration`.
|
|
1828
1835
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -1834,15 +1841,15 @@ Equivalent to [`joystickInstance.rumble(0, 0)`](#joystickinstancerumblelow-high-
|
|
|
1834
1841
|
|
|
1835
1842
|
### joystickInstance.hasRumbleTriggers
|
|
1836
1843
|
|
|
1837
|
-
|
|
1844
|
+
- `<boolean>`
|
|
1838
1845
|
|
|
1839
1846
|
Is `true` if the joystick has rumble motors on the triggers.
|
|
1840
1847
|
|
|
1841
1848
|
### joystickInstance.rumbleTriggers([left[, right[, duration]]])
|
|
1842
1849
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
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`
|
|
1846
1853
|
|
|
1847
1854
|
Makes the joystick triggers rumble for a set `duration`.
|
|
1848
1855
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -1854,7 +1861,7 @@ Equivalent to [`joystickInstance.rumbleTriggers(0, 0)`](#joystickinstancerumblet
|
|
|
1854
1861
|
|
|
1855
1862
|
### joystickInstance.closed
|
|
1856
1863
|
|
|
1857
|
-
|
|
1864
|
+
- `<boolean>`
|
|
1858
1865
|
|
|
1859
1866
|
Is `true` if the instance is closed.
|
|
1860
1867
|
A closed instance object must not be used any further.
|
|
@@ -1863,7 +1870,6 @@ A closed instance object must not be used any further.
|
|
|
1863
1870
|
|
|
1864
1871
|
Closes the instance.
|
|
1865
1872
|
|
|
1866
|
-
|
|
1867
1873
|
## sdl.controller
|
|
1868
1874
|
|
|
1869
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").
|
|
@@ -1875,7 +1881,7 @@ Because controllers are an abstraction over joysticks, they operate on the same
|
|
|
1875
1881
|
For a joystick device to also be available as a controller device it needs a "mapping".
|
|
1876
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.
|
|
1877
1883
|
See the sample output [`here`](#sdlcontrollerdevices) for an example.
|
|
1878
|
-
SDL has pretty good default controller mappings, but if you need more, there's a community sourced database available on https://github.com/gabomdq/SDL_GameControllerDB.
|
|
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).
|
|
1879
1885
|
Add them via:
|
|
1880
1886
|
|
|
1881
1887
|
```js
|
|
@@ -1890,7 +1896,7 @@ sdl.controller.addMappings(mappings)
|
|
|
1890
1896
|
|
|
1891
1897
|
### Event: 'deviceAdd'
|
|
1892
1898
|
|
|
1893
|
-
|
|
1899
|
+
- `device: <object>`: An object from [`sdl.controller.devices`](#sdlcontrollerdevices) indicating the device that caused the event.
|
|
1894
1900
|
|
|
1895
1901
|
Fired when a new controller device becomes available.
|
|
1896
1902
|
Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of controller devices.
|
|
@@ -1899,7 +1905,7 @@ Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of c
|
|
|
1899
1905
|
|
|
1900
1906
|
### Event: 'deviceRemove'
|
|
1901
1907
|
|
|
1902
|
-
|
|
1908
|
+
- `device: <object>`: An object from [`sdl.controller.devices`](#sdlcontrollerdevices) indicating the device that caused the event.
|
|
1903
1909
|
|
|
1904
1910
|
Fired when an existing controller device is removed.
|
|
1905
1911
|
Check [`sdl.controller.devices`](#sdlcontrollerdevices) to get the new list of controller devices.
|
|
@@ -1907,44 +1913,44 @@ When this event is emitted, all instances that were opened from the removed devi
|
|
|
1907
1913
|
|
|
1908
1914
|
### sdl.controller.addMappings(mappings)
|
|
1909
1915
|
|
|
1910
|
-
|
|
1916
|
+
- `mappings: <string>[]` An array of mappings to register.
|
|
1911
1917
|
|
|
1912
1918
|
Registers new mappings for controllers.
|
|
1913
1919
|
This may cause already opened controller instances to be [remapped](#event-remap).
|
|
1914
1920
|
|
|
1915
1921
|
### sdl.controller.devices
|
|
1916
1922
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
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.
|
|
1928
1934
|
|
|
1929
1935
|
A list of all the detected controller devices.
|
|
1930
1936
|
|
|
1931
1937
|
Possible values for `type` are `null` if it is unknown, or one of:
|
|
1932
1938
|
|
|
1933
|
-
| Value
|
|
1934
|
-
| ---
|
|
1935
|
-
| `'xbox360'`
|
|
1936
|
-
| `'xboxOne'`
|
|
1937
|
-
| `'ps3'`
|
|
1938
|
-
| `'ps4'`
|
|
1939
|
-
| `'nintendoSwitchPro'`
|
|
1940
|
-
| `'virtual'`
|
|
1941
|
-
| `'ps5'`
|
|
1942
|
-
| `'amazonLuna'`
|
|
1943
|
-
| `'googleStadia'`
|
|
1944
|
-
| `'nvidiaShield'`
|
|
1945
|
-
| `'nintendoSwitchJoyconLeft'`
|
|
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 |
|
|
1946
1952
|
| `'nintendoSwitchJoyconRight'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT |
|
|
1947
|
-
| `'nintendoSwitchJoyconPair'`
|
|
1953
|
+
| `'nintendoSwitchJoyconPair'` | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR |
|
|
1948
1954
|
|
|
1949
1955
|
Sample output:
|
|
1950
1956
|
|
|
@@ -1967,8 +1973,8 @@ Sample output:
|
|
|
1967
1973
|
|
|
1968
1974
|
### sdl.controller.openDevice(device)
|
|
1969
1975
|
|
|
1970
|
-
|
|
1971
|
-
|
|
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.
|
|
1972
1978
|
|
|
1973
1979
|
Initializes an controller device and returns a corresponding instance.
|
|
1974
1980
|
|
|
@@ -1981,8 +1987,8 @@ Instead, objects returned by [`sdl.controller.openDevice()`](#sdlcontrolleropend
|
|
|
1981
1987
|
|
|
1982
1988
|
### Event: 'axisMotion'
|
|
1983
1989
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1990
|
+
- `axis:`[`<Axis>`](#controllerinstanceaxes) The axis that moved.
|
|
1991
|
+
- `value: <number>` The new axis position.
|
|
1986
1992
|
|
|
1987
1993
|
Fired when one of the controller's axes moves.
|
|
1988
1994
|
|
|
@@ -1990,7 +1996,7 @@ Fired when one of the controller's axes moves.
|
|
|
1990
1996
|
|
|
1991
1997
|
### Event: 'buttonDown'
|
|
1992
1998
|
|
|
1993
|
-
|
|
1999
|
+
- `button:`[`<Button>`](#controllerinstancebuttons) The button that was pressed.
|
|
1994
2000
|
|
|
1995
2001
|
Fired when one of the controller's buttons is pressed.
|
|
1996
2002
|
|
|
@@ -1998,10 +2004,24 @@ Fired when one of the controller's buttons is pressed.
|
|
|
1998
2004
|
|
|
1999
2005
|
### Event: 'buttonUp'
|
|
2000
2006
|
|
|
2001
|
-
|
|
2007
|
+
- `button: <number>` The index of the button that was released.
|
|
2002
2008
|
|
|
2003
2009
|
Fired when one of the controller's buttons is released.
|
|
2004
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
|
+
|
|
2005
2025
|
### Event: 'remap'
|
|
2006
2026
|
|
|
2007
2027
|
Fired when a new mapping for the controller is applied (usually via [`sdl.controller.addMappings()`](#sdlcontrolleraddmappingsmappings)).
|
|
@@ -2016,38 +2036,38 @@ Handle cleanup here.
|
|
|
2016
2036
|
|
|
2017
2037
|
### controllerInstance.device
|
|
2018
2038
|
|
|
2019
|
-
|
|
2039
|
+
- `<object>`
|
|
2020
2040
|
|
|
2021
2041
|
The [device](#sdlcontrollerdevices) from which the instance was opened.
|
|
2022
2042
|
|
|
2023
2043
|
### controllerInstance.firmwareVersion
|
|
2024
2044
|
|
|
2025
|
-
|
|
2045
|
+
- `<number>`
|
|
2026
2046
|
|
|
2027
2047
|
The controller's firmware version.
|
|
2028
2048
|
|
|
2029
2049
|
### controllerInstance.serialNumber
|
|
2030
2050
|
|
|
2031
|
-
|
|
2051
|
+
- `<string>|<null>`
|
|
2032
2052
|
|
|
2033
2053
|
The controller's serial number, or `null` if it is not available.
|
|
2034
2054
|
|
|
2035
2055
|
### controllerInstance.steamHandle
|
|
2036
2056
|
|
|
2037
|
-
|
|
2057
|
+
- `<Buffer>|<null>`
|
|
2038
2058
|
|
|
2039
2059
|
The controller's steam handle, or `null` if it is not available.
|
|
2040
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)
|
|
2041
2061
|
|
|
2042
2062
|
### controllerInstance.axes
|
|
2043
2063
|
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
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
|
|
2051
2071
|
|
|
2052
2072
|
An object mapping each axis of the controller's axes to its position.
|
|
2053
2073
|
The values are normalized from `-1` to `+1`.
|
|
@@ -2055,39 +2075,39 @@ It may be necessary to impose certain tolerances on these values to account for
|
|
|
2055
2075
|
|
|
2056
2076
|
### controllerInstance.buttons
|
|
2057
2077
|
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
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
|
|
2078
2098
|
|
|
2079
2099
|
An object mapping each of the controller's buttons to a boolean value.
|
|
2080
2100
|
Each value in the object is either `true` if the corresponding button is pressed, or `false` otherwise.
|
|
2081
2101
|
|
|
2082
2102
|
### controllerInstance.power
|
|
2083
2103
|
|
|
2084
|
-
|
|
2104
|
+
- [`<PowerLevel>`](#power-levels)`|<null>`
|
|
2085
2105
|
|
|
2086
2106
|
The current power level of the joystick device, or `null` if it is unknown.
|
|
2087
2107
|
|
|
2088
2108
|
### controllerInstance.setPlayer(index)
|
|
2089
2109
|
|
|
2090
|
-
|
|
2110
|
+
- `index: <number>` The player index to assign to the controller.
|
|
2091
2111
|
|
|
2092
2112
|
Sets the player index of the controller.
|
|
2093
2113
|
|
|
@@ -2097,29 +2117,29 @@ Clears player assignment and player led.
|
|
|
2097
2117
|
|
|
2098
2118
|
### controllerInstance.hasLed
|
|
2099
2119
|
|
|
2100
|
-
|
|
2120
|
+
- `<boolean>`
|
|
2101
2121
|
|
|
2102
2122
|
Is `true` if the controller has a LED light whose color can be controlled.
|
|
2103
2123
|
|
|
2104
2124
|
### controllerInstance.setLed(red, green, blue)
|
|
2105
2125
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
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`.
|
|
2109
2129
|
|
|
2110
2130
|
Sets the color of the LED light on the controller.
|
|
2111
2131
|
|
|
2112
2132
|
### controllerInstance.hasRumble
|
|
2113
2133
|
|
|
2114
|
-
|
|
2134
|
+
- `<boolean>`
|
|
2115
2135
|
|
|
2116
2136
|
Is `true` if the controller has rumble motors.
|
|
2117
2137
|
|
|
2118
2138
|
### controllerInstance.rumble([low[, high[, duration]]])
|
|
2119
2139
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
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`
|
|
2123
2143
|
|
|
2124
2144
|
Makes the controller rumble for a set `duration`.
|
|
2125
2145
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -2131,15 +2151,15 @@ Equivalent to [`controllerInstance.rumble(0, 0)`](#controllerinstancerumblelow-h
|
|
|
2131
2151
|
|
|
2132
2152
|
### controllerInstance.hasRumbleTriggers
|
|
2133
2153
|
|
|
2134
|
-
|
|
2154
|
+
- `<boolean>`
|
|
2135
2155
|
|
|
2136
2156
|
Is `true` if the controller has rumble motors on the triggers.
|
|
2137
2157
|
|
|
2138
2158
|
### controllerInstance.rumbleTriggers([left[, right[, duration]]])
|
|
2139
2159
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
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`
|
|
2143
2163
|
|
|
2144
2164
|
Makes the controller triggers rumble for a set `duration`.
|
|
2145
2165
|
Calling this function again before `duration` has ran out, overrides the previous call.
|
|
@@ -2151,7 +2171,7 @@ Equivalent to [`controllerInstance.rumbleTriggers(0, 0)`](#controllerinstancerum
|
|
|
2151
2171
|
|
|
2152
2172
|
### controllerInstance.closed
|
|
2153
2173
|
|
|
2154
|
-
|
|
2174
|
+
- `<boolean>`
|
|
2155
2175
|
|
|
2156
2176
|
Is `true` if the instance is closed.
|
|
2157
2177
|
A closed instance object must not be used any further.
|
|
@@ -2160,12 +2180,11 @@ A closed instance object must not be used any further.
|
|
|
2160
2180
|
|
|
2161
2181
|
Closes the instance.
|
|
2162
2182
|
|
|
2163
|
-
|
|
2164
2183
|
## sdl.sensor
|
|
2165
2184
|
|
|
2166
2185
|
### sdl.sensor.STANDARD_GRAVITY
|
|
2167
2186
|
|
|
2168
|
-
|
|
2187
|
+
- `<number>`
|
|
2169
2188
|
|
|
2170
2189
|
Accelerometers are affected by the force of gravity:
|
|
2171
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.
|
|
@@ -2173,11 +2192,11 @@ Use the `sdl.sensor.STANDARD_GRAVITY` constant to correct for gravitational acce
|
|
|
2173
2192
|
|
|
2174
2193
|
### sdl.sensor.devices
|
|
2175
2194
|
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
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.
|
|
2181
2200
|
|
|
2182
2201
|
A list of all the detected sensor devices.
|
|
2183
2202
|
|
|
@@ -2190,8 +2209,8 @@ Sample output:
|
|
|
2190
2209
|
|
|
2191
2210
|
### sdl.sensor.openDevice(device)
|
|
2192
2211
|
|
|
2193
|
-
|
|
2194
|
-
|
|
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.
|
|
2195
2214
|
|
|
2196
2215
|
Initializes a sensor device and returns a corresponding instance.
|
|
2197
2216
|
|
|
@@ -2216,17 +2235,17 @@ Handle cleanup here.
|
|
|
2216
2235
|
|
|
2217
2236
|
### sensorInstance.device
|
|
2218
2237
|
|
|
2219
|
-
|
|
2238
|
+
- `<object>`
|
|
2220
2239
|
|
|
2221
2240
|
The [device](#sdlsensordevices) from which the `sensorInstance` was opened.
|
|
2222
2241
|
|
|
2223
2242
|
### sensorInstance.data
|
|
2224
2243
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
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.
|
|
2230
2249
|
|
|
2231
2250
|
An object reporting the latest measurement from the sensor.
|
|
2232
2251
|
|
|
@@ -2238,13 +2257,14 @@ For gyroscopes, the `x`, `y`, and `z` values correspond to the current rate of r
|
|
|
2238
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.
|
|
2239
2258
|
|
|
2240
2259
|
For phones held in portrait mode and game controllers held in front of you, the axes are defined as follows:
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2260
|
+
|
|
2261
|
+
- -X ... +X : left ... right
|
|
2262
|
+
- -Y ... +Y : bottom ... top
|
|
2263
|
+
- -Z ... +Z : farther ... closer
|
|
2244
2264
|
|
|
2245
2265
|
### sensorInstance.closed
|
|
2246
2266
|
|
|
2247
|
-
|
|
2267
|
+
- `<boolean>`
|
|
2248
2268
|
|
|
2249
2269
|
Is `true` if the instance is closed.
|
|
2250
2270
|
A closed instance object must not be used any further.
|
|
@@ -2253,7 +2273,6 @@ A closed instance object must not be used any further.
|
|
|
2253
2273
|
|
|
2254
2274
|
Closes the instance.
|
|
2255
2275
|
|
|
2256
|
-
|
|
2257
2276
|
## sdl.audio
|
|
2258
2277
|
|
|
2259
2278
|
### Audio data
|
|
@@ -2266,10 +2285,10 @@ A _sample_ is a single number representing the intensity of an audio channel at
|
|
|
2266
2285
|
For audio with multiple channels, each point in time is represented by multiple samples (one per channel) that together make up a _frame_.
|
|
2267
2286
|
The samples in a frame are arranged as follows:
|
|
2268
2287
|
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
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.
|
|
2273
2292
|
|
|
2274
2293
|
So for example, to play 3 seconds of a 440Hz sine wave, you could do:
|
|
2275
2294
|
|
|
@@ -2316,32 +2335,32 @@ playbackInstance.play()
|
|
|
2316
2335
|
|
|
2317
2336
|
String values used to represent how audio samples are stored in a Buffer.
|
|
2318
2337
|
|
|
2319
|
-
| Value
|
|
2320
|
-
| ---
|
|
2321
|
-
| `'s8'`
|
|
2322
|
-
| `'u8'`
|
|
2323
|
-
| `'s16lsb'` | `AUDIO_S16LSB`
|
|
2324
|
-
| `'s16msb'` | `AUDIO_S16MSB`
|
|
2325
|
-
| `'s16sys'` | `AUDIO_S16SYS`
|
|
2326
|
-
| `'s16'`
|
|
2327
|
-
| `'u16lsb'` | `AUDIO_U16LSB`
|
|
2328
|
-
| `'u16msb'` | `AUDIO_U16MSB`
|
|
2329
|
-
| `'u16sys'` | `AUDIO_U16SYS`
|
|
2330
|
-
| `'u16'`
|
|
2331
|
-
| `'s32lsb'` | `AUDIO_S32LSB`
|
|
2332
|
-
| `'s32msb'` | `AUDIO_S32MSB`
|
|
2333
|
-
| `'s32sys'` | `AUDIO_S32SYS`
|
|
2334
|
-
| `'s32'`
|
|
2335
|
-
| `'f32lsb'` | `AUDIO_F32LSB`
|
|
2336
|
-
| `'f32msb'` | `AUDIO_F32MSB`
|
|
2337
|
-
| `'f32sys'` | `AUDIO_F32SYS`
|
|
2338
|
-
| `'f32'`
|
|
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'` |
|
|
2339
2358
|
|
|
2340
2359
|
<a id="audio-event-deviceadd"></a>
|
|
2341
2360
|
|
|
2342
2361
|
### Event: 'deviceAdd'
|
|
2343
2362
|
|
|
2344
|
-
|
|
2363
|
+
- `device: <object>`: An object from [`sdl.audio.devices`](#sdlaudiodevices) indicating the device that caused the event.
|
|
2345
2364
|
|
|
2346
2365
|
Fired when a new audio device becomes available.
|
|
2347
2366
|
Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devices.
|
|
@@ -2350,7 +2369,7 @@ Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devic
|
|
|
2350
2369
|
|
|
2351
2370
|
### Event: 'deviceRemove'
|
|
2352
2371
|
|
|
2353
|
-
|
|
2372
|
+
- `device: <object>`: An object from [`sdl.audio.devices`](#sdlaudiodevices) indicating the device that caused the event.
|
|
2354
2373
|
|
|
2355
2374
|
Fired when an existing audio device is removed.
|
|
2356
2375
|
Check [`sdl.audio.devices`](#sdlaudiodevices) to get the new list of audio devices.
|
|
@@ -2358,8 +2377,8 @@ When the `'deviceRemove'` event is emitted, all instances that were opened from
|
|
|
2358
2377
|
|
|
2359
2378
|
### sdl.audio.bytesPerSample(format)
|
|
2360
2379
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2380
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2381
|
+
- Returns: `<number>` The number of bytes.
|
|
2363
2382
|
|
|
2364
2383
|
Helper function which maps each sample format to the corresponding number of bytes its samples take up.
|
|
2365
2384
|
|
|
@@ -2367,8 +2386,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2367
2386
|
|
|
2368
2387
|
### sdl.audio.minSampleValue(format)
|
|
2369
2388
|
|
|
2370
|
-
|
|
2371
|
-
|
|
2389
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2390
|
+
- Returns: `<number>` The minimum sample value.
|
|
2372
2391
|
|
|
2373
2392
|
Helper function which maps each sample format to the corresponding minimum value its samples can take.
|
|
2374
2393
|
|
|
@@ -2376,8 +2395,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2376
2395
|
|
|
2377
2396
|
### sdl.audio.maxSampleValue(format)
|
|
2378
2397
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2398
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2399
|
+
- Returns: `<number>` The maximum sample value.
|
|
2381
2400
|
|
|
2382
2401
|
Helper function which maps each sample format to the corresponding maximum value its samples can take.
|
|
2383
2402
|
|
|
@@ -2385,8 +2404,8 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2385
2404
|
|
|
2386
2405
|
### sdl.audio.zeroSampleValue(format)
|
|
2387
2406
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2407
|
+
- `format: `[`<SampleFormat>`](#sample-formats): The desired sample format.
|
|
2408
|
+
- Returns: `<number>` The zero sample value.
|
|
2390
2409
|
|
|
2391
2410
|
Helper function which maps each sample format to the sample value that corresponds to silence.
|
|
2392
2411
|
|
|
@@ -2394,10 +2413,10 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2394
2413
|
|
|
2395
2414
|
### sdl.audio.readSample(format, buffer[, offset])
|
|
2396
2415
|
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
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.
|
|
2401
2420
|
|
|
2402
2421
|
Helper function which calls the appropriate `read*` method of `Buffer` based on the format argument.
|
|
2403
2422
|
For example, a call to `sdl.audio.readSample('f32', buffer, offset)` would be equivalent to `buffer.readFloatLE(offset)`.
|
|
@@ -2406,11 +2425,11 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2406
2425
|
|
|
2407
2426
|
### sdl.audio.writeSample(format, buffer, value[, offset])
|
|
2408
2427
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
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`.
|
|
2414
2433
|
|
|
2415
2434
|
Helper function which calls the appropriate `write*` method of `Buffer` based on the format argument.
|
|
2416
2435
|
For example, a call to `sdl.audio.writeSample('f32', buffer, value, offset)` would be equivalent to `buffer.writeFloatLE(value, offset)`.
|
|
@@ -2419,9 +2438,9 @@ This function is also available from `@kmamal/sdl/helpers`.
|
|
|
2419
2438
|
|
|
2420
2439
|
### sdl.audio.devices
|
|
2421
2440
|
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2441
|
+
- `<object>[]`
|
|
2442
|
+
- `type: <string>` Either `'playback'` or `'recording'`.
|
|
2443
|
+
- `name: <string>` The name of the device.
|
|
2425
2444
|
|
|
2426
2445
|
A list of all the detected audio devices.
|
|
2427
2446
|
Sample output for PulseAudio:
|
|
@@ -2442,15 +2461,15 @@ const playbackInstance = sdl.audio.openDevice({ type: 'playback' })
|
|
|
2442
2461
|
|
|
2443
2462
|
### sdl.audio.openDevice(device[, options])
|
|
2444
2463
|
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
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.
|
|
2454
2473
|
|
|
2455
2474
|
Initializes an audio device for playback/recording and returns a corresponding instance.
|
|
2456
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).
|
|
@@ -2478,7 +2497,6 @@ The `buffered` option specifies the "delay" between the application and the audi
|
|
|
2478
2497
|
With smaller values you have smaller delays, but you also have to read/write data from/to the driver more frequently.
|
|
2479
2498
|
Applications such as virtual instruments that need to play audio in reaction to user input should set `buffered` to a lower value.
|
|
2480
2499
|
|
|
2481
|
-
|
|
2482
2500
|
## class AudioInstance
|
|
2483
2501
|
|
|
2484
2502
|
The `AudioInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2493,92 +2511,92 @@ Handle cleanup here.
|
|
|
2493
2511
|
|
|
2494
2512
|
### audioInstance.id
|
|
2495
2513
|
|
|
2496
|
-
|
|
2514
|
+
- `<number>`
|
|
2497
2515
|
|
|
2498
2516
|
A unique identifier for the instance.
|
|
2499
2517
|
|
|
2500
2518
|
### audioInstance.device
|
|
2501
2519
|
|
|
2502
|
-
|
|
2520
|
+
- `<object>`
|
|
2503
2521
|
|
|
2504
2522
|
The device passed to [`sdl.audio.openDevice()`](#sdlaudioopendevicedevice-options) when the `audioInstance` was opened.
|
|
2505
2523
|
|
|
2506
2524
|
### audioInstance.channels
|
|
2507
2525
|
|
|
2508
|
-
|
|
2526
|
+
- `<number>`
|
|
2509
2527
|
|
|
2510
2528
|
The number of channels the instance was opened with.
|
|
2511
2529
|
|
|
2512
2530
|
### audioInstance.frequency
|
|
2513
2531
|
|
|
2514
|
-
|
|
2532
|
+
- `<number>`
|
|
2515
2533
|
|
|
2516
2534
|
The sampling frequency (in frames per second) the instance was opened with.
|
|
2517
2535
|
|
|
2518
2536
|
### audioInstance.format
|
|
2519
2537
|
|
|
2520
|
-
|
|
2538
|
+
- [`<SampleFormat>`](#sample-formats)
|
|
2521
2539
|
|
|
2522
2540
|
The audio sample format the instance was opened with.
|
|
2523
2541
|
|
|
2524
2542
|
### audioInstance.bytesPerSample
|
|
2525
2543
|
|
|
2526
|
-
|
|
2544
|
+
- `<number>`
|
|
2527
2545
|
|
|
2528
2546
|
The number of bytes that make up a single audio sample, based on the format the instance was opened with.
|
|
2529
2547
|
|
|
2530
2548
|
### audioInstance.minSampleValue
|
|
2531
2549
|
|
|
2532
|
-
|
|
2550
|
+
- `<number>`
|
|
2533
2551
|
|
|
2534
2552
|
The minimum value a sample can take, based on the format the instance was opened with.
|
|
2535
2553
|
|
|
2536
2554
|
### audioInstance.maxSampleValue
|
|
2537
2555
|
|
|
2538
|
-
|
|
2556
|
+
- `<number>`
|
|
2539
2557
|
|
|
2540
2558
|
The maximum value a sample can take, based on the format the instance was opened with.
|
|
2541
2559
|
|
|
2542
2560
|
### audioInstance.zeroSampleValue
|
|
2543
2561
|
|
|
2544
|
-
|
|
2562
|
+
- `<number>`
|
|
2545
2563
|
|
|
2546
2564
|
The sample value that corresponds to silence, based on the format the instance was opened with.
|
|
2547
2565
|
|
|
2548
2566
|
### audioInstance.readSample(buffer[, offset])
|
|
2549
2567
|
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
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.
|
|
2553
2571
|
|
|
2554
2572
|
Helper function which calls the appropriate `read*` method of `Buffer` based on the format the instance was opened with.
|
|
2555
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)`.
|
|
2556
2574
|
|
|
2557
2575
|
### audioInstance.writeSample(buffer, value[, offset])
|
|
2558
2576
|
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
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`.
|
|
2563
2581
|
|
|
2564
2582
|
Helper function which calls the appropriate `write*` method of `Buffer` based on the format the instance was opened with.
|
|
2565
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)`.
|
|
2566
2584
|
|
|
2567
2585
|
### audioInstance.buffered
|
|
2568
2586
|
|
|
2569
|
-
|
|
2587
|
+
- `<number>`
|
|
2570
2588
|
|
|
2571
2589
|
The buffer size (in frames) the instance was opened with.
|
|
2572
2590
|
|
|
2573
2591
|
### audioInstance.playing
|
|
2574
2592
|
|
|
2575
|
-
|
|
2593
|
+
- `<boolean>`
|
|
2576
2594
|
|
|
2577
2595
|
Is `true` if the instance is currently playing.
|
|
2578
2596
|
|
|
2579
2597
|
### audioInstance.play([play])
|
|
2580
2598
|
|
|
2581
|
-
|
|
2599
|
+
- `show: <boolean>` Set to `true` to start the instance, `false` to stop. Default: `true`
|
|
2582
2600
|
|
|
2583
2601
|
Starts or stops the instance.
|
|
2584
2602
|
|
|
@@ -2588,7 +2606,7 @@ Equivalent to [`audioInstance.play(false)`](#audioinstanceplayplay)
|
|
|
2588
2606
|
|
|
2589
2607
|
### audioInstance.queued
|
|
2590
2608
|
|
|
2591
|
-
|
|
2609
|
+
- `<number>`
|
|
2592
2610
|
|
|
2593
2611
|
The number of bytes that are currently queued up, waiting to be either played by the system or dequeued by the user.
|
|
2594
2612
|
|
|
@@ -2598,7 +2616,7 @@ Clears the queued data.
|
|
|
2598
2616
|
|
|
2599
2617
|
### audioInstance.closed
|
|
2600
2618
|
|
|
2601
|
-
|
|
2619
|
+
- `<boolean>`
|
|
2602
2620
|
|
|
2603
2621
|
Is `true` if the instance is closed.
|
|
2604
2622
|
A closed instance object must not be used any further.
|
|
@@ -2607,7 +2625,6 @@ A closed instance object must not be used any further.
|
|
|
2607
2625
|
|
|
2608
2626
|
Closes the instance.
|
|
2609
2627
|
|
|
2610
|
-
|
|
2611
2628
|
## class AudioPlaybackInstance extends AudioInstance
|
|
2612
2629
|
|
|
2613
2630
|
The `AudioPlaybackInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2615,12 +2632,11 @@ Instead, objects returned by [`sdl.audio.openDevice()`](#sdlaudioopendevicedevic
|
|
|
2615
2632
|
|
|
2616
2633
|
### playbackInstance.enqueue(buffer[, bytes])
|
|
2617
2634
|
|
|
2618
|
-
|
|
2619
|
-
|
|
2635
|
+
- `buffer: <Buffer>` The buffer to read data from.
|
|
2636
|
+
- `bytes: <number>` The number of bytes to read from the buffer. Default: `buffer.length`
|
|
2620
2637
|
|
|
2621
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.
|
|
2622
2639
|
|
|
2623
|
-
|
|
2624
2640
|
## class AudioRecordingInstance extends AudioInstance
|
|
2625
2641
|
|
|
2626
2642
|
The `AudioRecordingInstance` class is not directly exposed by the API so you can't (and shouldn't) use it with the `new` operator.
|
|
@@ -2628,13 +2644,12 @@ Instead, objects returned by [`sdl.audio.openDevice()`](#sdlaudioopendevicedevic
|
|
|
2628
2644
|
|
|
2629
2645
|
### recordingInstance.dequeue(buffer[, bytes])
|
|
2630
2646
|
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
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.
|
|
2634
2650
|
|
|
2635
2651
|
Takes recorded audio data that has is waiting on the queue, and writes it to the provided buffer.
|
|
2636
2652
|
|
|
2637
|
-
|
|
2638
2653
|
## sdl.clipboard
|
|
2639
2654
|
|
|
2640
2655
|
<a id="clipboard-event-update"></a>
|
|
@@ -2646,29 +2661,27 @@ Check [`sdl.clipboard.text`](#sdlclipboardtext) to get the new contents of the c
|
|
|
2646
2661
|
|
|
2647
2662
|
### sdl.clipboard.text
|
|
2648
2663
|
|
|
2649
|
-
|
|
2664
|
+
- `<string>`
|
|
2650
2665
|
|
|
2651
2666
|
The current text value on the clipboard.
|
|
2652
2667
|
|
|
2653
2668
|
### sdl.clipboard.setText(text)
|
|
2654
2669
|
|
|
2655
|
-
|
|
2670
|
+
- `text: <string>` The new value to save on the clipboard.
|
|
2656
2671
|
|
|
2657
2672
|
Changes the text contents of the clipboard.
|
|
2658
2673
|
|
|
2659
|
-
|
|
2660
2674
|
## sdl.power
|
|
2661
2675
|
|
|
2662
2676
|
### sdl.power.info
|
|
2663
2677
|
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
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.
|
|
2668
2682
|
|
|
2669
2683
|
The curent power information of the device.
|
|
2670
2684
|
|
|
2671
|
-
|
|
2672
2685
|
## Helpers
|
|
2673
2686
|
|
|
2674
2687
|
The `@kmamal/sdl` library must only be imported from the main thread.
|
|
@@ -2686,13 +2699,12 @@ For an example of their use see [this example](https://github.com/kmamal/node-sd
|
|
|
2686
2699
|
|
|
2687
2700
|
The functions included in `@kmamal/sdl/helpers` are:
|
|
2688
2701
|
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
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)
|
|
2696
2708
|
|
|
2697
2709
|
## Building from source
|
|
2698
2710
|
|
|
@@ -2714,11 +2726,11 @@ You need to have `cmake` installed for that to work.
|
|
|
2714
2726
|
You could also have found your way to the "Building from source" section because you are trying to contribute to this package.
|
|
2715
2727
|
There are some npm scripts in `package.json` that could be of use to you:
|
|
2716
2728
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
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.
|
|
2722
2734
|
|
|
2723
2735
|
The SDL headers and libs get downloaded to `sdl/`, the build happens in `build/`, and the final binaries get collected into `dist/`.
|
|
2724
2736
|
|