RetroArch/settings_data.h

329 lines
12 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
2014-01-01 00:50:59 +00:00
* Copyright (C) 2013-2014 - Jason Fetters
2015-01-07 16:46:50 +00:00
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_SETTINGS_DATA_H__
#define __RARCH_SETTINGS_DATA_H__
#include <stdint.h>
2014-10-22 01:35:04 +00:00
#include <file/config_file.h>
#include <retro_miscellaneous.h>
#include "settings_list.h"
2014-08-17 18:42:35 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2014-08-26 23:30:18 +00:00
#define BINDFOR(s) (*(&(s))->value.keybind)
2015-01-09 15:22:56 +00:00
/**
* setting_data_reset_setting:
* @setting : pointer to setting
*
* Reset a setting's value to its defaults.
**/
void setting_data_reset_setting(rarch_setting_t* setting);
2015-01-09 15:22:56 +00:00
/**
* setting_data_reset:
* @settings : pointer to settings
*
* Reset all settings to their default values.
**/
void setting_data_reset(rarch_setting_t* settings);
2015-01-09 15:22:56 +00:00
/**
* setting_data_reset:
* @settings : pointer to settings
* @name : name of setting to search for
*
* Search for a setting with a specified name (@name).
*
* Returns: pointer to setting if found, NULL otherwise.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t* setting_data_find_setting(rarch_setting_t* settings,
const char* name);
2015-01-09 15:22:56 +00:00
/**
* setting_data_set_with_string_representation:
* @setting : pointer to setting
* @value : value for the setting (string)
*
* Set a settings' value with a string. It is assumed
* that the string has been properly formatted.
**/
2014-08-27 19:14:36 +00:00
void setting_data_set_with_string_representation(
rarch_setting_t* setting, const char* value);
2015-01-09 15:22:56 +00:00
/**
* setting_data_get_string_representation:
* @setting : pointer to setting
* @buf : buffer to write contents of string representation to.
* @sizeof_buf : size of the buffer (@buf)
*
* Get a setting value's string representation.
**/
2015-01-30 09:35:06 +00:00
void setting_data_get_string_representation(void *data,
2014-08-27 19:14:36 +00:00
char* buf, size_t sizeof_buf);
2015-01-09 15:45:58 +00:00
/**
* setting_data_action_setting:
* @name : name of setting.
* @short_description : short description of setting.
* @group : group that the setting belongs to.
* @subgroup : subgroup that the setting belongs to.
*
* Initializes a setting of type ST_ACTION.
*
* Returns: setting of type ST_ACTION.
**/
rarch_setting_t setting_data_action_setting(const char *name,
const char *short_description,
const char *group,
const char *subgroup);
2015-01-09 15:45:58 +00:00
/**
* setting_data_group_setting:
* @type : type of settting.
* @name : name of setting.
*
* Initializes a setting of type ST_GROUP.
*
* Returns: setting of type ST_GROUP.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_group_setting(enum setting_type type,
const char* name);
2015-01-09 15:45:58 +00:00
/**
* setting_data_subgroup_setting:
* @type : type of settting.
* @name : name of setting.
* @parent_name : group that the subgroup setting belongs to.
*
* Initializes a setting of type ST_SUBGROUP.
*
* Returns: setting of type ST_SUBGROUP.
**/
rarch_setting_t setting_data_subgroup_setting(enum setting_type type,
const char* name, const char *parent_name);
2015-01-09 15:45:58 +00:00
/**
* setting_data_bool_setting:
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of bool setting.
* @default_value : Default value (in bool format).
* @off : String value for "Off" label.
* @on : String value for "On" label.
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a setting of type ST_BOOL.
*
* Returns: setting of type ST_BOOL.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_bool_setting(const char* name,
const char* description, bool* target, bool default_value,
const char *off, const char *on, const char * group,
const char *subgroup, change_handler_t change_handler,
change_handler_t read_handler);
2015-01-09 15:45:58 +00:00
/**
* setting_data_int_setting:
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of signed integer setting.
* @default_value : Default value (in signed integer format).
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a setting of type ST_INT.
*
* Returns: setting of type ST_INT.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_int_setting(const char* name,
const char* description, int* target, int default_value,
const char *group, const char *subgroup,
change_handler_t change_handler, change_handler_t read_handler);
2015-01-09 15:45:58 +00:00
/**
* setting_data_uint_setting:
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of unsigned integer setting.
* @default_value : Default value (in unsigned integer format).
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a setting of type ST_UINT.
*
* Returns: setting of type ST_UINT.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_uint_setting(const char* name,
const char* description, unsigned int* target,
unsigned int default_value, const char *group,
const char *subgroup, change_handler_t change_handler,
change_handler_t read_handler);
2015-01-09 15:45:58 +00:00
/**
* setting_data_float_setting:
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of float setting.
* @default_value : Default value (in float).
* @rounding : Rounding (for float-to-string representation).
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a setting of type ST_FLOAT.
*
* Returns: setting of type ST_FLOAT.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_float_setting(const char* name,
const char* description, float* target, float default_value,
const char *rounding, const char *group, const char *subgroup,
change_handler_t change_handler, change_handler_t read_handler);
2015-01-09 15:45:58 +00:00
/**
* setting_data_string_setting:
* @type : type of setting.
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of string setting.
* @size : Size of string setting.
* @default_value : Default value (in string format).
* @empty : TODO/FIXME: ???
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a string setting (of type @type).
*
* Returns: String setting of type @type.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_string_setting(enum setting_type type,
const char* name, const char* description, char* target,
unsigned size, const char* default_value, const char *empty,
const char *group, const char *subgroup,
change_handler_t change_handler, change_handler_t read_handler);
2015-01-09 15:45:58 +00:00
/**
* setting_data_bind_setting:
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of bind setting.
* @idx : Index of bind setting.
* @idx_offset : Index offset of bind setting.
* @default_value : Default value (in bind format).
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
*
* Initializes a setting of type ST_BIND.
*
* Returns: setting of type ST_BIND.
**/
2014-08-27 19:14:36 +00:00
rarch_setting_t setting_data_bind_setting(const char* name,
const char* description, struct retro_keybind* target, uint32_t idx,
uint32_t idx_offset,
2014-08-27 19:14:36 +00:00
const struct retro_keybind* default_value, const char *group,
const char *subgroup);
2014-11-14 23:20:55 +00:00
2015-01-13 23:35:27 +00:00
/**
* setting_data_string_setting_options:
* @type : type of settting.
* @name : name of setting.
* @short_description : Short description of setting.
* @target : Target of bind setting.
* @size : Size of string setting.
* @default_value : Default value.
* @empty : N/A.
* @values : Values, separated by a delimiter.
* @group : Group that the setting belongs to.
* @subgroup : Subgroup that the setting belongs to.
* @change_handler : Function callback for change handler function pointer.
* @read_handler : Function callback for read handler function pointer.
*
* Initializes a string options list setting.
*
* Returns: string option list setting.
**/
2014-11-14 23:20:55 +00:00
rarch_setting_t setting_data_string_setting_options(enum setting_type type,
const char* name, const char* short_description, char* target,
unsigned size, const char* default_value, const char *empty, const char *values,
const char *group, const char *subgroup, change_handler_t change_handler,
change_handler_t read_handler);
2014-08-27 19:14:36 +00:00
2015-01-09 15:45:58 +00:00
/**
* setting_data_get_description:
* @label : identifier label of setting
* @msg : output message
* @sizeof_msg : size of @msg
*
* Writes a 'Help' description message to @msg if there is
* one available based on the identifier label of the setting
* (@label).
*
* Returns: 0 (always for now). TODO: make it handle -1 as well.
**/
int setting_data_get_description(const char *label, char *msg,
2014-08-27 19:14:36 +00:00
size_t msg_sizeof);
#ifdef HAVE_MENU
2015-01-09 15:45:58 +00:00
/**
* setting_data_get_label:
* @list : File list on which to perform the search
2015-01-09 15:45:58 +00:00
* @type_str : String for the type to be represented on-screen as
* a label.
* @type_str_size : Size of @type_str
* @w : Width of the string (for text label representation
* purposes in the menu display driver).
* @type : Identifier of setting.
* @menu_label : Menu Label identifier of setting.
* @label : Label identifier of setting.
* @idx : Index identifier of setting.
*
* Get associated label of a setting.
**/
2015-02-03 03:24:34 +00:00
void setting_data_get_label(file_list_t *list, char *type_str,
size_t type_str_size, unsigned *w, unsigned type,
const char *menu_label, const char *label, unsigned idx);
2014-08-27 21:17:32 +00:00
#endif
2015-01-09 15:45:58 +00:00
/**
* setting_data_new:
* @mask : Bitmask of settings to include.
*
* Request a list of settings based on @mask.
*
* Returns: settings list composed of all requested
* settings on success, otherwise NULL.
**/
rarch_setting_t* setting_data_new(unsigned mask);
2013-08-27 02:12:22 +00:00
2014-08-17 18:42:35 +00:00
#ifdef __cplusplus
}
#endif
#endif