#Is there a way to use gamepad for editor shortcuts?

1 messages · Page 1 of 1 (latest)

tiny tide
#

More specifically, I want to connect my controller and use it face buttons to add specific nodes to scene. Like "press A to add HBox", "press B to add VBox" et cetera.

left loom
#

So you can find/set all the shortcuts here: Editor -> Editor settings -> shortcuts.

However, 2 things:

  • I haven't tested it, but it's listening for key presses, so it might not work for controllers. Maybe some extra software (depending on OS) could be used so that controller buttons are "translated" to key presses.
  • There are no shortcuts for such specific actions like adding a specific control node, etc.

A potentially more reasonable alternative to the above is writing your own @tool script. You could have that script listen to any controller button and you code exactly what the action(s) should be. It's obviously more work than just "clicking around a setting menu", but you'll be fully flexible in terms of buttons/combinations and the exact action(s).

tiny tide
# left loom So you can find/set all the shortcuts here: Editor -> Editor settings -> shortcu...

Thanks! This was the script I wrote. Not very good due to my skills, but works fine:


extends Node

@onready var timer = %InputTimer
@export var timer_time: float = 0.3
var shot: bool = false

var aType
var bType
var xType
var yType

var dleftType
var drightType
var dupType
var ddownType

var current_theme

func _ready() -> void:
    aType = HBoxContainer
    bType = VBoxContainer
    xType = CenterContainer
    yType = MarginContainer
    
    dupType = PanelContainer
    drightType = Button
    
    current_theme = load("res://UI/Themes/WoodenBG.tres")
     
func _process(delta: float) -> void:
    if Engine.is_editor_hint():
        var selector = EditorInterface.get_selection()
        
        if Input.is_joy_button_pressed(0,JOY_BUTTON_A) and shot == false:
            for nodes in selector.get_selected_nodes():
                var new_node = aType.new()
                nodes.add_child(new_node)
                new_node.owner = get_tree().edited_scene_root 
            timer_things()
            
        if Input.is_joy_button_pressed(0,JOY_BUTTON_B) and shot == false:
            for nodes in selector.get_selected_nodes():
                var new_node = bType.new()
                nodes.add_child(new_node)
                new_node.owner = get_tree().edited_scene_root 
            timer_things()
            
func timer_things() -> void:
    shot = true
    timer.start(0.2)
    await timer.timeout
    shot = false
    
func set_theme(new_node) -> void:
    new_node.theme = current_theme
tender wingBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/