Add OS::open_midi_inputs and OS::close_midi_inputs
This commit is contained in:
parent
6c569c90b6
commit
05fc12ddb6
10 changed files with 55 additions and 10 deletions
|
@ -225,6 +225,14 @@ PoolStringArray _OS::get_connected_midi_inputs() {
|
||||||
return OS::get_singleton()->get_connected_midi_inputs();
|
return OS::get_singleton()->get_connected_midi_inputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _OS::open_midi_inputs() {
|
||||||
|
return OS::get_singleton()->open_midi_inputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _OS::close_midi_inputs() {
|
||||||
|
return OS::get_singleton()->close_midi_inputs();
|
||||||
|
}
|
||||||
|
|
||||||
void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
|
void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
|
||||||
|
|
||||||
OS::VideoMode vm;
|
OS::VideoMode vm;
|
||||||
|
@ -1063,6 +1071,8 @@ void _OS::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
|
ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
|
||||||
ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
|
ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
|
||||||
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
|
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
|
||||||
|
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs);
|
||||||
|
ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
|
ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
|
||||||
ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
|
ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
|
||||||
|
|
|
@ -153,6 +153,8 @@ public:
|
||||||
virtual String get_audio_driver_name(int p_driver) const;
|
virtual String get_audio_driver_name(int p_driver) const;
|
||||||
|
|
||||||
virtual PoolStringArray get_connected_midi_inputs();
|
virtual PoolStringArray get_connected_midi_inputs();
|
||||||
|
virtual void open_midi_inputs();
|
||||||
|
virtual void close_midi_inputs();
|
||||||
|
|
||||||
virtual int get_screen_count() const;
|
virtual int get_screen_count() const;
|
||||||
virtual int get_current_screen() const;
|
virtual int get_current_screen() const;
|
||||||
|
|
|
@ -689,6 +689,18 @@ PoolStringArray OS::get_connected_midi_inputs() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OS::open_midi_inputs() {
|
||||||
|
|
||||||
|
if (MIDIDriver::get_singleton())
|
||||||
|
MIDIDriver::get_singleton()->open();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OS::close_midi_inputs() {
|
||||||
|
|
||||||
|
if (MIDIDriver::get_singleton())
|
||||||
|
MIDIDriver::get_singleton()->close();
|
||||||
|
}
|
||||||
|
|
||||||
OS::OS() {
|
OS::OS() {
|
||||||
void *volatile stack_bottom;
|
void *volatile stack_bottom;
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@ public:
|
||||||
virtual const char *get_audio_driver_name(int p_driver) const;
|
virtual const char *get_audio_driver_name(int p_driver) const;
|
||||||
|
|
||||||
virtual PoolStringArray get_connected_midi_inputs();
|
virtual PoolStringArray get_connected_midi_inputs();
|
||||||
|
virtual void open_midi_inputs();
|
||||||
|
virtual void close_midi_inputs();
|
||||||
|
|
||||||
virtual int get_screen_count() const { return 1; }
|
virtual int get_screen_count() const { return 1; }
|
||||||
virtual int get_current_screen() const { return 0; }
|
virtual int get_current_screen() const { return 0; }
|
||||||
|
|
|
@ -92,6 +92,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() {
|
MIDIDriverCoreMidi::MIDIDriverCoreMidi() {
|
||||||
|
|
||||||
client = 0;
|
client = 0;
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
virtual Error open();
|
virtual Error open();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
|
PoolStringArray get_connected_inputs();
|
||||||
|
|
||||||
MIDIDriverCoreMidi();
|
MIDIDriverCoreMidi();
|
||||||
virtual ~MIDIDriverCoreMidi();
|
virtual ~MIDIDriverCoreMidi();
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,12 @@ Error MIDIDriverWinMidi::open() {
|
||||||
char err[256];
|
char err[256];
|
||||||
midiInGetErrorText(res, err, 256);
|
midiInGetErrorText(res, err, 256);
|
||||||
ERR_PRINTS("midiInOpen error: " + String(err));
|
ERR_PRINTS("midiInOpen error: " + String(err));
|
||||||
|
|
||||||
|
MIDIINCAPS caps;
|
||||||
|
res = midiInGetDevCaps(i, &caps, sizeof(MIDIINCAPS));
|
||||||
|
if (res == MMSYSERR_NOERROR) {
|
||||||
|
ERR_PRINTS("Can't open MIDI device \"" + String(caps.szPname) + "\", is it being used by another application?");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1351,8 +1351,6 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
|
||||||
midi_driver.open();
|
|
||||||
|
|
||||||
input = memnew(InputDefault);
|
input = memnew(InputDefault);
|
||||||
joypad_osx = memnew(JoypadOSX);
|
joypad_osx = memnew(JoypadOSX);
|
||||||
|
|
||||||
|
@ -1370,6 +1368,8 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||||
|
|
||||||
void OS_OSX::finalize() {
|
void OS_OSX::finalize() {
|
||||||
|
|
||||||
|
midi_driver.close();
|
||||||
|
|
||||||
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
|
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
|
||||||
CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
|
CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
|
||||||
|
|
||||||
|
|
|
@ -1219,10 +1219,6 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
|
||||||
#ifdef WINMIDI_ENABLED
|
|
||||||
driver_midi.open();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TRACKMOUSEEVENT tme;
|
TRACKMOUSEEVENT tme;
|
||||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||||
tme.dwFlags = TME_LEAVE;
|
tme.dwFlags = TME_LEAVE;
|
||||||
|
|
|
@ -342,10 +342,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
|
||||||
#ifdef ALSAMIDI_ENABLED
|
|
||||||
driver_alsamidi.open();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
|
ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE);
|
||||||
ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE);
|
ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue