mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(iOS) Cleanups
This commit is contained in:
parent
94c65d23e3
commit
38fe0d0119
@ -89,8 +89,8 @@ static void unzip_file(const char* path, const char* output_directory)
|
||||
|
||||
static void file_action(enum file_action action, NSString* source, NSString* target)
|
||||
{
|
||||
NSError* error = nil;
|
||||
bool result = false;
|
||||
NSError* error = nil;
|
||||
bool result = false;
|
||||
NSFileManager* manager = [NSFileManager defaultManager];
|
||||
|
||||
switch (action)
|
||||
@ -122,8 +122,8 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
if (!item)
|
||||
return NULL;
|
||||
|
||||
item.path = path;
|
||||
item.isDirectory = path_is_directory(path.UTF8String);
|
||||
item.path = path;
|
||||
item.isDirectory = path_is_directory(path.UTF8String);
|
||||
|
||||
return item;
|
||||
}
|
||||
@ -135,24 +135,24 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
if (!item)
|
||||
return NULL;
|
||||
|
||||
item.path = BOXSTRING(element->data);
|
||||
item.isDirectory = (element->attr.i == RARCH_DIRECTORY);
|
||||
item.path = BOXSTRING(element->data);
|
||||
item.isDirectory = (element->attr.i == RARCH_DIRECTORY);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
- (UITableViewCell*)cellForTableView:(UITableView *)tableView
|
||||
{
|
||||
static NSString* const cell_id = @"path_item";
|
||||
static NSString* const cell_id = @"path_item";
|
||||
static NSString* const icon_types[2] = { @"ic_file", @"ic_dir" };
|
||||
uint32_t type_id = self.isDirectory ? 1 : 0;
|
||||
UITableViewCell* result = [tableView dequeueReusableCellWithIdentifier:cell_id];
|
||||
uint32_t type_id = self.isDirectory ? 1 : 0;
|
||||
UITableViewCell *result = [tableView dequeueReusableCellWithIdentifier:cell_id];
|
||||
|
||||
if (!result)
|
||||
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cell_id];
|
||||
|
||||
result.textLabel.text = [self.path lastPathComponent];
|
||||
result.imageView.image = [UIImage imageNamed:icon_types[type_id]];
|
||||
result.textLabel.text = [self.path lastPathComponent];
|
||||
result.imageView.image = [UIImage imageNamed:icon_types[type_id]];
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -169,23 +169,24 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
|
||||
@implementation RADirectoryList
|
||||
|
||||
- (id)initWithPath:(NSString*)path extensions:(const char*)extensions action:(void (^)(RADirectoryList* list, RADirectoryItem* item))action
|
||||
- (id)initWithPath:(NSString*)path extensions:(const char*)extensions
|
||||
action:(void (^)(RADirectoryList* list, RADirectoryItem* item))action
|
||||
{
|
||||
if ((self = [super initWithStyle:UITableViewStylePlain]))
|
||||
{
|
||||
self.path = path ? path : NSHomeDirectory();
|
||||
self.chooseAction = action;
|
||||
self.extensions = extensions ? BOXSTRING(extensions) : 0;
|
||||
self.hidesHeaders = YES;
|
||||
NSMutableArray *toolbarButtons;
|
||||
self.path = path ? path : NSHomeDirectory();
|
||||
self.chooseAction = action;
|
||||
self.extensions = extensions ? BOXSTRING(extensions) : 0;
|
||||
self.hidesHeaders = YES;
|
||||
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Up") style:UIBarButtonItemStyleBordered target:self
|
||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Up") style:UIBarButtonItemStyleBordered target:self
|
||||
action:@selector(gotoParent)];
|
||||
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self
|
||||
action:@selector(cancelBrowser)];
|
||||
|
||||
// NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices.
|
||||
NSMutableArray* toolbarButtons = [NSMutableArray arrayWithObjects:
|
||||
/* NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices. */
|
||||
toolbarButtons = [NSMutableArray arrayWithObjects:
|
||||
[[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Home") style:UIBarButtonItemStyleBordered target:self
|
||||
action:@selector(gotoHomeDir)],
|
||||
[[UIBarButtonItem alloc] initWithTitle:BOXSTRING("App") style:UIBarButtonItemStyleBordered target:self
|
||||
@ -201,7 +202,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
nil
|
||||
];
|
||||
|
||||
self.toolbarItems = toolbarButtons;
|
||||
self.toolbarItems = toolbarButtons;
|
||||
|
||||
[self.tableView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(fileAction:)]];
|
||||
@ -242,19 +243,21 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
|
||||
- (void)browseTo:(NSString*)path
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
NSString *i;
|
||||
struct string_list *contents = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
self.path = path;
|
||||
self.title = self.path.lastPathComponent;
|
||||
self.path = path;
|
||||
self.title = self.path.lastPathComponent;
|
||||
|
||||
/* Need one array per section. */
|
||||
self.sections = [NSMutableArray array];
|
||||
self.sections = [NSMutableArray array];
|
||||
|
||||
for (NSString* i in [self sectionIndexTitlesForTableView:self.tableView])
|
||||
for (i in [self sectionIndexTitlesForTableView:self.tableView])
|
||||
[self.sections addObject:[NSMutableArray arrayWithObject:i]];
|
||||
|
||||
/* List contents */
|
||||
struct string_list *contents = dir_list_new(self.path.UTF8String,
|
||||
contents = dir_list_new(self.path.UTF8String,
|
||||
settings->menu.navigation.browser.filter.supported_extensions_enable ? self.extensions.UTF8String : NULL, true);
|
||||
|
||||
if (contents)
|
||||
@ -268,20 +271,16 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
if (self.forDirectory)
|
||||
[self.sections[0] addObject:[RAMenuItemBasic itemWithDescription:BOXSTRING("[ Use This Folder ]")
|
||||
action:^{ weakSelf.chooseAction(weakSelf, [RADirectoryItem directoryItemFromPath:path]); }]];
|
||||
|
||||
dir_list_sort(contents, true);
|
||||
|
||||
for (i = 0; i < contents->size; i ++)
|
||||
{
|
||||
const char* basename = path_basename(contents->elems[i].data);
|
||||
const char *basename = path_basename(contents->elems[i].data);
|
||||
char is_directory = (contents->elems[i].attr.i == RARCH_DIRECTORY);
|
||||
uint32_t section = is_directory ? 0 : isalpha(basename[0]) ? (toupper(basename[0]) - 'A') + 2 : 1;
|
||||
|
||||
uint32_t section = isalpha(basename[0]) ? (toupper(basename[0]) - 'A') + 2 : 1;
|
||||
char is_directory = (contents->elems[i].attr.i == RARCH_DIRECTORY);
|
||||
section = is_directory ? 0 : section;
|
||||
|
||||
if (! ( self.forDirectory && ! is_directory )) {
|
||||
[self.sections[section] addObject:[RADirectoryItem directoryItemFromElement:&contents->elems[i]]];
|
||||
}
|
||||
if (! ( self.forDirectory && ! is_directory ))
|
||||
[self.sections[section] addObject:[RADirectoryItem directoryItemFromElement:&contents->elems[i]]];
|
||||
}
|
||||
|
||||
dir_list_free(contents);
|
||||
@ -317,23 +316,23 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
return names;
|
||||
}
|
||||
|
||||
// File management
|
||||
// Called as a selector from a toolbar button
|
||||
/* File management
|
||||
* Called as a selector from a toolbar button. */
|
||||
- (void)createNewFolder
|
||||
{
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new folder name") message:BOXSTRING("") delegate:self
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new folder name") message:BOXSTRING("") delegate:self
|
||||
cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
alertView.tag = FA_CREATE;
|
||||
alertView.tag = FA_CREATE;
|
||||
[alertView show];
|
||||
}
|
||||
|
||||
// Called by the long press gesture recognizer
|
||||
/* Called by the long press gesture recognizer. */
|
||||
- (void)fileAction:(UILongPressGestureRecognizer*)gesture
|
||||
{
|
||||
if (gesture.state == UIGestureRecognizerStateBegan)
|
||||
{
|
||||
CGPoint point = [gesture locationInView:self.tableView];
|
||||
CGPoint point = [gesture locationInView:self.tableView];
|
||||
NSIndexPath* idx_path = [self.tableView indexPathForRowAtPoint:point];
|
||||
|
||||
if (idx_path)
|
||||
@ -343,12 +342,12 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
NSString *button4_name = (get_ios_version_major() >= 7) ? BOXSTRING("AirDrop") : BOXSTRING("Delete");
|
||||
NSString *button5_name = (get_ios_version_major() >= 7) ? BOXSTRING("Delete") : nil;
|
||||
|
||||
self.selectedItem = [self itemForIndexPath:idx_path];
|
||||
is_zip = !(strcmp(self.selectedItem.path.pathExtension.UTF8String, "zip"));
|
||||
self.selectedItem = [self itemForIndexPath:idx_path];
|
||||
is_zip = !(strcmp(self.selectedItem.path.pathExtension.UTF8String, "zip"));
|
||||
|
||||
menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self
|
||||
cancelButtonTitle:BOXSTRING("Cancel") destructiveButtonTitle:nil
|
||||
otherButtonTitles:is_zip ? BOXSTRING("Unzip") : BOXSTRING("Zip"), BOXSTRING("Move"), BOXSTRING("Rename"), button4_name, button5_name, nil];
|
||||
cancelButtonTitle:BOXSTRING("Cancel") destructiveButtonTitle:nil
|
||||
otherButtonTitles:is_zip ? BOXSTRING("Unzip") : BOXSTRING("Zip"), BOXSTRING("Move"), BOXSTRING("Rename"), button4_name, button5_name, nil];
|
||||
[menu showFromToolbar:self.navigationController.toolbar];
|
||||
|
||||
}
|
||||
@ -363,10 +362,10 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
|
||||
if (!strcmp(action.UTF8String, "Unzip"))
|
||||
{
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter target directory") message:@"" delegate:self
|
||||
cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
alertView.tag = FA_UNZIP;
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter target directory") message:@"" delegate:self
|
||||
cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
alertView.tag = FA_UNZIP;
|
||||
[alertView textFieldAtIndex:0].text = [[target lastPathComponent] stringByDeletingPathExtension];
|
||||
[alertView show];
|
||||
}
|
||||
@ -374,19 +373,20 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
[self.navigationController pushViewController:[[RAFoldersList alloc] initWithFilePath:target] animated:YES];
|
||||
else if (!strcmp(action.UTF8String, "Rename"))
|
||||
{
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new name") message:@"" delegate:self cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
alertView.tag = FA_MOVE;
|
||||
UIAlertView* alertView = [[UIAlertView alloc]
|
||||
initWithTitle:BOXSTRING("Enter new name") message:@""
|
||||
delegate:self cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
alertView.tag = FA_MOVE;
|
||||
[alertView textFieldAtIndex:0].text = target.lastPathComponent;
|
||||
[alertView show];
|
||||
}
|
||||
#ifdef __IPHONE_7_0
|
||||
else if (!strcmp(action.UTF8String, "AirDrop") && (get_ios_version_major() >= 7))
|
||||
{
|
||||
// TODO: Zip if not already zipped
|
||||
|
||||
NSURL* url = [NSURL fileURLWithPath:self.selectedItem.path isDirectory:self.selectedItem.isDirectory];
|
||||
NSArray* items = [NSArray arrayWithObject:url];
|
||||
/* TODO: ZIP if not already zipped. */
|
||||
NSURL *url = [NSURL fileURLWithPath:self.selectedItem.path isDirectory:self.selectedItem.isDirectory];
|
||||
NSArray *items = [NSArray arrayWithObject:url];
|
||||
UIActivityViewController* avc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
|
||||
|
||||
[self presentViewController:avc animated:YES completion:nil];
|
||||
@ -394,15 +394,16 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
#endif
|
||||
else if (!strcmp(action.UTF8String, "Delete"))
|
||||
{
|
||||
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Really delete?") message:@"" delegate:self cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.tag = FA_DELETE;
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Really delete?") message:@"" delegate:self cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("OK"), nil];
|
||||
alertView.tag = FA_DELETE;
|
||||
[alertView show];
|
||||
}
|
||||
else if (!strcmp(action.UTF8String, "Cancel")) /* Zip */
|
||||
apple_display_alert("Action not supported.", "Action Failed");
|
||||
}
|
||||
|
||||
// Called by various alert views created in this class, the alertView.tag value is the action to take.
|
||||
/* Called by various alert views created in this class,
|
||||
* the alertView.tag value is the action to take. */
|
||||
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
if (buttonIndex != alertView.firstOtherButtonIndex)
|
||||
@ -433,20 +434,23 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
{
|
||||
if ((self = [super initWithStyle:UITableViewStyleGrouped]))
|
||||
{
|
||||
NSString *sourceItem;
|
||||
RAMenuItemBasic *parentItem;
|
||||
NSMutableArray *items;
|
||||
struct string_list* contents;
|
||||
RAFoldersList* __weak weakSelf = self;
|
||||
self.path = path;
|
||||
|
||||
// Parent item
|
||||
NSString* sourceItem = self.path.stringByDeletingLastPathComponent;
|
||||
/* Parent item */
|
||||
sourceItem = self.path.stringByDeletingLastPathComponent;
|
||||
|
||||
RAMenuItemBasic* parentItem = [RAMenuItemBasic itemWithDescription:BOXSTRING("<Parent>") association:sourceItem.stringByDeletingLastPathComponent
|
||||
parentItem = [RAMenuItemBasic itemWithDescription:BOXSTRING("<Parent>") association:sourceItem.stringByDeletingLastPathComponent
|
||||
action:^(id userdata){ [weakSelf moveInto:userdata]; } detail:NULL];
|
||||
[self.sections addObject:@[BOXSTRING(""), parentItem]];
|
||||
|
||||
|
||||
// List contents
|
||||
struct string_list* contents = dir_list_new([self.path stringByDeletingLastPathComponent].UTF8String, NULL, true);
|
||||
NSMutableArray* items = [NSMutableArray arrayWithObject:BOXSTRING("")];
|
||||
/* List contents */
|
||||
contents = dir_list_new([self.path stringByDeletingLastPathComponent].UTF8String, NULL, true);
|
||||
items = [NSMutableArray arrayWithObject:BOXSTRING("")];
|
||||
|
||||
if (contents)
|
||||
{
|
||||
@ -457,19 +461,16 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
{
|
||||
if (contents->elems[i].attr.i == RARCH_DIRECTORY)
|
||||
{
|
||||
const char* basename = path_basename(contents->elems[i].data);
|
||||
|
||||
const char* basename = path_basename(contents->elems[i].data);
|
||||
RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(basename) association:BOXSTRING(contents->elems[i].data)
|
||||
action:^(id userdata){ [weakSelf moveInto:userdata]; } detail:NULL];
|
||||
action:^(id userdata){ [weakSelf moveInto:userdata]; } detail:NULL];
|
||||
[items addObject:item];
|
||||
}
|
||||
}
|
||||
|
||||
dir_list_free(contents);
|
||||
}
|
||||
|
||||
[self setTitle:[BOXSTRING("Move ") stringByAppendingString: self.path.lastPathComponent]];
|
||||
|
||||
[self.sections addObject:items];
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,13 @@ void main_exit_save_config(void);
|
||||
static void rarch_draw(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
|
||||
{
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
int ret = 0;
|
||||
bool iterate = iterate_observer && !runloop->is_paused;
|
||||
int ret = 0;
|
||||
bool iterate = iterate_observer && !runloop->is_paused;
|
||||
|
||||
if (!iterate)
|
||||
return;
|
||||
|
||||
ret = rarch_main_iterate();
|
||||
ret = rarch_main_iterate();
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
@ -83,15 +83,15 @@ int get_ios_version_major(void)
|
||||
const void* apple_get_frontend_settings(void)
|
||||
{
|
||||
static rarch_setting_t settings[9];
|
||||
|
||||
|
||||
if (settings[0].type == ST_NONE)
|
||||
{
|
||||
const char *GROUP_NAME = "Frontend Settings";
|
||||
const char *SUBGROUP_NAME = "Frontend";
|
||||
const char *GROUP_NAME = "Frontend Settings";
|
||||
const char *SUBGROUP_NAME = "Frontend";
|
||||
settings[0] = setting_group_setting(ST_GROUP, "Frontend Settings");
|
||||
settings[1] = setting_group_setting(ST_SUB_GROUP, "Frontend");
|
||||
settings[2] = setting_string_setting(ST_STRING, "ios_btmode", "Bluetooth Input Type", apple_frontend_settings.bluetooth_mode,
|
||||
sizeof(apple_frontend_settings.bluetooth_mode), "none", "<null>", GROUP_NAME, SUBGROUP_NAME, NULL, NULL);
|
||||
sizeof(apple_frontend_settings.bluetooth_mode), "none", "<null>", GROUP_NAME, SUBGROUP_NAME, NULL, NULL);
|
||||
|
||||
/* Set iOS_btmode options based on runtime environment. */
|
||||
if (btstack_try_load())
|
||||
@ -100,12 +100,12 @@ const void* apple_get_frontend_settings(void)
|
||||
settings[2].values = "icade|keyboard|small_keyboard";
|
||||
|
||||
settings[3] = setting_string_setting(ST_STRING, "ios_orientations", "Screen Orientations", apple_frontend_settings.orientations,
|
||||
sizeof(apple_frontend_settings.orientations), "both", "<null>", GROUP_NAME, SUBGROUP_NAME, NULL, NULL);
|
||||
sizeof(apple_frontend_settings.orientations), "both", "<null>", GROUP_NAME, SUBGROUP_NAME, NULL, NULL);
|
||||
settings[3].values = "both|landscape|portrait";
|
||||
settings[4] = setting_group_setting(ST_END_SUB_GROUP, 0);
|
||||
settings[5] = setting_group_setting(ST_END_GROUP, 0);
|
||||
}
|
||||
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ extern float apple_gfx_ctx_get_native_scale(void);
|
||||
/* Input helpers: This is kept here because it needs ObjC */
|
||||
static void handle_touch_event(NSArray* touches)
|
||||
{
|
||||
NSUInteger i;
|
||||
unsigned i;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
|
||||
float scale = apple_gfx_ctx_get_native_scale();
|
||||
@ -126,7 +126,7 @@ static void handle_touch_event(NSArray* touches)
|
||||
|
||||
for (i = 0; i < touches.count && (apple->touch_count < MAX_TOUCHES); i++)
|
||||
{
|
||||
UITouch* touch = [touches objectAtIndex:i];
|
||||
UITouch *touch = [touches objectAtIndex:i];
|
||||
|
||||
if (touch.view != [RAGameView get].view)
|
||||
continue;
|
||||
@ -178,19 +178,20 @@ enum
|
||||
|
||||
- (id)_keyCommandForEvent:(UIEvent*)event
|
||||
{
|
||||
NSUInteger i;
|
||||
// This gets called twice with the same timestamp for each keypress, that's fine for polling
|
||||
// but is bad for business with events.
|
||||
/* This gets called twice with the same timestamp
|
||||
* for each keypress, that's fine for polling
|
||||
* but is bad for business with events. */
|
||||
static double last_time_stamp;
|
||||
|
||||
if (last_time_stamp == event.timestamp)
|
||||
return [super _keyCommandForEvent:event];
|
||||
last_time_stamp = event.timestamp;
|
||||
|
||||
// If the _hidEvent is null, [event _keyCode] will crash. (This happens with the on screen keyboard.)
|
||||
/* If the _hidEvent is null, [event _keyCode] will crash.
|
||||
* (This happens with the on screen keyboard). */
|
||||
if (event._hidEvent)
|
||||
{
|
||||
NSString* ch = (NSString*)event._privateInput;
|
||||
NSString *ch = (NSString*)event._privateInput;
|
||||
uint32_t character = 0;
|
||||
uint32_t mod = 0;
|
||||
|
||||
@ -203,7 +204,9 @@ enum
|
||||
|
||||
if (ch && ch.length != 0)
|
||||
{
|
||||
unsigned i;
|
||||
character = [ch characterAtIndex:0];
|
||||
|
||||
apple_input_keyboard_event(event._isKeyDown,
|
||||
(uint32_t)event._keyCode, 0, mod,
|
||||
RETRO_DEVICE_KEYBOARD);
|
||||
@ -228,19 +231,24 @@ enum
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
[super sendEvent:event];
|
||||
|
||||
|
||||
if (event.allTouches.count)
|
||||
handle_touch_event(event.allTouches.allObjects);
|
||||
|
||||
if (!(get_ios_version_major() >= 7) && [event respondsToSelector:@selector(_gsEvent)])
|
||||
{
|
||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
||||
const uint8_t* eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);
|
||||
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
|
||||
|
||||
if (eventType == GSEVENT_TYPE_KEYDOWN || eventType == GSEVENT_TYPE_KEYUP)
|
||||
apple_input_keyboard_event(eventType == GSEVENT_TYPE_KEYDOWN,
|
||||
*(uint16_t*)&eventMem[0x3C], 0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
const uint8_t *eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);
|
||||
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case GSEVENT_TYPE_KEYDOWN:
|
||||
case GSEVENT_TYPE_KEYUP:
|
||||
apple_input_keyboard_event(eventType == GSEVENT_TYPE_KEYDOWN,
|
||||
*(uint16_t*)&eventMem[0x3C], 0, 0, RETRO_DEVICE_KEYBOARD);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,15 +286,15 @@ void notify_content_loaded(void)
|
||||
- (void)applicationDidFinishLaunching:(UIApplication *)application
|
||||
{
|
||||
driver_t *driver = NULL;
|
||||
apple_platform = self;
|
||||
|
||||
apple_platform = self;
|
||||
[self setDelegate:self];
|
||||
|
||||
if (rarch_main(0, NULL))
|
||||
apple_rarch_exited();
|
||||
|
||||
// Setup window
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
/* Setup window */
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
[self pushViewController:[RAMainMenu new] animated:YES];
|
||||
@ -360,9 +368,9 @@ void notify_content_loaded(void)
|
||||
|
||||
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
||||
{
|
||||
NSString* filename = (NSString*)url.path.lastPathComponent;
|
||||
NSString *filename = (NSString*)url.path.lastPathComponent;
|
||||
NSError *error = nil;
|
||||
|
||||
NSError* error = nil;
|
||||
[[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:[self.documentsDirectory stringByAppendingPathComponent:filename] error:&error];
|
||||
|
||||
if (error)
|
||||
|
Loading…
x
Reference in New Issue
Block a user