mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 04:20:28 +00:00
input_device_info - slim down - we don't need config_path and some of
the char arrays can be much smaller
This commit is contained in:
parent
94accbb6ef
commit
c82401dcb4
@ -3926,7 +3926,6 @@ void input_config_reset(void)
|
||||
* to zero manually) */
|
||||
input_st->input_device_info[i].name[0] = '\0';
|
||||
input_st->input_device_info[i].display_name[0] = '\0';
|
||||
input_st->input_device_info[i].config_path[0] = '\0';
|
||||
input_st->input_device_info[i].config_name[0] = '\0';
|
||||
input_st->input_device_info[i].joypad_driver[0] = '\0';
|
||||
input_st->input_device_info[i].vid = 0;
|
||||
@ -4046,15 +4045,6 @@ const char *input_config_get_device_name(unsigned port)
|
||||
return input_st->input_device_info[port].name;
|
||||
}
|
||||
|
||||
|
||||
const char *input_config_get_device_config_path(unsigned port)
|
||||
{
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
if (string_is_empty(input_st->input_device_info[port].config_path))
|
||||
return NULL;
|
||||
return input_st->input_device_info[port].config_path;
|
||||
}
|
||||
|
||||
const char *input_config_get_device_display_name(unsigned port)
|
||||
{
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
@ -4139,21 +4129,6 @@ void input_config_set_device_display_name(unsigned port, const char *name)
|
||||
sizeof(input_st->input_device_info[port].display_name));
|
||||
}
|
||||
|
||||
void input_config_set_device_config_path(unsigned port, const char *path)
|
||||
{
|
||||
if (!string_is_empty(path))
|
||||
{
|
||||
char parent_dir_name[128];
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
if (fill_pathname_parent_dir_name(parent_dir_name,
|
||||
path, sizeof(parent_dir_name)))
|
||||
fill_pathname_join_special(
|
||||
input_st->input_device_info[port].config_path,
|
||||
parent_dir_name, path_basename_nocompression(path),
|
||||
sizeof(input_st->input_device_info[port].config_path));
|
||||
}
|
||||
}
|
||||
|
||||
void input_config_set_device_config_name(unsigned port, const char *name)
|
||||
{
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
@ -4207,12 +4182,6 @@ void input_config_clear_device_display_name(unsigned port)
|
||||
input_st->input_device_info[port].display_name[0] = '\0';
|
||||
}
|
||||
|
||||
void input_config_clear_device_config_path(unsigned port)
|
||||
{
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
input_st->input_device_info[port].config_path[0] = '\0';
|
||||
}
|
||||
|
||||
void input_config_clear_device_config_name(unsigned port)
|
||||
{
|
||||
input_driver_state_t *input_st = &input_driver_st;
|
||||
|
@ -109,7 +109,7 @@
|
||||
/**
|
||||
* Takes as input analog key identifiers and converts them to corresponding
|
||||
* bind IDs ident_minus and ident_plus.
|
||||
*
|
||||
*
|
||||
* @param idx Analog key index (eg RETRO_DEVICE_INDEX_ANALOG_LEFT)
|
||||
* @param ident Analog key identifier (eg RETRO_DEVICE_ID_ANALOG_X)
|
||||
* @param ident_minus Bind ID minus, will be set by function.
|
||||
@ -255,9 +255,8 @@ typedef struct
|
||||
uint16_t vid;
|
||||
uint16_t pid;
|
||||
char joypad_driver[32];
|
||||
char name[256];
|
||||
char display_name[256];
|
||||
char config_path[PATH_MAX_LENGTH]; /* Path to the RetroArch config file */
|
||||
char name[128];
|
||||
char display_name[128];
|
||||
char config_name[256]; /* Base name of the RetroArch config file */
|
||||
bool autoconfigured;
|
||||
} input_device_info_t;
|
||||
@ -307,16 +306,16 @@ typedef struct input_list_element_t
|
||||
* Organizes the functions and data structures of each driver that are accessed
|
||||
* by other parts of the input code. The input_driver structs are the "interface"
|
||||
* between RetroArch and the input driver.
|
||||
*
|
||||
* Every driver must establish an input_driver struct with pointers to its own
|
||||
*
|
||||
* Every driver must establish an input_driver struct with pointers to its own
|
||||
* implementations of these functions, and each of those input_driver structs is
|
||||
* declared below.
|
||||
*/
|
||||
struct input_driver
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Initializes input driver.
|
||||
*
|
||||
*
|
||||
* @param joypad_driver Name of the joypad driver associated with the
|
||||
* input driver
|
||||
*/
|
||||
@ -331,7 +330,7 @@ struct input_driver
|
||||
*/
|
||||
void (*poll)(void *data);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Queries state for a specified control on a specified input port. This
|
||||
* function pointer can be set to NULL if not supported by the input driver,
|
||||
* for example if a joypad driver is responsible for quering state for a
|
||||
@ -346,10 +345,10 @@ struct input_driver
|
||||
* with hardware device ID and autoconfig mapping.
|
||||
* @param retro_keybinds Structure for control mappings for all libretro
|
||||
* input device abstractions
|
||||
* @param keyboard_mapping_blocked
|
||||
* @param keyboard_mapping_blocked
|
||||
* If true, disregard custom keyboard mapping
|
||||
* @param port Which RetroArch port is being polled
|
||||
* @param device Which libretro abstraction is being polled
|
||||
* @param device Which libretro abstraction is being polled
|
||||
* (RETRO_DEVICE_ID_RETROPAD, RETRO_DEVICE_ID_MOUSE)
|
||||
* @param index For controls with more than one axis or multiple
|
||||
* simultaneous inputs, such as an analog joystick
|
||||
@ -370,7 +369,7 @@ struct input_driver
|
||||
|
||||
/**
|
||||
* Frees the input struct.
|
||||
*
|
||||
*
|
||||
* @param data The input state struct.
|
||||
*/
|
||||
void (*free)(void *data);
|
||||
@ -379,16 +378,16 @@ struct input_driver
|
||||
* Sets the state related for sensors, such as polling rate or to deactivate
|
||||
* the sensor entirely, etc. This function pointer may be set to NULL if
|
||||
* setting sensor values is not supported.
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @param data
|
||||
* The input state struct
|
||||
* @param port
|
||||
* The port of the device
|
||||
* @param effect
|
||||
* @param effect
|
||||
* Sensor action
|
||||
* @param rate
|
||||
* @param rate
|
||||
* Sensor rate update
|
||||
*
|
||||
*
|
||||
* @return true if the operation is successful.
|
||||
**/
|
||||
bool (*set_sensor_state)(void *data, unsigned port,
|
||||
@ -398,14 +397,14 @@ struct input_driver
|
||||
* Retrieves the sensor state associated with the provided port and ID. This
|
||||
* function pointer may be set to NULL if retreiving sensor state is not
|
||||
* supported.
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @param data
|
||||
* The input state struct
|
||||
* @param port
|
||||
* The port of the device
|
||||
* @param id
|
||||
* @param id
|
||||
* Sensor ID
|
||||
*
|
||||
*
|
||||
* @return The current state associated with the port and ID as a float
|
||||
**/
|
||||
float (*get_sensor_input)(void *data, unsigned port, unsigned id);
|
||||
@ -413,9 +412,9 @@ struct input_driver
|
||||
/**
|
||||
* The means for an input driver to indicate to RetroArch which libretro
|
||||
* input abstractions the driver supports.
|
||||
*
|
||||
*
|
||||
* @param data The input state struct.
|
||||
*
|
||||
*
|
||||
* @return A unit64_t composed via bitwise operators.
|
||||
*/
|
||||
uint64_t (*get_capabilities)(void *data);
|
||||
@ -429,7 +428,7 @@ struct input_driver
|
||||
* Grab or ungrab the mouse according to the value of `state`. This function
|
||||
* pointer can be set to NULL if the driver does not support grabbing the
|
||||
* mouse.
|
||||
*
|
||||
*
|
||||
* @param data The input state struct
|
||||
* @param state True to grab the mouse, false to ungrab
|
||||
*/
|
||||
@ -439,9 +438,9 @@ struct input_driver
|
||||
* Check to see if the input driver has claimed stdin, and therefore it is
|
||||
* not available for other input. This function pointercan be set to NULL if
|
||||
* the driver does not support claiming stdin.
|
||||
*
|
||||
*
|
||||
* @param data The input state struct
|
||||
*
|
||||
*
|
||||
* @return True if the input driver has claimed stdin.
|
||||
*/
|
||||
bool (*grab_stdin)(void *data);
|
||||
@ -473,7 +472,7 @@ struct rarch_joypad_driver
|
||||
|
||||
/**
|
||||
* Callback for keypress events
|
||||
*
|
||||
*
|
||||
* @param userdata The user data that was passed through from the keyboard press callback.
|
||||
* @param code keycode
|
||||
**/
|
||||
@ -528,7 +527,7 @@ typedef struct
|
||||
#ifdef HAVE_NETWORKGAMEPAD
|
||||
input_remote_t *remote;
|
||||
#endif
|
||||
char *osk_grid[45]; /* ptr alignment */
|
||||
char *osk_grid[45]; /* ptr alignment */
|
||||
#if defined(HAVE_TRANSLATE)
|
||||
#if defined(HAVE_ACCESSIBILITY)
|
||||
int ai_gamepad_state[MAX_USERS];
|
||||
@ -573,25 +572,25 @@ const char* config_get_input_driver_options(void);
|
||||
|
||||
/**
|
||||
* Sets the rumble state.
|
||||
*
|
||||
* @param port
|
||||
*
|
||||
* @param port
|
||||
* User number.
|
||||
* @param joy_idx
|
||||
* TODO/FIXME ???
|
||||
* @param effect
|
||||
* @param effect
|
||||
* Rumble effect.
|
||||
* @param strength
|
||||
* @param strength
|
||||
* Strength of rumble effect.
|
||||
*
|
||||
* @return true if the rumble state has been successfully set
|
||||
**/
|
||||
bool input_driver_set_rumble(
|
||||
unsigned port, unsigned joy_idx,
|
||||
unsigned port, unsigned joy_idx,
|
||||
enum retro_rumble_effect effect, uint16_t strength);
|
||||
/**
|
||||
* Sets the rumble gain.
|
||||
*
|
||||
* @param gain
|
||||
* @param gain
|
||||
* Rumble gain, 0-100 [%]
|
||||
* @param input_max_users
|
||||
* TODO/FIXME - ???
|
||||
@ -604,14 +603,14 @@ bool input_driver_set_rumble_gain(
|
||||
|
||||
/**
|
||||
* Sets the sensor state.
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* User number.
|
||||
* @param sensors_enable
|
||||
* TODO/FIXME - ???
|
||||
* @param effect
|
||||
* @param effect
|
||||
* Sensor action
|
||||
* @param rate
|
||||
* @param rate
|
||||
* Sensor rate update
|
||||
*
|
||||
* @return true if the sensor state has been successfully set
|
||||
@ -621,13 +620,13 @@ bool input_driver_set_sensor(
|
||||
enum retro_sensor_action action, unsigned rate);
|
||||
|
||||
/**
|
||||
* Retrieves the sensor state associated with the provided port and ID.
|
||||
*
|
||||
* Retrieves the sensor state associated with the provided port and ID.
|
||||
*
|
||||
* @param port
|
||||
* Port of the device
|
||||
* @param sensors_enable
|
||||
* TODO/FIXME - ???
|
||||
* @param id
|
||||
* @param id
|
||||
* Sensor ID
|
||||
*
|
||||
* @return The current state associated with the port and ID as a float
|
||||
@ -654,7 +653,7 @@ bool input_driver_ungrab_mouse(void);
|
||||
const char* config_get_joypad_driver_options(void);
|
||||
|
||||
/**
|
||||
* Initialize a joypad driver of name ident. If ident points to NULL or a
|
||||
* Initialize a joypad driver of name ident. If ident points to NULL or a
|
||||
* zero-length string, equivalent to calling input_joypad_init_first().
|
||||
*
|
||||
* @param ident identifier of driver to initialize.
|
||||
@ -668,10 +667,10 @@ const input_device_driver_t *input_joypad_init_driver(
|
||||
|
||||
/**
|
||||
* Registers a newly connected pad with RetroArch.
|
||||
*
|
||||
* @param port
|
||||
*
|
||||
* @param port
|
||||
* Joystick number
|
||||
* @param driver
|
||||
* @param driver
|
||||
* Handle for joypad driver handling joystick's input
|
||||
**/
|
||||
void input_pad_connect(unsigned port, input_device_driver_t *driver);
|
||||
@ -679,14 +678,14 @@ void input_pad_connect(unsigned port, input_device_driver_t *driver);
|
||||
/**
|
||||
* Called by drivers when keyboard events are fired. Interfaces with the global
|
||||
* driver struct and libretro callbacks.
|
||||
*
|
||||
* @param down
|
||||
*
|
||||
* @param down
|
||||
* Was Keycode pressed down?
|
||||
* @param code
|
||||
* @param code
|
||||
* Keycode.
|
||||
* @param character
|
||||
* @param character
|
||||
* Character inputted.
|
||||
* @param mod
|
||||
* @param mod
|
||||
* TODO/FIXME/???
|
||||
**/
|
||||
void input_keyboard_event(bool down, unsigned code, uint32_t character,
|
||||
@ -698,7 +697,7 @@ input_driver_state_t *input_state_get_ptr(void);
|
||||
#ifdef HAVE_HID
|
||||
/**
|
||||
* Get an enumerated list of all HID driver names
|
||||
*
|
||||
*
|
||||
* @return String listing of all HID driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_hid_driver_options(void);
|
||||
@ -712,7 +711,7 @@ const hid_driver_t *input_hid_init_first(void);
|
||||
|
||||
/**
|
||||
* Get a pointer to the HID driver data structure
|
||||
*
|
||||
*
|
||||
* @return Pointer to hid_data struct
|
||||
**/
|
||||
void *hid_driver_get_data(void);
|
||||
@ -729,7 +728,7 @@ void hid_driver_reset_data(void);
|
||||
|
||||
/**
|
||||
* Set the name of the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
*/
|
||||
@ -737,59 +736,49 @@ void input_config_set_device_name(unsigned port, const char *name);
|
||||
|
||||
/**
|
||||
* Set the formatted "display name" of the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
*/
|
||||
void input_config_set_device_display_name(unsigned port, const char *name);
|
||||
void input_config_set_mouse_display_name(unsigned port, const char *name);
|
||||
|
||||
/**
|
||||
* Set the configuration path for the device in the specified port
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param path
|
||||
* The path of the device config.
|
||||
*/
|
||||
void input_config_set_device_config_path(unsigned port, const char *path);
|
||||
|
||||
/**
|
||||
* Set the configuration name for the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param name
|
||||
* @param name
|
||||
* The name of the config to set.
|
||||
*/
|
||||
void input_config_set_device_config_name(unsigned port, const char *name);
|
||||
|
||||
/**
|
||||
* Set the joypad driver for the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param driver
|
||||
* @param driver
|
||||
* The driver to set the given port to.
|
||||
*/
|
||||
void input_config_set_device_joypad_driver(unsigned port, const char *driver);
|
||||
|
||||
/**
|
||||
* Set the vendor ID (vid) for the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param vid
|
||||
* @param vid
|
||||
* The VID to set the given device port to.
|
||||
*/
|
||||
void input_config_set_device_vid(unsigned port, uint16_t vid);
|
||||
|
||||
/**
|
||||
* Set the pad ID (pid) for the device in the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param pid
|
||||
* @param pid
|
||||
* The PID to set the given device port to.
|
||||
*/
|
||||
void input_config_set_device_pid(unsigned port, uint16_t pid);
|
||||
@ -799,7 +788,7 @@ void input_config_set_device_pid(unsigned port, uint16_t pid);
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param autoconfigured
|
||||
* @param autoconfigured
|
||||
* Whether or nor the device is configured automatically.
|
||||
*/
|
||||
void input_config_set_device_autoconfigured(unsigned port, bool autoconfigured);
|
||||
@ -809,17 +798,17 @@ void input_config_set_device_autoconfigured(unsigned port, bool autoconfigured);
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param name_index
|
||||
* @param name_index
|
||||
* The name index to set the device to use.
|
||||
*/
|
||||
void input_config_set_device_name_index(unsigned port, unsigned name_index);
|
||||
|
||||
/**
|
||||
* Sets the device type of the specified port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device to be assigned to
|
||||
* @param id
|
||||
* @param id
|
||||
* The device type (RETRO_DEVICE_JOYPAD, RETRO_DEVICE_MOUSE, etc)
|
||||
*/
|
||||
void input_config_set_device(unsigned port, unsigned id);
|
||||
@ -827,7 +816,6 @@ void input_config_set_device(unsigned port, unsigned id);
|
||||
/* Clear input_device_info */
|
||||
void input_config_clear_device_name(unsigned port);
|
||||
void input_config_clear_device_display_name(unsigned port);
|
||||
void input_config_clear_device_config_path(unsigned port);
|
||||
void input_config_clear_device_config_name(unsigned port);
|
||||
void input_config_clear_device_joypad_driver(unsigned port);
|
||||
|
||||
@ -841,13 +829,12 @@ unsigned input_config_get_device(unsigned port);
|
||||
const char *input_config_get_device_name(unsigned port);
|
||||
const char *input_config_get_device_display_name(unsigned port);
|
||||
const char *input_config_get_mouse_display_name(unsigned port);
|
||||
const char *input_config_get_device_config_path(unsigned port);
|
||||
const char *input_config_get_device_config_name(unsigned port);
|
||||
const char *input_config_get_device_joypad_driver(unsigned port);
|
||||
|
||||
/**
|
||||
* Retrieves the vendor id (vid) of a connected controller
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device
|
||||
*
|
||||
@ -857,7 +844,7 @@ uint16_t input_config_get_device_vid(unsigned port);
|
||||
|
||||
/**
|
||||
* Retrieves the pad id (pad) of a connected controller
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device
|
||||
*
|
||||
@ -877,7 +864,7 @@ bool input_config_get_device_autoconfigured(unsigned port);
|
||||
|
||||
/**
|
||||
* Get the name index number for the device in this port
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device
|
||||
*
|
||||
@ -894,7 +881,7 @@ unsigned input_config_get_device_name_index(unsigned port);
|
||||
* @deprecated input_config_get_device_name_ptr is required by linuxraw_joypad
|
||||
* and parport_joypad. These drivers should be refactored such that this
|
||||
* low-level access is not required.
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device
|
||||
*
|
||||
@ -908,7 +895,7 @@ char *input_config_get_device_name_ptr(unsigned port);
|
||||
* @deprecated input_config_get_device_name_size is required by linuxraw_joypad
|
||||
* and parport_joypad. These drivers should be refactored such that this
|
||||
* low-level access is not required.
|
||||
*
|
||||
*
|
||||
* @param port
|
||||
* The port of the device
|
||||
*
|
||||
@ -1060,9 +1047,9 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
|
||||
* @character : Character inputted.
|
||||
* @mod : TODO/FIXME: ???
|
||||
*
|
||||
* Keyboard event utils. Called by drivers when keyboard events
|
||||
* Keyboard event utils. Called by drivers when keyboard events
|
||||
* are fired.
|
||||
* This interfaces with the global system driver struct
|
||||
* This interfaces with the global system driver struct
|
||||
* and libretro callbacks.
|
||||
**/
|
||||
void input_keyboard_event(bool down, unsigned code,
|
||||
|
@ -174,11 +174,6 @@ static void input_autoconfigure_set_config_file(
|
||||
if (!string_is_empty(config->path))
|
||||
{
|
||||
const char *config_file_name = path_basename_nocompression(config->path);
|
||||
|
||||
strlcpy(autoconfig_handle->device_info.config_path,
|
||||
config->path,
|
||||
sizeof(autoconfig_handle->device_info.config_path));
|
||||
|
||||
if (!string_is_empty(config_file_name))
|
||||
strlcpy(autoconfig_handle->device_info.config_name,
|
||||
config_file_name,
|
||||
@ -413,14 +408,6 @@ static void cb_input_autoconfigure_connect(
|
||||
input_config_set_device_vid(port, autoconfig_handle->device_info.vid);
|
||||
input_config_set_device_pid(port, autoconfig_handle->device_info.pid);
|
||||
|
||||
/* > Config file path/name */
|
||||
if (!string_is_empty(autoconfig_handle->device_info.config_path))
|
||||
input_config_set_device_config_path(port,
|
||||
autoconfig_handle->device_info.config_path);
|
||||
else
|
||||
input_config_set_device_config_path(port,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
|
||||
|
||||
if (!string_is_empty(autoconfig_handle->device_info.config_name))
|
||||
input_config_set_device_config_name(port,
|
||||
autoconfig_handle->device_info.config_name);
|
||||
@ -633,7 +620,6 @@ bool input_autoconfigure_connect(
|
||||
autoconfig_handle->device_info.pid = pid;
|
||||
autoconfig_handle->device_info.name[0] = '\0';
|
||||
autoconfig_handle->device_info.display_name[0] = '\0';
|
||||
autoconfig_handle->device_info.config_path[0] = '\0';
|
||||
autoconfig_handle->device_info.config_name[0] = '\0';
|
||||
autoconfig_handle->device_info.joypad_driver[0] = '\0';
|
||||
autoconfig_handle->device_info.autoconfigured = false;
|
||||
@ -770,7 +756,6 @@ static void cb_input_autoconfigure_disconnect(
|
||||
* callback, to ensure it occurs on the main thread */
|
||||
input_config_clear_device_name(port);
|
||||
input_config_clear_device_display_name(port);
|
||||
input_config_clear_device_config_path(port);
|
||||
input_config_clear_device_config_name(port);
|
||||
input_config_clear_device_joypad_driver(port);
|
||||
input_config_set_device_vid(port, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user