Revert "input refactoring: create input_driver.c"

This commit is contained in:
Autechre 2021-08-18 18:45:53 +02:00 committed by GitHub
parent a66b1b3e48
commit ae327a769b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 736 additions and 881 deletions

View file

@ -302,7 +302,6 @@ OBJ += \
$(LIBRETRO_COMM_DIR)/file/file_path_io.o \
file_path_special.o \
$(LIBRETRO_COMM_DIR)/hash/lrc_hash.o \
input/input_driver.o \
input/common/input_hid_common.o \
led/led_driver.o \
gfx/video_coord_array.o \

View file

@ -1341,8 +1341,8 @@ void cheat_manager_apply_rumble(struct item_cheat *cheat, unsigned int curr_valu
{
cheat->rumble_primary_end_time = current_time + (cheat->rumble_primary_duration * 1000);
cheat->rumble_secondary_end_time = current_time + (cheat->rumble_secondary_duration * 1000);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
}
}
else
@ -1354,24 +1354,24 @@ void cheat_manager_apply_rumble(struct item_cheat *cheat, unsigned int curr_valu
if (cheat->rumble_primary_end_time <= current_time)
{
if (cheat->rumble_primary_end_time != 0)
input_set_rumble_state(cheat->rumble_port,
input_driver_set_rumble_state(cheat->rumble_port,
RETRO_RUMBLE_STRONG, 0);
cheat->rumble_primary_end_time = 0;
}
else
{
input_set_rumble_state(cheat->rumble_port,
input_driver_set_rumble_state(cheat->rumble_port,
RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
}
if (cheat->rumble_secondary_end_time <= current_time)
{
if (cheat->rumble_secondary_end_time != 0)
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, 0);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, 0);
cheat->rumble_secondary_end_time = 0;
}
else
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
}
void cheat_manager_apply_retro_cheats(void)

View file

@ -1946,7 +1946,7 @@ static struct config_float_setting *populate_settings_float(
SETTING_FLOAT("video_font_size", &settings->floats.video_font_size, true, DEFAULT_FONT_SIZE, false);
SETTING_FLOAT("fastforward_ratio", &settings->floats.fastforward_ratio, true, DEFAULT_FASTFORWARD_RATIO, false);
SETTING_FLOAT("slowmotion_ratio", &settings->floats.slowmotion_ratio, true, DEFAULT_SLOWMOTION_RATIO, false);
SETTING_FLOAT("input_axis_threshold", &settings->floats.input_axis_threshold, true, DEFAULT_AXIS_THRESHOLD, false);
SETTING_FLOAT("input_axis_threshold", input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD), true, DEFAULT_AXIS_THRESHOLD, false);
SETTING_FLOAT("input_analog_deadzone", &settings->floats.input_analog_deadzone, true, DEFAULT_ANALOG_DEADZONE, false);
SETTING_FLOAT("input_analog_sensitivity", &settings->floats.input_analog_sensitivity, true, DEFAULT_ANALOG_SENSITIVITY, false);
SETTING_FLOAT("video_msg_bgcolor_opacity", &settings->floats.video_msg_bgcolor_opacity, true, message_bgcolor_opacity, false);
@ -1977,7 +1977,7 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("input_duty_cycle", &settings->uints.input_turbo_duty_cycle, true, turbo_duty_cycle, false);
SETTING_UINT("input_turbo_mode", &settings->uints.input_turbo_mode, true, turbo_mode, false);
SETTING_UINT("input_turbo_default_button", &settings->uints.input_turbo_default_button, true, turbo_default_btn, false);
SETTING_UINT("input_max_users", &settings->uints.input_max_users, true, input_max_users, false);
SETTING_UINT("input_max_users", input_driver_get_uint(INPUT_ACTION_MAX_USERS), true, input_max_users, false);
SETTING_UINT("fps_update_interval", &settings->uints.fps_update_interval, true, DEFAULT_FPS_UPDATE_INTERVAL, false);
SETTING_UINT("memory_update_interval", &settings->uints.memory_update_interval, true, DEFAULT_MEMORY_UPDATE_INTERVAL, false);
SETTING_UINT("input_menu_toggle_gamepad_combo", &settings->uints.input_menu_toggle_gamepad_combo, true, DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO, false);
@ -4787,8 +4787,8 @@ bool input_remapping_save_file(const char *path)
"a", "x", "l", "r", "l2", "r2",
"l3", "r3", "l_x+", "l_x-", "l_y+", "l_y-", "r_x+", "r_x-", "r_y+", "r_y-" };
config_file_t *conf = NULL;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
settings_t *settings = config_get_ptr();
unsigned max_users = settings->uints.input_max_users;
const char *dir_input_remapping = settings->paths.directory_input_remapping;
remap_file[0] = '\0';

View file

@ -165,7 +165,6 @@ typedef struct settings
unsigned input_poll_type_behavior;
unsigned input_dingux_rumble_gain;
unsigned input_auto_game_focus;
unsigned input_max_users;
unsigned netplay_port;
unsigned netplay_input_latency_frames_min;
@ -353,7 +352,6 @@ typedef struct settings
float slowmotion_ratio;
float fastforward_ratio;
float input_analog_deadzone;
float input_axis_threshold;
float input_analog_sensitivity;
} floats;

View file

@ -664,18 +664,14 @@ FONTS
/*============================================================
INPUT
============================================================ */
#include "../input/input_driver.c"
#include "../input/input_keymaps.c"
#include "../tasks/task_autodetect.c"
#ifdef HAVE_BLISSBOX
#include "../tasks/task_autodetect_blissbox.c"
#endif
#ifdef HAVE_AUDIOMIXER
#include "../tasks/task_audio_mixer.c"
#endif
#include "../input/input_keymaps.c"
#ifdef HAVE_OVERLAY
#include "../led/drivers/led_overlay.c"
@ -693,6 +689,8 @@ INPUT
#endif
#endif
#include "../input/input_autodetect_builtin.c"
#if defined(SN_TARGET_PSP2) || defined(PSP) || defined(VITA)
#include "../input/drivers/psp_input.c"
#include "../input/drivers_joypad/psp_joypad.c"

View file

@ -385,12 +385,12 @@ static void android_input_poll_main_cmd(void)
video_driver_unset_stub_frame();
if (enable_accelerometer)
input_set_sensor_state(0,
input_sensor_set_state(0,
RETRO_SENSOR_ACCELEROMETER_ENABLE,
android_app->accelerometer_event_rate);
if (enable_gyroscope)
input_set_sensor_state(0,
input_sensor_set_state(0,
RETRO_SENSOR_GYROSCOPE_ENABLE,
android_app->gyroscope_event_rate);
}
@ -415,12 +415,12 @@ static void android_input_poll_main_cmd(void)
/* Avoid draining battery while app is not being used. */
if (disable_accelerometer)
input_set_sensor_state(0,
input_sensor_set_state(0,
RETRO_SENSOR_ACCELEROMETER_DISABLE,
android_app->accelerometer_event_rate);
if (disable_gyroscope)
input_set_sensor_state(0,
input_sensor_set_state(0,
RETRO_SENSOR_GYROSCOPE_DISABLE,
android_app->gyroscope_event_rate);
}

View file

@ -174,6 +174,13 @@ enum input_turbo_default_button
INPUT_TURBO_DEFAULT_BUTTON_LAST
};
enum input_action
{
INPUT_ACTION_NONE = 0,
INPUT_ACTION_AXIS_THRESHOLD,
INPUT_ACTION_MAX_USERS
};
/* Specialized _MOUSE that targets the full screen regardless of viewport.
*/
#define RARCH_DEVICE_MOUSE_SCREEN (RETRO_DEVICE_MOUSE | 0x10000)

View file

@ -1,444 +0,0 @@
/**
* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - 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 Foundation, 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/>.
**/
#include <string/stdstring.h>
#include "input_driver.h"
#include "retroarch.h"
#include "verbosity.h"
#include "configuration.h"
#include "../list_special.h"
/**************************************/
static void *input_null_init(const char *joypad_driver) { return (void*)-1; }
static void input_null_poll(void *data) { }
static int16_t input_null_input_state(
void *data,
const input_device_driver_t *joypad,
const input_device_driver_t *sec_joypad,
rarch_joypad_info_t *joypad_info,
const struct retro_keybind **retro_keybinds,
bool keyboard_mapping_blocked,
unsigned port, unsigned device, unsigned index, unsigned id) { return 0; }
static void input_null_free(void *data) { }
static bool input_null_set_sensor_state(void *data, unsigned port,
enum retro_sensor_action action, unsigned rate) { return false; }
static float input_null_get_sensor_input(void *data, unsigned port, unsigned id) { return 0.0; }
static uint64_t input_null_get_capabilities(void *data) { return 0; }
static void input_null_grab_mouse(void *data, bool state) { }
static bool input_null_grab_stdin(void *data) { return false; }
static input_driver_t input_null = {
input_null_init,
input_null_poll,
input_null_input_state,
input_null_free,
input_null_set_sensor_state,
input_null_get_sensor_input,
input_null_get_capabilities,
"null",
input_null_grab_mouse,
input_null_grab_stdin
};
static input_device_driver_t null_joypad = {
NULL, /* init */
NULL, /* query_pad */
NULL, /* destroy */
NULL, /* button */
NULL, /* state */
NULL, /* get_buttons */
NULL, /* axis */
NULL, /* poll */
NULL,
NULL, /* name */
"null",
};
#ifdef HAVE_HID
static bool null_hid_joypad_query(void *data, unsigned pad) {
return pad < MAX_USERS; }
static const char *null_hid_joypad_name(
void *data, unsigned pad) { return NULL; }
static void null_hid_joypad_get_buttons(void *data,
unsigned port, input_bits_t *state) { BIT256_CLEAR_ALL_PTR(state); }
static int16_t null_hid_joypad_button(
void *data, unsigned port, uint16_t joykey) { return 0; }
static bool null_hid_joypad_rumble(void *data, unsigned pad,
enum retro_rumble_effect effect, uint16_t strength) { return false; }
static int16_t null_hid_joypad_axis(
void *data, unsigned port, uint32_t joyaxis) { return 0; }
static void *null_hid_init(void) { return (void*)-1; }
static void null_hid_free(const void *data) { }
static void null_hid_poll(void *data) { }
static int16_t null_hid_joypad_state(
void *data,
rarch_joypad_info_t *joypad_info,
const void *binds_data,
unsigned port) { return 0; }
static hid_driver_t null_hid = {
null_hid_init, /* init */
null_hid_joypad_query, /* joypad_query */
null_hid_free, /* free */
null_hid_joypad_button, /* button */
null_hid_joypad_state, /* state */
null_hid_joypad_get_buttons, /* get_buttons */
null_hid_joypad_axis, /* axis */
null_hid_poll, /* poll */
null_hid_joypad_rumble, /* rumble */
null_hid_joypad_name, /* joypad_name */
"null",
};
#endif
input_device_driver_t *joypad_drivers[] = {
#ifdef HAVE_XINPUT
&xinput_joypad,
#endif
#ifdef GEKKO
&gx_joypad,
#endif
#ifdef WIIU
&wiiu_joypad,
#endif
#ifdef _XBOX1
&xdk_joypad,
#endif
#if defined(ORBIS)
&ps4_joypad,
#endif
#if defined(__PSL1GHT__) || defined(__PS3__)
&ps3_joypad,
#endif
#if defined(PSP) || defined(VITA)
&psp_joypad,
#endif
#if defined(PS2)
&ps2_joypad,
#endif
#ifdef _3DS
&ctr_joypad,
#endif
#ifdef SWITCH
&switch_joypad,
#endif
#ifdef HAVE_DINPUT
&dinput_joypad,
#endif
#ifdef HAVE_UDEV
&udev_joypad,
#endif
#if defined(__linux) && !defined(ANDROID)
&linuxraw_joypad,
#endif
#ifdef HAVE_PARPORT
&parport_joypad,
#endif
#ifdef ANDROID
&android_joypad,
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
&sdl_joypad,
#endif
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
&sdl_dingux_joypad,
#endif
#ifdef __QNX__
&qnx_joypad,
#endif
#ifdef HAVE_MFI
&mfi_joypad,
#endif
#ifdef DJGPP
&dos_joypad,
#endif
/* Selecting the HID gamepad driver disables the Wii U gamepad. So while
* we want the HID code to be compiled & linked, we don't want the driver
* to be selectable in the UI. */
#if defined(HAVE_HID) && !defined(WIIU)
&hid_joypad,
#endif
#ifdef EMSCRIPTEN
&rwebpad_joypad,
#endif
&null_joypad,
NULL,
};
input_driver_t *input_drivers[] = {
#ifdef ORBIS
&input_ps4,
#endif
#if defined(__PSL1GHT__) || defined(__PS3__)
&input_ps3,
#endif
#if defined(SN_TARGET_PSP2) || defined(PSP) || defined(VITA)
&input_psp,
#endif
#if defined(PS2)
&input_ps2,
#endif
#if defined(_3DS)
&input_ctr,
#endif
#if defined(SWITCH)
&input_switch,
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
&input_sdl,
#endif
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
&input_sdl_dingux,
#endif
#ifdef HAVE_DINPUT
&input_dinput,
#endif
#ifdef HAVE_X11
&input_x,
#endif
#ifdef __WINRT__
&input_uwp,
#endif
#ifdef XENON
&input_xenon360,
#endif
#if defined(HAVE_XINPUT2) || defined(HAVE_XINPUT_XBOX1) || defined(__WINRT__)
&input_xinput,
#endif
#ifdef GEKKO
&input_gx,
#endif
#ifdef WIIU
&input_wiiu,
#endif
#ifdef ANDROID
&input_android,
#endif
#ifdef HAVE_UDEV
&input_udev,
#endif
#if defined(__linux__) && !defined(ANDROID)
&input_linuxraw,
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA_METAL)
&input_cocoa,
#endif
#ifdef __QNX__
&input_qnx,
#endif
#ifdef EMSCRIPTEN
&input_rwebinput,
#endif
#ifdef DJGPP
&input_dos,
#endif
#if defined(_WIN32) && !defined(_XBOX) && _WIN32_WINNT >= 0x0501 && !defined(__WINRT__)
#ifdef HAVE_WINRAWINPUT
/* winraw only available since XP */
&input_winraw,
#endif
#endif
&input_null,
NULL,
};
#ifdef HAVE_HID
hid_driver_t *hid_drivers[] = {
#if defined(HAVE_BTSTACK)
&btstack_hid,
#endif
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
&iohidmanager_hid,
#endif
#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS)
&libusb_hid,
#endif
#ifdef HW_RVL
&wiiusb_hid,
#endif
&null_hid,
NULL,
};
#endif
/**************************************/
/* private function prototypes */
static const input_device_driver_t *input_joypad_init_first(void *data);
/**************************************/
bool input_driver_set_rumble(
input_driver_state_t *driver_state, unsigned port, unsigned joy_idx,
enum retro_rumble_effect effect, uint16_t strength)
{
const input_device_driver_t *primary_joypad;
const input_device_driver_t *sec_joypad;
bool rumble_state = false;
if (!driver_state || (joy_idx >= MAX_USERS))
return false;
primary_joypad = driver_state->primary_joypad;
sec_joypad = driver_state->secondary_joypad;
if (primary_joypad && primary_joypad->set_rumble)
rumble_state = primary_joypad->set_rumble(joy_idx, effect, strength);
/* if sec_joypad exists, this set_rumble() return value will replace primary_joypad's return */
if (sec_joypad && sec_joypad->set_rumble)
rumble_state = sec_joypad->set_rumble(joy_idx, effect, strength);
return rumble_state;
}
/**************************************/
bool input_driver_set_sensor(
input_driver_state_t *driver_state, unsigned port, bool sensors_enable,
enum retro_sensor_action action, unsigned rate)
{
const input_driver_t *current_driver;
void *current_data;
if (!driver_state || !driver_state->current_data)
return false;
current_driver = driver_state->current_driver;
current_data = driver_state->current_data;
/* If sensors are disabled, inhibit any enable
* actions (but always allow disable actions) */
if (!sensors_enable &&
((action == RETRO_SENSOR_ACCELEROMETER_ENABLE) ||
(action == RETRO_SENSOR_GYROSCOPE_ENABLE) ||
(action == RETRO_SENSOR_ILLUMINANCE_ENABLE)))
return false;
if (current_driver && current_driver->set_sensor_state)
return current_driver->set_sensor_state(current_data,
port, action, rate);
return false;
}
/**************************************/
float input_driver_get_sensor(
input_driver_state_t *driver_state,
unsigned port, bool sensors_enable, unsigned id)
{
const input_driver_t *current_driver;
void *current_data;
if (!driver_state || !driver_state->current_data)
return 0.0f;
current_driver = driver_state->current_driver;
current_data = driver_state->current_data;
if (sensors_enable && current_driver->get_sensor_input)
return current_driver->get_sensor_input(current_data, port, id);
return 0.0f;
}
/**************************************/
bool input_driver_get_nonblocking(input_driver_state_t *driver_state)
{
if (!driver_state)
return false;
return driver_state->nonblocking_flag;
}
void input_driver_set_nonblocking(input_driver_state_t *driver_state,
bool new_value)
{
if (!driver_state)
return;
driver_state->nonblocking_flag = new_value;
}
/**************************************/
const input_device_driver_t *input_joypad_init_driver(
const char *ident, void *data)
{
unsigned i;
if (ident && *ident)
{
for (i = 0; joypad_drivers[i]; i++)
{
if (string_is_equal(ident, joypad_drivers[i]->ident)
&& 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 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;
}

View file

@ -22,6 +22,8 @@
#include <stddef.h>
#include <sys/types.h>
#include "input_types.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
@ -33,13 +35,11 @@
#include <retro_miscellaneous.h>
#include "input_defines.h"
#include "input_types.h"
#include "../msg_hash.h"
#include "include/hid_types.h"
#include "include/hid_driver.h"
#include "include/gamepad.h"
#include "configuration.h"
RETRO_BEGIN_DECLS
@ -279,21 +279,6 @@ struct rarch_joypad_driver
const char *ident;
};
typedef struct
{
/* pointers */
input_driver_t *current_driver;
void *current_data;
const input_device_driver_t *primary_joypad; /* ptr alignment */
const input_device_driver_t *secondary_joypad; /* ptr alignment */
/* primitives */
bool nonblocking_flag;
} input_driver_state_t;
void input_driver_init_joypads(void);
/**
* Get an enumerated list of all input driver names
*
@ -302,54 +287,73 @@ void input_driver_init_joypads(void);
const char* config_get_input_driver_options(void);
/**
* Sets the rumble state.
* Sets the rumble state. Used by RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE.
*
* @param driver_state
* @param port User number.
* @param joy_idx
* @param effect Rumble effect.
* @param strength Strength of rumble effect.
* @param port User number.
* @param effect Rumble effect.
* @param strength Strength of rumble effect.
*
* @return true if the rumble state has been successfully set
**/
bool input_driver_set_rumble(
input_driver_state_t *driver_state, unsigned port, unsigned joy_idx,
enum retro_rumble_effect effect, uint16_t strength);
bool input_driver_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
/**
* Sets the sensor state.
* Sets the sensor state. Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
*
* @param driver_state
* @param port
* @param sensors_enable
* @param effect Sensor action
* @param rate Sensor rate update
* @param effect Sensor action
* @param rate Sensor rate update
*
* @return true if the sensor state has been successfully set
**/
bool input_driver_set_sensor(
input_driver_state_t *driver_state, unsigned port, bool sensors_enable,
enum retro_sensor_action action, unsigned rate);
bool input_sensor_set_state(unsigned port,
enum retro_sensor_action action, unsigned rate);
/**
* Retrieves the sensor state associated with the provided port and ID.
*
* @param driver_state
* @param port
* @param sensors_enable
* @param id Sensor ID
* @param id Sensor ID
*
* @return The current state associated with the port and ID as a float
**/
float input_driver_get_sensor(
input_driver_state_t *driver_state,
unsigned port, bool sensors_enable, unsigned id);
float input_sensor_get_input(unsigned port, unsigned id);
/**
* Retrieves the input driver state struct
*
* @return The input state struct
**/
void *input_driver_get_data(void);
bool input_driver_get_nonblocking(input_driver_state_t *driver_state);
/**
* Sets the input_driver_nonblock_state flag to true
**/
void input_driver_set_nonblock_state(void);
void input_driver_set_nonblocking(input_driver_state_t *driver_state,
bool new_value);
/**
* Sets the input_driver_nonblock_state flag to false
**/
void input_driver_unset_nonblock_state(void);
/**
* If the action is INPUT_ACTION_AXIS_THRESHOLD, return the current
* input_driver_axis_threshold.
*
* @return value of input_driver_axis_threshold or NULL for actions other than
* INPUT_ACTION_AXIS_THRESHOLD
**/
float *input_driver_get_float(enum input_action action);
/**
* If the action is INPUT_ACTION_MAX_USERS, return the current
* input_driver_max_users.
*
* @return value of input_driver_axis_threshold or NULL for actions other than
* INPUT_ACTION_AXIS_THRESHOLD
**/
unsigned *input_driver_get_uint(enum input_action action);
/**
* Get an enumerated list of all joypad driver names
@ -363,8 +367,6 @@ const char* config_get_joypad_driver_options(void);
* zero-length string, equivalent to calling input_joypad_init_first().
*
* @param ident identifier of driver to initialize.
* @param data joypad state data pointer, which can be NULL and will be
* initialized by the new joypad driver, if one is found.
*
* @return The joypad driver if found, otherwise NULL.
**/
@ -726,11 +728,28 @@ void input_config_reset(void);
#define DEFAULT_MAX_PADS 16
#endif /* defined(ANDROID) */
extern input_device_driver_t *joypad_drivers[];
extern input_driver_t *input_drivers[];
#ifdef HAVE_HID
extern hid_driver_t *hid_drivers[];
#endif
extern input_device_driver_t dinput_joypad;
extern input_device_driver_t linuxraw_joypad;
extern input_device_driver_t parport_joypad;
extern input_device_driver_t udev_joypad;
extern input_device_driver_t xinput_joypad;
extern input_device_driver_t sdl_joypad;
extern input_device_driver_t sdl_dingux_joypad;
extern input_device_driver_t ps4_joypad;
extern input_device_driver_t ps3_joypad;
extern input_device_driver_t psp_joypad;
extern input_device_driver_t ps2_joypad;
extern input_device_driver_t ctr_joypad;
extern input_device_driver_t switch_joypad;
extern input_device_driver_t xdk_joypad;
extern input_device_driver_t gx_joypad;
extern input_device_driver_t wiiu_joypad;
extern input_device_driver_t hid_joypad;
extern input_device_driver_t android_joypad;
extern input_device_driver_t qnx_joypad;
extern input_device_driver_t mfi_joypad;
extern input_device_driver_t dos_joypad;
extern input_device_driver_t rwebpad_joypad;
extern input_driver_t input_android;
extern input_driver_t input_sdl;
@ -757,29 +776,6 @@ extern input_driver_t input_dos;
extern input_driver_t input_winraw;
extern input_driver_t input_wayland;
extern input_device_driver_t dinput_joypad;
extern input_device_driver_t linuxraw_joypad;
extern input_device_driver_t parport_joypad;
extern input_device_driver_t udev_joypad;
extern input_device_driver_t xinput_joypad;
extern input_device_driver_t sdl_joypad;
extern input_device_driver_t sdl_dingux_joypad;
extern input_device_driver_t ps4_joypad;
extern input_device_driver_t ps3_joypad;
extern input_device_driver_t psp_joypad;
extern input_device_driver_t ps2_joypad;
extern input_device_driver_t ctr_joypad;
extern input_device_driver_t switch_joypad;
extern input_device_driver_t xdk_joypad;
extern input_device_driver_t gx_joypad;
extern input_device_driver_t wiiu_joypad;
extern input_device_driver_t hid_joypad;
extern input_device_driver_t android_joypad;
extern input_device_driver_t qnx_joypad;
extern input_device_driver_t mfi_joypad;
extern input_device_driver_t dos_joypad;
extern input_device_driver_t rwebpad_joypad;
#ifdef HAVE_HID
extern hid_driver_t iohidmanager_hid;
extern hid_driver_t btstack_hid;

View file

@ -6152,7 +6152,7 @@ unsigned menu_displaylist_build_list(
case DISPLAYLIST_OPTIONS_REMAPPINGS:
{
unsigned p;
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
#ifdef HAVE_CONFIGFILE
if (menu_entries_append_enum(list,
@ -6488,7 +6488,7 @@ unsigned menu_displaylist_build_list(
{
unsigned user;
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
for (user = 0; user < max_users; user++)
{
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
@ -7245,7 +7245,7 @@ unsigned menu_displaylist_build_list(
{
unsigned user;
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
for (user = 0; user < max_users; user++)
{
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
@ -9740,7 +9740,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
break;
case DISPLAYLIST_OPTIONS_REMAPPINGS_PORT:
{
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
const char *menu_driver = menu_driver_ident();
bool is_rgui = string_is_equal(menu_driver, "rgui");
file_list_t *list = info->list;

View file

@ -7986,11 +7986,11 @@ static void general_write_handler(rarch_setting_t *setting)
{
/* Event rate does not matter when disabling
* sensors - set to zero */
input_set_sensor_state(i,
input_sensor_set_state(i,
RETRO_SENSOR_ACCELEROMETER_DISABLE, 0);
input_set_sensor_state(i,
input_sensor_set_state(i,
RETRO_SENSOR_GYROSCOPE_DISABLE, 0);
input_set_sensor_state(i,
input_sensor_set_state(i,
RETRO_SENSOR_ILLUMINANCE_DISABLE, 0);
}
}
@ -12579,7 +12579,7 @@ static bool setting_append_list(
CONFIG_UINT(
list, list_info,
&settings->uints.input_max_users,
input_driver_get_uint(INPUT_ACTION_MAX_USERS),
MENU_ENUM_LABEL_INPUT_MAX_USERS,
MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS,
input_max_users,
@ -13005,7 +13005,7 @@ static bool setting_append_list(
CONFIG_FLOAT(
list, list_info,
&settings->floats.input_axis_threshold,
input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD),
MENU_ENUM_LABEL_INPUT_BUTTON_AXIS_THRESHOLD,
MENU_ENUM_LABEL_VALUE_INPUT_BUTTON_AXIS_THRESHOLD,
DEFAULT_AXIS_THRESHOLD,
@ -18973,7 +18973,7 @@ static bool setting_append_list(
/* TODO/FIXME - add enum_idx */
{
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
for (user = 0; user < max_users; user++)
{
char s1[64], s2[64];

View file

@ -1452,7 +1452,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
if (netplay->catch_up)
{
netplay->catch_up = false;
input_unset_nonblock_state();
input_driver_unset_nonblock_state();
driver_set_nonblock_state();
}
return;
@ -1645,7 +1645,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_driver_unset_nonblock_state();
driver_set_nonblock_state();
}
@ -1674,7 +1674,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
/* We're definitely falling behind! */
netplay->catch_up = true;
netplay->catch_up_time = 0;
input_set_nonblock_state();
input_driver_set_nonblock_state();
driver_set_nonblock_state();
}
else

File diff suppressed because it is too large Load diff

View file

@ -44,9 +44,6 @@
#include "core_type.h"
#include "core.h"
#include "input/input_driver.h"
#include "input/input_types.h"
#ifdef HAVE_MENU
#include "menu/menu_defines.h"
#endif
@ -790,6 +787,9 @@ void recording_driver_update_streaming_url(void);
#include "gfx/video_defines.h"
#include "gfx/video_coord_array.h"
#include "input/input_driver.h"
#include "input/input_types.h"
#define RARCH_SCALE_BASE 256
#define VIDEO_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1)
@ -2011,31 +2011,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);
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);
/******************************************************************************
* END helper functions for input_driver refactoring
******************************************************************************/
bool input_key_pressed(int key, bool keyboard_pressed);
bool input_mouse_grabbed(void);
@ -2043,6 +2018,8 @@ 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_joypads(void);
void *input_driver_init_wrap(input_driver_t *input, const char *name);
/* Human readable order of input binds */

View file

@ -802,6 +802,256 @@ static const gfx_ctx_driver_t *gfx_ctx_gl_drivers[] = {
NULL
};
static void *input_null_init(const char *joypad_driver) { return (void*)-1; }
static void input_null_poll(void *data) { }
static int16_t input_null_input_state(
void *data,
const input_device_driver_t *joypad,
const input_device_driver_t *sec_joypad,
rarch_joypad_info_t *joypad_info,
const struct retro_keybind **retro_keybinds,
bool keyboard_mapping_blocked,
unsigned port, unsigned device, unsigned index, unsigned id) { return 0; }
static void input_null_free(void *data) { }
static bool input_null_set_sensor_state(void *data, unsigned port,
enum retro_sensor_action action, unsigned rate) { return false; }
static float input_null_get_sensor_input(void *data, unsigned port, unsigned id) { return 0.0; }
static uint64_t input_null_get_capabilities(void *data) { return 0; }
static void input_null_grab_mouse(void *data, bool state) { }
static bool input_null_grab_stdin(void *data) { return false; }
static input_driver_t input_null = {
input_null_init,
input_null_poll,
input_null_input_state,
input_null_free,
input_null_set_sensor_state,
input_null_get_sensor_input,
input_null_get_capabilities,
"null",
input_null_grab_mouse,
input_null_grab_stdin
};
static input_driver_t *input_drivers[] = {
#ifdef ORBIS
&input_ps4,
#endif
#if defined(__PSL1GHT__) || defined(__PS3__)
&input_ps3,
#endif
#if defined(SN_TARGET_PSP2) || defined(PSP) || defined(VITA)
&input_psp,
#endif
#if defined(PS2)
&input_ps2,
#endif
#if defined(_3DS)
&input_ctr,
#endif
#if defined(SWITCH)
&input_switch,
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
&input_sdl,
#endif
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
&input_sdl_dingux,
#endif
#ifdef HAVE_DINPUT
&input_dinput,
#endif
#ifdef HAVE_X11
&input_x,
#endif
#ifdef __WINRT__
&input_uwp,
#endif
#ifdef XENON
&input_xenon360,
#endif
#if defined(HAVE_XINPUT2) || defined(HAVE_XINPUT_XBOX1) || defined(__WINRT__)
&input_xinput,
#endif
#ifdef GEKKO
&input_gx,
#endif
#ifdef WIIU
&input_wiiu,
#endif
#ifdef ANDROID
&input_android,
#endif
#ifdef HAVE_UDEV
&input_udev,
#endif
#if defined(__linux__) && !defined(ANDROID)
&input_linuxraw,
#endif
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA_METAL)
&input_cocoa,
#endif
#ifdef __QNX__
&input_qnx,
#endif
#ifdef EMSCRIPTEN
&input_rwebinput,
#endif
#ifdef DJGPP
&input_dos,
#endif
#if defined(_WIN32) && !defined(_XBOX) && _WIN32_WINNT >= 0x0501 && !defined(__WINRT__)
#ifdef HAVE_WINRAWINPUT
/* winraw only available since XP */
&input_winraw,
#endif
#endif
&input_null,
NULL,
};
static input_device_driver_t null_joypad = {
NULL, /* init */
NULL, /* query_pad */
NULL, /* destroy */
NULL, /* button */
NULL, /* state */
NULL, /* get_buttons */
NULL, /* axis */
NULL, /* poll */
NULL,
NULL, /* name */
"null",
};
static input_device_driver_t *joypad_drivers[] = {
#ifdef HAVE_XINPUT
&xinput_joypad,
#endif
#ifdef GEKKO
&gx_joypad,
#endif
#ifdef WIIU
&wiiu_joypad,
#endif
#ifdef _XBOX1
&xdk_joypad,
#endif
#if defined(ORBIS)
&ps4_joypad,
#endif
#if defined(__PSL1GHT__) || defined(__PS3__)
&ps3_joypad,
#endif
#if defined(PSP) || defined(VITA)
&psp_joypad,
#endif
#if defined(PS2)
&ps2_joypad,
#endif
#ifdef _3DS
&ctr_joypad,
#endif
#ifdef SWITCH
&switch_joypad,
#endif
#ifdef HAVE_DINPUT
&dinput_joypad,
#endif
#ifdef HAVE_UDEV
&udev_joypad,
#endif
#if defined(__linux) && !defined(ANDROID)
&linuxraw_joypad,
#endif
#ifdef HAVE_PARPORT
&parport_joypad,
#endif
#ifdef ANDROID
&android_joypad,
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
&sdl_joypad,
#endif
#if defined(DINGUX) && defined(HAVE_SDL_DINGUX)
&sdl_dingux_joypad,
#endif
#ifdef __QNX__
&qnx_joypad,
#endif
#ifdef HAVE_MFI
&mfi_joypad,
#endif
#ifdef DJGPP
&dos_joypad,
#endif
/* Selecting the HID gamepad driver disables the Wii U gamepad. So while
* we want the HID code to be compiled & linked, we don't want the driver
* to be selectable in the UI. */
#if defined(HAVE_HID) && !defined(WIIU)
&hid_joypad,
#endif
#ifdef EMSCRIPTEN
&rwebpad_joypad,
#endif
&null_joypad,
NULL,
};
#ifdef HAVE_HID
static bool null_hid_joypad_query(void *data, unsigned pad) {
return pad < MAX_USERS; }
static const char *null_hid_joypad_name(
void *data, unsigned pad) { return NULL; }
static void null_hid_joypad_get_buttons(void *data,
unsigned port, input_bits_t *state) { BIT256_CLEAR_ALL_PTR(state); }
static int16_t null_hid_joypad_button(
void *data, unsigned port, uint16_t joykey) { return 0; }
static bool null_hid_joypad_rumble(void *data, unsigned pad,
enum retro_rumble_effect effect, uint16_t strength) { return false; }
static int16_t null_hid_joypad_axis(
void *data, unsigned port, uint32_t joyaxis) { return 0; }
static void *null_hid_init(void) { return (void*)-1; }
static void null_hid_free(const void *data) { }
static void null_hid_poll(void *data) { }
static int16_t null_hid_joypad_state(
void *data,
rarch_joypad_info_t *joypad_info,
const void *binds_data,
unsigned port) { return 0; }
static hid_driver_t null_hid = {
null_hid_init, /* init */
null_hid_joypad_query, /* joypad_query */
null_hid_free, /* free */
null_hid_joypad_button, /* button */
null_hid_joypad_state, /* state */
null_hid_joypad_get_buttons, /* get_buttons */
null_hid_joypad_axis, /* axis */
null_hid_poll, /* poll */
null_hid_joypad_rumble, /* rumble */
null_hid_joypad_name, /* joypad_name */
"null",
};
static hid_driver_t *hid_drivers[] = {
#if defined(HAVE_BTSTACK)
&btstack_hid,
#endif
#if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER)
&iohidmanager_hid,
#endif
#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS)
&libusb_hid,
#endif
#ifdef HW_RVL
&wiiusb_hid,
#endif
&null_hid,
NULL,
};
#endif
static bluetooth_driver_t bluetooth_null = {
NULL, /* init */
NULL, /* free */
@ -1487,8 +1737,6 @@ typedef struct runloop runloop_state_t;
struct rarch_state
{
input_driver_state_t input_driver_state;
double audio_source_ratio_original;
double audio_source_ratio_current;
struct retro_system_av_info video_driver_av_info; /* double alignment */
@ -1647,6 +1895,8 @@ struct rarch_state
#ifdef HAVE_NETWORKGAMEPAD
input_remote_t *input_driver_remote;
#endif
input_driver_t *current_input;
void *current_input_data;
#ifdef HAVE_HID
const void *hid_data;
@ -1689,6 +1939,10 @@ struct rarch_state
midi_event_t midi_drv_output_event; /* ptr alignment */
core_info_state_t core_info_st; /* ptr alignment */
struct retro_hw_render_callback hw_render; /* ptr alignment */
const input_device_driver_t *joypad; /* ptr alignment */
#ifdef HAVE_MFI
const input_device_driver_t *sec_joypad; /* ptr alignment */
#endif
#ifdef HAVE_BSV_MOVIE
bsv_movie_t *bsv_movie_state_handle; /* ptr alignment */
#endif
@ -1814,6 +2068,7 @@ struct rarch_state
unsigned osk_last_codepoint;
unsigned osk_last_codepoint_len;
unsigned input_driver_flushing_input;
unsigned input_driver_max_users;
unsigned input_hotkey_block_counter;
#ifdef HAVE_ACCESSIBILITY
unsigned gamepad_input_override;
@ -1839,6 +2094,8 @@ struct rarch_state
float audio_driver_input;
float audio_driver_volume_gain;
float input_driver_axis_threshold;
enum osk_type osk_idx;
enum rarch_core_type current_core_type;
enum rarch_core_type explicit_current_core_type;
@ -2050,6 +2307,7 @@ struct rarch_state
bool input_driver_block_hotkey;
bool input_driver_block_libretro_input;
bool input_driver_nonblock_state;
bool input_driver_grab_mouse_state;
bool input_driver_analog_requested[MAX_USERS];

View file

@ -264,8 +264,7 @@ UserBindsPage::UserBindsPage(QObject *parent) :
QWidget *UserBindsPage::widget()
{
unsigned p, retro_id;
settings_t *settings = config_get_ptr();
unsigned max_users = settings->uints.input_max_users;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
QWidget *widget = new QWidget;
QGridLayout *layout = new QGridLayout;
QComboBox *userCombo = new QComboBox;