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:
@ -39,8 +39,9 @@
|
||||
|
||||
void MIDIDriverCoreMidi::read(const MIDIPacketList *packet_list, void *read_proc_ref_con, void *src_conn_ref_con) {
|
||||
MIDIPacket *packet = const_cast<MIDIPacket *>(packet_list->packet);
|
||||
int *device_index = static_cast<int *>(src_conn_ref_con);
|
||||
for (UInt32 i = 0; i < packet_list->numPackets; i++) {
|
||||
receive_input_packet(packet->timeStamp, packet->data, packet->length);
|
||||
receive_input_packet(*device_index, packet->timeStamp, packet->data, packet->length);
|
||||
packet = MIDIPacketNext(packet);
|
||||
}
|
||||
}
|
||||
@ -64,7 +65,7 @@ Error MIDIDriverCoreMidi::open() {
|
||||
for (int i = 0; i < sources; i++) {
|
||||
MIDIEndpointRef source = MIDIGetSource(i);
|
||||
if (source) {
|
||||
MIDIPortConnectSource(port_in, source, (void *)this);
|
||||
MIDIPortConnectSource(port_in, source, static_cast<void *>(&i));
|
||||
connected_sources.insert(i, source);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user