mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-22 02:44:38 +00:00
(iOS) Some cleanup
This commit is contained in:
parent
9743cada8b
commit
9cb5513e59
@ -26,9 +26,6 @@
|
||||
- (void)refreshConfig;
|
||||
- (void)refreshSystemConfig;
|
||||
|
||||
- (IBAction)startBluetooth;
|
||||
- (IBAction)stopBluetooth;
|
||||
|
||||
@property (strong, nonatomic) NSString* documentsDirectory; // e.g. /var/mobile/Documents
|
||||
@property (strong, nonatomic) NSString* systemDirectory; // e.g. /var/mobile/Documents/.RetroArch
|
||||
@property (strong, nonatomic) NSString* systemConfigPath; // e.g. /var/mobile/Documents/.RetroArch/frontend.cfg
|
||||
@ -37,3 +34,4 @@
|
||||
|
||||
// utility.m
|
||||
extern NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue);
|
||||
extern bool path_make_and_check_directory(const char* path, mode_t mode, int amode);
|
||||
|
@ -64,7 +64,7 @@ static bool btstack_loaded;
|
||||
static bool btstack_open;
|
||||
static bool btstack_poweron;
|
||||
|
||||
bool btstack_load()
|
||||
bool btstack_try_load()
|
||||
{
|
||||
assert(sizeof(void**) == sizeof(void(*)()));
|
||||
|
||||
@ -108,47 +108,28 @@ bool btstack_load()
|
||||
return true;
|
||||
}
|
||||
|
||||
void btstack_start()
|
||||
void btstack_set_poweron(bool on)
|
||||
{
|
||||
if (!btstack_load())
|
||||
if (!btstack_try_load())
|
||||
return;
|
||||
|
||||
if (!btstack_open)
|
||||
|
||||
if (!btstack_open && bt_open_ptr())
|
||||
{
|
||||
if (bt_open_ptr())
|
||||
{
|
||||
ios_add_log_message("BTstack: bt_open failed");
|
||||
btstack_loaded = false;
|
||||
return;
|
||||
}
|
||||
ios_add_log_message("BTstack: bt_open failed");
|
||||
btstack_loaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
btstack_open = true;
|
||||
if (!btstack_poweron)
|
||||
if (on != btstack_poweron)
|
||||
{
|
||||
ios_add_log_message("BTstack: Turning on");
|
||||
bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_ON);
|
||||
btstack_poweron = true;
|
||||
}
|
||||
}
|
||||
|
||||
void btstack_stop()
|
||||
{
|
||||
if (btstack_load() && btstack_open && btstack_poweron)
|
||||
{
|
||||
ios_add_log_message("BTstack: Turning off");
|
||||
bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_OFF);
|
||||
btstack_poweron = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool btstack_is_loaded()
|
||||
{
|
||||
return btstack_load();
|
||||
btstack_poweron = on;
|
||||
ios_add_log_message("BTstack: Turning %s", on ? "on" : "off");
|
||||
bt_send_cmd_ptr(btstack_set_power_mode_ptr, on ? HCI_POWER_ON : HCI_POWER_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
bool btstack_is_running()
|
||||
{
|
||||
return btstack_poweron;
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,8 @@
|
||||
#include "btstack/utils.h"
|
||||
#include "btstack/btstack.h"
|
||||
|
||||
bool btstack_load();
|
||||
void btstack_start();
|
||||
void btstack_stop();
|
||||
bool btstack_is_loaded();
|
||||
bool btstack_try_load();
|
||||
void btstack_set_poweron(bool on);
|
||||
bool btstack_is_running();
|
||||
|
||||
#ifndef BUILDING_BTDYNAMIC
|
||||
|
@ -13,7 +13,6 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -37,14 +36,6 @@ static bool enable_btstack;
|
||||
static bool use_icade;
|
||||
static uint32_t icade_buttons;
|
||||
|
||||
bool path_make_and_check_directory(const char* path, mode_t mode, int amode)
|
||||
{
|
||||
if (!path_is_directory(path) && mkdir(path, mode) != 0)
|
||||
return false;
|
||||
|
||||
return access(path, amode) == 0;
|
||||
}
|
||||
|
||||
// Input helpers
|
||||
void ios_copy_input(ios_input_data_t* data)
|
||||
{
|
||||
@ -445,10 +436,7 @@ static void event_reload_config(void* userdata)
|
||||
config_get_bool(conf, "ios_use_icade", &use_icade);
|
||||
config_get_bool(conf, "ios_use_btstack", &enable_btstack);
|
||||
|
||||
if (enable_btstack)
|
||||
[self startBluetooth];
|
||||
else
|
||||
[self stopBluetooth];
|
||||
btstack_set_poweron(enable_btstack);
|
||||
|
||||
config_file_free(conf);
|
||||
}
|
||||
@ -542,19 +530,6 @@ static void event_reload_config(void* userdata)
|
||||
[self pushViewController:[RASystemSettingsList new] animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark Bluetooth Helpers
|
||||
- (IBAction)startBluetooth
|
||||
{
|
||||
if (btstack_is_loaded() && !btstack_is_running())
|
||||
btstack_start();
|
||||
}
|
||||
|
||||
- (IBAction)stopBluetooth
|
||||
{
|
||||
if (btstack_is_loaded())
|
||||
btstack_stop();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void ios_rarch_exited(void* result)
|
||||
|
@ -351,7 +351,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
|
||||
[NSArray arrayWithObjects:@"Bluetooth",
|
||||
// TODO: Note that with this turned off the native bluetooth is expected to be a real keyboard
|
||||
boolean_setting(config, @"ios_use_icade", @"Native BT is iCade", @"false"),
|
||||
btstack_is_loaded() ? boolean_setting(config, @"ios_use_btstack", @"Enable BTstack", @"false") : nil,
|
||||
btstack_try_load() ? boolean_setting(config, @"ios_use_btstack", @"Enable BTstack", @"false") : nil,
|
||||
nil],
|
||||
[NSArray arrayWithObjects:@"Orientations",
|
||||
boolean_setting(config, @"ios_allow_portrait", @"Portrait", @"true"),
|
||||
@ -392,16 +392,9 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
|
||||
if ([@"Diagnostic Log" isEqualToString:setting.label])
|
||||
[[RetroArch_iOS get] pushViewController:[RALogView new] animated:YES];
|
||||
else if ([@"Enable BTstack" isEqualToString:setting.label])
|
||||
{
|
||||
if ([@"true" isEqualToString:setting.value])
|
||||
[RetroArch_iOS.get startBluetooth];
|
||||
else
|
||||
[RetroArch_iOS.get stopBluetooth];
|
||||
}
|
||||
btstack_set_poweron([setting.value isEqualToString:@"true"]);
|
||||
else if([@"Global Core Config" isEqualToString:setting.label])
|
||||
{
|
||||
[RetroArch_iOS.get pushViewController:[[RASettingsList alloc] initWithModule:nil] animated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
RAModuleInfo* data = (RAModuleInfo*)objc_getAssociatedObject(setting, "USERDATA");
|
||||
|
@ -13,6 +13,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "file.h"
|
||||
#import "views.h"
|
||||
|
||||
// Fetch a value from a config file, returning defaultValue if the value is not present
|
||||
@ -27,6 +28,15 @@ NSString* ios_get_value_from_config(config_file_t* config, NSString* name, NSStr
|
||||
return result;
|
||||
}
|
||||
|
||||
// Ensures a directory exists and has correct permissions
|
||||
bool path_make_and_check_directory(const char* path, mode_t mode, int amode)
|
||||
{
|
||||
if (!path_is_directory(path) && mkdir(path, mode) != 0)
|
||||
return false;
|
||||
|
||||
return access(path, amode) == 0;
|
||||
}
|
||||
|
||||
// Simple class to reduce code duplication for fixed table views
|
||||
@implementation RATableViewController
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user