1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

More documentation for input_common.c

This commit is contained in:
twinaphex 2015-01-12 04:19:57 +01:00
parent 2dadadab56
commit 5f611f7270
6 changed files with 95 additions and 16 deletions

View File

@ -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

View File

@ -28,7 +28,9 @@
extern "C" {
#endif
#ifndef MAX_EGLIMAGE_TEXTURES
#define MAX_EGLIMAGE_TEXTURES 32
#endif
enum gfx_ctx_api
{

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
/**