Skip to content

Porting Godot 3: Input

Caroline Joy Bell edited this page Apr 15, 2024 · 1 revision

Overview

Note: Homebrodot adds set and get functions for various joypad sensors in Godot 3, which is not a feature present in upstream Godot 3 at the time of writing this (but was added in Godot 4).

Implementing input is a mostly freeform system in Godot 3; most of the platform code could be doing pretty much anything, as long as it updates the InputDefault singleton. For interacting with it, there's a couple important things to note:

  • Each input device (up to 16) has an id, which is an int
  • InputDefault expects Godot's input table values for reference of what button was just pressed.

What MUST Be Implemented

  • A function to process inputs, which should probably be run every loop within OS:run() for your platform.
  • Your input system must talk to the DefaultInput singleton for Godot to detect inputs.

What Is Optional

  • Handling for multiple controllers (input can be handled in a singular way for platforms where only one joypad is relevant, like handhelds)