mirror of https://github.com/AxioDL/boo.git
CoreMidi API usage adjustment to prefer latest connected HW
This commit is contained in:
parent
1877c546ac
commit
d5b42b785e
|
@ -122,27 +122,32 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||
|
||||
ItemCount numDevices = MIDIGetNumberOfDevices();
|
||||
ret.reserve(numDevices);
|
||||
for (ItemCount i=0 ; i<numDevices ; ++i)
|
||||
for (int i=int(numDevices)-1 ; i>=0 ; --i)
|
||||
{
|
||||
MIDIDeviceRef dev = MIDIGetDevice(i);
|
||||
if (!dev)
|
||||
continue;
|
||||
|
||||
CFStringRef idstr;
|
||||
if (MIDIObjectGetStringProperty(dev, kMIDIPropertyDeviceID, &idstr))
|
||||
SInt32 idNum;
|
||||
if (MIDIObjectGetIntegerProperty(dev, kMIDIPropertyUniqueID, &idNum))
|
||||
continue;
|
||||
|
||||
CFStringRef namestr;
|
||||
if (MIDIObjectGetStringProperty(dev, kMIDIPropertyDisplayName, &namestr))
|
||||
const char* nameCstr;
|
||||
if (MIDIObjectGetStringProperty(dev, kMIDIPropertyName, &namestr))
|
||||
continue;
|
||||
|
||||
if (!(nameCstr = CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8)))
|
||||
{
|
||||
CFRelease(idstr);
|
||||
CFRelease(namestr);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.push_back(std::make_pair(std::string(CFStringGetCStringPtr(idstr, kCFStringEncodingUTF8)),
|
||||
std::string(CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8))));
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
ret.push_back(std::make_pair(std::string(idStr),
|
||||
std::string(nameCstr)));
|
||||
|
||||
CFRelease(idstr);
|
||||
CFRelease(namestr);
|
||||
}
|
||||
|
||||
|
@ -158,16 +163,16 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||
if (!dev)
|
||||
continue;
|
||||
|
||||
CFStringRef idstr;
|
||||
if (MIDIObjectGetStringProperty(dev, kMIDIPropertyDeviceID, &idstr))
|
||||
SInt32 idNum;
|
||||
if (MIDIObjectGetIntegerProperty(dev, kMIDIPropertyUniqueID, &idNum))
|
||||
continue;
|
||||
|
||||
if (!strcmp(CFStringGetCStringPtr(idstr, kCFStringEncodingUTF8), name))
|
||||
{
|
||||
CFRelease(idstr);
|
||||
return dev;
|
||||
}
|
||||
CFRelease(idstr);
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
if (strcmp(idStr, name))
|
||||
continue;
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -256,12 +261,18 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||
std::string description() const
|
||||
{
|
||||
CFStringRef namestr;
|
||||
if (MIDIObjectGetStringProperty(m_midi, kMIDIPropertyDisplayName, &namestr))
|
||||
const char* nameCstr;
|
||||
if (MIDIObjectGetStringProperty(m_midi, kMIDIPropertyName, &namestr))
|
||||
return {};
|
||||
|
||||
std::string ret(CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8));
|
||||
if (!(nameCstr = CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8)))
|
||||
{
|
||||
CFRelease(namestr);
|
||||
return {};
|
||||
}
|
||||
|
||||
CFRelease(namestr);
|
||||
return ret;
|
||||
return nameCstr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -284,12 +295,18 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||
std::string description() const
|
||||
{
|
||||
CFStringRef namestr;
|
||||
if (MIDIObjectGetStringProperty(m_midi, kMIDIPropertyDisplayName, &namestr))
|
||||
const char* nameCstr;
|
||||
if (MIDIObjectGetStringProperty(m_midi, kMIDIPropertyName, &namestr))
|
||||
return {};
|
||||
|
||||
std::string ret(CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8));
|
||||
if (!(nameCstr = CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8)))
|
||||
{
|
||||
CFRelease(namestr);
|
||||
return {};
|
||||
}
|
||||
|
||||
CFRelease(namestr);
|
||||
return ret;
|
||||
return nameCstr;
|
||||
}
|
||||
|
||||
size_t send(const void* buf, size_t len) const
|
||||
|
@ -338,12 +355,18 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
|||
std::string description() const
|
||||
{
|
||||
CFStringRef namestr;
|
||||
if (MIDIObjectGetStringProperty(m_midiIn, kMIDIPropertyDisplayName, &namestr))
|
||||
const char* nameCstr;
|
||||
if (MIDIObjectGetStringProperty(m_midiIn, kMIDIPropertyName, &namestr))
|
||||
return {};
|
||||
|
||||
std::string ret(CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8));
|
||||
if (!(nameCstr = CFStringGetCStringPtr(namestr, kCFStringEncodingUTF8)))
|
||||
{
|
||||
CFRelease(namestr);
|
||||
return {};
|
||||
}
|
||||
|
||||
CFRelease(namestr);
|
||||
return ret;
|
||||
return nameCstr;
|
||||
}
|
||||
|
||||
size_t send(const void* buf, size_t len) const
|
||||
|
|
|
@ -74,12 +74,12 @@ public:
|
|||
NSMenuItem* fsItem = [appMenu addItemWithTitle:@"Toggle Full Screen"
|
||||
action:@selector(toggleFs:)
|
||||
keyEquivalent:@"f"];
|
||||
[fsItem setKeyEquivalentModifierMask:NSCommandKeyMask];
|
||||
[fsItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
NSMenuItem* quitItem = [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %s", m_friendlyName.c_str()]
|
||||
action:@selector(quitApp:)
|
||||
keyEquivalent:@"q"];
|
||||
[quitItem setKeyEquivalentModifierMask:NSCommandKeyMask];
|
||||
[quitItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
|
||||
[[rootMenu addItemWithTitle:[NSString stringWithUTF8String:m_friendlyName.c_str()]
|
||||
action:nil keyEquivalent:@""] setSubmenu:appMenu];
|
||||
[[NSApplication sharedApplication] setMainMenu:rootMenu];
|
||||
|
|
|
@ -617,13 +617,13 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
|||
static inline boo::EModifierKey getMod(NSUInteger flags)
|
||||
{
|
||||
boo::EModifierKey ret = boo::EModifierKey::None;
|
||||
if (flags & NSControlKeyMask)
|
||||
if (flags & NSEventModifierFlagControl)
|
||||
ret |= boo::EModifierKey::Ctrl;
|
||||
if (flags & NSAlternateKeyMask)
|
||||
if (flags & NSEventModifierFlagOption)
|
||||
ret |= boo::EModifierKey::Alt;
|
||||
if (flags & NSShiftKeyMask)
|
||||
if (flags & NSEventModifierFlagShift)
|
||||
ret |= boo::EModifierKey::Shift;
|
||||
if (flags & NSCommandKeyMask)
|
||||
if (flags & NSEventModifierFlagCommand)
|
||||
ret |= boo::EModifierKey::Command;
|
||||
return ret;
|
||||
}
|
||||
|
@ -1061,23 +1061,23 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||
NSUInteger changedFlags = modFlags ^ lastModifiers;
|
||||
|
||||
NSUInteger downFlags = changedFlags & modFlags;
|
||||
if (downFlags & NSControlKeyMask)
|
||||
if (downFlags & NSEventModifierFlagControl)
|
||||
booContext->m_callback->modKeyDown(boo::EModifierKey::Ctrl, false);
|
||||
if (downFlags & NSAlternateKeyMask)
|
||||
if (downFlags & NSEventModifierFlagOption)
|
||||
booContext->m_callback->modKeyDown(boo::EModifierKey::Alt, false);
|
||||
if (downFlags & NSShiftKeyMask)
|
||||
if (downFlags & NSEventModifierFlagShift)
|
||||
booContext->m_callback->modKeyDown(boo::EModifierKey::Shift, false);
|
||||
if (downFlags & NSCommandKeyMask)
|
||||
if (downFlags & NSEventModifierFlagCommand)
|
||||
booContext->m_callback->modKeyDown(boo::EModifierKey::Command, false);
|
||||
|
||||
NSUInteger upFlags = changedFlags & ~modFlags;
|
||||
if (upFlags & NSControlKeyMask)
|
||||
if (upFlags & NSEventModifierFlagControl)
|
||||
booContext->m_callback->modKeyUp(boo::EModifierKey::Ctrl);
|
||||
if (upFlags & NSAlternateKeyMask)
|
||||
if (upFlags & NSEventModifierFlagOption)
|
||||
booContext->m_callback->modKeyUp(boo::EModifierKey::Alt);
|
||||
if (upFlags & NSShiftKeyMask)
|
||||
if (upFlags & NSEventModifierFlagShift)
|
||||
booContext->m_callback->modKeyUp(boo::EModifierKey::Shift);
|
||||
if (upFlags & NSCommandKeyMask)
|
||||
if (upFlags & NSEventModifierFlagCommand)
|
||||
booContext->m_callback->modKeyUp(boo::EModifierKey::Command);
|
||||
|
||||
lastModifiers = modFlags;
|
||||
|
@ -1392,7 +1392,7 @@ public:
|
|||
|
||||
bool isFullscreen() const
|
||||
{
|
||||
return ([m_nsWindow styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask;
|
||||
return ([m_nsWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
|
||||
}
|
||||
|
||||
void setFullscreen(bool fs)
|
||||
|
@ -1455,14 +1455,14 @@ public:
|
|||
#endif
|
||||
|
||||
if ((style & EWindowStyle::Close) != EWindowStyle::None)
|
||||
m_nsWindow.styleMask |= NSClosableWindowMask;
|
||||
m_nsWindow.styleMask |= NSWindowStyleMaskClosable;
|
||||
else
|
||||
m_nsWindow.styleMask &= ~NSClosableWindowMask;
|
||||
m_nsWindow.styleMask &= ~NSWindowStyleMaskClosable;
|
||||
|
||||
if ((style & EWindowStyle::Resize) != EWindowStyle::None)
|
||||
m_nsWindow.styleMask |= NSResizableWindowMask;
|
||||
m_nsWindow.styleMask |= NSWindowStyleMaskResizable;
|
||||
else
|
||||
m_nsWindow.styleMask &= ~NSResizableWindowMask;
|
||||
m_nsWindow.styleMask &= ~NSWindowStyleMaskResizable;
|
||||
}
|
||||
|
||||
EWindowStyle getStyle() const
|
||||
|
@ -1473,8 +1473,8 @@ public:
|
|||
#else
|
||||
retval |= EWindowStyle::Titlebar;
|
||||
#endif
|
||||
retval |= (m_nsWindow.styleMask & NSClosableWindowMask) ? EWindowStyle::Close : EWindowStyle::None;
|
||||
retval |= (m_nsWindow.styleMask & NSResizableWindowMask) ? EWindowStyle::Resize: EWindowStyle::None;
|
||||
retval |= (m_nsWindow.styleMask & NSWindowStyleMaskClosable) ? EWindowStyle::Close : EWindowStyle::None;
|
||||
retval |= (m_nsWindow.styleMask & NSWindowStyleMaskResizable) ? EWindowStyle::Resize: EWindowStyle::None;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1522,10 +1522,10 @@ IWindow* _WindowCocoaNew(const SystemString& title, NSOpenGLContext* lastGLCtx,
|
|||
- (id)initWithBooWindow:(boo::WindowCocoa *)bw title:(const boo::SystemString&)title
|
||||
{
|
||||
self = [self initWithContentRect:[self genFrameDefault]
|
||||
styleMask:NSTitledWindowMask|
|
||||
NSClosableWindowMask|
|
||||
NSMiniaturizableWindowMask|
|
||||
NSResizableWindowMask
|
||||
styleMask:NSWindowStyleMaskTitled|
|
||||
NSWindowStyleMaskClosable|
|
||||
NSWindowStyleMaskMiniaturizable|
|
||||
NSWindowStyleMaskTitled
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
self.releasedWhenClosed = NO;
|
||||
|
|
Loading…
Reference in New Issue