Skip to main content

gasm/
sys.rs

1//! Raw ABI. On wasm32 these are the real imports (see spec/ABI.md). On other
2//! targets they are backed by [`crate::native`], an in-process stub host used
3//! for native parity tests and benchmarks.
4//!
5//! GENERATED from spec/abi.json by scripts/gen-abi.mjs. Do not edit by hand.
6
7#![allow(clippy::missing_safety_doc)]
8
9#[cfg(target_arch = "wasm32")]
10mod imports {
11    #[link(wasm_import_module = "gasm")]
12    unsafe extern "C" {
13        /// Write a line to the runner's log.
14        pub fn log(msg: *const u8, msg_len: u32);
15        /// 1 if the runner provides an import module ("gasm:gfx") or a function in one ("gasm.asset_size64", "gasm:gfx.destroy"), else 0. Calling an import the runner lacks traps, so probe optional features first.
16        pub fn has(name: *const u8, name_len: u32) -> i32;
17        /// Monotonic time in milliseconds (virtual, frame-derived in headless runs).
18        pub fn time_ms() -> f64;
19        /// Rate (Hz) at which the runner calls gasm_frame(). Default 60; 1-1000.
20        pub fn set_frame_rate(hz: f64);
21        /// Present RGBA8 pixels (bytes R,G,B,A), stride bytes per row, w,h <= 4096. Copied before returning; letterboxed by the runner.
22        pub fn video_present(rgba: *const u8, width: u32, height: u32, stride: u32);
23        /// Show video_present frames at display aspect num:den (4:3 for 320x200 DOS games) instead of square pixels; 0:0 resets. Both 1..65535 with 1/8 <= num/den <= 8, else traps. Display and the pointer frame position only (not hashed). Newer than has: probe has("gasm.video_set_aspect") first.
24        pub fn video_set_aspect(num: u32, den: u32);
25        /// Format for audio_push: 8-192 kHz, 1 or 2 channels. Default 44100/2.
26        pub fn audio_config(sample_rate: u32, channels: u32);
27        /// Queue frames x channels interleaved f32 samples in [-1, 1]; the runner resamples.
28        pub fn audio_push(samples: *const f32, frames: u32);
29        /// Bitmask of GASM_BTN_* held on virtual pad player (0..3), stable within a frame.
30        pub fn input_pad(player: u32) -> u32;
31        /// UTF-8 text typed since the previous frame (backspace = \b, enter = \n), stable within a frame. Returns its length (copied only if length <= cap; cap = 0 queries), or -1 if the runner has no keyboard.
32        pub fn text_input(dst: *mut u8, cap: u32) -> i32;
33        /// GASM_INPUT_* flags: KEYS_RAW (the runner stops mapping the keyboard to pads; gamepads still map), POINTER_HIDDEN (hide the system cursor over the game), POINTER_LOCKED (capture the pointer for relative motion; best effort, the browser needs a click).
34        pub fn input_mode(flags: u32);
35        /// Held keys as a bitset indexed by GASM_KEY_* (bit k%8 of byte k/8), stable within a frame. Copies min(len, GASM_KEY_STATE_BYTES) bytes; returns GASM_KEY_STATE_BYTES, or -1 if the runner has no keyboard.
36        pub fn key_state(dst: *mut u8, len: u32) -> i32;
37        /// Key presses and releases since the previous frame, in order: 4 bytes each (u16 GASM_KEY_* code, u8 1 = down / 0 = up, u8 0). Returns the byte length (copied only if <= cap; cap = 0 queries), or -1 if the runner has no keyboard.
38        pub fn key_events(dst: *mut u8, cap: u32) -> i32;
39        /// Mouse/touch state for this frame as GASM_POINTER_BYTES bytes (see ABI.md: position in drawable and frame pixels, relative motion, wheel, buttons held/pressed/released, flags). Copied only if cap is large enough; returns GASM_POINTER_BYTES, or -1 if the runner has no pointer.
40        pub fn pointer(dst: *mut u8, cap: u32) -> i32;
41        /// Raw gamepad/joystick in slot 0-3 (connection order) as GASM_GAMEPAD_BYTES bytes: u32 flags (GASM_GAMEPAD_CONNECTED, GASM_GAMEPAD_STANDARD), u32 button count, u32 axis count, f32 buttons[32] (0-1), f32 axes[16] (-1..1). Standard mapping: W3C button and axis order. Copied only if cap is large enough; returns GASM_GAMEPAD_BYTES, or -1 if slot > 3 or the runner has no gamepad support.
42        pub fn gamepad(slot: u32, dst: *mut u8, cap: u32) -> i32;
43        /// Device name of the gamepad in slot: its length (copied only if <= cap), or -1 if the slot is empty.
44        pub fn gamepad_name(slot: u32, dst: *mut u8, cap: u32) -> i32;
45        /// Size in bytes of asset name, -1 if it does not exist, or -2 if it is 2 GiB or larger (use asset_size64).
46        pub fn asset_size(name: *const u8, name_len: u32) -> i32;
47        /// Size in bytes of asset name (any size), or -1 if it does not exist.
48        pub fn asset_size64(name: *const u8, name_len: u32) -> i64;
49        /// Copy up to cap bytes of asset name into dst. Bytes copied, or -1 if missing.
50        pub fn asset_read(name: *const u8, name_len: u32, dst: *mut u8, cap: u32) -> i32;
51        /// Copy up to len bytes of asset name starting at offset (streaming). Bytes copied (0 at the end), or -1 if missing.
52        pub fn asset_read_at(name: *const u8, name_len: u32, offset: u32, dst: *mut u8, len: u32) -> i32;
53        /// asset_read_at with a 64-bit offset, for assets of 4 GiB and more.
54        pub fn asset_read_at64(name: *const u8, name_len: u32, offset: u64, dst: *mut u8, len: u32) -> i32;
55        /// Number of assets.
56        pub fn asset_count() -> u32;
57        /// Name of asset index (0 .. asset_count-1, sorted by UTF-8 bytes; folder entries as named on disk). Its length (copied only if length <= cap; cap = 0 queries), or -1 if index is out of range.
58        pub fn asset_name(index: u32, dst: *mut u8, cap: u32) -> i32;
59        /// Launch parameter value length, or -1 if unset. Copied only if length <= cap (cap = 0 queries the length).
60        pub fn param(name: *const u8, name_len: u32, dst: *mut u8, cap: u32) -> i32;
61        /// Name the game's window or tab (the runner adds its own suffix). Control characters and bidi overrides are removed and the rest is cut to 256 bytes; empty resets to the default. Newer than has: probe has("gasm.set_title") first.
62        pub fn set_title(title: *const u8, title_len: u32);
63    }
64
65    #[link(wasm_import_module = "gasm:gfx")]
66    unsafe extern "C" {
67        /// Current drawable width in pixels.
68        #[link_name = "width"]
69        pub fn gfx_width() -> u32;
70        /// Current drawable height in pixels.
71        #[link_name = "height"]
72        pub fn gfx_height() -> u32;
73        /// Compile WGSL source.
74        #[link_name = "create_shader"]
75        pub fn gfx_create_shader(wgsl: *const u8, wgsl_len: u32) -> u32;
76        /// size: non-zero multiple of 4; usage: GASM_BUF_* (WebGPU GPUBufferUsage bits; COPY_DST always added).
77        #[link_name = "create_buffer"]
78        pub fn gfx_create_buffer(size: u32, usage: u32) -> u32;
79        /// GPURenderPipelineDescriptor as JSON. layout: "auto" (default) or an array of bind group layout handles.
80        #[link_name = "create_pipeline"]
81        pub fn gfx_create_pipeline(json: *const u8, json_len: u32) -> u32;
82        /// {"layout":L,"entries":[...]} or {"pipeline":P,"group":G,"entries":[...]}; entries {"binding":B,"buffer":H,"offset":O,"size":S}, {"binding":B,"texture":T} or {"binding":B,"sampler":S}.
83        #[link_name = "create_bind_group"]
84        pub fn gfx_create_bind_group(json: *const u8, json_len: u32) -> u32;
85        /// GPUBindGroupLayoutDescriptor subset: {"entries":[{"binding":B,"visibility":GASM_STAGE_*,"buffer":{"type":"uniform"|"read-only-storage","hasDynamicOffset":bool,"minBindingSize":N} | "texture":{"sampleType":"float"|"unfilterable-float","viewDimension":"2d"} | "sampler":{"type":"filtering"|"non-filtering"}}]}.
86        #[link_name = "create_bind_group_layout"]
87        pub fn gfx_create_bind_group_layout(json: *const u8, json_len: u32) -> u32;
88        /// 2D texture: {"size":[w,h],"format":"rgba8unorm"|"rgba8unorm-srgb","mipLevelCount":n}, w,h 1-8192. Usage is TEXTURE_BINDING | COPY_DST.
89        #[link_name = "create_texture"]
90        pub fn gfx_create_texture(json: *const u8, json_len: u32) -> u32;
91        /// Upload a tightly packed RGBA8 region (len = width*height*4) of mip level mip at (x, y). Queued like write_buffer.
92        #[link_name = "write_texture"]
93        pub fn gfx_write_texture(texture: u32, mip: u32, x: u32, y: u32, width: u32, height: u32, data: *const u8, len: u32);
94        /// GPUSamplerDescriptor subset: addressModeU/V, magFilter, minFilter, mipmapFilter, lodMinClamp, lodMaxClamp, maxAnisotropy (1-16).
95        #[link_name = "create_sampler"]
96        pub fn gfx_create_sampler(json: *const u8, json_len: u32) -> u32;
97        /// Queue a write, applied before the frame's draws. offset/len: multiples of 4.
98        #[link_name = "write_buffer"]
99        pub fn gfx_write_buffer(buffer: u32, offset: u32, data: *const u8, len: u32);
100        /// Start the frame (clears color and depth). 1 = will be shown, 0 = discarded (the guest may skip draws).
101        #[link_name = "begin_frame"]
102        pub fn gfx_begin_frame(r: f32, g: f32, b: f32, a: f32) -> u32;
103        #[link_name = "set_pipeline"]
104        pub fn gfx_set_pipeline(pipeline: u32);
105        #[link_name = "set_bind_group"]
106        pub fn gfx_set_bind_group(index: u32, bind_group: u32);
107        /// set_bind_group with count dynamic offsets (multiples of 256), one per dynamic-offset entry of the layout, in binding order.
108        #[link_name = "set_bind_group_offsets"]
109        pub fn gfx_set_bind_group_offsets(index: u32, bind_group: u32, offsets: *const u32, count: u32);
110        /// Viewport in drawable pixels (clamped to the drawable), depth range 0-1. Reset to the whole drawable by begin_frame.
111        #[link_name = "set_viewport"]
112        pub fn gfx_set_viewport(x: f32, y: f32, width: f32, height: f32, min_depth: f32, max_depth: f32);
113        /// Scissor rectangle in drawable pixels (clamped to the drawable). Reset to the whole drawable by begin_frame.
114        #[link_name = "set_scissor_rect"]
115        pub fn gfx_set_scissor_rect(x: u32, y: u32, width: u32, height: u32);
116        /// slot 0-7; buffer with GASM_BUF_VERTEX; offset a multiple of 4, at most the buffer size.
117        #[link_name = "set_vertex_buffer"]
118        pub fn gfx_set_vertex_buffer(slot: u32, buffer: u32, offset: u32);
119        /// buffer with GASM_BUF_INDEX; format GASM_INDEX_U16 or GASM_INDEX_U32 (anything else traps); offset a multiple of the index size, at most the buffer size.
120        #[link_name = "set_index_buffer"]
121        pub fn gfx_set_index_buffer(buffer: u32, format: u32, offset: u32);
122        /// Needs a pipeline, and a vertex buffer in every slot the pipeline reads, large enough for the vertices and instances drawn (else traps).
123        #[link_name = "draw"]
124        pub fn gfx_draw(vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32);
125        /// Like draw, plus an index buffer holding first_index + index_count indices.
126        #[link_name = "draw_indexed"]
127        pub fn gfx_draw_indexed(index_count: u32, instance_count: u32, first_index: u32, base_vertex: i32, first_instance: u32);
128        /// Submit and present.
129        #[link_name = "end_frame"]
130        pub fn gfx_end_frame();
131        /// Release an object of any kind. The handle becomes invalid (later use, including another destroy, traps) and is never reused; objects created from it stay valid. GPU memory is freed once nothing in a submitted frame uses it.
132        #[link_name = "destroy"]
133        pub fn gfx_destroy(handle: u32);
134    }
135
136    #[link(wasm_import_module = "gasm:net")]
137    unsafe extern "C" {
138        /// Open a ws:// or wss:// URL. Handle > 0, or -1 if denied/invalid.
139        #[link_name = "open"]
140        pub fn net_open(url: *const u8, url_len: u32) -> i32;
141        /// GASM_NET_CONNECTING / OPEN / CLOSED / ERROR.
142        #[link_name = "state"]
143        pub fn net_state(conn: i32) -> u32;
144        /// Send one message (len > 0). 0, or -1 if not open.
145        #[link_name = "send"]
146        pub fn net_send(conn: i32, data: *const u8, len: u32) -> i32;
147        /// Next message's length (copied only if <= cap, else it stays queued), 0 if none, -1 if closed and drained.
148        #[link_name = "recv"]
149        pub fn net_recv(conn: i32, dst: *mut u8, cap: u32) -> i32;
150        /// Close (flushing queued messages); closing again does nothing.
151        #[link_name = "close"]
152        pub fn net_close(conn: i32);
153    }
154
155    #[link(wasm_import_module = "gasm:storage")]
156    unsafe extern "C" {
157        /// Value length, or -1 if missing. Copied only if length <= cap.
158        #[link_name = "get"]
159        pub fn storage_get(key: *const u8, key_len: u32, dst: *mut u8, cap: u32) -> i32;
160        /// 0, or a GASM_STORAGE_ERR_* code: invalid key, value too large, quota exceeded, I/O error.
161        #[link_name = "set"]
162        pub fn storage_set(key: *const u8, key_len: u32, data: *const u8, len: u32) -> i32;
163        /// 0 if deleted, -1 if it did not exist.
164        #[link_name = "delete"]
165        pub fn storage_delete(key: *const u8, key_len: u32) -> i32;
166        /// Number of keys in the namespace.
167        #[link_name = "count"]
168        pub fn storage_count() -> u32;
169        /// Key index (0 .. count-1, sorted): its length (copied only if <= cap; cap = 0 queries), or -1 if out of range.
170        #[link_name = "key"]
171        pub fn storage_key(index: u32, dst: *mut u8, cap: u32) -> i32;
172    }
173
174    #[link(wasm_import_module = "wasi_snapshot_preview1")]
175    unsafe extern "C" {
176        /// End the game; 0 is a normal exit.
177        pub fn proc_exit(code: i32) -> !;
178    }
179}
180
181#[cfg(target_arch = "wasm32")]
182pub use imports::*;
183
184#[cfg(not(target_arch = "wasm32"))]
185pub use crate::native::abi::*;
186
187/// Every import module and `module.function` of this ABI version (what `gasm::has` can report).
188pub const IMPORTS: [&str; 64] = [
189    "gasm", "gasm.log", "gasm.has", "gasm.time_ms",
190    "gasm.set_frame_rate", "gasm.video_present", "gasm.video_set_aspect", "gasm.audio_config",
191    "gasm.audio_push", "gasm.input_pad", "gasm.text_input", "gasm.input_mode",
192    "gasm.key_state", "gasm.key_events", "gasm.pointer", "gasm.gamepad",
193    "gasm.gamepad_name", "gasm.asset_size", "gasm.asset_size64", "gasm.asset_read",
194    "gasm.asset_read_at", "gasm.asset_read_at64", "gasm.asset_count", "gasm.asset_name",
195    "gasm.param", "gasm.set_title", "gasm:gfx", "gasm:gfx.width",
196    "gasm:gfx.height", "gasm:gfx.create_shader", "gasm:gfx.create_buffer", "gasm:gfx.create_pipeline",
197    "gasm:gfx.create_bind_group", "gasm:gfx.create_bind_group_layout", "gasm:gfx.create_texture", "gasm:gfx.write_texture",
198    "gasm:gfx.create_sampler", "gasm:gfx.write_buffer", "gasm:gfx.begin_frame", "gasm:gfx.set_pipeline",
199    "gasm:gfx.set_bind_group", "gasm:gfx.set_bind_group_offsets", "gasm:gfx.set_viewport", "gasm:gfx.set_scissor_rect",
200    "gasm:gfx.set_vertex_buffer", "gasm:gfx.set_index_buffer", "gasm:gfx.draw", "gasm:gfx.draw_indexed",
201    "gasm:gfx.end_frame", "gasm:gfx.destroy", "gasm:net", "gasm:net.open",
202    "gasm:net.state", "gasm:net.send", "gasm:net.recv", "gasm:net.close",
203    "gasm:storage", "gasm:storage.get", "gasm:storage.set", "gasm:storage.delete",
204    "gasm:storage.count", "gasm:storage.key", "wasi_snapshot_preview1", "wasi_snapshot_preview1.proc_exit",
205];
206
207// ---- buttons
208/// Virtual gamepad buttons (bit positions). Face buttons by position: East=A, South=B, North=X, West=Y.
209pub const GASM_BTN_A: u32 = 1 << 0;
210pub const GASM_BTN_B: u32 = 1 << 1;
211pub const GASM_BTN_X: u32 = 1 << 2;
212pub const GASM_BTN_Y: u32 = 1 << 3;
213pub const GASM_BTN_L: u32 = 1 << 4;
214pub const GASM_BTN_R: u32 = 1 << 5;
215pub const GASM_BTN_SELECT: u32 = 1 << 6;
216pub const GASM_BTN_START: u32 = 1 << 7;
217pub const GASM_BTN_UP: u32 = 1 << 8;
218pub const GASM_BTN_DOWN: u32 = 1 << 9;
219pub const GASM_BTN_LEFT: u32 = 1 << 10;
220pub const GASM_BTN_RIGHT: u32 = 1 << 11;
221
222// ---- buffer usage
223pub const GASM_BUF_COPY_DST: u32 = 0x08;
224pub const GASM_BUF_INDEX: u32 = 0x10;
225pub const GASM_BUF_VERTEX: u32 = 0x20;
226pub const GASM_BUF_UNIFORM: u32 = 0x40;
227pub const GASM_BUF_STORAGE: u32 = 0x80;
228
229// ---- shader stages
230/// Bind group layout entry visibility (WebGPU GPUShaderStage bits).
231pub const GASM_STAGE_VERTEX: u32 = 0x1;
232pub const GASM_STAGE_FRAGMENT: u32 = 0x2;
233
234// ---- index formats
235pub const GASM_INDEX_U16: u32 = 0;
236pub const GASM_INDEX_U32: u32 = 1;
237
238// ---- net states
239pub const GASM_NET_CONNECTING: u32 = 0;
240pub const GASM_NET_OPEN: u32 = 1;
241pub const GASM_NET_CLOSED: u32 = 2;
242pub const GASM_NET_ERROR: u32 = 3;
243
244// ---- input modes
245/// input_mode flags.
246pub const GASM_INPUT_KEYS_RAW: u32 = 1 << 0;
247pub const GASM_INPUT_POINTER_HIDDEN: u32 = 1 << 1;
248pub const GASM_INPUT_POINTER_LOCKED: u32 = 1 << 2;
249
250// ---- storage errors
251/// gasm_storage_set results.
252pub const GASM_STORAGE_OK: i32 = 0;
253pub const GASM_STORAGE_ERR_KEY: i32 = -1;
254pub const GASM_STORAGE_ERR_SIZE: i32 = -2;
255pub const GASM_STORAGE_ERR_QUOTA: i32 = -3;
256pub const GASM_STORAGE_ERR_IO: i32 = -4;
257
258// ---- pointer
259/// pointer() layout and bits: little-endian fields at the GASM_POINTER_OFF_* byte offsets: f32 x, y (drawable px), fx, fy (frame px), dx, dy (relative motion), wheel_x, wheel_y (lines; y > 0 = down), u32 buttons, pressed, released, flags.
260pub const GASM_POINTER_BYTES: u32 = 48;
261pub const GASM_POINTER_OFF_X: u32 = 0;
262pub const GASM_POINTER_OFF_Y: u32 = 4;
263pub const GASM_POINTER_OFF_FX: u32 = 8;
264pub const GASM_POINTER_OFF_FY: u32 = 12;
265pub const GASM_POINTER_OFF_DX: u32 = 16;
266pub const GASM_POINTER_OFF_DY: u32 = 20;
267pub const GASM_POINTER_OFF_WHEEL_X: u32 = 24;
268pub const GASM_POINTER_OFF_WHEEL_Y: u32 = 28;
269pub const GASM_POINTER_OFF_BUTTONS: u32 = 32;
270pub const GASM_POINTER_OFF_PRESSED: u32 = 36;
271pub const GASM_POINTER_OFF_RELEASED: u32 = 40;
272pub const GASM_POINTER_OFF_FLAGS: u32 = 44;
273pub const GASM_MOUSE_LEFT: u32 = 1 << 0;
274pub const GASM_MOUSE_RIGHT: u32 = 1 << 1;
275pub const GASM_MOUSE_MIDDLE: u32 = 1 << 2;
276pub const GASM_MOUSE_BACK: u32 = 1 << 3;
277pub const GASM_MOUSE_FORWARD: u32 = 1 << 4;
278pub const GASM_POINTER_INSIDE: u32 = 1 << 0;
279pub const GASM_POINTER_IS_HIDDEN: u32 = 1 << 1;
280pub const GASM_POINTER_IS_LOCKED: u32 = 1 << 2;
281
282// ---- gamepad
283/// gamepad() layout: little-endian fields at the GASM_GAMEPAD_OFF_* byte offsets: u32 flags, u32 button count, u32 axis count, f32 button values (32), f32 axis values (16). Standard mapping (W3C): buttons 0 south, 1 east, 2 west, 3 north, 4/5 shoulders, 6/7 triggers, 8 select, 9 start, 10/11 stick clicks, 12-15 d-pad up/down/left/right, 16 home; axes 0/1 left stick x/y, 2/3 right stick x/y (y > 0 = down).
284pub const GASM_GAMEPAD_BYTES: u32 = 204;
285pub const GASM_GAMEPAD_BUTTONS: u32 = 32;
286pub const GASM_GAMEPAD_AXES: u32 = 16;
287pub const GASM_GAMEPAD_OFF_FLAGS: u32 = 0;
288pub const GASM_GAMEPAD_OFF_BUTTON_COUNT: u32 = 4;
289pub const GASM_GAMEPAD_OFF_AXIS_COUNT: u32 = 8;
290pub const GASM_GAMEPAD_OFF_BUTTONS: u32 = 12;
291pub const GASM_GAMEPAD_OFF_AXES: u32 = 140;
292pub const GASM_GAMEPAD_CONNECTED: u32 = 1 << 0;
293pub const GASM_GAMEPAD_STANDARD: u32 = 1 << 1;
294
295// ---- keyboard
296/// key_state() size, and the size of one key_events() record.
297pub const GASM_KEY_STATE_BYTES: u32 = 32;
298pub const GASM_KEY_EVENT_BYTES: u32 = 4;
299
300/// Physical keys (W3C KeyboardEvent.code names; layout-independent). The third column is the W3C name.
301pub mod keys {
302    pub const ESCAPE: u32 = 1;
303    pub const F1: u32 = 2;
304    pub const F2: u32 = 3;
305    pub const F3: u32 = 4;
306    pub const F4: u32 = 5;
307    pub const F5: u32 = 6;
308    pub const F6: u32 = 7;
309    pub const F7: u32 = 8;
310    pub const F8: u32 = 9;
311    pub const F9: u32 = 10;
312    pub const F10: u32 = 11;
313    pub const F11: u32 = 12;
314    pub const F12: u32 = 13;
315    pub const BACKQUOTE: u32 = 14;
316    pub const DIGIT0: u32 = 15;
317    pub const DIGIT1: u32 = 16;
318    pub const DIGIT2: u32 = 17;
319    pub const DIGIT3: u32 = 18;
320    pub const DIGIT4: u32 = 19;
321    pub const DIGIT5: u32 = 20;
322    pub const DIGIT6: u32 = 21;
323    pub const DIGIT7: u32 = 22;
324    pub const DIGIT8: u32 = 23;
325    pub const DIGIT9: u32 = 24;
326    pub const MINUS: u32 = 25;
327    pub const EQUAL: u32 = 26;
328    pub const BACKSPACE: u32 = 27;
329    pub const TAB: u32 = 28;
330    pub const KEY_A: u32 = 29;
331    pub const KEY_B: u32 = 30;
332    pub const KEY_C: u32 = 31;
333    pub const KEY_D: u32 = 32;
334    pub const KEY_E: u32 = 33;
335    pub const KEY_F: u32 = 34;
336    pub const KEY_G: u32 = 35;
337    pub const KEY_H: u32 = 36;
338    pub const KEY_I: u32 = 37;
339    pub const KEY_J: u32 = 38;
340    pub const KEY_K: u32 = 39;
341    pub const KEY_L: u32 = 40;
342    pub const KEY_M: u32 = 41;
343    pub const KEY_N: u32 = 42;
344    pub const KEY_O: u32 = 43;
345    pub const KEY_P: u32 = 44;
346    pub const KEY_Q: u32 = 45;
347    pub const KEY_R: u32 = 46;
348    pub const KEY_S: u32 = 47;
349    pub const KEY_T: u32 = 48;
350    pub const KEY_U: u32 = 49;
351    pub const KEY_V: u32 = 50;
352    pub const KEY_W: u32 = 51;
353    pub const KEY_X: u32 = 52;
354    pub const KEY_Y: u32 = 53;
355    pub const KEY_Z: u32 = 54;
356    pub const BRACKET_LEFT: u32 = 55;
357    pub const BRACKET_RIGHT: u32 = 56;
358    pub const BACKSLASH: u32 = 57;
359    pub const CAPS_LOCK: u32 = 58;
360    pub const SEMICOLON: u32 = 59;
361    pub const QUOTE: u32 = 60;
362    pub const ENTER: u32 = 61;
363    pub const SHIFT_LEFT: u32 = 62;
364    pub const INTL_BACKSLASH: u32 = 63;
365    pub const COMMA: u32 = 64;
366    pub const PERIOD: u32 = 65;
367    pub const SLASH: u32 = 66;
368    pub const SHIFT_RIGHT: u32 = 67;
369    pub const CONTROL_LEFT: u32 = 68;
370    pub const META_LEFT: u32 = 69;
371    pub const ALT_LEFT: u32 = 70;
372    pub const SPACE: u32 = 71;
373    pub const ALT_RIGHT: u32 = 72;
374    pub const META_RIGHT: u32 = 73;
375    pub const CONTEXT_MENU: u32 = 74;
376    pub const CONTROL_RIGHT: u32 = 75;
377    pub const PRINT_SCREEN: u32 = 76;
378    pub const SCROLL_LOCK: u32 = 77;
379    pub const PAUSE: u32 = 78;
380    pub const INSERT: u32 = 79;
381    pub const HOME: u32 = 80;
382    pub const PAGE_UP: u32 = 81;
383    pub const DELETE: u32 = 82;
384    pub const END: u32 = 83;
385    pub const PAGE_DOWN: u32 = 84;
386    pub const ARROW_UP: u32 = 85;
387    pub const ARROW_LEFT: u32 = 86;
388    pub const ARROW_DOWN: u32 = 87;
389    pub const ARROW_RIGHT: u32 = 88;
390    pub const NUM_LOCK: u32 = 89;
391    pub const NUMPAD_DIVIDE: u32 = 90;
392    pub const NUMPAD_MULTIPLY: u32 = 91;
393    pub const NUMPAD_SUBTRACT: u32 = 92;
394    pub const NUMPAD_ADD: u32 = 93;
395    pub const NUMPAD_ENTER: u32 = 94;
396    pub const NUMPAD_DECIMAL: u32 = 95;
397    pub const NUMPAD0: u32 = 96;
398    pub const NUMPAD1: u32 = 97;
399    pub const NUMPAD2: u32 = 98;
400    pub const NUMPAD3: u32 = 99;
401    pub const NUMPAD4: u32 = 100;
402    pub const NUMPAD5: u32 = 101;
403    pub const NUMPAD6: u32 = 102;
404    pub const NUMPAD7: u32 = 103;
405    pub const NUMPAD8: u32 = 104;
406    pub const NUMPAD9: u32 = 105;
407    pub const NUMPAD_EQUAL: u32 = 106;
408    pub const NUMPAD_COMMA: u32 = 107;
409    pub const INTL_RO: u32 = 108;
410    pub const INTL_YEN: u32 = 109;
411    pub const F13: u32 = 110;
412    pub const F14: u32 = 111;
413    pub const F15: u32 = 112;
414    pub const F16: u32 = 113;
415    pub const F17: u32 = 114;
416    pub const F18: u32 = 115;
417    pub const F19: u32 = 116;
418    pub const F20: u32 = 117;
419    pub const F21: u32 = 118;
420    pub const F22: u32 = 119;
421    pub const F23: u32 = 120;
422    pub const F24: u32 = 121;
423    /// W3C names by code (index 0 is unused).
424    pub const NAMES: [&str; 122] = [
425        "", "Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Backquote", "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "Minus", "Equal", "Backspace", "Tab", "KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ", "BracketLeft", "BracketRight", "Backslash", "CapsLock", "Semicolon", "Quote", "Enter", "ShiftLeft", "IntlBackslash", "Comma", "Period", "Slash", "ShiftRight", "ControlLeft", "MetaLeft", "AltLeft", "Space", "AltRight", "MetaRight", "ContextMenu", "ControlRight", "PrintScreen", "ScrollLock", "Pause", "Insert", "Home", "PageUp", "Delete", "End", "PageDown", "ArrowUp", "ArrowLeft", "ArrowDown", "ArrowRight", "NumLock", "NumpadDivide", "NumpadMultiply", "NumpadSubtract", "NumpadAdd", "NumpadEnter", "NumpadDecimal", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadEqual", "NumpadComma", "IntlRo", "IntlYen", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24",
426    ];
427}