Integrating MIDI Keyboard Support with *Global InputMap*

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I’m looking to enhance my game’s input controls by integrating a MIDI keyboard. To achieve this, I need to incorporate MIDI input events into the game’s InputMap, which is the same one found in the project settings.

Here’s the function I’ve created for this purpose:

func add_midi_inputs() -> void:
	OS.open_midi_inputs()
	var input:InputEvent = InputEventMIDI.new()
	input.message = 11
	InputMap.action_add_event(&"DEBUG QUIT", input)

This code doesn’t produce any errors, but I’m concerned that the InputMap being modified is not the global one used throughout the game, but rather a newly instantiated object.

It is singleton, why do you think it is newly object?
New here is event with type InputEventMIDI and this is normal
Action named "DEBUG QUIT" must be already exists in Project Settings - Input Map, if not - you need to call InputMap.add_action(&"DEBUG QUIT") first