Updates pt. 6

This commit is contained in:
twinaphex 2015-03-20 22:41:15 +01:00
parent 208815fd8e
commit 55ba05a1a3
15 changed files with 74 additions and 42 deletions

View File

@ -360,7 +360,8 @@ static void poll_iteration(void)
#pragma mark Menus #pragma mark Menus
- (IBAction)showCoresDirectory:(id)sender - (IBAction)showCoresDirectory:(id)sender
{ {
[[NSWorkspace sharedWorkspace] openFile:BOXSTRING(g_settings.libretro_directory)]; settings_t *settings = config_get_ptr();
[[NSWorkspace sharedWorkspace] openFile:BOXSTRING(settings->libretro_directory)];
} }
- (IBAction)showPreferences:(id)sender - (IBAction)showPreferences:(id)sender

View File

@ -68,14 +68,15 @@ static RAScreen* get_chosen_screen(void)
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_6) #if defined(OSX) && !defined(MAC_OS_X_VERSION_10_6)
return [NSScreen mainScreen]; return [NSScreen mainScreen];
#else #else
if (g_settings.video.monitor_index >= RAScreen.screens.count) settings_t *settings = config_get_ptr();
if (settings->video.monitor_index >= RAScreen.screens.count)
{ {
RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n"); RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n");
return RAScreen.mainScreen; return RAScreen.mainScreen;
} }
NSArray *screens = [RAScreen screens]; NSArray *screens = [RAScreen screens];
return (RAScreen*)[screens objectAtIndex:g_settings.video.monitor_index]; return (RAScreen*)[screens objectAtIndex:settings->video.monitor_index];
#endif #endif
} }
@ -281,13 +282,16 @@ static void apple_gfx_ctx_update_window_title(void *data)
static char buf[128], buf_fps[128]; static char buf[128], buf_fps[128];
bool got_text = video_monitor_get_fps(buf, sizeof(buf), bool got_text = video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps)); buf_fps, sizeof(buf_fps));
settings_t *settings = config_get_ptr();
(void)got_text; (void)got_text;
#ifdef OSX #ifdef OSX
static const char* const text = buf; /* < Can't access buffer directly in the block */ static const char* const text = buf; /* < Can't access buffer directly in the block */
if (got_text) if (got_text)
[[g_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]]; [[g_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]];
#endif #endif
if (g_settings.fps_show) if (settings->fps_show)
rarch_main_msg_queue_push(buf_fps, 1, 1, false); rarch_main_msg_queue_push(buf_fps, 1, 1, false);
} }

View File

@ -231,6 +231,8 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)browseTo:(NSString*)path - (void)browseTo:(NSString*)path
{ {
settings_t *settings = config_get_ptr();
self.path = path; self.path = path;
self.title = self.path.lastPathComponent; self.title = self.path.lastPathComponent;
@ -241,7 +243,8 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
[self.sections addObject:[NSMutableArray arrayWithObject:i]]; [self.sections addObject:[NSMutableArray arrayWithObject:i]];
/* List contents */ /* List contents */
struct string_list *contents = dir_list_new(self.path.UTF8String, g_settings.menu.navigation.browser.filter.supported_extensions_enable ? self.extensions.UTF8String : NULL, true); struct string_list *contents = dir_list_new(self.path.UTF8String,
settings->menu.navigation.browser.filter.supported_extensions_enable ? self.extensions.UTF8String : NULL, true);
if (contents) if (contents)
{ {

View File

@ -18,18 +18,20 @@
static const char *android_joypad_name(unsigned pad) static const char *android_joypad_name(unsigned pad)
{ {
return g_settings.input.device_names[pad]; settings_t *settings = config_get_ptr();
return settings->input.device_names[pad];
} }
static bool android_joypad_init(void) static bool android_joypad_init(void)
{ {
unsigned autoconf_pad; unsigned autoconf_pad;
settings_t *settings = config_get_ptr();
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
android_joypad_name(autoconf_pad), android_joypad_name(autoconf_pad),
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,
android_joypad_name(autoconf_pad), 0, 0, android_joypad_name(autoconf_pad), 0, 0,

View File

@ -160,6 +160,7 @@ static void add_device(void* context, IOReturn result,
char device_name[PATH_MAX_LENGTH]; char device_name[PATH_MAX_LENGTH];
CFStringRef device_name_ref; CFStringRef device_name_ref;
CFNumberRef vendorID, productID; CFNumberRef vendorID, productID;
settings_t *settings = config_get_ptr();
struct pad_connection* connection = (struct pad_connection*) struct pad_connection* connection = (struct pad_connection*)
calloc(1, sizeof(*connection)); calloc(1, sizeof(*connection));
@ -199,8 +200,8 @@ static void add_device(void* context, IOReturn result,
if (device_name[0] == '\0') if (device_name[0] == '\0')
return; return;
strlcpy(g_settings.input.device_names[connection->slot], strlcpy(settings->input.device_names[connection->slot],
device_name, sizeof(g_settings.input.device_names)); device_name, sizeof(settings->input.device_names));
input_config_autoconfigure_joypad(connection->slot, input_config_autoconfigure_joypad(connection->slot,
device_name, connection->v_id, connection->p_id, apple_hid_joypad.ident); device_name, connection->v_id, connection->p_id, apple_hid_joypad.ident);

View File

@ -196,14 +196,16 @@ static const char *gx_joypad_name_static(unsigned pad)
static void handle_hotplug(unsigned port, uint32_t ptype) static void handle_hotplug(unsigned port, uint32_t ptype)
{ {
settings_t *settings = config_get_ptr();
pad_type[port] = ptype; pad_type[port] = ptype;
if (!g_settings.input.autodetect_enable) if (!settings->input.autodetect_enable)
return; return;
strlcpy(g_settings.input.device_names[port], strlcpy(settings->input.device_names[port],
gx_joypad_name(port), gx_joypad_name(port),
sizeof(g_settings.input.device_names[port])); sizeof(settings->input.device_names[port]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(port, input_config_autoconfigure_joypad(port,
gx_joypad_name(port), gx_joypad_name(port),
@ -214,6 +216,7 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
static bool gx_joypad_init(void) static bool gx_joypad_init(void)
{ {
int autoconf_pad; int autoconf_pad;
settings_t *settings = config_get_ptr();
SYS_SetResetCallback(reset_cb); SYS_SetResetCallback(reset_cb);
#ifdef HW_RVL #ifdef HW_RVL
@ -235,9 +238,9 @@ static bool gx_joypad_init(void)
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
{ {
pad_type[autoconf_pad] = WPAD_EXP_GAMECUBE; pad_type[autoconf_pad] = WPAD_EXP_GAMECUBE;
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
gx_joypad_name_static(autoconf_pad), gx_joypad_name_static(autoconf_pad),
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,
gx_joypad_name_static(autoconf_pad), gx_joypad_name_static(autoconf_pad),

View File

@ -76,6 +76,8 @@ static void poll_pad(struct linuxraw_joypad *pad)
static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad) static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad)
{ {
settings_t *settings = config_get_ptr();
if (pad->fd >= 0) if (pad->fd >= 0)
return false; return false;
@ -89,7 +91,7 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
*pad->ident = '\0'; *pad->ident = '\0';
if (pad->fd >= 0) if (pad->fd >= 0)
{ {
if (ioctl(pad->fd, JSIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) >= 0) if (ioctl(pad->fd, JSIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) >= 0)
{ {
RARCH_LOG("[Joypad]: Found pad: %s on %s.\n", pad->ident, path); RARCH_LOG("[Joypad]: Found pad: %s on %s.\n", pad->ident, path);
@ -216,6 +218,7 @@ static void linuxraw_joypad_setup_notify(void)
static bool linuxraw_joypad_init(void) static bool linuxraw_joypad_init(void)
{ {
unsigned i; unsigned i;
settings_t *settings = config_get_ptr();
g_epoll = epoll_create(MAX_USERS + 1); g_epoll = epoll_create(MAX_USERS + 1);
if (g_epoll < 0) if (g_epoll < 0)
@ -229,8 +232,8 @@ static bool linuxraw_joypad_init(void)
if (!pad) if (!pad)
continue; continue;
pad->fd = -1; pad->fd = -1;
pad->ident = g_settings.input.device_names[i]; pad->ident = settings->input.device_names[i];
snprintf(path, sizeof(path), "/dev/input/js%u", i); snprintf(path, sizeof(path), "/dev/input/js%u", i);

View File

@ -108,13 +108,13 @@ static void parport_poll_pad(struct parport_joypad *pad)
static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad)
{ {
int i;
int datadir = 1; /* read */ int datadir = 1; /* read */
char data; char data;
struct ppdev_frob_struct frob; struct ppdev_frob_struct frob;
bool set_control = false; bool set_control = false;
int i;
int mode = IEEE1284_MODE_BYTE; int mode = IEEE1284_MODE_BYTE;
settings_t *settings = config_get_ptr();
if (pad->fd >= 0) if (pad->fd >= 0)
return false; return false;
@ -179,7 +179,7 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad
if (!set_control) if (!set_control)
RARCH_WARN("[Joypad]: Failed to clear nStrobe and nIRQ bits on %s\n", path); RARCH_WARN("[Joypad]: Failed to clear nStrobe and nIRQ bits on %s\n", path);
strlcpy(pad->ident, path, sizeof(g_settings.input.device_names[0])); strlcpy(pad->ident, path, sizeof(settings->input.device_names[0]));
for (i = 0; i < PARPORT_NUM_BUTTONS; i++) for (i = 0; i < PARPORT_NUM_BUTTONS; i++)
pad->button_enable[i] = true; pad->button_enable[i] = true;
@ -231,6 +231,7 @@ static bool parport_joypad_init(void)
bool found_disabled_button; bool found_disabled_button;
char buf[PARPORT_NUM_BUTTONS * 3 + 1]; char buf[PARPORT_NUM_BUTTONS * 3 + 1];
char pin[3 + 1]; char pin[3 + 1];
settings_t *settings = config_get_ptr();
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1); memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
@ -239,8 +240,8 @@ static bool parport_joypad_init(void)
char path[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH];
struct parport_joypad *pad = &parport_pads[i]; struct parport_joypad *pad = &parport_pads[i];
pad->fd = -1; pad->fd = -1;
pad->ident = g_settings.input.device_names[i]; pad->ident = settings->input.device_names[i];
snprintf(path, sizeof(path), "/dev/parport%u", i); snprintf(path, sizeof(path), "/dev/parport%u", i);

View File

@ -34,20 +34,22 @@ static INLINE int16_t convert_u8_to_s16(uint8_t val)
static const char *ps3_joypad_name(unsigned pad) static const char *ps3_joypad_name(unsigned pad)
{ {
return g_settings.input.device_names[pad]; settings_t *settings = config_get_ptr();
return settings->input.device_names[pad];
} }
static bool ps3_joypad_init(void) static bool ps3_joypad_init(void)
{ {
unsigned autoconf_pad; unsigned autoconf_pad;
settings_t *settings = config_get_ptr();
cellPadInit(MAX_PADS); cellPadInit(MAX_PADS);
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
"SixAxis Controller", "SixAxis Controller",
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,
ps3_joypad_name(autoconf_pad), ps3_joypad_name(autoconf_pad),

View File

@ -27,12 +27,13 @@ static const char *psp_joypad_name(unsigned pad)
static bool psp_joypad_init(void) static bool psp_joypad_init(void)
{ {
unsigned autoconf_pad; unsigned autoconf_pad;
settings_t *settings = config_get_ptr();
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
psp_joypad_name(autoconf_pad), psp_joypad_name(autoconf_pad),
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,
psp_joypad_name(autoconf_pad), psp_joypad_name(autoconf_pad),

View File

@ -19,17 +19,19 @@
static const char *qnx_joypad_name(unsigned pad) static const char *qnx_joypad_name(unsigned pad)
{ {
return g_settings.input.device_names[pad]; settings_t *settings = config_get_ptr();
return settings->input.device_names[pad];
} }
static bool qnx_joypad_init(void) static bool qnx_joypad_init(void)
{ {
unsigned autoconf_pad; unsigned autoconf_pad;
settings_t *settings = config_get_ptr();
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], "None", strlcpy(settings->input.device_names[autoconf_pad], "None",
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,
qnx_joypad_name(autoconf_pad), qnx_joypad_name(autoconf_pad),

View File

@ -92,6 +92,7 @@ static void pad_connect(unsigned id)
bool success = false; bool success = false;
int32_t product = 0; int32_t product = 0;
int32_t vendor = 0; int32_t vendor = 0;
settings_t *settings = config_get_ptr();
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
SDL_JoystickGUID guid; SDL_JoystickGUID guid;
@ -123,7 +124,7 @@ static void pad_connect(unsigned id)
return; return;
} }
strlcpy(g_settings.input.device_names[id], pad_name(id), sizeof(g_settings.input.device_names[id])); strlcpy(settings->input.device_names[id], pad_name(id), sizeof(settings->input.device_names[id]));
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
guid = SDL_JoystickGetGUID(pad->joypad); guid = SDL_JoystickGetGUID(pad->joypad);
@ -188,6 +189,7 @@ static void pad_connect(unsigned id)
static void pad_disconnect(unsigned id) static void pad_disconnect(unsigned id)
{ {
settings_t *settings = config_get_ptr();
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
if (sdl_pads[id].haptic) if (sdl_pads[id].haptic)
SDL_HapticClose(sdl_pads[id].haptic); SDL_HapticClose(sdl_pads[id].haptic);
@ -205,7 +207,7 @@ static void pad_disconnect(unsigned id)
RARCH_LOG("[SDL]: Joypad #%u disconnected.\n", id); RARCH_LOG("[SDL]: Joypad #%u disconnected.\n", id);
} }
g_settings.input.device_names[id][0] = '\0'; settings->input.device_names[id][0] = '\0';
memset(&sdl_pads[id], 0, sizeof(sdl_pads[id])); memset(&sdl_pads[id], 0, sizeof(sdl_pads[id]));
} }

View File

@ -315,6 +315,8 @@ static int find_vacant_pad(void)
static void free_pad(unsigned pad, bool hotplug) static void free_pad(unsigned pad, bool hotplug)
{ {
settings_t *settings = config_get_ptr();
if (udev_pads[pad].fd >= 0) if (udev_pads[pad].fd >= 0)
close(udev_pads[pad].fd); close(udev_pads[pad].fd);
@ -323,8 +325,8 @@ static void free_pad(unsigned pad, bool hotplug)
*udev_pads[pad].ident = '\0'; *udev_pads[pad].ident = '\0';
memset(&udev_pads[pad], 0, sizeof(udev_pads[pad])); memset(&udev_pads[pad], 0, sizeof(udev_pads[pad]));
udev_pads[pad].fd = -1; udev_pads[pad].fd = -1;
udev_pads[pad].ident = g_settings.input.device_names[pad]; udev_pads[pad].ident = settings->input.device_names[pad];
/* Avoid autoconfig spam if we're reiniting driver. */ /* Avoid autoconfig spam if we're reiniting driver. */
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
@ -345,8 +347,9 @@ static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *pat
unsigned long absbit[NBITS(ABS_MAX)] = {0}; unsigned long absbit[NBITS(ABS_MAX)] = {0};
unsigned long ffbit[NBITS(FF_MAX)] = {0}; unsigned long ffbit[NBITS(FF_MAX)] = {0};
unsigned buttons = 0, axes = 0; unsigned buttons = 0, axes = 0;
settings_t *settings = config_get_ptr();
if (ioctl(fd, EVIOCGNAME(sizeof(g_settings.input.device_names[0])), pad->ident) < 0) if (ioctl(fd, EVIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) < 0)
{ {
RARCH_LOG("[udev]: Failed to get pad name.\n"); RARCH_LOG("[udev]: Failed to get pad name.\n");
return false; return false;
@ -515,11 +518,12 @@ static bool udev_joypad_init(void)
struct udev_list_entry *devs = NULL; struct udev_list_entry *devs = NULL;
struct udev_list_entry *item = NULL; struct udev_list_entry *item = NULL;
struct udev_enumerate *enumerate = NULL; struct udev_enumerate *enumerate = NULL;
settings_t *settings = config_get_ptr();
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
{ {
udev_pads[i].fd = -1; udev_pads[i].fd = -1;
udev_pads[i].ident = g_settings.input.device_names[i]; udev_pads[i].ident = settings->input.device_names[i];
} }
g_udev = udev_new(); g_udev = udev_new();

View File

@ -153,6 +153,7 @@ static bool winxinput_joypad_init(void)
unsigned i, autoconf_pad; unsigned i, autoconf_pad;
XINPUT_STATE dummy_state; XINPUT_STATE dummy_state;
const char *version = "1.4"; const char *version = "1.4";
settings_t *settings = config_get_ptr();
g_winxinput_dll = NULL; g_winxinput_dll = NULL;
@ -245,9 +246,9 @@ static bool winxinput_joypad_init(void)
{ {
if (pad_index_to_xuser_index(autoconf_pad) > -1) if (pad_index_to_xuser_index(autoconf_pad) > -1)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
winxinput_joypad_name(autoconf_pad), winxinput_joypad_name(autoconf_pad),
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,

View File

@ -35,12 +35,14 @@ static const char* const XBOX_CONTROLLER_NAMES[4] =
static const char *xdk_joypad_name(unsigned pad) static const char *xdk_joypad_name(unsigned pad)
{ {
return g_settings.input.device_names[pad]; settings_t *settings = config_get_ptr();
return settings->input.device_names[pad];
} }
static bool xdk_joypad_init(void) static bool xdk_joypad_init(void)
{ {
unsigned autoconf_pad; unsigned autoconf_pad;
settings_t *settings = config_get_ptr();
#ifdef _XBOX1 #ifdef _XBOX1
XInitDevices(0, NULL); XInitDevices(0, NULL);
@ -63,9 +65,9 @@ static bool xdk_joypad_init(void)
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
{ {
strlcpy(g_settings.input.device_names[autoconf_pad], strlcpy(settings->input.device_names[autoconf_pad],
"XInput Controller", "XInput Controller",
sizeof(g_settings.input.device_names[autoconf_pad])); sizeof(settings->input.device_names[autoconf_pad]));
/* TODO - implement VID/PID? */ /* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(autoconf_pad, input_config_autoconfigure_joypad(autoconf_pad,