From 926b703ace6679c39e2be06c26c13aa28a5c1768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20St=C4=99pie=C5=84?= Date: Sat, 22 Aug 2026 15:55:18 +0200 Subject: [PATCH] feat: add input action and project setting mappings --- project.godot | 30 +++++++++++++++++++++++- src/Godot/Mappings/InputAction.cs | 30 ++++++++++++++++++++++++ src/Godot/Mappings/InputAction.cs.uid | 1 + src/Godot/Mappings/ProjectSetting.cs | 20 ++++++++++++++++ src/Godot/Mappings/ProjectSetting.cs.uid | 1 + 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/Godot/Mappings/InputAction.cs create mode 100644 src/Godot/Mappings/InputAction.cs.uid create mode 100644 src/Godot/Mappings/ProjectSetting.cs create mode 100644 src/Godot/Mappings/ProjectSetting.cs.uid diff --git a/project.godot b/project.godot index 42ade09..4b81689 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Night Shift" -run/main_scene="uid://p766ipnev5hb" +run/main_scene="uid://c44pljehe0qun" config/features=PackedStringArray("4.7", "C#", "Forward Plus") config/icon="res://icon.svg" @@ -29,6 +29,34 @@ project/assembly_name="NightShift" naming/scene_name_casing=1 naming/script_name_casing=1 +[input] + +move_forward={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +] +} +move_back={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +] +} +jump={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} + [physics] 3d/physics_engine="Jolt Physics" diff --git a/src/Godot/Mappings/InputAction.cs b/src/Godot/Mappings/InputAction.cs new file mode 100644 index 0000000..90bd096 --- /dev/null +++ b/src/Godot/Mappings/InputAction.cs @@ -0,0 +1,30 @@ +using System; + +namespace Game.Godot.Mappings; + +public enum InputAction +{ + MoveLeft, + MoveRight, + MoveForward, + MoveBack, + Jump, + Cancel +} + +public static class InputActionExtensions +{ + /// + /// Godot Input Map action name for this action. + /// + public static string ActionName(this InputAction action) => action switch + { + InputAction.MoveLeft => "move_left", + InputAction.MoveRight => "move_right", + InputAction.MoveForward => "move_forward", + InputAction.MoveBack => "move_back", + InputAction.Jump => "jump", + InputAction.Cancel => "ui_cancel", + _ => throw new ArgumentOutOfRangeException(nameof(action), action, null) + }; +} diff --git a/src/Godot/Mappings/InputAction.cs.uid b/src/Godot/Mappings/InputAction.cs.uid new file mode 100644 index 0000000..e8350f1 --- /dev/null +++ b/src/Godot/Mappings/InputAction.cs.uid @@ -0,0 +1 @@ +uid://bwrbj8sdi6tqe diff --git a/src/Godot/Mappings/ProjectSetting.cs b/src/Godot/Mappings/ProjectSetting.cs new file mode 100644 index 0000000..8b6b0cf --- /dev/null +++ b/src/Godot/Mappings/ProjectSetting.cs @@ -0,0 +1,20 @@ +using System; + +namespace Game.Godot.Mappings; + +public enum ProjectSetting +{ + Gravity +} + +public static class ProjectSettingExtensions +{ + /// + /// ProjectSettings key for this setting. + /// + public static string SettingPath(this ProjectSetting setting) => setting switch + { + ProjectSetting.Gravity => "physics/3d/default_gravity", + _ => throw new ArgumentOutOfRangeException(nameof(setting), setting, null) + }; +} diff --git a/src/Godot/Mappings/ProjectSetting.cs.uid b/src/Godot/Mappings/ProjectSetting.cs.uid new file mode 100644 index 0000000..276f730 --- /dev/null +++ b/src/Godot/Mappings/ProjectSetting.cs.uid @@ -0,0 +1 @@ +uid://c6kb654ebimt6