diff --git a/frontend/frontend_ios.c b/frontend/frontend_ios.c index d351c1d428..2492711955 100644 --- a/frontend/frontend_ios.c +++ b/frontend/frontend_ios.c @@ -92,10 +92,9 @@ void* rarch_main_ios(void* args) #ifdef HAVE_RGUI char* system_directory = ios_get_rarch_system_directory(); - strlcpy(g_extern.savestate_dir, system_directory, - sizeof(g_extern.savestate_dir)); - strlcpy(g_extern.savefile_dir, system_directory, - sizeof(g_extern.savefile_dir)); + strlcpy(g_extern.savestate_dir, system_directory, sizeof(g_extern.savestate_dir)); + strlcpy(g_extern.savefile_dir, system_directory, sizeof(g_extern.savefile_dir)); + free(system_directory); menu_init(); g_extern.lifecycle_mode_state |= 1ULL << MODE_GAME; @@ -168,8 +167,6 @@ void* rarch_main_ios(void* args) if (g_extern.main_is_init) rarch_main_deinit(); - - free(system_directory); #else while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()); rarch_main_deinit(); diff --git a/ios/Assets/PauseView.xib b/ios/Assets/PauseView.xib index 6a3a7d88ba..4136ceee9c 100644 --- a/ios/Assets/PauseView.xib +++ b/ios/Assets/PauseView.xib @@ -41,8 +41,11 @@ 292 {{160, 237}, {120, 44}} + + _NS:9 NO + 4 IBIPadFramework 0 0 @@ -75,6 +78,7 @@ 292 {{20, 20}, {120, 44}} + _NS:9 NO @@ -97,6 +101,7 @@ 292 {{160, 20}, {120, 44}} + _NS:9 NO @@ -119,9 +124,11 @@ 292 {{20, 237}, {120, 44}} + _NS:9 NO + 1 IBIPadFramework 0 0 @@ -141,9 +148,11 @@ 292 {{20, 186}, {120, 44}} + _NS:9 NO + 3 IBIPadFramework 0 0 @@ -163,9 +172,11 @@ 292 {{160, 186}, {120, 44}} + _NS:9 NO + 2 IBIPadFramework 0 0 @@ -185,14 +196,16 @@ 292 {{20, 135}, {260, 44}} + _NS:9 NO - 1 + 10 IBIPadFramework 10 0 + 0 1 2 3 @@ -202,7 +215,6 @@ 7 8 9 - 10 @@ -258,6 +270,7 @@ 292 {{20, 71}, {120, 44}} + _NS:9 NO @@ -280,6 +293,7 @@ 292 {{160, 71}, {120, 44}} + _NS:9 NO @@ -300,6 +314,7 @@ {{0, 20}, {300, 300}} + 3 @@ -324,12 +339,12 @@ - closeGamePressed: + basicEvent: 7 - 23 + 215 @@ -342,30 +357,30 @@ - resetGame: + basicEvent: 7 - 138 + 214 - saveState: + basicEvent: 7 - 137 + 212 - loadState: + basicEvent: 7 - 136 + 213 @@ -418,13 +433,13 @@ - + @@ -515,9 +530,20 @@ - 210 + 215 + + + + + RetroArch_iOS + UINavigationController + + IBProjectSource + ./Classes/RetroArch_iOS.h + + + - 0 IBIPadFramework YES diff --git a/ios/RetroArch/RAGameView.m b/ios/RetroArch/RAGameView.m index 13329491ed..50df2a4a7d 100644 --- a/ios/RetroArch/RAGameView.m +++ b/ios/RetroArch/RAGameView.m @@ -81,21 +81,21 @@ static UIView* g_pause_indicator_view; - (void)openPauseMenu { // Setup save state selector - UISegmentedControl* stateSelect = (UISegmentedControl*)[g_pause_view viewWithTag:1]; + UISegmentedControl* stateSelect = (UISegmentedControl*)[g_pause_view viewWithTag:10]; stateSelect.selectedSegmentIndex = (g_extern.state_slot < 10) ? g_extern.state_slot : -1; g_extern.is_paused = true; // [UIView animateWithDuration:0.2 - animations:^ { g_pause_view.alpha = 1.0f; } - completion:^(BOOL finished){}]; + animations:^{ g_pause_view.alpha = 1.0f; } + completion:^(BOOL finished) { }]; } - (void)closePauseMenu { [UIView animateWithDuration:0.2 - animations:^ { g_pause_view.alpha = 0.0f; } + animations:^{ g_pause_view.alpha = 0.0f; } completion:^(BOOL finished) { } ]; @@ -105,9 +105,9 @@ static UIView* g_pause_indicator_view; - (void)hidePauseButton { [UIView animateWithDuration:0.2 - animations:^ { g_pause_indicator_view.alpha = ALMOST_INVISIBLE; } - completion:^(BOOL finished) { } - ]; + animations:^{ g_pause_indicator_view.alpha = ALMOST_INVISIBLE; } + completion:^(BOOL finished) { } + ]; } - (void)suspend diff --git a/ios/RetroArch/RetroArch_iOS.h b/ios/RetroArch/RetroArch_iOS.h index 1232f3701b..118fd460f0 100644 --- a/ios/RetroArch/RetroArch_iOS.h +++ b/ios/RetroArch/RetroArch_iOS.h @@ -33,5 +33,6 @@ @end // utility.m -extern NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue); +extern void ios_clear_config_hack(); extern bool path_make_and_check_directory(const char* path, mode_t mode, int amode); +extern NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue); diff --git a/ios/RetroArch/input/ios_input.h b/ios/RetroArch/input/ios_input.h index f87f165f55..57f55cc834 100644 --- a/ios/RetroArch/input/ios_input.h +++ b/ios/RetroArch/input/ios_input.h @@ -44,7 +44,4 @@ extern ios_input_data_t g_ios_input_data; // Defined in main.m, must be called on the emu thread in a dispatch_sync block void ios_copy_input(ios_input_data_t* data); -// Called from main.m, defined in ios_input.c -void ios_add_key_event(bool down, unsigned keycode, uint32_t character, uint16_t keyModifiers); - #endif diff --git a/ios/RetroArch/main.m b/ios/RetroArch/main.m index 702a9db720..e81aee9cbc 100644 --- a/ios/RetroArch/main.m +++ b/ios/RetroArch/main.m @@ -154,19 +154,18 @@ int main(int argc, char *argv[]) extern void* rarch_main_ios(void* args); extern void ios_frontend_post_event(void (*fn)(void*), void* userdata); -static void event_game_reset(void* userdata) -{ - rarch_game_reset(); -} -static void event_load_state(void* userdata) +// These are based on the tag property of the button used to trigger the event +enum basic_event_t { RESET = 1, LOAD_STATE = 2, SAVE_STATE = 3, QUIT = 4 }; +static void event_basic_command(void* userdata) { - rarch_load_state(); -} - -static void event_save_state(void* userdata) -{ - rarch_save_state(); + switch ((enum basic_event_t)userdata) + { + case RESET: rarch_game_reset(); return; + case LOAD_STATE: rarch_load_state(); return; + case SAVE_STATE: rarch_save_state(); return; + case QUIT: g_extern.system.shutdown = true; return; + } } static void event_set_state_slot(void* userdata) @@ -176,31 +175,16 @@ static void event_set_state_slot(void* userdata) static void event_show_rgui(void* userdata) { - if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU)) - { - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU); - g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); - } - else - { - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU); - } -} - -static void event_quit(void* userdata) -{ - g_extern.system.shutdown = true; + const bool in_menu = g_extern.lifecycle_mode_state & (1 << MODE_MENU); + g_extern.lifecycle_mode_state &= ~(1ULL << (in_menu ? MODE_MENU : MODE_GAME)); + g_extern.lifecycle_mode_state |= (1ULL << (in_menu ? MODE_GAME : MODE_MENU)); } static void event_reload_config(void* userdata) { - // Need to clear these otherwise stale versions may be used! - memset(g_settings.input.overlay, 0, sizeof(g_settings.input.overlay)); - memset(g_settings.video.shader_path, 0, sizeof(g_settings.video.shader_path)); + ios_clear_config_hack(); uninit_drivers(); - g_extern.block_config_read = false; config_load(); init_drivers(); } @@ -398,11 +382,7 @@ static void event_reload_config(void* userdata) if (_isRunning) ios_frontend_post_event(&event_reload_config, 0); else - { - // Need to clear these otherwise stale versions may be used! - memset(g_settings.input.overlay, 0, sizeof(g_settings.input.overlay)); - memset(g_settings.video.shader_path, 0, sizeof(g_settings.video.shader_path)); - } + ios_clear_config_hack(); } - (void)refreshSystemConfig @@ -467,30 +447,14 @@ static void event_reload_config(void* userdata) } } -- (IBAction)resetGame:(id)sender +- (IBAction)basicEvent:(id)sender { if (_isRunning) - ios_frontend_post_event(&event_game_reset, 0); + ios_frontend_post_event(&event_basic_command, ((UIView*)sender).tag); [self closePauseMenu:sender]; } -- (IBAction)loadState:(id)sender -{ - if (_isRunning) - ios_frontend_post_event(&event_load_state, 0); - - [self closePauseMenu:sender]; -} - -- (IBAction)saveState:(id)sender -{ - if (_isRunning) - ios_frontend_post_event(&event_save_state, 0); - - [self closePauseMenu:sender]; -} - - (IBAction)chooseState:(id)sender { if (_isRunning) @@ -513,12 +477,6 @@ static void event_reload_config(void* userdata) btpad_set_inquiry_state(false); } -- (IBAction)closeGamePressed:(id)sender -{ - [self closePauseMenu:sender]; - ios_frontend_post_event(event_quit, 0); -} - - (IBAction)showSettings { if (_module) diff --git a/ios/RetroArch/utility.m b/ios/RetroArch/utility.m index 9d0544723b..48dc91fdec 100644 --- a/ios/RetroArch/utility.m +++ b/ios/RetroArch/utility.m @@ -13,9 +13,20 @@ * If not, see . */ +#include + +#include "general.h" #include "file.h" #import "views.h" +// Little nudge to prevent stale values when reloading the confg file +void ios_clear_config_hack() +{ + g_extern.block_config_read = false; + memset(g_settings.input.overlay, 0, sizeof(g_settings.input.overlay)); + memset(g_settings.video.shader_path, 0, sizeof(g_settings.video.shader_path)); +} + // Fetch a value from a config file, returning defaultValue if the value is not present NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue) {