Files
tactical-shooter/client/characters/input/input_handler.gd
T
shawn e9dc05983c Save workspace artifacts: character-controller, gdextension scaffold, network scripts, map-pipeline, server config
Includes code from task workspaces that was never pushed:
- client/characters/ — fps_character_controller.gd (400 lines), fps_camera.gd, input_handler.gd
- gdextension/simulation/ — C++ GDExtension scaffold: entity, movement, hit detection, simulation server, state serializer, bitstream (14 files)
- scripts/network/ — ENet-based network_manager.gd, server/client_main.gd, player.gd
- scripts/map_packaging/ — PCK pipeline: pack_map.gd, map_downloader.gd, map_registry_server.py, README
- scripts/config/ — server_config.gd (480 lines)
- scenes/ — client_main, server_main, player, test_range
- project.godot, export_presets.cfg
2026-07-01 18:30:44 -04:00

60 lines
2.5 KiB
GDScript

## InputHandler — maps Godot Input Actions to FPS character controls.
##
## This script is NOT required at runtime — it exists to document the input
## map bindings that FPSCharacterController expects. Add these actions to
## your Project → Input Map (or load this script as an autoload for reference).
##
## Bindings (tactical FPS layout):
##
## Action Key Description
## ───────────────────────────────────────────────────────
## move_forward W Walk forward
## move_backward S Walk backward
## move_left A Strafe left
## move_right D Strafe right
## jump Space Jump
## sprint Shift Sprint / walk-toggle
## crouch Ctrl Crouch (hold or toggle)
## shoot Mouse LMB Fire weapon
## aim Mouse RMB Aim down sights
## reload R Reload weapon
## interact E Use/interact
## toggle_walk_toggle (not bound) Toggle walk-toggle mode
## toggle_crouch_toggle (not bound) Toggle crouch-toggle mode
## ui_cancel Esc Release mouse capture
##
## Implementation note:
## FPSCharacterController reads input directly via Input.is_action_pressed()
## in _physics_process. No separate InputHandler node is needed unless you
## want to add rebinding, analog input smoothing, or input buffering.
extends Node
func _ready() -> void:
# This script documents bindings only — no runtime logic.
# To enforce default bindings at startup, uncomment the next lines:
# _ensure_action(&"move_forward", KEY_W)
# _ensure_action(&"move_backward", KEY_S)
# _ensure_action(&"move_left", KEY_A)
# _ensure_action(&"move_right", KEY_D)
# _ensure_action(&"jump", KEY_SPACE)
# _ensure_action(&"sprint", KEY_SHIFT)
# _ensure_action(&"crouch", KEY_CTRL)
# _ensure_action(&"shoot", MOUSE_BUTTON_LEFT)
# _ensure_action(&"aim", MOUSE_BUTTON_RIGHT)
# _ensure_action(&"reload", KEY_R)
# _ensure_action(&"interact", KEY_E)
pass
## Ensure an input action exists with the given default key binding.
## Only sets the binding if the action does not already exist.
func _ensure_action(action_name: StringName, key: Key) -> void:
if InputMap.has_action(action_name):
return
var ev := InputEventKey.new()
ev.keycode = key
InputMap.add_action(action_name)
InputMap.action_add_event(action_name, ev)