2013-04-04 11:58:30 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2013-04-04 11:58:30 +00:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2016-05-09 23:25:47 +00:00
|
|
|
#ifndef CORE_OPTION_MANAGER_H__
|
|
|
|
#define CORE_OPTION_MANAGER_H__
|
2013-04-04 11:58:30 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
2016-02-04 19:56:22 +00:00
|
|
|
|
|
|
|
#include <boolean.h>
|
2016-06-03 03:49:46 +00:00
|
|
|
#include <retro_common_api.h>
|
2017-01-17 18:39:12 +00:00
|
|
|
#include <lists/string_list.h>
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2016-06-03 03:49:46 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2013-04-21 08:05:12 +00:00
|
|
|
|
2016-09-03 16:50:04 +00:00
|
|
|
struct core_option
|
|
|
|
{
|
|
|
|
char *desc;
|
|
|
|
char *key;
|
|
|
|
struct string_list *vals;
|
|
|
|
size_t index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct core_option_manager
|
|
|
|
{
|
|
|
|
config_file_t *conf;
|
|
|
|
char conf_path[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
struct core_option *opts;
|
|
|
|
size_t size;
|
|
|
|
bool updated;
|
|
|
|
};
|
|
|
|
|
2013-04-04 11:58:30 +00:00
|
|
|
typedef struct core_option_manager core_option_manager_t;
|
|
|
|
|
2015-01-16 01:10:17 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_new:
|
2015-01-16 01:10:17 +00:00
|
|
|
* @conf_path : Filesystem path to write core option config file to.
|
|
|
|
* @vars : Pointer to variable array handle.
|
|
|
|
*
|
|
|
|
* Creates and initializes a core manager handle.
|
|
|
|
*
|
|
|
|
* Returns: handle to new core manager handle, otherwise NULL.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
core_option_manager_t *core_option_manager_new(const char *conf_path,
|
2016-03-20 03:29:40 +00:00
|
|
|
const void *data);
|
2014-09-02 03:10:54 +00:00
|
|
|
|
2015-01-16 01:10:17 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_updated:
|
2015-01-16 01:10:17 +00:00
|
|
|
* @opt : options manager handle
|
|
|
|
*
|
|
|
|
* Has a core option been updated?
|
|
|
|
*
|
|
|
|
* Returns: true (1) if a core option has been updated,
|
|
|
|
* otherwise false (0).
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
bool core_option_manager_updated(core_option_manager_t *opt);
|
2014-09-07 03:47:18 +00:00
|
|
|
|
2015-01-16 01:10:17 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_flush:
|
2015-01-16 01:10:17 +00:00
|
|
|
* @opt : options manager handle
|
|
|
|
*
|
|
|
|
* Writes core option key-pair values to file.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if core option values could be
|
|
|
|
* successfully saved to disk, otherwise false (0).
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
bool core_option_manager_flush(core_option_manager_t *opt);
|
2014-09-07 03:47:18 +00:00
|
|
|
|
2015-11-16 03:09:39 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_flush_game_specific:
|
2015-11-16 03:09:39 +00:00
|
|
|
* @opt : options manager handle
|
|
|
|
* @path : path for the core options file
|
|
|
|
*
|
|
|
|
* Writes core option key-pair values to a custom file.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if core option values could be
|
|
|
|
* successfully saved to disk, otherwise false (0).
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
bool core_option_manager_flush_game_specific(
|
2016-09-17 11:47:26 +00:00
|
|
|
core_option_manager_t *opt, const char* path);
|
2015-11-16 03:09:39 +00:00
|
|
|
|
2015-01-16 01:10:17 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_free:
|
2015-01-16 01:10:17 +00:00
|
|
|
* @opt : options manager handle
|
|
|
|
*
|
|
|
|
* Frees core option manager handle.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_free(core_option_manager_t *opt);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_get(core_option_manager_t *opt, void *data);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_size:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : options manager handle
|
|
|
|
*
|
|
|
|
* Gets total number of options.
|
|
|
|
*
|
|
|
|
* Returns: Total number of options.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
size_t core_option_manager_size(core_option_manager_t *opt);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_get_desc:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : options manager handle
|
2015-01-15 21:05:07 +00:00
|
|
|
* @idx : idx identifier of the option
|
2015-01-09 21:01:19 +00:00
|
|
|
*
|
|
|
|
* Gets description for an option.
|
|
|
|
*
|
|
|
|
* Returns: Description for an option.
|
|
|
|
**/
|
2017-12-12 07:55:31 +00:00
|
|
|
const char *core_option_manager_get_desc(core_option_manager_t *opt,
|
2016-02-04 19:58:53 +00:00
|
|
|
size_t idx);
|
2014-09-07 03:47:18 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_get_val:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : options manager handle
|
2015-01-15 21:05:07 +00:00
|
|
|
* @idx : idx identifier of the option
|
2015-01-09 21:01:19 +00:00
|
|
|
*
|
|
|
|
* Gets value for an option.
|
|
|
|
*
|
|
|
|
* Returns: Value for an option.
|
|
|
|
**/
|
2017-12-12 07:55:31 +00:00
|
|
|
const char *core_option_manager_get_val(core_option_manager_t *opt,
|
2016-02-04 19:58:53 +00:00
|
|
|
size_t idx);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_set_val(core_option_manager_t *opt,
|
2015-01-15 21:05:07 +00:00
|
|
|
size_t idx, size_t val_idx);
|
2013-11-22 14:30:02 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_next:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : pointer to core option manager object.
|
2015-01-15 21:05:07 +00:00
|
|
|
* @idx : idx of core option to be reset to defaults.
|
2015-01-09 21:01:19 +00:00
|
|
|
*
|
|
|
|
* Get next value for core option specified by @idx.
|
|
|
|
* Options wrap around.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_next(core_option_manager_t *opt, size_t idx);
|
2014-09-07 03:47:18 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_prev:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : pointer to core option manager object.
|
2015-01-15 21:05:07 +00:00
|
|
|
* @idx : idx of core option to be reset to defaults.
|
2015-01-09 21:01:19 +00:00
|
|
|
* Options wrap around.
|
|
|
|
*
|
|
|
|
* Get previous value for core option specified by @idx.
|
|
|
|
* Options wrap around.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_prev(core_option_manager_t *opt, size_t idx);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2015-01-09 21:01:19 +00:00
|
|
|
/**
|
2016-05-09 23:21:55 +00:00
|
|
|
* core_option_manager_set_default:
|
2015-01-09 21:01:19 +00:00
|
|
|
* @opt : pointer to core option manager object.
|
2015-01-15 21:05:07 +00:00
|
|
|
* @idx : idx of core option to be reset to defaults.
|
2015-01-09 21:01:19 +00:00
|
|
|
*
|
|
|
|
* Reset core option specified by @idx and sets default value for option.
|
|
|
|
**/
|
2016-05-09 23:21:55 +00:00
|
|
|
void core_option_manager_set_default(core_option_manager_t *opt, size_t idx);
|
2013-04-04 11:58:30 +00:00
|
|
|
|
2016-06-03 03:49:46 +00:00
|
|
|
RETRO_END_DECLS
|
2013-04-21 08:05:12 +00:00
|
|
|
|
2013-04-04 11:58:30 +00:00
|
|
|
#endif
|