diff options
Diffstat (limited to 'drivers/coremidi')
-rw-r--r-- | drivers/coremidi/SCsub | 2 | ||||
-rw-r--r-- | drivers/coremidi/core_midi.cpp | 28 | ||||
-rw-r--r-- | drivers/coremidi/core_midi.h | 9 |
3 files changed, 29 insertions, 10 deletions
diff --git a/drivers/coremidi/SCsub b/drivers/coremidi/SCsub index 233593b0f9..4c24925192 100644 --- a/drivers/coremidi/SCsub +++ b/drivers/coremidi/SCsub @@ -4,5 +4,3 @@ Import('env') # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") - -Export('env') diff --git a/drivers/coremidi/core_midi.cpp b/drivers/coremidi/core_midi.cpp index 3619be4a8e..2ebbabaa38 100644 --- a/drivers/coremidi/core_midi.cpp +++ b/drivers/coremidi/core_midi.cpp @@ -31,7 +31,8 @@ #ifdef COREMIDI_ENABLED #include "core_midi.h" -#include "print_string.h" + +#include "core/print_string.h" #include <CoreAudio/HostTime.h> #include <CoreServices/CoreServices.h> @@ -50,13 +51,13 @@ Error MIDIDriverCoreMidi::open() { OSStatus result = MIDIClientCreate(name, NULL, NULL, &client); CFRelease(name); if (result != noErr) { - ERR_PRINTS("MIDIClientCreate failed: " + String(GetMacOSStatusErrorString(result))); + ERR_PRINTS("MIDIClientCreate failed, code: " + itos(result)); return ERR_CANT_OPEN; } result = MIDIInputPortCreate(client, CFSTR("Godot Input"), MIDIDriverCoreMidi::read, (void *)this, &port_in); if (result != noErr) { - ERR_PRINTS("MIDIInputPortCreate failed: " + String(GetMacOSStatusErrorString(result))); + ERR_PRINTS("MIDIInputPortCreate failed, code: " + itos(result)); return ERR_CANT_OPEN; } @@ -64,7 +65,7 @@ Error MIDIDriverCoreMidi::open() { for (int i = 0; i < sources; i++) { MIDIEndpointRef source = MIDIGetSource(i); - if (source != NULL) { + if (source) { MIDIPortConnectSource(port_in, source, (void *)this); connected_sources.insert(i, source); } @@ -92,6 +93,25 @@ void MIDIDriverCoreMidi::close() { } } +PoolStringArray MIDIDriverCoreMidi::get_connected_inputs() { + + PoolStringArray list; + + for (int i = 0; i < connected_sources.size(); i++) { + MIDIEndpointRef source = connected_sources[i]; + CFStringRef ref = NULL; + char name[256]; + + MIDIObjectGetStringProperty(source, kMIDIPropertyDisplayName, &ref); + CFStringGetCString(ref, name, sizeof(name), kCFStringEncodingUTF8); + CFRelease(ref); + + list.push_back(name); + } + + return list; +} + MIDIDriverCoreMidi::MIDIDriverCoreMidi() { client = 0; diff --git a/drivers/coremidi/core_midi.h b/drivers/coremidi/core_midi.h index fd35e12f4b..ea6b0fcb06 100644 --- a/drivers/coremidi/core_midi.h +++ b/drivers/coremidi/core_midi.h @@ -33,12 +33,11 @@ #ifndef CORE_MIDI_H #define CORE_MIDI_H -#include <stdio.h> +#include "core/os/midi_driver.h" +#include "core/vector.h" #include <CoreMIDI/CoreMIDI.h> - -#include "core/vector.h" -#include "os/midi_driver.h" +#include <stdio.h> class MIDIDriverCoreMidi : public MIDIDriver { @@ -53,6 +52,8 @@ public: virtual Error open(); virtual void close(); + PoolStringArray get_connected_inputs(); + MIDIDriverCoreMidi(); virtual ~MIDIDriverCoreMidi(); }; |