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

Get rid of some needless getters/setters

This commit is contained in:
twinaphex 2021-09-30 21:10:12 +02:00
parent ef875f6102
commit ddceb51f89
7 changed files with 66 additions and 102 deletions

View File

@ -45,7 +45,8 @@ static void *qnx_joypad_init(void *data)
static int32_t qnx_joypad_button(unsigned port, uint16_t joykey)
{
qnx_input_device_t* controller = NULL;
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
qnx_input_t *qnx =
(qnx_input_t*)input_state_get_ptr()->current_data;
if (!qnx || port >= DEFAULT_MAX_PADS)
return 0;
@ -99,7 +100,8 @@ static int16_t qnx_joypad_axis_state(
static int16_t qnx_joypad_axis(unsigned port, uint32_t joyaxis)
{
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
qnx_input_t *qnx =
(qnx_input_t*)input_state_get_ptr()->current_data;
qnx_input_device_t* controller = NULL;
if (!qnx || port >= DEFAULT_MAX_PADS)
return 0;
@ -114,7 +116,8 @@ static int16_t qnx_joypad_state(
{
unsigned i;
int16_t ret = 0;
qnx_input_t *qnx = (qnx_input_t*)input_driver_get_data();
qnx_input_t *qnx =
(qnx_input_t*)input_state_get_ptr()->current_data;
qnx_input_device_t* controller = NULL;
uint16_t port_idx = joypad_info->joy_idx;

View File

@ -308,12 +308,36 @@ input_driver_state_t *input_state_get_ptr(void)
return &input_driver_st;
}
/* private function prototypes */
/**
* Finds first suitable joypad driver and initializes. Used as a fallback by
* input_joypad_init_driver when no matching driver is found.
*
* @param data joypad state data pointer, which can be NULL and will be
* initialized by the new joypad driver, if one is found.
*
* @return joypad driver if found and initialized, otherwise NULL.
**/
static const input_device_driver_t *input_joypad_init_first(void *data)
{
unsigned i;
static const input_device_driver_t *input_joypad_init_first(void *data);
for (i = 0; joypad_drivers[i]; i++)
{
if ( joypad_drivers[i]
&& joypad_drivers[i]->init)
{
void *ptr = joypad_drivers[i]->init(data);
if (ptr)
{
RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n",
joypad_drivers[i]->ident);
return joypad_drivers[i];
}
}
}
/**************************************/
return NULL;
}
bool input_driver_set_rumble(
unsigned port, unsigned joy_idx,
@ -429,36 +453,6 @@ const input_device_driver_t *input_joypad_init_driver(
return input_joypad_init_first(data); /* fall back to first available driver */
}
/**
* Finds first suitable joypad driver and initializes. Used as a fallback by
* input_joypad_init_driver when no matching driver is found.
*
* @param data joypad state data pointer, which can be NULL and will be
* initialized by the new joypad driver, if one is found.
*
* @return joypad driver if found and initialized, otherwise NULL.
**/
static const input_device_driver_t *input_joypad_init_first(void *data)
{
unsigned i;
for (i = 0; joypad_drivers[i]; i++)
{
if ( joypad_drivers[i]
&& joypad_drivers[i]->init)
{
void *ptr = joypad_drivers[i]->init(data);
if (ptr)
{
RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n",
joypad_drivers[i]->ident);
return joypad_drivers[i];
}
}
}
return NULL;
}
bool input_driver_button_combo(
unsigned mode,
@ -2187,16 +2181,6 @@ bool input_set_sensor_state(unsigned port,
port, input_sensors_enable, action, rate);
}
void input_set_nonblock_state(void)
{
input_driver_st.nonblocking_flag = true;
}
void input_unset_nonblock_state(void)
{
input_driver_st.nonblocking_flag = false;
}
const char *joypad_driver_name(unsigned i)
{
if (!input_driver_st.primary_joypad || !input_driver_st.primary_joypad->name)
@ -2208,14 +2192,14 @@ void joypad_driver_reinit(void *data, const char *joypad_driver_name)
{
if (input_driver_st.primary_joypad)
{
const input_device_driver_t *tmp = input_driver_st.primary_joypad;
const input_device_driver_t *tmp = input_driver_st.primary_joypad;
input_driver_st.primary_joypad = NULL;
tmp->destroy();
}
#ifdef HAVE_MFI
if (input_driver_st.secondary_joypad)
{
const input_device_driver_t *tmp = input_driver_st.secondary_joypad;
const input_device_driver_t *tmp = input_driver_st.secondary_joypad;
input_driver_st.secondary_joypad = NULL;
tmp->destroy();
}
@ -2290,11 +2274,6 @@ bool input_set_rumble_gain(unsigned gain)
return false;
}
void *input_driver_get_data(void)
{
return input_driver_st.current_data;
}
uint64_t input_driver_get_capabilities(void)
{
if ( !input_driver_st.current_driver ||

View File

@ -845,13 +845,32 @@ void input_config_get_bind_string_joykey(
int16_t input_state_internal(unsigned port, unsigned device,
unsigned idx, unsigned id);
/*****************************************************************************/
bool input_key_pressed(int key, bool keyboard_pressed);
bool input_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
bool input_set_rumble_gain(unsigned gain);
float input_get_sensor_state(unsigned port, unsigned id);
bool input_set_sensor_state(unsigned port,
enum retro_sensor_action action, unsigned rate);
bool input_mouse_grabbed(void);
void *input_driver_init_wrap(input_driver_t *input, const char *name);
const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id);
void input_config_reset_autoconfig_binds(unsigned port);
void input_config_reset(void);
const char *joypad_driver_name(unsigned i);
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
#if defined(ANDROID)
#define DEFAULT_MAX_PADS 8
#define ANDROID_KEYBOARD_PORT DEFAULT_MAX_PADS

View File

@ -3134,7 +3134,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
if (netplay->catch_up)
{
netplay->catch_up = false;
input_unset_nonblock_state();
input_state_get_ptr()->nonblocking_flag = false;
driver_set_nonblock_state();
}
return;
@ -3327,7 +3327,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
if (netplay->self_frame_count + 1 >= lo_frame_count)
{
netplay->catch_up = false;
input_unset_nonblock_state();
input_state_get_ptr()->nonblocking_flag = false;
driver_set_nonblock_state();
}
@ -3354,9 +3354,9 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
if (netplay->catch_up_behind <= cur_behind)
{
/* We're definitely falling behind! */
netplay->catch_up = true;
netplay->catch_up_time = 0;
input_set_nonblock_state();
netplay->catch_up = true;
netplay->catch_up_time = 0;
input_state_get_ptr()->nonblocking_flag = true;
driver_set_nonblock_state();
}
else

View File

@ -830,44 +830,6 @@ unsigned int retroarch_get_rotation(void);
void retroarch_init_task_queue(void);
/******************************************************************************
* BEGIN helper functions for input_driver refactoring
*
* These functions have similar names and signatures to functions that now require
* an input_driver_state_t pointer to be passed to them. They essentially wrap
* the newer functions by grabbing pointer to the driver state struct and the
* settings struct.
******************************************************************************/
bool input_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
bool input_set_rumble_gain(unsigned gain);
float input_get_sensor_state(unsigned port, unsigned id);
bool input_set_sensor_state(unsigned port,
enum retro_sensor_action action, unsigned rate);
void input_set_nonblock_state(void);
void input_unset_nonblock_state(void);
void *input_driver_get_data(void);
/******************************************************************************
* END helper functions for input_driver refactoring
******************************************************************************/
bool input_key_pressed(int key, bool keyboard_pressed);
bool input_mouse_grabbed(void);
const char *joypad_driver_name(unsigned i);
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
void *input_driver_init_wrap(input_driver_t *input, const char *name);
/* Human readable order of input binds */
static const unsigned input_config_bind_order[] = {
RETRO_DEVICE_ID_JOYPAD_UP,

View File

@ -427,7 +427,7 @@ static ui_application_t ui_application_cocoa = {
NSPoint pos = CONVERT_POINT();
cocoa_input_data_t
*apple = (cocoa_input_data_t*)
input_driver_get_data();
input_state_get_ptr()->current_data;
if (!apple)
return;
/* Relative */
@ -456,7 +456,7 @@ static ui_application_t ui_application_cocoa = {
NSPoint pos = CONVERT_POINT();
cocoa_input_data_t
*apple = (cocoa_input_data_t*)
input_driver_get_data();
input_state_get_ptr()->current_data;
if (!apple || pos.y < 0)
return;
apple->mouse_buttons |= (1 << number);
@ -471,7 +471,7 @@ static ui_application_t ui_application_cocoa = {
NSPoint pos = CONVERT_POINT();
cocoa_input_data_t
*apple = (cocoa_input_data_t*)
input_driver_get_data();
input_state_get_ptr()->current_data;
if (!apple || pos.y < 0)
return;
apple->mouse_buttons &= ~(1 << number);

View File

@ -111,7 +111,8 @@ void get_ios_version(int *major, int *minor)
static void handle_touch_event(NSArray* touches)
{
unsigned i;
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
cocoa_input_data_t *apple = (cocoa_input_data_t*)
input_state_get_ptr()->current_data;
float scale = cocoa_screen_get_native_scale();
if (!apple)