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 "../common/RetroArch_Apple.h"
#include <retro_miscellaneous.h>
#include "../../settings_data.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
{
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()))
BINDFOR(*[self setting]).key = input_keymaps_translate_keysym_to_rk(value);
@ -143,13 +147,14 @@ NSWindowDelegate>
- (void)awakeFromNib
{
const rarch_setting_t *setting_data;
int i;
NSMutableArray* thisGroup = nil;
NSMutableArray* thisSubGroup = nil;
self.settings = [NSMutableArray array];
setting_data = (const rarch_setting_t *)driver.menu->list_settings;
const rarch_setting_t *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)
{
@ -257,34 +262,30 @@ NSWindowDelegate>
/* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */
if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")])
return objc_getAssociatedObject(item, associated_name_tag);
else
#endif
return BOXSTRING("");
return BOXSTRING("");
}
else
{
char buffer[PATH_MAX];
rarch_setting_t *setting_data = NULL, *setting = NULL;
setting_data = (rarch_setting_t*)driver.menu->list_settings;
setting = (rarch_setting_t*)&setting_data[[item intValue]];
if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")])
return BOXSTRING(setting->short_description);
else
{
switch (setting->type)
{
case ST_BOOL:
return BOXINT(*setting->value.boolean);
default:
{
setting_data_get_string_representation(setting, buffer, sizeof(buffer));
if (buffer[0] == '\0')
strlcpy(buffer, "N/A", sizeof(buffer));
return BOXSTRING(buffer);
}
}
}
char buffer[PATH_MAX_LENGTH];
rarch_setting_t *setting_data = (rarch_setting_t*)driver.menu->list_settings;
rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]];
if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")])
return BOXSTRING(setting->short_description);
switch (setting->type)
{
case ST_BOOL:
return BOXINT(*setting->value.boolean);
default:
{
setting_data_get_string_representation(setting, buffer, sizeof(buffer));
if (buffer[0] == '\0')
strlcpy(buffer, "N/A", sizeof(buffer));
return BOXSTRING(buffer);
}
}
}
}
@ -311,8 +312,10 @@ NSWindowDelegate>
case ST_BIND:
return self.binderCell;
default:
return tableColumn.dataCell;
break;
}
return tableColumn.dataCell;
}
- (IBAction)outlineViewClicked:(id)sender
@ -346,19 +349,22 @@ NSWindowDelegate>
- (void)controlTextDidEndEditing:(NSNotification*)notification
{
if ([notification object] == self.outline)
{
NSText* editor = [[notification userInfo] objectForKey:BOXSTRING("NSFieldEditor")];
id item = [self.outline itemAtRow:[self.outline selectedRow]];
NSText* editor;
id item;
if ([item isKindOfClass:[NSNumber class]])
{
rarch_setting_t *setting_data = (rarch_setting_t *)driver.menu->list_settings;
rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]];
NSString *editor_string = (NSString*)editor.string;
setting_data_set_with_string_representation(setting, editor_string.UTF8String);
}
if ([notification object] != self.outline)
return;
editor = [[notification userInfo] objectForKey:BOXSTRING("NSFieldEditor")];
item = [self.outline itemAtRow:[self.outline selectedRow]];
if ([item isKindOfClass:[NSNumber class]])
{
rarch_setting_t *setting_data = (rarch_setting_t *)driver.menu->list_settings;
rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]];
NSString *editor_string = (NSString*)editor.string;
setting_data_set_with_string_representation(setting, editor_string.UTF8String);
}
}

View File

@ -24,6 +24,7 @@
#include <file/dir_list.h>
#include "../../file_ops.h"
#include <file/file_path.h>
#include <retro_miscellaneous.h>
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,
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));
path_basedir(path);

View File

@ -20,6 +20,7 @@
#include "../../input/input_keymaps.h"
#include "../../input/drivers/apple_input.h"
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include "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
{
char buffer[PATH_MAX];
char buffer[PATH_MAX_LENGTH];
UITableViewCell* result;
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
{
char buffer[PATH_MAX];
char buffer[PATH_MAX_LENGTH];
NSString *desc = BOXSTRING("N/A");
UIAlertView *alertView;
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++)
{
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;
const char *path = NULL, *entry_label = NULL;
unsigned type = 0, w = 0;

View File

@ -25,6 +25,7 @@
#include "compat/strl.h"
#include "compat/posix_string.h"
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include <stdio.h>
#include <string.h>
@ -220,7 +221,7 @@ static const struct cmd_map map[] = {
static bool cmd_set_shader(const char *arg)
{
char msg[PATH_MAX];
char msg[PATH_MAX_LENGTH];
const char *ext;
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)
{
const char *argv = NULL;
static char config_path[PATH_MAX_LENGTH];
const char *argv = NULL;
*config_path = '\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)
{
const char *argv = NULL;
static char core_path[PATH_MAX_LENGTH];
const char *argv = NULL;
*core_path = '\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)
{
const char *argv = NULL;
static char path[PATH_MAX_LENGTH];
const char *argv = NULL;
*path = '\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)
{
const char *argv = NULL;
static char path[PATH_MAX_LENGTH];
const char *argv = NULL;
*path = '\0';
argv = (*env)->GetStringUTFChars(env, jstr, 0);

View File

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

View File

@ -25,6 +25,7 @@
#include "../../general.h"
#include <file/file_path.h>
#include <retro_miscellaneous.h>
static bool exit_spawn;
static bool exitspawn_start_game;
@ -200,7 +201,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
#endif
#ifndef IS_SALAMANDER
static char path[PATH_MAX];
static char path[PATH_MAX_LENGTH];
*path = '\0';
#if defined(_XBOX1)
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,
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,
hlsl->cg_shader->pass[i].source.path, sizeof(path_buf));

View File

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

View File

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

View File

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

View File

@ -15,6 +15,7 @@
#include <xtl.h>
#include <xgraphics.h>
#include <retro_miscellaneous.h>
#include "../screenshot.h"
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;
HRESULT ret = S_OK;
char filename[PATH_MAX];
char shotname[PATH_MAX];
char filename[PATH_MAX_LENGTH];
char shotname[PATH_MAX_LENGTH];
fill_dated_filename(shotname, "bmp", sizeof(shotname));
snprintf(filename, sizeof(filename), "%s\\%s", g_settings.screenshot_directory, shotname);