mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
tvOS: Minor fixes to run correctly on tvOS 13 (#16944)
This commit is contained in:
parent
810fe4545f
commit
b3af19f65f
ui/drivers
@ -244,7 +244,7 @@ void cocoa_file_load_with_detect_core(const char *filename);
|
||||
static NSDictionary<NSNumber *,NSArray<NSNumber*>*> *map;
|
||||
static dispatch_once_t once;
|
||||
dispatch_once(&once, ^{
|
||||
map = @{
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@(UIPressTypeUpArrow): @[ @(RETROK_UP), @( 0 ) ],
|
||||
@(UIPressTypeDownArrow): @[ @(RETROK_DOWN), @( 0 ) ],
|
||||
@(UIPressTypeLeftArrow): @[ @(RETROK_LEFT), @( 0 ) ],
|
||||
@ -253,10 +253,16 @@ void cocoa_file_load_with_detect_core(const char *filename);
|
||||
@(UIPressTypeSelect): @[ @(RETROK_z), @('z') ],
|
||||
@(UIPressTypeMenu) : @[ @(RETROK_x), @('x') ],
|
||||
@(UIPressTypePlayPause): @[ @(RETROK_s), @('s') ],
|
||||
}];
|
||||
|
||||
@(UIPressTypePageUp): @[ @(RETROK_PAGEUP), @( 0 ) ],
|
||||
@(UIPressTypePageDown): @[ @(RETROK_PAGEDOWN), @( 0 ) ],
|
||||
};
|
||||
if (@available(tvOS 14.3, *))
|
||||
{
|
||||
[dict addEntriesFromDictionary:@{
|
||||
@(UIPressTypePageUp): @[ @(RETROK_PAGEUP), @( 0 ) ],
|
||||
@(UIPressTypePageDown): @[ @(RETROK_PAGEDOWN), @( 0 ) ],
|
||||
}];
|
||||
}
|
||||
map = dict;
|
||||
});
|
||||
NSArray<NSNumber*>* keyvals = map[@(type)];
|
||||
if (!keyvals)
|
||||
@ -270,12 +276,15 @@ void cocoa_file_load_with_detect_core(const char *filename);
|
||||
{
|
||||
for (UIPress *press in presses)
|
||||
{
|
||||
bool has_key = false;
|
||||
if (@available(tvOS 14, *))
|
||||
has_key = !![press key];
|
||||
/* If we're at the top it doesn't matter who pressed it, we want to leave */
|
||||
if (press.type == UIPressTypeMenu && [self menuIsAtTop])
|
||||
[super pressesBegan:presses withEvent:event];
|
||||
else if (!press.key && [self didMicroGamepadPress:press.type])
|
||||
else if (!has_key && [self didMicroGamepadPress:press.type])
|
||||
[self sendKeyForPress:press.type down:true];
|
||||
else if (press.key)
|
||||
else if (has_key)
|
||||
[super pressesBegan:[NSSet setWithObject:press] withEvent:event];
|
||||
}
|
||||
}
|
||||
|
@ -387,10 +387,15 @@ enum
|
||||
#else
|
||||
- (void)handleUIPress:(UIPress *)press withEvent:(UIPressesEvent *)event down:(BOOL)down
|
||||
{
|
||||
NSString *ch = (NSString*)press.key.characters;
|
||||
NSString *ch;
|
||||
uint32_t character = 0;
|
||||
uint32_t mod = 0;
|
||||
NSUInteger mods = event.modifierFlags;
|
||||
NSUInteger mods = 0;
|
||||
if (@available(iOS 13.4, tvOS 13.4, *))
|
||||
{
|
||||
ch = (NSString*)press.key.characters;
|
||||
mods = event.modifierFlags;
|
||||
}
|
||||
|
||||
if (mods & UIKeyModifierAlphaShift)
|
||||
mod |= RETROKMOD_CAPSLOCK;
|
||||
@ -420,9 +425,10 @@ enum
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
|
||||
apple_input_keyboard_event(down,
|
||||
(uint32_t)press.key.keyCode, character, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
if (@available(iOS 13.4, tvOS 13.4, *))
|
||||
apple_input_keyboard_event(down,
|
||||
(uint32_t)press.key.keyCode, character, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
|
||||
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
@ -674,23 +680,26 @@ enum
|
||||
#ifdef HAVE_MFI
|
||||
extern void *apple_gamecontroller_joypad_init(void *data);
|
||||
apple_gamecontroller_joypad_init(NULL);
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidConnectNotification
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification *note)
|
||||
{
|
||||
GCMouse *mouse = note.object;
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float delta_x, float delta_y)
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data;
|
||||
if (!apple || !apple->mouse_grabbed)
|
||||
return;
|
||||
apple->mouse_rel_x += (int16_t)delta_x;
|
||||
apple->mouse_rel_y -= (int16_t)delta_y;
|
||||
apple->window_pos_x += (int16_t)delta_x;
|
||||
apple->window_pos_y -= (int16_t)delta_y;
|
||||
};
|
||||
}];
|
||||
if (@available(macOS 11, iOS 14, tvOS 14, *))
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidConnectNotification
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification *note)
|
||||
{
|
||||
GCMouse *mouse = note.object;
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float delta_x, float delta_y)
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data;
|
||||
if (!apple || !apple->mouse_grabbed)
|
||||
return;
|
||||
apple->mouse_rel_x += (int16_t)delta_x;
|
||||
apple->mouse_rel_y -= (int16_t)delta_y;
|
||||
apple->window_pos_x += (int16_t)delta_x;
|
||||
apple->window_pos_y -= (int16_t)delta_y;
|
||||
};
|
||||
}];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user