module
Lapis::Docs::C_GAMEPLAY_AND_DECLARATIVE_DSL::D_LOW_LATENCY_INPUT
Overview
Low-Latency Input & Controls
Comprehensive guide to authoring ultra-responsive controls, FPS camera look, sub-frame motion sampling, and zero-allocation input polling.
Executive Summary & Key Topics
| Topic | Method / Anchor | Description |
|---|---|---|
| Input Processing Paradigms | .topic_00_input_methods |
Event-driven (_unhandled_input) vs frame polling (Input singleton). |
| Continuous Input Polling | .topic_01_polling_input |
Reading keyboard, mouse, and gamepad analog axes without heap allocations. |
| Sub-Frame FPS Mouse Look | .topic_02_mouse_look |
Smooth 3D first-person camera rotation with InputEventMouseMotion. |
Related Guides & Source References
- Input Guide:
src/libgodot/extensions/input.cr - Live Specs:
spec/suites/test_input.cr
Defined in:
libgodot/docs/c_gameplay_and_declarative_dsl/d_low_latency_input.crClass Method Summary
-
.topic_00_input_methods : Nil
Input Processing Paradigms: Event-driven (_unhandled_input) vs frame polling (Input singleton).
-
.topic_01_polling_input : Nil
Continuous Input Polling: Reading keyboard, mouse, and gamepad analog axes without heap allocations.
-
.topic_02_mouse_look : Nil
Sub-Frame FPS Mouse Look: Smooth 3D first-person camera rotation with InputEventMouseMotion.
Class Method Detail
Input Processing Paradigms: Event-driven (_unhandled_input) vs frame polling (Input singleton).
Key Topics & Information
- Event-driven: _unhandled_input(event : InputEvent) for discrete actions & mouse motion
- Polling: Input.action_pressed? and Input.action_just_pressed? for responsive movement
- Axis queries: Input.vector and Input.axis for 2D/3D direction
- Sub-frame mouse look with event accumulation disabled
Continuous Input Polling: Reading keyboard, mouse, and gamepad analog axes without heap allocations.
Inside _physics_process(delta):
def _physics_process(delta : Float64) : Void
# 1. 2D Movement vector with automatic deadzone normalization
move_vector = Input.vector("move_left", "move_right", "move_up", "move_down")
# 2. Discrete action checks
if Input.action_just_pressed?("jump") && on_floor?
cur_vel = velocity
cur_vel.y = -500.0_f32
self.velocity = cur_vel
end
# 3. Continuous firing
if Input.action_pressed?("attack")
fire_weapon!
end
end
Sub-Frame FPS Mouse Look: Smooth 3D first-person camera rotation with InputEventMouseMotion.
To achieve competitive-grade, zero-stutter camera look:
def _ready : Void
# Lock and hide mouse cursor for FPS look:
Input.mouse_mode = Input::MouseMode::Captured
# Disable mouse accumulation for sub-frame raw precision:
Input.use_accumulated_input = false
end
def _unhandled_input(event : InputEvent) : Void
if motion = event.as?(InputEventMouseMotion)
rotate_y(-motion.relative.x * sensitivity)
camera.rotate_x(-motion.relative.y * sensitivity)
end
end