Code reformatting to abide by 80-character limit

This commit is contained in:
twinaphex 2014-08-20 16:26:34 +02:00
parent 16c2fe9437
commit 51637bc69e
5 changed files with 180 additions and 103 deletions

View File

@ -77,7 +77,7 @@ static int main_entry_iterate_clear_input(args_type() args)
rarch_input_poll();
if (!menu_input())
{
// Restore libretro keyboard callback.
/* Restore libretro keyboard callback. */
g_extern.system.key_event = key_event;
g_extern.lifecycle_state &= ~(1ULL << MODE_CLEAR_INPUT);
@ -93,13 +93,12 @@ static int main_entry_iterate_shutdown(args_type() args)
if (!g_settings.load_dummy_on_core_shutdown)
return 1;
// Load dummy core instead of exiting RetroArch completely.
/* Load dummy core instead of exiting RetroArch completely. */
rarch_main_command(RARCH_CMD_PREPARE_DUMMY);
return 0;
}
static int main_entry_iterate_content(args_type() args)
{
if (rarch_main_iterate())
@ -115,7 +114,7 @@ static int main_entry_iterate_content(args_type() args)
static int main_entry_iterate_load_content(args_type() args)
{
// If content loading fails, we go back to menu.
/* If content loading fails, we go back to menu. */
if (!load_menu_content())
g_extern.lifecycle_state = (1ULL << MODE_MENU_PREINIT);
@ -131,19 +130,20 @@ static int main_entry_iterate_menu_preinit(args_type() args)
if (!driver.menu)
return 1;
// Menu should always run with vsync on.
/* Menu should always run with vsync on. */
rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE);
// Stop all rumbling when entering the menu.
/* Stop all rumbling when entering the menu. */
for (i = 0; i < MAX_PLAYERS; i++)
{
driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0);
driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0);
}
// Override keyboard callback to redirect to menu instead.
// We'll use this later for something ...
// FIXME: This should probably be moved to menu_common somehow.
/* Override keyboard callback to redirect to menu instead.
* We'll use this later for something ...
* FIXME: This should probably be moved to menu_common somehow.
*/
key_event = g_extern.system.key_event;
g_extern.system.key_event = menu_key_event;
@ -174,8 +174,11 @@ static int main_entry_iterate_menu(args_type() args)
g_extern.lifecycle_state |= (1ULL << MODE_CLEAR_INPUT);
// If QUIT state came from command interface, we'll only see it once due to MODE_CLEAR_INPUT.
if (input_key_pressed_func(RARCH_QUIT_KEY) || !driver.video->alive(driver.video_data))
/* If QUIT state came from command interface, we'll only see it
* once due to MODE_CLEAR_INPUT.
*/
if (input_key_pressed_func(RARCH_QUIT_KEY) ||
!driver.video->alive(driver.video_data))
return 1;
}
@ -212,18 +215,22 @@ void main_exit(args_type() args)
if (g_settings.config_save_on_exit && *g_extern.config_path)
{
// save last core-specific config to the default config location, needed on
// consoles for core switching and reusing last good config for new cores.
/* Save last core-specific config to the default config location,
* needed on consoles for core switching and reusing last good
* config for new cores.
*/
config_save_file(g_extern.config_path);
// Flush out the core specific config.
if (*g_extern.core_specific_config_path && g_settings.core_specific_config)
/* Flush out the core specific config. */
if (*g_extern.core_specific_config_path &&
g_settings.core_specific_config)
config_save_file(g_extern.core_specific_config_path);
}
if (g_extern.main_is_init)
{
driver.menu_data_own = false; // Do not want menu context to live any more.
/* Do not want menu context to live any more. */
driver.menu_data_own = false;
rarch_main_deinit();
}
@ -238,9 +245,11 @@ void main_exit(args_type() args)
if (driver.frontend_ctx && driver.frontend_ctx->deinit)
driver.frontend_ctx->deinit(args);
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN) && driver.frontend_ctx
if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN)
&& driver.frontend_ctx
&& driver.frontend_ctx->exitspawn)
driver.frontend_ctx->exitspawn(g_settings.libretro, sizeof(g_settings.libretro));
driver.frontend_ctx->exitspawn(g_settings.libretro,
sizeof(g_settings.libretro));
rarch_main_clear_state();
@ -274,7 +283,8 @@ static void check_defaults_dirs(void)
path_mkdir(g_defaults.system_dir);
}
bool main_load_content(int argc, char **argv, args_type() args, environment_get_t environ_get,
bool main_load_content(int argc, char **argv, args_type() args,
environment_get_t environ_get,
process_args_t process_args)
{
int *rarch_argc_ptr;
@ -346,8 +356,9 @@ returntype main_entry(signature())
rarch_main_clear_state();
if (!(ret = (main_load_content(argc, argv, args, driver.frontend_ctx->environment_get,
driver.frontend_ctx->process_args))))
if (!(ret = (main_load_content(argc, argv, args,
driver.frontend_ctx->environment_get,
driver.frontend_ctx->process_args))))
return_var(ret);
#if defined(HAVE_MENU)
@ -355,8 +366,9 @@ returntype main_entry(signature())
if (ret)
#endif
{
// If we started content directly from command line,
// push it to content history.
/* If we started content directly from command line,
* push it to content history.
*/
if (!g_extern.libretro_dummy)
menu_content_history_push_current();
}

View File

@ -27,8 +27,9 @@
struct defaults g_defaults;
//We need to set libretro to the first entry in the cores
//directory so that it will be saved to the config file
/*We need to set libretro to the first entry in the cores
* directory so that it will be saved to the config file
*/
static void find_first_libretro_core(char *first_file,
size_t size_of_first_file, const char *dir,
const char * ext)
@ -37,7 +38,8 @@ static void find_first_libretro_core(char *first_file,
size_t i;
bool ret = false;
RARCH_LOG("Searching for valid libretro implementation in: \"%s\".\n", dir);
RARCH_LOG("Searching for valid libretro implementation in: \"%s\".\n",
dir);
list = (struct string_list*)dir_list_new(dir, ext, false);
if (!list)
@ -77,10 +79,12 @@ static void find_first_libretro_core(char *first_file,
dir_list_free(list);
}
static void find_and_set_first_file(char *path, size_t sizeof_path, const char *ext)
static void find_and_set_first_file(char *path, size_t sizeof_path,
const char *ext)
{
//Last fallback - we'll need to start the first executable file
// we can find in the RetroArch cores directory
/* Last fallback - we'll need to start the first executable file
* we can find in the RetroArch cores directory.
*/
char first_file[PATH_MAX] = {0};
find_first_libretro_core(first_file, sizeof(first_file),
@ -97,7 +101,7 @@ static void find_and_set_first_file(char *path, size_t sizeof_path, const char *
static void salamander_init(char *libretro_path, size_t sizeof_libretro_path)
{
//normal executable loading path
/* normal executable loading path */
bool config_file_exists = false;
if (path_file_exists(g_defaults.config_path))
@ -115,7 +119,7 @@ static void salamander_init(char *libretro_path, size_t sizeof_libretro_path)
strlcpy(libretro_path, tmp_str, sizeof_libretro_path);
}
#ifdef GEKKO
else // stupid libfat bug or something; somtimes it says the file is there when it doesn't
else /* stupid libfat bug or something; sometimes it says the file is there when it doesn't */
config_file_exists = false;
#endif
}
@ -142,10 +146,10 @@ int main(int argc, char *argv[])
{
char libretro_path[PATH_MAX];
void *args = NULL;
struct rarch_main_wrap *wrap_args;
struct rarch_main_wrap *wrap_args = NULL;
frontend_ctx_driver_t *frontend_ctx = NULL;
frontend_ctx_driver_t *frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first();
wrap_args = NULL;
frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first();
if (!frontend_ctx)
return 0;

View File

@ -23,12 +23,14 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content)
libretro_free_system_info(&menu->info);
if (*g_settings.libretro)
{
libretro_get_system_info(g_settings.libretro, &menu->info, load_no_content);
libretro_get_system_info(g_settings.libretro, &menu->info,
load_no_content);
#endif
// Keep track of info for the currently selected core.
/* Keep track of info for the currently selected core. */
if (menu->core_info)
{
if (core_info_list_get_info(menu->core_info, menu->core_info_current, g_settings.libretro))
if (core_info_list_get_info(menu->core_info,
menu->core_info_current, g_settings.libretro))
{
const core_info_t *info = (const core_info_t*)menu->core_info_current;
@ -48,8 +50,11 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content)
#endif
}
// When selection is presented back, returns 0. If it can make a decision right now, returns -1.
int menu_defer_core(core_info_list_t *core_info, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path)
/* When selection is presented back, returns 0.
* If it can make a decision right now, returns -1.
*/
int menu_defer_core(core_info_list_t *core_info, const char *dir,
const char *path, char *deferred_path, size_t sizeof_deferred_path)
{
const core_info_t *info = NULL;
size_t supported = 0;
@ -57,9 +62,11 @@ int menu_defer_core(core_info_list_t *core_info, const char *dir, const char *pa
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
if (core_info)
core_info_list_get_supported_cores(core_info, deferred_path, &info, &supported);
core_info_list_get_supported_cores(core_info, deferred_path, &info,
&supported);
if (supported == 1) // Can make a decision right now.
/* Can make a decision right now. */
if (supported == 1)
{
strlcpy(g_extern.fullpath, deferred_path, sizeof(g_extern.fullpath));
@ -79,10 +86,12 @@ int menu_defer_core(core_info_list_t *core_info, const char *dir, const char *pa
void menu_content_history_push_current(void)
{
// g_extern.fullpath can be relative here.
// Ensure we're pushing absolute path.
char tmp[PATH_MAX];
/* g_extern.fullpath can be relative here.
* Ensure we're pushing absolute path.
*/
if (!g_extern.history)
return;
@ -122,7 +131,7 @@ static void load_menu_content_prepare(void)
driver.menu->info.library_name ? driver.menu->info.library_name : "");
}
// redraw menu frame
/* redraw menu frame */
driver.menu->old_input_state = driver.menu->trigger_state = 0;
driver.menu->do_held = false;
driver.menu->msg_force = true;
@ -130,7 +139,7 @@ static void load_menu_content_prepare(void)
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate)
driver.menu_ctx->backend->iterate(MENU_ACTION_NOOP);
// Draw frame for loading message
/* Draw frame for loading message */
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
@ -212,14 +221,15 @@ bool load_menu_content(void)
return false;
}
// Update menu state which depends on config.
/* Update menu state which depends on config. */
if (driver.menu)
menu_update_libretro_info(driver.menu);
rarch_main_command(RARCH_CMD_HISTORY_DEINIT);
rarch_main_command(RARCH_CMD_HISTORY_INIT);
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_init)
if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->shader_manager_init)
driver.menu_ctx->backend->shader_manager_init(driver.menu);
rarch_main_command(RARCH_CMD_VIDEO_SET_ASPECT_RATIO);
@ -240,7 +250,8 @@ void *menu_init(const void *data)
if (!(menu = (menu_handle_t*)menu_ctx->init()))
return NULL;
strlcpy(g_settings.menu.driver, menu_ctx->ident, sizeof(g_settings.menu.driver));
strlcpy(g_settings.menu.driver, menu_ctx->ident,
sizeof(g_settings.menu.driver));
menu->menu_stack = (file_list_t*)calloc(1, sizeof(file_list_t));
menu->selection_buf = (file_list_t*)calloc(1, sizeof(file_list_t));
@ -264,7 +275,8 @@ void *menu_init(const void *data)
menu_update_libretro_info(menu);
if (menu_ctx && menu_ctx->backend && menu_ctx->backend->shader_manager_init)
if (menu_ctx && menu_ctx->backend
&& menu_ctx->backend->shader_manager_init)
menu_ctx->backend->shader_manager_init(menu);
rarch_main_command(RARCH_CMD_HISTORY_INIT);
@ -307,7 +319,8 @@ void menu_free(void *data)
free(data);
}
void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bool selected)
void menu_ticker_line(char *buf, size_t len, unsigned index,
const char *str, bool selected)
{
size_t str_len = strlen(str);
@ -324,7 +337,7 @@ void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bo
}
else
{
// Wrap long strings in options with some kind of ticker line.
/* Wrap long strings in options with some kind of ticker line. */
unsigned ticker_period = 2 * (str_len - len) + 4;
unsigned phase = index % ticker_period;
@ -335,7 +348,12 @@ void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bo
unsigned left_offset = phase - phase_left_stop;
unsigned right_offset = (str_len - len) - (phase - phase_right_stop);
// Ticker period: [Wait at left (2 ticks), Progress to right (type_len - w), Wait at right (2 ticks), Progress to left].
/* Ticker period:
* [Wait at left (2 ticks),
* Progress to right(type_len - w),
* Wait at right (2 ticks),
* Progress to left].
*/
if (phase < phase_left_stop)
strlcpy(buf, str, len + 1);
else if (phase < phase_left_moving)
@ -391,7 +409,8 @@ bool menu_iterate(void)
#endif
rarch_check_fullscreen();
if (input_key_pressed_func(RARCH_QUIT_KEY) || !driver.video->alive(driver.video_data))
if (input_key_pressed_func(RARCH_QUIT_KEY)
|| !driver.video->alive(driver.video_data))
{
g_extern.lifecycle_state |= (1ULL << MODE_GAME);
return false;
@ -430,7 +449,9 @@ bool menu_iterate(void)
if (driver.block_input)
driver.menu->trigger_state = 0;
// don't run anything first frame, only capture held inputs for old_input_state
/* don't run anything first frame, only capture held inputs
* for old_input_state.
*/
if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_UP))
action = MENU_ACTION_UP;
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN))
@ -452,25 +473,30 @@ bool menu_iterate(void)
else if (driver.menu->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT))
action = MENU_ACTION_SELECT;
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate)
if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->iterate)
input_entry_ret = driver.menu_ctx->backend->iterate(action);
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
if (driver.video_data && driver.video_poke &&
driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data,
driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
rarch_render_cached_frame();
// Throttle in case VSync is broken (avoid 1000+ FPS Menu).
/* Throttle in case VSync is broken (avoid 1000+ FPS Menu). */
driver.menu->time = rarch_get_time_usec();
driver.menu->delta = (driver.menu->time - driver.menu->last_time) / 1000;
driver.menu->target_msec = 750 / g_settings.video.refresh_rate; // Try to sleep less, so we can hopefully rely on FPS logger.
driver.menu->target_msec = 750 / g_settings.video.refresh_rate;
/* Try to sleep less, so we can hopefully rely on FPS logger. */
driver.menu->sleep_msec = driver.menu->target_msec - driver.menu->delta;
if (driver.menu->sleep_msec > 0)
rarch_sleep((unsigned int)driver.menu->sleep_msec);
driver.menu->last_time = rarch_get_time_usec();
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
if (driver.video_data && driver.video_poke
&& driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, false,
MENU_TEXTURE_FULLSCREEN);
@ -495,10 +521,12 @@ bool menu_iterate(void)
return true;
}
// Quite intrusive and error prone.
// Likely to have lots of small bugs.
// Cleanly exit the main loop to ensure that all the tiny details get set properly.
// This should mitigate most of the smaller bugs.
/* Quite intrusive and error prone.
* Likely to have lots of small bugs.
* Cleanly exit the main loop to ensure that all the tiny details
* get set properly.
* This should mitigate most of the smaller bugs.
*/
bool menu_replace_config(const char *path)
{
if (strcmp(path, g_extern.config_path) == 0)
@ -509,26 +537,31 @@ bool menu_replace_config(const char *path)
strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path));
g_extern.block_config_read = false;
*g_settings.libretro = '\0'; // Load core in new config.
*g_settings.libretro = '\0'; /* Load core in new config. */
rarch_main_command(RARCH_CMD_PREPARE_DUMMY);
return true;
}
// Save a new config to a file. Filename is based on heuristics to avoid typing.
/* Save a new config to a file. Filename is based
* on heuristics to avoid typing.
*/
bool menu_save_new_config(void)
{
char config_dir[PATH_MAX], config_name[PATH_MAX], config_path[PATH_MAX], msg[512];
char config_dir[PATH_MAX], config_name[PATH_MAX],
config_path[PATH_MAX], msg[PATH_MAX];
bool ret = false;
bool found_path = false;
*config_dir = '\0';
if (*g_settings.menu_config_directory)
strlcpy(config_dir, g_settings.menu_config_directory, sizeof(config_dir));
else if (*g_extern.config_path) // Fallback
fill_pathname_basedir(config_dir, g_extern.config_path, sizeof(config_dir));
strlcpy(config_dir, g_settings.menu_config_directory,
sizeof(config_dir));
else if (*g_extern.config_path) /* Fallback */
fill_pathname_basedir(config_dir, g_extern.config_path,
sizeof(config_dir));
else
{
const char *msg = "Config directory not set. Cannot save new config.";
@ -538,10 +571,12 @@ bool menu_save_new_config(void)
return false;
}
if (*g_settings.libretro && path_file_exists(g_settings.libretro)) // Infer file name based on libretro core.
/* Infer file name based on libretro core. */
if (*g_settings.libretro && path_file_exists(g_settings.libretro))
{
unsigned i;
// In case of collision, find an alternative name.
/* In case of collision, find an alternative name. */
for (i = 0; i < 16; i++)
{
char tmp[64];
@ -566,12 +601,13 @@ bool menu_save_new_config(void)
}
}
// Fallback to system time ...
/* Fallback to system time... */
if (!found_path)
{
RARCH_WARN("Cannot infer new config path. Use current time.\n");
fill_dated_filename(config_name, "cfg", sizeof(config_name));
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
fill_pathname_join(config_path, config_dir, config_name,
sizeof(config_path));
}
if (config_save_file(config_path))
@ -583,7 +619,8 @@ bool menu_save_new_config(void)
}
else
{
snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", config_path);
snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".",
config_path);
RARCH_ERR("%s\n", msg);
}
@ -600,7 +637,9 @@ static inline int menu_list_get_first_char(file_list_t *buf, unsigned offset)
file_list_get_alt_at_offset(buf, offset, &path);
ret = tolower(*path);
// "Normalize" non-alphabetical entries so they are lumped together for purposes of jumping.
/* "Normalize" non-alphabetical entries so they are lumped together
* for purposes of jumping.
*/
if (ret < 'a')
ret = 'a' - 1;
else if (ret > 'z')
@ -608,12 +647,15 @@ static inline int menu_list_get_first_char(file_list_t *buf, unsigned offset)
return ret;
}
static inline bool menu_list_elem_is_dir(file_list_t *buf, unsigned offset)
static inline bool menu_list_elem_is_dir(file_list_t *buf,
unsigned offset)
{
rarch_setting_t *setting = NULL;
const char *path = NULL;
unsigned type = 0;
file_list_get_at_offset(buf, offset, &path, &type, setting);
return type != MENU_FILE_PLAIN;
}

View File

@ -29,10 +29,12 @@
#include "menu_input_line_cb.h"
#include "../../settings_data.h"
//forward decls
extern void menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str);
/* forward decls */
void menu_common_setting_set_current_string(rarch_setting_t *setting,
const char *str);
void menu_key_start_line(void *data, const char *label, input_keyboard_line_complete_t cb)
void menu_key_start_line(void *data, const char *label,
input_keyboard_line_complete_t cb)
{
menu_handle_t *menu = (menu_handle_t*)data;
@ -53,7 +55,9 @@ static void menu_key_end_line(void *data)
menu->keyboard.display = false;
menu->keyboard.label = NULL;
menu->old_input_state = -1ULL; // Avoid triggering states on pressing return.
/* Avoid triggering states on pressing return. */
menu->old_input_state = -1ULL;
}
static void menu_search_callback(void *userdata, const char *str)
@ -126,7 +130,8 @@ void preset_filename_callback(void *userdata, const char *str)
return;
}
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_save_preset)
if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->shader_manager_save_preset)
driver.menu_ctx->backend->shader_manager_save_preset(str && *str ? str : NULL, false);
menu_key_end_line(menu);
}
@ -154,14 +159,16 @@ void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mo
void menu_poll_bind_state(struct menu_bind_state *state)
{
unsigned i, b, a, h;
const rarch_joypad_driver_t *joypad = NULL;
if (!state)
return;
unsigned i, b, a, h;
memset(state->state, 0, sizeof(state->state));
state->skip = driver.input->input_state(driver.input_data, NULL, 0, RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
state->skip = driver.input->input_state(driver.input_data, NULL, 0,
RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
const rarch_joypad_driver_t *joypad = NULL;
if (driver.input && driver.input_data && driver.input->get_joypad_driver)
joypad = driver.input->get_joypad_driver(driver.input_data);
@ -228,7 +235,7 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, struct men
}
}
// Axes are a bit tricky ...
/* Axes are a bit tricky ... */
for (a = 0; a < MENU_MAX_AXES; a++)
{
int locked_distance = abs(n->axes[a] - new_state->axis_state[p].locked_axes[a]);
@ -236,17 +243,20 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, struct men
if (abs(n->axes[a]) >= 20000 &&
locked_distance >= 20000 &&
rested_distance >= 20000) // Take care of case where axis rests on +/- 0x7fff (e.g. 360 controller on Linux)
rested_distance >= 20000)
{
/* Take care of case where axis rests on +/- 0x7fff
* (e.g. 360 controller on Linux)
*/
state->target->joyaxis = n->axes[a] > 0 ? AXIS_POS(a) : AXIS_NEG(a);
state->target->joykey = NO_BTN;
// Lock the current axis.
/* Lock the current axis */
new_state->axis_state[p].locked_axes[a] = n->axes[a] > 0 ? 0x7fff : -0x7fff;
return true;
}
if (locked_distance >= 20000) // Unlock the axis.
if (locked_distance >= 20000) /* Unlock the axis. */
new_state->axis_state[p].locked_axes[a] = 0;
}
@ -254,6 +264,7 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, struct men
{
uint16_t trigged = n->hats[h] & (~o->hats[h]);
uint16_t sane_trigger = 0;
if (trigged & HAT_UP_MASK)
sane_trigger = HAT_UP_MASK;
else if (trigged & HAT_DOWN_MASK)
@ -274,7 +285,8 @@ static bool menu_poll_find_trigger_pad(struct menu_bind_state *state, struct men
return false;
}
bool menu_poll_find_trigger(struct menu_bind_state *state, struct menu_bind_state *new_state)
bool menu_poll_find_trigger(struct menu_bind_state *state,
struct menu_bind_state *new_state)
{
unsigned i;
@ -285,7 +297,8 @@ bool menu_poll_find_trigger(struct menu_bind_state *state, struct menu_bind_stat
{
if (menu_poll_find_trigger_pad(state, new_state, i))
{
g_settings.input.joypad_map[state->player] = i; // Update the joypad mapping automatically. More friendly that way.
// Update the joypad mapping automatically. More friendly that way.
g_settings.input.joypad_map[state->player] = i;
return true;
}
}
@ -302,25 +315,28 @@ bool menu_custom_bind_keyboard_cb(void *data, unsigned code)
menu->binds.target->key = (enum retro_key)code;
menu->binds.begin++;
menu->binds.target++;
menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
menu->binds.timeout_end = rarch_get_time_usec() +
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
return menu->binds.begin <= menu->binds.last;
}
uint64_t menu_input(void)
{
unsigned i;
uint64_t input_state;
uint64_t input_state = 0;
static const struct retro_keybind *binds[] = { g_settings.input.binds[0] };
if (!driver.menu)
return 0;
input_state = 0;
input_push_analog_dpad((struct retro_keybind*)binds[0],
(g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_NONE) ?
ANALOG_DPAD_LSTICK : g_settings.input.analog_dpad_mode[0]);
input_push_analog_dpad((struct retro_keybind*)binds[0], (g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_NONE) ? ANALOG_DPAD_LSTICK : g_settings.input.analog_dpad_mode[0]);
for (i = 0; i < MAX_PLAYERS; i++)
input_push_analog_dpad(g_settings.input.autoconf_binds[i], g_settings.input.analog_dpad_mode[i]);
input_push_analog_dpad(g_settings.input.autoconf_binds[i],
g_settings.input.analog_dpad_mode[i]);
if (!driver.block_libretro_input)
{
@ -329,11 +345,13 @@ uint64_t menu_input(void)
input_state |= driver.input->input_state(driver.input_data, binds,
0, RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
#ifdef HAVE_OVERLAY
input_state |= (driver.overlay_state.buttons & (UINT64_C(1) << i)) ? (1ULL << i) : 0;
input_state |= (driver.overlay_state.buttons & (UINT64_C(1) << i))
? (1ULL << i) : 0;
#endif
}
}
input_state |= input_key_pressed_func(RARCH_MENU_TOGGLE) ? (1ULL << RARCH_MENU_TOGGLE) : 0;
input_state |= input_key_pressed_func(RARCH_MENU_TOGGLE)
? (1ULL << RARCH_MENU_TOGGLE) : 0;
input_pop_analog_dpad((struct retro_keybind*)binds[0]);
for (i = 0; i < MAX_PLAYERS; i++)

View File

@ -65,12 +65,12 @@ void menu_set_navigation_last(menu_handle_t *menu)
void menu_descend_alphabet(menu_handle_t *menu, size_t *ptr_out)
{
size_t i, ptr;
size_t i = 0;
size_t ptr = *ptr_out;
if (!menu->scroll_indices_size)
return;
ptr = *ptr_out;
if (ptr == 0)
return;
@ -95,7 +95,8 @@ void menu_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out)
if (ptr == menu->scroll_indices[menu->scroll_indices_size - 1])
return;
while (i < menu->scroll_indices_size - 1 && menu->scroll_indices[i + 1] <= ptr)
while (i < menu->scroll_indices_size - 1
&& menu->scroll_indices[i + 1] <= ptr)
i++;
*ptr_out = menu->scroll_indices[i + 1];