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