Use PATH_MAX_LENGTH instead of PATH_MAX.

Refactor OSX settings menu code somewhat
This commit is contained in:
twinaphex 2015-01-17 05:47:33 +01:00
parent 3404f7a495
commit 46402deb04
12 changed files with 75 additions and 63 deletions

View File

@ -16,6 +16,7 @@
#import <objc/runtime.h> #import <objc/runtime.h>
#import "../common/RetroArch_Apple.h" #import "../common/RetroArch_Apple.h"
#include <retro_miscellaneous.h>
#include "../../settings_data.h" #include "../../settings_data.h"
#include "../../input/drivers/apple_input.h" #include "../../input/drivers/apple_input.h"
@ -69,7 +70,10 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
- (void)checkBind:(NSTimer*)send - (void)checkBind:(NSTimer*)send
{ {
int32_t value = 0; int32_t value = 0;
int32_t idx = self.setting->index ? self.setting->index - 1 : 0; int32_t idx = 0;
if (self.setting->index)
idx = self.setting->index - 1;
if ((value = apple_input_find_any_key())) if ((value = apple_input_find_any_key()))
BINDFOR(*[self setting]).key = input_keymaps_translate_keysym_to_rk(value); BINDFOR(*[self setting]).key = input_keymaps_translate_keysym_to_rk(value);
@ -143,13 +147,14 @@ NSWindowDelegate>
- (void)awakeFromNib - (void)awakeFromNib
{ {
const rarch_setting_t *setting_data; int i;
NSMutableArray* thisGroup = nil; NSMutableArray* thisGroup = nil;
NSMutableArray* thisSubGroup = nil; NSMutableArray* thisSubGroup = nil;
self.settings = [NSMutableArray array]; const rarch_setting_t *setting_data = (const rarch_setting_t *)driver.menu->list_settings;
setting_data = (const rarch_setting_t *)driver.menu->list_settings;
for (int i = 0; setting_data[i].type; i ++) self.settings = [NSMutableArray array];
for (i = 0; setting_data[i].type; i ++)
{ {
switch (setting_data[i].type) switch (setting_data[i].type)
{ {
@ -257,21 +262,18 @@ NSWindowDelegate>
/* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */ /* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */
if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")]) if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")])
return objc_getAssociatedObject(item, associated_name_tag); return objc_getAssociatedObject(item, associated_name_tag);
else
#endif #endif
return BOXSTRING(""); return BOXSTRING("");
} }
else else
{ {
char buffer[PATH_MAX]; char buffer[PATH_MAX_LENGTH];
rarch_setting_t *setting_data = NULL, *setting = NULL; rarch_setting_t *setting_data = (rarch_setting_t*)driver.menu->list_settings;
setting_data = (rarch_setting_t*)driver.menu->list_settings; rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]];
setting = (rarch_setting_t*)&setting_data[[item intValue]];
if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")]) if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")])
return BOXSTRING(setting->short_description); return BOXSTRING(setting->short_description);
else
{
switch (setting->type) switch (setting->type)
{ {
case ST_BOOL: case ST_BOOL:
@ -286,7 +288,6 @@ NSWindowDelegate>
} }
} }
} }
}
- (NSCell*)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item - (NSCell*)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{ {
@ -311,8 +312,10 @@ NSWindowDelegate>
case ST_BIND: case ST_BIND:
return self.binderCell; return self.binderCell;
default: default:
return tableColumn.dataCell; break;
} }
return tableColumn.dataCell;
} }
- (IBAction)outlineViewClicked:(id)sender - (IBAction)outlineViewClicked:(id)sender
@ -346,10 +349,14 @@ NSWindowDelegate>
- (void)controlTextDidEndEditing:(NSNotification*)notification - (void)controlTextDidEndEditing:(NSNotification*)notification
{ {
if ([notification object] == self.outline) NSText* editor;
{ id item;
NSText* editor = [[notification userInfo] objectForKey:BOXSTRING("NSFieldEditor")];
id item = [self.outline itemAtRow:[self.outline selectedRow]]; if ([notification object] != self.outline)
return;
editor = [[notification userInfo] objectForKey:BOXSTRING("NSFieldEditor")];
item = [self.outline itemAtRow:[self.outline selectedRow]];
if ([item isKindOfClass:[NSNumber class]]) if ([item isKindOfClass:[NSNumber class]])
{ {
@ -360,6 +367,5 @@ NSWindowDelegate>
setting_data_set_with_string_representation(setting, editor_string.UTF8String); setting_data_set_with_string_representation(setting, editor_string.UTF8String);
} }
} }
}
@end @end

View File

@ -24,6 +24,7 @@
#include <file/dir_list.h> #include <file/dir_list.h>
#include "../../file_ops.h" #include "../../file_ops.h"
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h>
static const void* const associated_module_key = &associated_module_key; static const void* const associated_module_key = &associated_module_key;
@ -31,9 +32,9 @@ static bool zlib_extract_callback(const char *name,
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
uint32_t crc32, void *userdata) uint32_t crc32, void *userdata)
{ {
char path[PATH_MAX]; char path[PATH_MAX_LENGTH];
// Make directory /* Make directory */
fill_pathname_join(path, (const char*)userdata, name, sizeof(path)); fill_pathname_join(path, (const char*)userdata, name, sizeof(path));
path_basedir(path); path_basedir(path);

View File

@ -20,6 +20,7 @@
#include "../../input/input_keymaps.h" #include "../../input/input_keymaps.h"
#include "../../input/drivers/apple_input.h" #include "../../input/drivers/apple_input.h"
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h>
#include "menu.h" #include "menu.h"
#include "../../menu/menu.h" #include "../../menu/menu.h"
@ -256,7 +257,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (UITableViewCell*)cellForTableView:(UITableView*)tableView - (UITableViewCell*)cellForTableView:(UITableView*)tableView
{ {
char buffer[PATH_MAX]; char buffer[PATH_MAX_LENGTH];
UITableViewCell* result; UITableViewCell* result;
static NSString* const cell_id = @"string_setting"; static NSString* const cell_id = @"string_setting";
@ -292,7 +293,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller - (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller
{ {
char buffer[PATH_MAX]; char buffer[PATH_MAX_LENGTH];
NSString *desc = BOXSTRING("N/A"); NSString *desc = BOXSTRING("N/A");
UIAlertView *alertView; UIAlertView *alertView;
UITextField *field; UITextField *field;
@ -640,7 +641,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
for (i = driver.menu->begin; i < end; i++) for (i = driver.menu->begin; i < end; i++)
{ {
rarch_setting_t *setting; rarch_setting_t *setting;
char type_str[PATH_MAX], path_buf[PATH_MAX]; char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
menu_file_list_cbs_t *cbs = NULL; menu_file_list_cbs_t *cbs = NULL;
const char *path = NULL, *entry_label = NULL; const char *path = NULL, *entry_label = NULL;
unsigned type = 0, w = 0; unsigned type = 0, w = 0;

View File

@ -25,6 +25,7 @@
#include "compat/strl.h" #include "compat/strl.h"
#include "compat/posix_string.h" #include "compat/posix_string.h"
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -220,7 +221,7 @@ static const struct cmd_map map[] = {
static bool cmd_set_shader(const char *arg) static bool cmd_set_shader(const char *arg)
{ {
char msg[PATH_MAX]; char msg[PATH_MAX_LENGTH];
const char *ext; const char *ext;
enum rarch_shader_type type = RARCH_SHADER_NONE; enum rarch_shader_type type = RARCH_SHADER_NONE;

View File

@ -532,8 +532,8 @@ static void frontend_android_get_environment_settings(int *argc,
if (android_app->getStringExtra && jstr) if (android_app->getStringExtra && jstr)
{ {
const char *argv = NULL;
static char config_path[PATH_MAX_LENGTH]; static char config_path[PATH_MAX_LENGTH];
const char *argv = NULL;
*config_path = '\0'; *config_path = '\0';
argv = (*env)->GetStringUTFChars(env, jstr, 0); argv = (*env)->GetStringUTFChars(env, jstr, 0);
@ -579,8 +579,8 @@ static void frontend_android_get_environment_settings(int *argc,
if (android_app->getStringExtra && jstr) if (android_app->getStringExtra && jstr)
{ {
const char *argv = NULL;
static char core_path[PATH_MAX_LENGTH]; static char core_path[PATH_MAX_LENGTH];
const char *argv = NULL;
*core_path = '\0'; *core_path = '\0';
argv = (*env)->GetStringUTFChars(env, jstr, 0); argv = (*env)->GetStringUTFChars(env, jstr, 0);
@ -599,8 +599,8 @@ static void frontend_android_get_environment_settings(int *argc,
if (android_app->getStringExtra && jstr) if (android_app->getStringExtra && jstr)
{ {
const char *argv = NULL;
static char path[PATH_MAX_LENGTH]; static char path[PATH_MAX_LENGTH];
const char *argv = NULL;
*path = '\0'; *path = '\0';
argv = (*env)->GetStringUTFChars(env, jstr, 0); argv = (*env)->GetStringUTFChars(env, jstr, 0);
@ -623,8 +623,8 @@ static void frontend_android_get_environment_settings(int *argc,
if (android_app->getStringExtra && jstr) if (android_app->getStringExtra && jstr)
{ {
const char *argv = NULL;
static char path[PATH_MAX_LENGTH]; static char path[PATH_MAX_LENGTH];
const char *argv = NULL;
*path = '\0'; *path = '\0';
argv = (*env)->GetStringUTFChars(env, jstr, 0); argv = (*env)->GetStringUTFChars(env, jstr, 0);

View File

@ -47,7 +47,7 @@ struct android_app
const ASensor* accelerometerSensor; const ASensor* accelerometerSensor;
uint64_t sensor_state_mask; uint64_t sensor_state_mask;
sthread_t *thread; sthread_t *thread;
char current_ime[PATH_MAX]; char current_ime[PATH_MAX_LENGTH];
jmethodID getIntent; jmethodID getIntent;
jmethodID onRetroArchExit; jmethodID onRetroArchExit;
jmethodID getStringExtra; jmethodID getStringExtra;

View File

@ -25,6 +25,7 @@
#include "../../general.h" #include "../../general.h"
#include <file/file_path.h> #include <file/file_path.h>
#include <retro_miscellaneous.h>
static bool exit_spawn; static bool exit_spawn;
static bool exitspawn_start_game; static bool exitspawn_start_game;
@ -200,7 +201,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
#endif #endif
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
static char path[PATH_MAX]; static char path[PATH_MAX_LENGTH];
*path = '\0'; *path = '\0';
#if defined(_XBOX1) #if defined(_XBOX1)
RARCH_LOG("Gets here top.\n"); RARCH_LOG("Gets here top.\n");

View File

@ -226,7 +226,7 @@ static void set_program_attributes(hlsl_shader_data_t *hlsl, unsigned i)
static bool load_shader(hlsl_shader_data_t *hlsl, static bool load_shader(hlsl_shader_data_t *hlsl,
void *data, const char *cgp_path, unsigned i) void *data, const char *cgp_path, unsigned i)
{ {
char path_buf[PATH_MAX]; char path_buf[PATH_MAX_LENGTH];
fill_pathname_resolve_relative(path_buf, cgp_path, fill_pathname_resolve_relative(path_buf, cgp_path,
hlsl->cg_shader->pass[i].source.path, sizeof(path_buf)); hlsl->cg_shader->pass[i].source.path, sizeof(path_buf));

View File

@ -58,7 +58,7 @@ struct input_device
int fd; int fd;
dev_t dev; dev_t dev;
device_handle_cb handle_cb; device_handle_cb handle_cb;
char devnode[PATH_MAX]; char devnode[PATH_MAX_LENGTH];
union union
{ {

View File

@ -172,7 +172,8 @@ static void handle_plugged_pad(void)
else if (event->mask & (IN_CREATE | IN_ATTRIB)) else if (event->mask & (IN_CREATE | IN_ATTRIB))
{ {
bool ret; bool ret;
char path[PATH_MAX]; char path[PATH_MAX_LENGTH];
snprintf(path, sizeof(path), "/dev/input/%s", event->name); snprintf(path, sizeof(path), "/dev/input/%s", event->name);
ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]); ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]);
@ -221,7 +222,7 @@ static bool linuxraw_joypad_init(void)
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
char path[PATH_MAX]; char path[PATH_MAX_LENGTH];
struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i]; struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i];
if (!pad) if (!pad)

View File

@ -61,7 +61,7 @@ typedef struct
typedef struct typedef struct
{ {
char name[256]; char name[256];
char rom[PATH_MAX]; char rom[PATH_MAX_LENGTH];
float alpha; float alpha;
float zoom; float zoom;
float y; float y;
@ -73,7 +73,7 @@ typedef struct
typedef struct typedef struct
{ {
char name[256]; char name[256];
char libretro[PATH_MAX]; char libretro[PATH_MAX_LENGTH];
GLuint icon; GLuint icon;
GLuint item_icon; GLuint item_icon;
float alpha; float alpha;
@ -87,7 +87,7 @@ typedef struct
struct lakka_texture_item struct lakka_texture_item
{ {
GLuint id; GLuint id;
char path[PATH_MAX]; char path[PATH_MAX_LENGTH];
}; };
typedef struct lakka_handle typedef struct lakka_handle

View File

@ -15,6 +15,7 @@
#include <xtl.h> #include <xtl.h>
#include <xgraphics.h> #include <xgraphics.h>
#include <retro_miscellaneous.h>
#include "../screenshot.h" #include "../screenshot.h"
bool screenshot_dump(const char *folder, const void *frame, bool screenshot_dump(const char *folder, const void *frame,
@ -29,8 +30,8 @@ bool screenshot_dump(const char *folder, const void *frame,
d3d_video_t *d3d = (d3d_video_t*)driver.video_data; d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
HRESULT ret = S_OK; HRESULT ret = S_OK;
char filename[PATH_MAX]; char filename[PATH_MAX_LENGTH];
char shotname[PATH_MAX]; char shotname[PATH_MAX_LENGTH];
fill_dated_filename(shotname, "bmp", sizeof(shotname)); fill_dated_filename(shotname, "bmp", sizeof(shotname));
snprintf(filename, sizeof(filename), "%s\\%s", g_settings.screenshot_directory, shotname); snprintf(filename, sizeof(filename), "%s\\%s", g_settings.screenshot_directory, shotname);