extends SceneTree ## Writes the game's InputMap actions into project.godot (the prototype's actions, set by ## prototype/tools/configure_project.gd, are left as they are). Idempotent: re-running replaces ## only these actions. Run with the editor closed: ## godot --headless --path . --script res://game/tools/configure_input.gd ## ## | Action | Keyboard / mouse | Gamepad | Used from | ## |--------------|------------------|----------------|-----------| ## | fear | Q | Left shoulder | Step 4 | ## | patch (hold) | F | Y | Step 4 | ## | interact | E | X | Step 5 | ## | build_mode | B | D-pad up | Step 6 | ## | rotate_left | Z | D-pad left | Step 6 | ## | rotate_right | C | D-pad right | Step 6 | ## | build_next | Tab | D-pad down | Step 6 | ## | build_1..4 | 1, 2, 3, 4 | - | Step 6 | ## | cancel | Right mouse | B | Step 6 | ## | pause | Escape | Start | Step 11 | ## | hide_tips | Backspace | Back | Step 11 | ## | toggle_mic | M | - | Co-op | ## | sprint (hold)| Shift | L3 (stick) | Sprint | ## | weapon_next | Tab | D-pad down | Weapons | ## | weapon_1..2 | 1, 2 | - | Weapons | ## | offhand | Right mouse | LT | Off-hand | ## The weapon keys are build mode's (build_next, build_1..2): outside build mode they pick the ## main weapon. offhand shares the right mouse button with cancel: in build mode it dismantles. ## STALE actions, from earlier versions of this table, are removed. const STALE: Array[String] = ["weapon_3"] func _initialize() -> void: _action("fear", [_key(KEY_Q), _joy(JOY_BUTTON_LEFT_SHOULDER)]) _action("patch", [_key(KEY_F), _joy(JOY_BUTTON_Y)]) _action("interact", [_key(KEY_E), _joy(JOY_BUTTON_X)]) _action("build_mode", [_key(KEY_B), _joy(JOY_BUTTON_DPAD_UP)]) _action("rotate_left", [_key(KEY_Z), _joy(JOY_BUTTON_DPAD_LEFT)]) _action("rotate_right", [_key(KEY_C), _joy(JOY_BUTTON_DPAD_RIGHT)]) _action("build_next", [_key(KEY_TAB), _joy(JOY_BUTTON_DPAD_DOWN)]) var number_keys: Array[Key] = [KEY_1, KEY_2, KEY_3, KEY_4] for i in 4: _action("build_%d" % (i + 1), [_key(number_keys[i])]) _action("cancel", [_mouse(MOUSE_BUTTON_RIGHT), _joy(JOY_BUTTON_B)]) _action("pause", [_key(KEY_ESCAPE), _joy(JOY_BUTTON_START)]) _action("hide_tips", [_key(KEY_BACKSPACE), _joy(JOY_BUTTON_BACK)]) _action("toggle_mic", [_key(KEY_M)]) _action("sprint", [_key(KEY_SHIFT), _joy(JOY_BUTTON_LEFT_STICK)]) _action("weapon_next", [_key(KEY_TAB), _joy(JOY_BUTTON_DPAD_DOWN)]) for i in 2: _action("weapon_%d" % (i + 1), [_key(number_keys[i])]) _action("offhand", [_mouse(MOUSE_BUTTON_RIGHT), _axis(JOY_AXIS_TRIGGER_LEFT)]) for a in STALE: ProjectSettings.clear("input/" + a) var err := ProjectSettings.save() print("configure_input: save -> %s" % error_string(err)) quit(0 if err == OK else 1) func _action(action_name: String, events: Array[InputEvent]) -> void: for e in events: e.device = -1 # all devices, matching events created in the editor ProjectSettings.set_setting("input/" + action_name, {"deadzone": 0.5, "events": events}) func _key(code: Key) -> InputEventKey: var e := InputEventKey.new() e.physical_keycode = code return e func _mouse(button: MouseButton) -> InputEventMouseButton: var e := InputEventMouseButton.new() e.button_index = button return e func _joy(button: JoyButton) -> InputEventJoypadButton: var e := InputEventJoypadButton.new() e.button_index = button return e func _axis(axis: JoyAxis) -> InputEventJoypadMotion: var e := InputEventJoypadMotion.new() e.axis = axis e.axis_value = 1.0 return e