chore(Metal): fix compiler warnings when targeting newer macOS versions

This commit is contained in:
Stuart Carnie 2018-07-04 00:24:04 -07:00
parent 30d2192338
commit 5240efc857
4 changed files with 76 additions and 31 deletions

View File

@ -371,7 +371,7 @@ static INLINE void write_quad6(SpriteVertex *pv,
/* Draw the line */
if (delim)
{
unsigned msg_len = delim - msg;
NSUInteger msg_len = delim - msg;
[self _renderLine:msg
video:video
length:msg_len

View File

@ -23,6 +23,10 @@
#include "cocoa_common.h"
#include "../../ui_companion_driver.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
static const NSEventMask NSEventMaskAny = NSAnyEventMask;
#endif
static void* ui_application_cocoa_initialize(void)
{
return NULL;
@ -30,7 +34,7 @@ static void* ui_application_cocoa_initialize(void)
static bool ui_application_cocoa_pending_events(void)
{
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (!event)
return false;
return true;
@ -40,7 +44,7 @@ static void ui_application_cocoa_process_events(void)
{
while (1)
{
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (!event)
break;
#if __has_feature(objc_arc)

View File

@ -25,6 +25,12 @@
#include "../../ui_companion_driver.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
static const NSAlertStyle NSAlertStyleCritical = NSCriticalAlertStyle;
static const NSAlertStyle NSAlertStyleWarning = NSWarningAlertStyle;
static const NSAlertStyle NSAlertStyleInformational = NSInformationalAlertStyle;
#endif
static enum ui_msg_window_response ui_msg_window_cocoa_dialog(ui_msg_window_state *state, enum ui_msg_window_type type)
{
NSInteger response;
@ -61,24 +67,32 @@ static enum ui_msg_window_response ui_msg_window_cocoa_dialog(ui_msg_window_stat
switch (type)
{
case UI_MSG_WINDOW_TYPE_ERROR:
[alert setAlertStyle:NSCriticalAlertStyle];
[alert setAlertStyle:NSAlertStyleCritical];
break;
case UI_MSG_WINDOW_TYPE_WARNING:
[alert setAlertStyle:NSWarningAlertStyle];
[alert setAlertStyle:NSAlertStyleWarning];
break;
case UI_MSG_WINDOW_TYPE_QUESTION:
[alert setAlertStyle:NSInformationalAlertStyle];
[alert setAlertStyle:NSAlertStyleInformational];
break;
case UI_MSG_WINDOW_TYPE_INFORMATION:
[alert setAlertStyle:NSInformationalAlertStyle];
[alert setAlertStyle:NSAlertStyleInformational];
break;
}
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
[alert beginSheetModalForWindow:(BRIDGE NSWindow *)ui_companion_driver_get_main_window()
completionHandler:^(NSModalResponse returnCode) {
[[NSApplication sharedApplication] stopModalWithCode:returnCode];
}];
response = [alert runModal];
#else
[alert beginSheetModalForWindow:(BRIDGE NSWindow *)ui_companion_driver_get_main_window()
modalDelegate:apple_platform
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:nil];
response = [[NSApplication sharedApplication] runModalForWindow:[alert window]];
#endif
switch (state->buttons)
{

View File

@ -69,6 +69,31 @@ static void app_terminate(void)
@implementation RApplication
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
static const NSEventType NSEventTypeKeyDown = NSKeyDown;
static const NSEventType NSEventTypeKeyUp = NSKeyUp;
static const NSEventType NSEventTypeFlagsChanged = NSFlagsChanged;
static const NSEventType NSEventTypeMouseMoved = NSMouseMoved;
static const NSEventType NSEventTypeLeftMouseDragged = NSLeftMouseDragged;
static const NSEventType NSEventTypeRightMouseDragged = NSRightMouseDragged;
static const NSEventType NSEventTypeOtherMouseDragged = NSOtherMouseDragged;
static const NSEventType NSEventTypeLeftMouseDown = NSLeftMouseDown;
static const NSEventType NSEventTypeRightMouseDown = NSRightMouseDown;
static const NSEventType NSEventTypeOtherMouseDown = NSOtherMouseDown;
static const NSEventType NSEventTypeLeftMouseUp = NSLeftMouseUp;
static const NSEventType NSEventTypeRightMouseUp = NSRightMouseUp;
static const NSEventType NSEventTypeOtherMouseUp = NSOtherMouseUp;
static const NSEventType NSEventTypeScrollWheel = NSScrollWheel;
// modifier flags
static const NSEventModifierFlags NSEventModifierFlagCapsLock = NSAlphaShiftKeyMask;
static const NSEventModifierFlags NSEventModifierFlagShift = NSShiftKeyMask;
static const NSEventModifierFlags NSEventModifierFlagControl = NSControlKeyMask;
static const NSEventModifierFlags NSEventModifierFlagOption = NSAlternateKeyMask;
static const NSEventModifierFlags NSEventModifierFlagCommand = NSCommandKeyMask;
static const NSEventModifierFlags NSEventModifierFlagNumericPad= NSNumericPadKeyMask;
#endif
- (void)sendEvent:(NSEvent *)event
{
NSEventType event_type;
@ -77,10 +102,10 @@ static void app_terminate(void)
event_type = event.type;
switch ((int32_t)event_type)
switch (event_type)
{
case NSKeyDown:
case NSKeyUp:
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
{
NSString* ch = (NSString*)event.characters;
uint32_t character = 0;
@ -91,29 +116,29 @@ static void app_terminate(void)
uint32_t i;
character = [ch characterAtIndex:0];
if (event.modifierFlags & NSAlphaShiftKeyMask)
if (event.modifierFlags & NSEventModifierFlagCapsLock)
mod |= RETROKMOD_CAPSLOCK;
if (event.modifierFlags & NSShiftKeyMask)
if (event.modifierFlags & NSEventModifierFlagShift)
mod |= RETROKMOD_SHIFT;
if (event.modifierFlags & NSControlKeyMask)
if (event.modifierFlags & NSEventModifierFlagControl)
mod |= RETROKMOD_CTRL;
if (event.modifierFlags & NSAlternateKeyMask)
if (event.modifierFlags & NSEventModifierFlagOption)
mod |= RETROKMOD_ALT;
if (event.modifierFlags & NSCommandKeyMask)
if (event.modifierFlags & NSEventModifierFlagCommand)
mod |= RETROKMOD_META;
if (event.modifierFlags & NSNumericPadKeyMask)
if (event.modifierFlags & NSEventModifierFlagNumericPad)
mod |= RETROKMOD_NUMLOCK;
for (i = 1; i < ch.length; i++)
apple_input_keyboard_event(event_type == NSKeyDown,
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
0, [ch characterAtIndex:i], mod, RETRO_DEVICE_KEYBOARD);
}
apple_input_keyboard_event(event_type == NSKeyDown,
apple_input_keyboard_event(event_type == NSEventTypeKeyDown,
event.keyCode, character, mod, RETRO_DEVICE_KEYBOARD);
}
break;
case NSFlagsChanged:
case NSEventTypeFlagsChanged:
{
static uint32_t old_flags = 0;
uint32_t new_flags = event.modifierFlags;
@ -125,10 +150,10 @@ static void app_terminate(void)
0, event.modifierFlags, RETRO_DEVICE_KEYBOARD);
}
break;
case NSMouseMoved:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
case NSEventTypeMouseMoved:
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
{
NSPoint pos;
NSPoint mouse_pos;
@ -150,12 +175,12 @@ static void app_terminate(void)
apple->window_pos_y = (int16_t)mouse_pos.y;
}
break;
case NSScrollWheel:
case NSEventTypeScrollWheel:
/* TODO/FIXME - properly implement. */
break;
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
{
NSPoint pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil];
apple = (cocoa_input_data_t*)input_driver_get_data();
@ -166,9 +191,9 @@ static void app_terminate(void)
apple->touch_count = 1;
}
break;
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
{
NSPoint pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil];
apple = (cocoa_input_data_t*)input_driver_get_data();
@ -178,6 +203,8 @@ static void app_terminate(void)
apple->touch_count = 0;
}
break;
default:
break;
}
}