From 5f611f727069151a3e834e98560a6ab45b30d1fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jan 2015 04:19:57 +0100 Subject: [PATCH] More documentation for input_common.c --- core_info.c | 35 ++++++++++++++++++++++------------- gfx/gfx_context.h | 2 ++ gfx/gx/gx_gfx.h | 2 +- input/apple_input.c | 2 +- input/input_common.c | 36 ++++++++++++++++++++++++++++++++++++ input/input_common.h | 34 +++++++++++++++++++++++++++++++++- 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/core_info.c b/core_info.c index e32d283d5c..8c91fa957d 100644 --- a/core_info.c +++ b/core_info.c @@ -37,8 +37,9 @@ static void core_info_list_resolve_all_extensions( for (i = 0; i < core_info_list->count; i++) { - all_ext_len += core_info_list->list[i].supported_extensions ? - (strlen(core_info_list->list[i].supported_extensions) + 2) : 0; + if (core_info_list->list[i].supported_extensions) + all_ext_len += + (strlen(core_info_list->list[i].supported_extensions) + 2); } if (all_ext_len) @@ -48,12 +49,12 @@ static void core_info_list_resolve_all_extensions( { for (i = 0; i < core_info_list->count; i++) { - if (core_info_list->list[i].supported_extensions) - { - strlcat(core_info_list->all_ext, - core_info_list->list[i].supported_extensions, all_ext_len); - strlcat(core_info_list->all_ext, "|", all_ext_len); - } + if (!core_info_list->list[i].supported_extensions) + continue; + + strlcat(core_info_list->all_ext, + core_info_list->list[i].supported_extensions, all_ext_len); + strlcat(core_info_list->all_ext, "|", all_ext_len); } } } @@ -333,7 +334,12 @@ bool core_info_list_get_by_id(core_info_list_t *core_info_list, { core_info_t *info = (core_info_t*)&core_info_list->list[i]; - if (info && info->path && strcmp(core_id, info->path) == 0) + if (!info) + continue; + if (!info->path) + continue; + + if (!strcmp(core_id, info->path)) { *out_info = *info; return true; @@ -421,12 +427,15 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, if (!core) continue; - if (!core_info_does_support_file(core, path) + if (core_info_does_support_file(core, path)) + continue; + #ifdef HAVE_ZLIB - && !core_info_does_support_any_file(core, list) + if (core_info_does_support_any_file(core, list)) + continue; #endif - ) - break; + + break; } #ifdef HAVE_ZLIB diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index fc74ff3773..795225fb98 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -28,7 +28,9 @@ extern "C" { #endif +#ifndef MAX_EGLIMAGE_TEXTURES #define MAX_EGLIMAGE_TEXTURES 32 +#endif enum gfx_ctx_api { diff --git a/gfx/gx/gx_gfx.h b/gfx/gx/gx_gfx.h index 2b7b47e325..1604b79995 100644 --- a/gfx/gx/gx_gfx.h +++ b/gfx/gx/gx_gfx.h @@ -32,7 +32,7 @@ typedef struct gx_video bool keep_aspect; bool double_strike; bool rgb32; - uint32_t *menu_data; // FIXME: Should be const uint16_t*. + uint32_t *menu_data; /* FIXME: Should be const uint16_t*. */ bool menu_texture_enable; rarch_viewport_t vp; unsigned scale; diff --git a/input/apple_input.c b/input/apple_input.c index 39304352fe..1166e8f98c 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -185,7 +185,7 @@ int32_t apple_input_find_any_button(uint32_t port) BIT32_SET(buttons, apple->icade_buttons); if (buttons) - for (i = 0; i != 32; i ++) + for (i = 0; i < 32; i++) if (buttons & (1 << i)) return i; diff --git a/input/input_common.c b/input/input_common.c index b7e795c9c4..964434b7e3 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -110,6 +110,21 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { #endif }; +/** + * input_translate_coord_viewport: + * @mouse_x : Pointer X coordinate. + * @mouse_y : Pointer Y coordinate. + * @res_x : Scaled X coordinate. + * @res_y : Scaled Y coordinate. + * @res_screen_x : Scaled screen X coordinate. + * @res_screen_y : Scaled screen Y coordinate. + * + * Translates pointer [X,Y] coordinates into scaled screen + * coordinates based on viewport info. + * + * Returns: true (1) if successful, false if video driver doesn't support + * viewport info. + **/ bool input_translate_coord_viewport(int mouse_x, int mouse_y, int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y) @@ -183,6 +198,14 @@ static enum retro_key find_rk_bind(const char *str) return RETROK_UNKNOWN; } +/** + * input_translate_str_to_rk: + * @str : String to translate to key ID. + * + * Translates tring representation to key identifier. + * + * Returns: key identifier. + **/ enum retro_key input_translate_str_to_rk(const char *str) { if (strlen(str) == 1 && isalpha(*str)) @@ -201,6 +224,7 @@ enum retro_key input_translate_str_to_rk(const char *str) unsigned input_translate_str_to_bind_id(const char *str) { unsigned i; + for (i = 0; input_config_bind_map[i].valid; i++) if (!strcmp(str, input_config_bind_map[i].base)) return i; @@ -303,6 +327,7 @@ static void input_get_bind_string_joykey(char *buf, const char *prefix, if (GET_HAT_DIR(bind->joykey)) { const char *dir; + switch (GET_HAT_DIR(bind->joykey)) { case HAT_UP_MASK: @@ -388,6 +413,16 @@ void input_get_bind_string(char *buf, const struct retro_keybind *bind, } #endif +/** + * input_push_analog_dpad: + * @binds : Binds to modify. + * @mode : Which analog stick to bind D-Pad to. + * E.g: + * ANALOG_DPAD_LSTICK + * ANALOG_DPAD_RSTICK + * + * Push analog to D-Pad mappings to binds. + **/ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) { unsigned i, j; @@ -423,6 +458,7 @@ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode) void input_pop_analog_dpad(struct retro_keybind *binds) { unsigned i; + for (i = RETRO_DEVICE_ID_JOYPAD_UP; i <= RETRO_DEVICE_ID_JOYPAD_RIGHT; i++) binds[i].joyaxis = binds[i].orig_joyaxis; } diff --git a/input/input_common.h b/input/input_common.h index f119d266af..f80ee90cd6 100644 --- a/input/input_common.h +++ b/input/input_common.h @@ -46,6 +46,21 @@ struct input_bind_map extern const struct input_bind_map input_config_bind_map[]; +/** + * input_translate_coord_viewport: + * @mouse_x : Pointer X coordinate. + * @mouse_y : Pointer Y coordinate. + * @res_x : Scaled X coordinate. + * @res_y : Scaled Y coordinate. + * @res_screen_x : Scaled screen X coordinate. + * @res_screen_y : Scaled screen Y coordinate. + * + * Translates pointer [X,Y] coordinates into scaled screen + * coordinates based on viewport info. + * + * Returns: true (1) if successful, false if video driver doesn't support + * viewport info. + **/ bool input_translate_coord_viewport(int mouse_x, int mouse_y, int16_t *res_x, int16_t *res_y, int16_t *res_screen_x, int16_t *res_screen_y); @@ -54,7 +69,14 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y, void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size); - +/** + * input_translate_str_to_rk: + * @str : String to translate to key ID. + * + * Translates tring representation to key identifier. + * + * Returns: key identifier. + **/ enum retro_key input_translate_str_to_rk(const char *str); const char *input_config_get_prefix(unsigned user, bool meta); @@ -79,6 +101,16 @@ void input_config_parse_joy_button(config_file_t *conf, const char *prefix, void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, const char *axis, struct retro_keybind *bind); +/** + * input_push_analog_dpad: + * @binds : Binds to modify. + * @mode : Which analog stick to bind D-Pad to. + * E.g: + * ANALOG_DPAD_LSTICK + * ANALOG_DPAD_RSTICK + * + * Push analog to D-Pad mappings to binds. + **/ void input_push_analog_dpad(struct retro_keybind *binds, unsigned mode); /**