code wiki / (root) / nx_input_abstract.nx

nx_input_abstract.nx

buildroot/runtime/nx_input_abstract.nx

9983 B235 linesdepth 3pulls 3 transitivereach 143 importersview sourcekind librarytopic input
docsdependenciesstructsconstsfunctions

about

nx_input_abstract.nx -- SOVEREIGN device-agnostic input core (F1102, game-platform lane). ONE semantic action state (up/down/left/right/A/B/menu/pause) driven by FOUR sources -- keyboard, gamepad buttons, gamepad axes, touch -- so a game loop reads ACTIONS, never devices. This moves the key->meaning mapping OUT of the JS shim and INTO the sovereign organ (the shim stays pure transport), and it is the enabler for platform-desktop-native (F1105) and vr-runtime (F1106): a VR controller surfaces as gamepad buttons/axes (WebXR gamepad), so it enters through the SAME ia_pad/ia_axis doors. Base-relative + integer-only + no syscalls CALLED (imports only for consts/compose) => the identical code runs natively (base=mmap) and in wasm (base=0), like nx_wasm_breeders. Per-source held masks are kept SEPARATE and unioned on read, so releasing a key can never eat a gamepad hold (the classic cross-device release bug -- gate tooth T4). Edge detection lives here too: ia_frame() returns the RISING edge, so "interact fires every frame while held" cannot recur (T2). Bindings are DATA rows (code,action) seeded by ia_init and rewritable at runtime via ia_bind (T6). Touch composes the EXISTING nx_touch_zone SSOT (virtual d-pad -> legacy keycode) then routes the code through the SAME binding table, so touch inherits rebinds for free. license_tier: ORIGINAL

dependencies 2 imports · 34 importers

nx_syscalls.nx nx_game_touch.nx nx_input_abstract.nx nx_craft_before_placement_t316.nx nx_desktop_game.nx nx_input_abstract_gate.nx nx_input_alias_regression_t121.nx nx_movement_base_engine_t139.nx nx_wasm_breeders.nx nx_wasm_craft.nx nx_wasm_craft_body_t137.nx nx_wasm_craft_contact_candidate.nx nx_wasm_craft_dunes_t70.nx

diagram shows first 10 each side; +0 more imports, +24 more importers in the complete lists below.

imports: nx_syscalls.nxnx_game_touch.nx

imported by: nx_craft_before_placement_t316.nxnx_desktop_game.nxnx_input_abstract_gate.nxnx_input_alias_regression_t121.nxnx_movement_base_engine_t139.nxnx_wasm_breeders.nxnx_wasm_craft.nxnx_wasm_craft_body_t137.nxnx_wasm_craft_contact_candidate.nxnx_wasm_craft_dunes_t70.nxnx_wasm_craft_gait_candidate.nxnx_wasm_craft_gait_candidate_t139.nxnx_wasm_craft_imported_body_t41.nxnx_wasm_craft_imported_body_t42.nxnx_wasm_craft_imported_body_t49.nxnx_wasm_craft_imported_t262.nxnx_wasm_craft_inspection_bounds_t181.nxnx_wasm_craft_inspection_distance_t218.nxnx_wasm_craft_inspection_t142.nxnx_wasm_craft_journal_index_t21.nxnx_wasm_craft_journal_index_t21_before_t44.nxnx_wasm_craft_lookup_candidate.nxnx_wasm_craft_move_t72.nxnx_wasm_craft_pre_inspection_t142.nxnx_wasm_craft_recovery_t20.nxnx_wasm_craft_relief_adopt_t143.nxnx_wasm_craft_relief_save_t143.nxnx_wasm_craft_relief_t143.nxnx_wasm_craft_residency_t44.nxnx_wasm_craft_turn_candidate_t139.nxnx_wasm_craft_visitors_canonical_t142.nxnx_wasm_craft_visitors_inspection_t142.nxnx_wasm_craft_visitors_t140.nxnx_wire_diablo2_gate.nx

structs

none

consts

23const IA_UP: i64 = 1
24const IA_DOWN: i64 = 2
25const IA_LEFT: i64 = 4
26const IA_RIGHT: i64 = 8
27const IA_A: i64 = 16
28const IA_B: i64 = 32
29const IA_MENU: i64 = 64
30const IA_PAUSE: i64 = 128
31const IA_JUMP: i64 = 256
32const IA_LUP: i64 = 512 // look up (keyboard pitch fallback)
33const IA_LDOWN: i64 = 1024 // look down
34const IA_MOD: i64 = 2048 // spare modifier
35const IA_HOME: i64 = 4096 // return-to-spawn (void-fall rescue)
38const IA_KB: i64 = 0 // keyboard-held action mask
39const IA_PAD: i64 = 1 // gamepad-button-held action mask
40const IA_AX: i64 = 2 // gamepad-axis-derived action mask (hysteresis state)
41const IA_TOUCH: i64 = 3 // touch-held action mask
42const IA_PREV: i64 = 4 // union mask latched by the previous ia_frame (edge detector)
43const IA_AXX: i64 = 5 // last raw x axis, milli (-1000..1000)
44const IA_AXY: i64 = 6 // last raw y axis, milli (+ = down, browser gamepad convention)
45const IA_NBIND: i64 = 7 // live binding rows
46const IA_BROW0: i64 = 8 // rows begin: (code, action) pairs
47const IA_MAXBIND: i64 = 24
48const IA_LOOKX: i64 = 56 // analog LOOK channel: accumulated relative deltas (mouse/touch-drag),
49const IA_LOOKY: i64 = 57 // drained once per frame by ia_look_take -- actions are bits, look is motion
50const IA_KEYROWS: i64 = 58 // physical keyboard holds by binding row; uses reserved arena slack
51const IA_LOOK_CLAMP: i64 = 30000
52const IA_WORDS: i64 = 64 // 8 + 2*24 = 56 bind area, +2 look, rounded up for slack
55const IA_TH_PRESS: i64 = 350
56const IA_TH_HOLD: i64 = 250

functions

58func ia_words() -> i64 { return IA_WORDS }
called by 1: main
61func ia_lookup(p: *i64, code: i64) -> i64
called by 1: ia_touch
72func ia_keyboard_union(p: *i64) -> i64
called by 2: ia_bindia_key
84func ia_bind(p: *i64, code: i64, act: i64) -> i64
110func ia_init(p: *i64) -> i64
130func ia_key(p: *i64, code: i64, down: i64) -> i64
148func ia_pad_decode(btn: i64) -> i64
called by 1: ia_pad
160func ia_pad(p: *i64, btn: i64, down: i64) -> i64
169func ia_ax1(active: i64, v: i64) -> i64
called by 1: ia_axis
177func ia_axis(p: *i64, idx: i64, milli: i64) -> i64
called by 2: seqmain calls 1: ia_ax1
192func ia_touch(p: *i64, tx: i64, ty: i64, w: i64, h: i64, down: i64) -> i64
called by 2: seqmain calls 2: nx_touch_zoneia_lookup
200func ia_held(p: *i64) -> i64
206func ia_frame(p: *i64) -> i64
called by 3: seqmainmain calls 1: ia_held
215func ia_look(p: *i64, dx: i64, dy: i64) -> i64
called by 2: dg_dispatch2main
229func ia_look_take(p: *i64, out: *i64) -> i64
called by 1: main