42c14fae59
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.0 KiB
2.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, example, tested, tests, test_file_path, file_path, params, output
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | example | tested | tests | test_file_path | file_path | params | output | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| input_unified | function | cpp | gamedev | 0.1.0 | impure | input_begin_frame(InputState&); input_process_event(InputState&, const SDL_Event*) | Snapshot unificado de input por frame para SDL3. Mapea keyboard (WASD+arrows), mouse, gamepad (SDL_Gamepad) y touch a botones logicos (left/right/up/down/action_a..y/start/back) y ejes analogicos. Expone flags *_pressed con rising edge limpio cada frame. Issue 0072b — runtime gamedev PC + WASM. |
|
false | error_go_core | fn::input::InputState input{}; // per frame: fn::input::input_begin_frame(input); SDL_Event e; while (SDL_PollEvent(&e)) { fn::input::input_process_event(input, &e); } if (input.a_pressed) jump(); player.x += input.lx * speed * dt; | false | cpp/functions/gamedev/input_unified.cpp |
|
Mutaciones in-place sobre InputState. Sin retorno. Sin asignaciones dinamicas. |
input_unified
Capa fina sobre SDL3 que normaliza todas las fuentes de input a un struct plano consultable cada frame. Sirve como fundacion para apps gamedev del registry (issue 0072b) y para tests headless.
Reglas de uso:
input_begin_framese llama UNA vez por frame antes de bombear eventos. Limpia los flags*_pressed(rising edge), no los*held.input_process_eventse llama por cadaSDL_Eventrecibido. Acumula state hasta que el siguientebegin_frameresetee edges.- Stick deadzone fijo a 0.15 — si la app necesita custom, reescribir snapshot tras la lectura.
- Touch ids estables mientras el dedo este pressed; al soltar se compacta el array.
- Gamepads conectados se abren automaticamente en
SDL_EVENT_GAMEPAD_ADDED.