mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
(iOS/OSX) Make frontend code more generic
This commit is contained in:
parent
266511b765
commit
423f4944ad
@ -21,49 +21,51 @@
|
||||
#include "../conf/config_file.h"
|
||||
#include "../file.h"
|
||||
|
||||
#ifdef IOS
|
||||
#include "../ios/RetroArch/rarch_wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RGUI
|
||||
#include "../frontend/menu/rgui.h"
|
||||
#endif
|
||||
|
||||
static pthread_mutex_t ios_event_queue_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct
|
||||
{
|
||||
void (*function)(void*);
|
||||
void* userdata;
|
||||
} ios_event_queue[16];
|
||||
static uint32_t ios_event_queue_size;
|
||||
} apple_event_queue[16];
|
||||
|
||||
void ios_frontend_post_event(void (*fn)(void*), void* userdata)
|
||||
static uint32_t apple_event_queue_size;
|
||||
|
||||
void apple_frontend_post_event(void (*fn)(void*), void* userdata)
|
||||
{
|
||||
pthread_mutex_lock(&ios_event_queue_lock);
|
||||
pthread_mutex_lock(&apple_event_queue_lock);
|
||||
|
||||
if (ios_event_queue_size < 16)
|
||||
if (apple_event_queue_size < 16)
|
||||
{
|
||||
ios_event_queue[ios_event_queue_size].function = fn;
|
||||
ios_event_queue[ios_event_queue_size].userdata = userdata;
|
||||
ios_event_queue_size ++;
|
||||
apple_event_queue[apple_event_queue_size].function = fn;
|
||||
apple_event_queue[apple_event_queue_size].userdata = userdata;
|
||||
apple_event_queue_size ++;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ios_event_queue_lock);
|
||||
pthread_mutex_unlock(&apple_event_queue_lock);
|
||||
}
|
||||
|
||||
static void process_events()
|
||||
{
|
||||
pthread_mutex_lock(&ios_event_queue_lock);
|
||||
pthread_mutex_lock(&apple_event_queue_lock);
|
||||
|
||||
for (int i = 0; i < ios_event_queue_size; i ++)
|
||||
ios_event_queue[i].function(ios_event_queue[i].userdata);
|
||||
for (int i = 0; i < apple_event_queue_size; i ++)
|
||||
apple_event_queue[i].function(apple_event_queue[i].userdata);
|
||||
|
||||
ios_event_queue_size = 0;
|
||||
apple_event_queue_size = 0;
|
||||
|
||||
pthread_mutex_unlock(&ios_event_queue_lock);
|
||||
pthread_mutex_unlock(&apple_event_queue_lock);
|
||||
}
|
||||
|
||||
|
||||
static void ios_free_main_wrap(struct rarch_main_wrap* wrap)
|
||||
static void apple_free_main_wrap(struct rarch_main_wrap* wrap)
|
||||
{
|
||||
if (wrap)
|
||||
{
|
||||
@ -77,11 +79,11 @@ static void ios_free_main_wrap(struct rarch_main_wrap* wrap)
|
||||
free(wrap);
|
||||
}
|
||||
|
||||
void* rarch_main_ios(void* args)
|
||||
void* rarch_main_apple(void* args)
|
||||
{
|
||||
struct rarch_main_wrap* argdata = (struct rarch_main_wrap*)args;
|
||||
int init_ret = rarch_main_init_wrap(argdata);
|
||||
ios_free_main_wrap(argdata);
|
||||
apple_free_main_wrap(argdata);
|
||||
|
||||
if (init_ret)
|
||||
{
|
@ -411,8 +411,8 @@ MAIN
|
||||
#include "../frontend/frontend_bbqnx.c"
|
||||
#elif defined(ANDROID)
|
||||
#include "../frontend/frontend_android.c"
|
||||
#elif defined(IOS)
|
||||
#include "../frontend/frontend_ios.c"
|
||||
#elif defined(__APPLE__)
|
||||
#include "../frontend/frontend_objc.c"
|
||||
#endif
|
||||
|
||||
#ifndef IS_XCODE
|
||||
|
@ -96,8 +96,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// From frontend/frontend_ios.c
|
||||
extern void* rarch_main_ios(void* args);
|
||||
extern void ios_frontend_post_event(void (*fn)(void*), void* userdata);
|
||||
extern void* rarch_main_apple(void* args);
|
||||
extern void apple_frontend_post_event(void (*fn)(void*), void* userdata);
|
||||
|
||||
|
||||
// These are based on the tag property of the button used to trigger the event
|
||||
@ -282,7 +282,7 @@ static void event_reload_config(void* userdata)
|
||||
else
|
||||
load_data->config_path = strdup(RAModuleInfo.globalConfigPath.UTF8String);
|
||||
|
||||
if (pthread_create(&_retroThread, 0, rarch_main_ios, load_data))
|
||||
if (pthread_create(&_retroThread, 0, rarch_main_apple, load_data))
|
||||
{
|
||||
[self rarchExited:NO];
|
||||
return;
|
||||
@ -318,7 +318,7 @@ static void event_reload_config(void* userdata)
|
||||
- (void)refreshConfig
|
||||
{
|
||||
if (_isRunning)
|
||||
ios_frontend_post_event(&event_reload_config, 0);
|
||||
apple_frontend_post_event(&event_reload_config, 0);
|
||||
else
|
||||
objc_clear_config_hack();
|
||||
}
|
||||
@ -388,7 +388,7 @@ static void event_reload_config(void* userdata)
|
||||
- (IBAction)basicEvent:(id)sender
|
||||
{
|
||||
if (_isRunning)
|
||||
ios_frontend_post_event(&event_basic_command, ((UIView*)sender).tag);
|
||||
apple_frontend_post_event(&event_basic_command, ((UIView*)sender).tag);
|
||||
|
||||
[self closePauseMenu:sender];
|
||||
}
|
||||
@ -396,13 +396,13 @@ static void event_reload_config(void* userdata)
|
||||
- (IBAction)chooseState:(id)sender
|
||||
{
|
||||
if (_isRunning)
|
||||
ios_frontend_post_event(event_set_state_slot, (void*)((UISegmentedControl*)sender).selectedSegmentIndex);
|
||||
apple_frontend_post_event(event_set_state_slot, (void*)((UISegmentedControl*)sender).selectedSegmentIndex);
|
||||
}
|
||||
|
||||
- (IBAction)showRGUI:(id)sender
|
||||
{
|
||||
if (_isRunning)
|
||||
ios_frontend_post_event(event_show_rgui, 0);
|
||||
apple_frontend_post_event(event_show_rgui, 0);
|
||||
|
||||
[self closePauseMenu:sender];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user