Add MIDI controller device index to InputEventMIDI.device property.

It is possible to query the OS for the connected MIDI controllers,
but the event messages' device field was not being used. This implements
controller index being sent in InputEventMIDI messages in the device
property, matching the index from OS.get_connected_midi_inputs().

Based on the work done by @ramdor.

Closes godotengine/godot-proposals#7733

Co-authored-by: Richie <richie_github@grange-lane.co.uk>
This commit is contained in:
Fernando Cosentino
2023-12-29 23:29:10 +00:00
parent 13a0d6e9b2
commit b9fd25ea18
6 changed files with 17 additions and 15 deletions

View File

@ -42,9 +42,10 @@ void MIDIDriver::set_singleton() {
singleton = this;
}
void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_t length) {
void MIDIDriver::receive_input_packet(int device_index, uint64_t timestamp, uint8_t *data, uint32_t length) {
Ref<InputEventMIDI> event;
event.instantiate();
event->set_device(device_index);
uint32_t param_position = 1;
if (length >= 1) {