now changes button mapping for nintendo controllers automatically
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.4">
|
||||
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.6">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
|
7
RPG Test gd4.csproj.old
Normal file
7
RPG Test gd4.csproj.old
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.4">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<RootNamespace>RPGTestgd4</RootNamespace>
|
||||
</PropertyGroup>
|
||||
</Project>
|
30
src/main.cs
30
src/main.cs
@@ -5,21 +5,38 @@ public partial class main : Node2D
|
||||
{
|
||||
[Export]
|
||||
public string currentController = Input.GetJoyName(0);
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//gamepad
|
||||
//CHANGE INPUT FOR NINTENDO CONTROLLER
|
||||
currentController = Input.GetJoyName(0);
|
||||
if (currentController.StartsWith("Nintendo"))
|
||||
{
|
||||
|
||||
InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B});
|
||||
InputMap.ActionEraseEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.A });
|
||||
InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.A });
|
||||
InputMap.ActionEraseEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.B });
|
||||
}
|
||||
//fullscreen
|
||||
else
|
||||
{
|
||||
InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.A });
|
||||
InputMap.ActionEraseEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B });
|
||||
InputMap.ActionAddEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.B });
|
||||
InputMap.ActionEraseEvent("ui_cancel", new InputEventJoypadButton() { ButtonIndex = JoyButton.A });
|
||||
}
|
||||
if (Input.IsActionJustPressed("ui_accept"))
|
||||
{
|
||||
GD.Print(currentController + " accept");
|
||||
}
|
||||
if (Input.IsActionJustPressed("ui_cancel"))
|
||||
{
|
||||
GD.Print(currentController + " cancel");
|
||||
}
|
||||
|
||||
//FULLSCREEN
|
||||
if (Input.IsActionJustPressed("hotkey_fullscreen"))
|
||||
{
|
||||
if (DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen)
|
||||
@@ -32,5 +49,4 @@ public partial class main : Node2D
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user