From 6b3dbff75fec30e4bc57dd31cd3d9387815d1dd9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Jun 2017 05:56:02 +0200 Subject: [PATCH] Merge input_driver.c and input_joypad_driver.c --- Makefile.common | 1 - gfx/drivers_context/wayland_ctx.c | 2 +- griffin/griffin.c | 1 - input/drivers/android_input.c | 1 - input/drivers/cocoa_input.c | 1 - input/drivers/ctr_input.c | 1 - input/drivers/dinput.c | 1 - input/drivers/dos_input.c | 1 - input/drivers/gx_input.c | 1 - input/drivers/linuxraw_input.c | 1 - input/drivers/ps3_input.c | 1 - input/drivers/psp_input.c | 1 - input/drivers/qnx_input.c | 1 - input/drivers/rwebinput_input.c | 1 - input/drivers/sdl_input.c | 1 - input/drivers/udev_input.c | 1 - input/drivers/wiiu_input.c | 1 - input/drivers/x11_input.c | 2 +- input/drivers/xdk_xinput_input.c | 1 - input/drivers/xenon360_input.c | 1 - input/drivers_joypad/ctr_joypad.c | 1 - input/drivers_joypad/dinput_joypad.c | 2 +- input/drivers_joypad/dos_joypad.c | 1 - input/drivers_joypad/null_joypad.c | 3 +- input/drivers_joypad/wiiu_joypad.c | 1 - input/drivers_keyboard/keyboard_event_xkb.c | 2 +- input/input_driver.c | 403 ++++++++++++++++++ input/input_driver.h | 218 +++++++++- input/input_joypad_driver.c | 433 -------------------- input/input_joypad_driver.h | 213 ---------- list_special.c | 1 - 31 files changed, 626 insertions(+), 674 deletions(-) delete mode 100644 input/input_joypad_driver.c diff --git a/Makefile.common b/Makefile.common index 259a88dde2..2924f0898f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -206,7 +206,6 @@ OBJ += frontend/frontend.o \ gfx/drivers_font_renderer/bitmapfont.o \ tasks/task_autodetect.o \ input/input_autodetect_builtin.o \ - input/input_joypad_driver.o \ input/input_config.o \ input/input_keymaps.o \ input/input_remapping.o \ diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 292cd405fd..3782b7c029 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -45,7 +45,7 @@ #include "../../frontend/frontend_driver.h" #include "../../input/input_keyboard.h" #include "../../input/input_keymaps.h" -#include "../../input/input_joypad_driver.h" +#include "../../input/input_driver.h" #include typedef struct gfx_ctx_wayland_data diff --git a/griffin/griffin.c b/griffin/griffin.c index 2f711d66ab..6e65802b7a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -416,7 +416,6 @@ INPUT ============================================================ */ #include "../tasks/task_autodetect.c" #include "../tasks/task_audio_mixer.c" -#include "../input/input_joypad_driver.c" #include "../input/input_config.c" #include "../input/input_keymaps.c" #include "../input/input_remapping.c" diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 7b7378b443..e61b3905f3 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -38,7 +38,6 @@ #include "../../frontend/drivers/platform_linux.h" #include "../../gfx/video_driver.h" -#include "../input_joypad_driver.h" #include "../drivers_keyboard/keyboard_event_android.h" #include "../../tasks/tasks_internal.h" #include "../../performance_counters.h" diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 2ae8609949..7e0dc9e742 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -24,7 +24,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../input_keymaps.h" #include "cocoa_input.h" #include "../../gfx/video_driver.h" diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index b66c2d6702..002212ec96 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -27,7 +27,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #define MAX_PADS 1 diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 909a8b96a8..b6c6d0387b 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -46,7 +46,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../input_keymaps.h" #include "../../gfx/video_driver.h" diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index b73f0f73ab..e985d5f5b5 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -19,7 +19,6 @@ #include "../input_driver.h" #include "../input_keymaps.h" -#include "../input_joypad_driver.h" #include "../drivers_keyboard/keyboard_event_dos.h" typedef struct dos_input diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index 984b32b4a7..4544709057 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -26,7 +26,6 @@ #include #include "../input_driver.h" -#include "../input_joypad_driver.h" #ifndef MAX_PADS #define MAX_PADS 4 diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 8fd73715ab..24778f0576 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -31,7 +31,6 @@ #include "../input_keymaps.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" typedef struct linuxraw_input { diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 78f5862439..b5e2037027 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -29,7 +29,6 @@ #include "../../defines/ps3_defines.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #ifdef HAVE_MOUSE #ifndef __PSL1GHT__ diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index 87470fc66d..d396072c13 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -43,7 +43,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" typedef struct psp_input { diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index ec1c97f727..5ae1e2740d 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -28,7 +28,6 @@ #endif #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../../gfx/video_driver.h" #include "../../tasks/tasks_internal.h" diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 527a65695c..d8b0c72cd5 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -24,7 +24,6 @@ #include "../input_keyboard.h" #include "../input_keymaps.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../../tasks/tasks_internal.h" #include "../../configuration.h" diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 0f1adce46f..c78f9debf1 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -26,7 +26,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../input_keymaps.h" #include "../input_keyboard.h" diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 843047dc8d..3e9a2dccf4 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -47,7 +47,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../input_keymaps.h" #include "../input_keyboard.h" diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 2425640b83..75554839a4 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -27,7 +27,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../input_keyboard.h" #include "../input_keymaps.h" #include diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index cc3441e294..c84c3ce2af 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -25,7 +25,7 @@ #include #include "../input_config.h" -#include "../input_joypad_driver.h" +#include "../input_driver.h" #include "../input_keymaps.h" #include "../../gfx/video_driver.h" diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index 3213003858..57293d87e7 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -29,7 +29,6 @@ #include #include "../input_driver.h" -#include "../input_joypad_driver.h" #define MAX_PADS 4 diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index 99fe132f46..e1d1142bb9 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -24,7 +24,6 @@ #include #include "../input_driver.h" -#include "../input_joypad_driver.h" #define MAX_PADS 4 diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index 9de073c9f4..9ec4bfc637 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -18,7 +18,6 @@ #include "../../config.h" #endif -#include "../input_joypad_driver.h" #include "../input_driver.h" #include "../input_config.h" diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 0523921246..681f8d2f19 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -32,7 +32,7 @@ #include "../../tasks/tasks_internal.h" #include "../gfx/video_driver.h" #include "../input_config.h" -#include "../input_joypad_driver.h" +#include "../input_driver.h" #include "../input_keymaps.h" #include "../../verbosity.h" diff --git a/input/drivers_joypad/dos_joypad.c b/input/drivers_joypad/dos_joypad.c index 686db8238e..755c51874c 100644 --- a/input/drivers_joypad/dos_joypad.c +++ b/input/drivers_joypad/dos_joypad.c @@ -26,7 +26,6 @@ #include -#include "../input_joypad_driver.h" #include "../input_driver.h" #include "../input_config.h" #include "../input_keyboard.h" diff --git a/input/drivers_joypad/null_joypad.c b/input/drivers_joypad/null_joypad.c index d67a80b543..c3377a45d6 100644 --- a/input/drivers_joypad/null_joypad.c +++ b/input/drivers_joypad/null_joypad.c @@ -18,7 +18,8 @@ #include #include #include -#include "../input_joypad_driver.h" + +#include "../input_driver.h" static const char *null_joypad_name(unsigned pad) { diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index b9eaae3416..34483832c2 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -25,7 +25,6 @@ #include "../input_config.h" #include "../input_driver.h" -#include "../input_joypad_driver.h" #include "../../tasks/tasks_internal.h" #include "../../retroarch.h" diff --git a/input/drivers_keyboard/keyboard_event_xkb.c b/input/drivers_keyboard/keyboard_event_xkb.c index 746c87c687..707aacfc9e 100644 --- a/input/drivers_keyboard/keyboard_event_xkb.c +++ b/input/drivers_keyboard/keyboard_event_xkb.c @@ -23,7 +23,7 @@ #include -#include "../input_joypad_driver.h" +#include "../input_driver.h" #include "../input_keymaps.h" #include "../input_keyboard.h" #include "../../configuration.h" diff --git a/input/input_driver.c b/input/input_driver.c index 3551f25a3e..15d6adcdfa 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -14,7 +14,11 @@ * If not, see . */ +#include #include +#include + +#include #ifdef HAVE_CONFIG_H #include "../config.h" @@ -104,6 +108,62 @@ static const input_driver_t *input_drivers[] = { NULL, }; +static input_device_driver_t *joypad_drivers[] = { +#ifdef __CELLOS_LV2__ + &ps3_joypad, +#endif +#ifdef HAVE_XINPUT + &xinput_joypad, +#endif +#ifdef GEKKO + &gx_joypad, +#endif +#ifdef WIIU + &wiiu_joypad, +#endif +#ifdef _XBOX + &xdk_joypad, +#endif +#if defined(PSP) || defined(VITA) + &psp_joypad, +#endif +#ifdef _3DS + &ctr_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 +#ifdef __QNX__ + &qnx_joypad, +#endif +#ifdef HAVE_MFI + &mfi_joypad, +#endif +#ifdef DJGPP + &dos_joypad, +#endif +#ifdef HAVE_HID + &hid_joypad, +#endif + &null_joypad, + NULL, +}; + typedef struct turbo_buttons turbo_buttons_t; /* Turbo support. */ @@ -1143,3 +1203,346 @@ bool input_driver_is_data_ptr_same(void *data) { return (current_input_data == data); } + +/** + * joypad_driver_find_handle: + * @idx : index of driver to get handle to. + * + * Returns: handle to joypad driver at index. Can be NULL + * if nothing found. + **/ +const void *joypad_driver_find_handle(int idx) +{ + const void *drv = joypad_drivers[idx]; + if (!drv) + return NULL; + return drv; +} + +/** + * joypad_driver_find_ident: + * @idx : index of driver to get handle to. + * + * Returns: Human-readable identifier of joypad driver at index. Can be NULL + * if nothing found. + **/ +const char *joypad_driver_find_ident(int idx) +{ + const input_device_driver_t *drv = joypad_drivers[idx]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_joypad_driver_options: + * + * Get an enumerated list of all joypad driver names, separated by '|'. + * + * Returns: string listing of all joypad driver names, separated by '|'. + **/ +const char* config_get_joypad_driver_options(void) +{ + return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL); +} + +/** + * input_joypad_init_driver: + * @ident : identifier of driver to initialize. + * + * Initialize a joypad driver of name @ident. + * + * If ident points to NULL or a zero-length string, + * equivalent to calling input_joypad_init_first(). + * + * Returns: joypad driver if found, otherwise NULL. + **/ +const input_device_driver_t *input_joypad_init_driver( + const char *ident, void *data) +{ + unsigned i; + if (!ident || !*ident) + return input_joypad_init_first(data); + + for (i = 0; joypad_drivers[i]; i++) + { + if (string_is_equal(ident, joypad_drivers[i]->ident) + && joypad_drivers[i]->init(data)) + { + RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n", + joypad_drivers[i]->ident); + return joypad_drivers[i]; + } + } + + return input_joypad_init_first(data); +} + +/** + * input_joypad_init_first: + * + * Finds first suitable joypad driver and initializes. + * + * Returns: joypad driver if found, otherwise NULL. + **/ +const input_device_driver_t *input_joypad_init_first(void *data) +{ + unsigned i; + + for (i = 0; joypad_drivers[i]; i++) + { + if (joypad_drivers[i]->init(data)) + { + RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n", + joypad_drivers[i]->ident); + return joypad_drivers[i]; + } + } + + return NULL; +} + +/** + * input_joypad_name: + * @drv : Input device driver handle. + * @port : Joystick number. + * + * Gets name of the joystick (@port). + * + * Returns: name of joystick #port. + **/ +const char *input_joypad_name(const input_device_driver_t *drv, + unsigned port) +{ + if (!drv) + return NULL; + return drv->name(port); +} + +/** + * input_joypad_set_rumble: + * @drv : Input device driver handle. + * @port : User number. + * @effect : Rumble effect to set. + * @strength : Strength of rumble effect. + * + * Sets rumble effect @effect with strength @strength. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool input_joypad_set_rumble(const input_device_driver_t *drv, + unsigned port, enum retro_rumble_effect effect, uint16_t strength) +{ + unsigned joy_idx = 0; + + if (!input_config_get_bind_idx(port, &joy_idx)) + return false; + + if (!drv || !drv->set_rumble) + return false; + + return drv->set_rumble(joy_idx, effect, strength); +} + +/** + * input_joypad_is_pressed: + * @drv : Input device driver handle. + * @port : User number. + * @binds : Binds of user. + * @key : Identifier of key. + * + * Checks if key (@key) was being pressed by user + * with number @port with provided keybinds (@binds). + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_joypad_pressed( + const input_device_driver_t *drv, + rarch_joypad_info_t joypad_info, + unsigned port, + const struct retro_keybind *binds, + unsigned key) +{ + /* Auto-binds are per joypad, not per user. */ + uint64_t joykey = (binds[key].joykey != NO_BTN) + ? binds[key].joykey : joypad_info.auto_binds[key].joykey; + + if ((uint16_t)joykey == NO_BTN || !drv->button(joypad_info.joy_idx, (uint16_t)joykey)) + { + uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) + ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; + int16_t axis = drv->axis(joypad_info.joy_idx, joyaxis); + float scaled_axis = (float)abs(axis) / 0x8000; + return scaled_axis > joypad_info.axis_threshold; + } + + return true; +} + +/** + * input_joypad_analog: + * @drv : Input device driver handle. + * @port : User number. + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @binds : Binds of user. + * + * Gets analog value of analog key identifiers @idx and @ident + * from user with number @port with provided keybinds (@binds). + * + * Returns: analog value on success, otherwise 0. + **/ +int16_t input_joypad_analog(const input_device_driver_t *drv, + rarch_joypad_info_t joypad_info, + unsigned port, unsigned idx, unsigned ident, + const void *binds_data) +{ + uint32_t axis_minus, axis_plus; + int16_t pressed_minus, pressed_plus, res; + unsigned ident_minus = 0; + unsigned ident_plus = 0; + const struct retro_keybind *bind_minus = NULL; + const struct retro_keybind *bind_plus = NULL; + const struct retro_keybind *binds = (const struct retro_keybind*) + binds_data; + + input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); + + bind_minus = &binds[ident_minus]; + bind_plus = &binds[ident_plus]; + + if (!bind_minus->valid || !bind_plus->valid) + return 0; + + axis_minus = bind_minus->joyaxis; + axis_plus = bind_plus->joyaxis; + + if (axis_minus == AXIS_NONE) + axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; + if (axis_plus == AXIS_NONE) + axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; + + pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); + pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); + res = pressed_plus - pressed_minus; + + if (res == 0) + { + int16_t digital_left = 0; + int16_t digital_right = 0; + uint64_t key_minus = bind_minus->joykey; + uint64_t key_plus = bind_plus->joykey; + + if (key_minus == NO_BTN) + key_minus = joypad_info.auto_binds[ident_minus].joykey; + if (key_plus == NO_BTN) + key_plus = joypad_info.auto_binds[ident_plus].joykey; + + if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) + digital_left = -0x7fff; + if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) + digital_right = 0x7fff; + return digital_right + digital_left; + } + + return res; +} + +/** + * input_joypad_axis_raw: + * @drv : Input device driver handle. + * @port : Joystick number. + * @axis : Identifier of axis. + * + * Checks if axis (@axis) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if axis was pressed, otherwise + * false (0). + **/ +int16_t input_joypad_axis_raw(const input_device_driver_t *drv, + unsigned port, unsigned axis) +{ + if (!drv) + return 0; + return drv->axis(port, AXIS_POS(axis)) + + drv->axis(port, AXIS_NEG(axis)); +} + +/** + * input_joypad_button_raw: + * @drv : Input device driver handle. + * @port : Joystick number. + * @button : Identifier of key. + * + * Checks if key (@button) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_joypad_button_raw(const input_device_driver_t *drv, + unsigned port, unsigned button) +{ + if (!drv) + return false; + return drv->button(port, button); +} + +bool input_joypad_hat_raw(const input_device_driver_t *drv, + unsigned port, unsigned hat_dir, unsigned hat) +{ + if (!drv) + return false; + return drv->button(port, HAT_MAP(hat, hat_dir)); +} + +/** + * input_conv_analog_id_to_bind_id: + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @ident_minus : Bind ID minus, will be set by function. + * @ident_plus : Bind ID plus, will be set by function. + * + * Takes as input analog key identifiers and converts + * them to corresponding bind IDs @ident_minus and @ident_plus. + **/ +void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, + unsigned *ident_minus, unsigned *ident_plus) +{ + switch ((idx << 1) | ident) + { + case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X: + *ident_minus = RARCH_ANALOG_LEFT_X_MINUS; + *ident_plus = RARCH_ANALOG_LEFT_X_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y: + *ident_minus = RARCH_ANALOG_LEFT_Y_MINUS; + *ident_plus = RARCH_ANALOG_LEFT_Y_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X: + *ident_minus = RARCH_ANALOG_RIGHT_X_MINUS; + *ident_plus = RARCH_ANALOG_RIGHT_X_PLUS; + break; + + case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y: + *ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS; + *ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS; + break; + } +} diff --git a/input/input_driver.h b/input/input_driver.h index 26c3a7af4e..77bcf6f460 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -23,14 +23,17 @@ #include #include +#include -#include "input_joypad_driver.h" #include "input_defines.h" #include "../msg_hash.h" RETRO_BEGIN_DECLS +typedef struct rarch_joypad_driver input_device_driver_t; + + enum input_device_type { INPUT_DEVICE_TYPE_NONE = 0, @@ -85,6 +88,13 @@ struct retro_keybind char joyaxis_label[256]; }; +typedef struct rarch_joypad_info +{ + unsigned joy_idx; + const struct retro_keybind *auto_binds; + float axis_threshold; +} rarch_joypad_info_t; + typedef struct input_driver { /* Inits input driver. @@ -125,6 +135,21 @@ typedef struct input_driver void (*keyboard_mapping_set_block)(void *data, bool value); } input_driver_t; +struct rarch_joypad_driver +{ + bool (*init)(void *data); + bool (*query_pad)(unsigned); + void (*destroy)(void); + bool (*button)(unsigned, uint16_t); + uint64_t (*get_buttons)(unsigned); + int16_t (*axis)(unsigned, uint32_t); + void (*poll)(void); + bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t); + const char *(*name)(unsigned); + + const char *ident; +}; + extern const input_driver_t *current_input; extern void *current_input_data; @@ -337,6 +362,197 @@ unsigned *input_driver_get_uint(enum input_action action); bool input_driver_is_data_ptr_same(void *data); +/** + * joypad_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to joypad driver at index. Can be NULL + * if nothing found. + **/ +const void *joypad_driver_find_handle(int index); + +/** + * joypad_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of joypad driver at index. Can be NULL + * if nothing found. + **/ +const char *joypad_driver_find_ident(int index); + +/** + * config_get_joypad_driver_options: + * + * Get an enumerated list of all joypad driver names, separated by '|'. + * + * Returns: string listing of all joypad driver names, separated by '|'. + **/ +const char* config_get_joypad_driver_options(void); + +/** + * input_joypad_init_driver: + * @ident : identifier of driver to initialize. + * + * Initialize a joypad driver of name @ident. + * + * If ident points to NULL or a zero-length string, + * equivalent to calling input_joypad_init_first(). + * + * Returns: joypad driver if found, otherwise NULL. + **/ +const input_device_driver_t *input_joypad_init_driver(const char *ident, void *data); + +/** + * input_joypad_init_first: + * + * Finds first suitable joypad driver and initializes. + * + * Returns: joypad driver if found, otherwise NULL. + **/ +const input_device_driver_t *input_joypad_init_first(void *data); + +/** + * input_conv_analog_id_to_bind_id: + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @ident_minus : Bind ID minus, will be set by function. + * @ident_plus : Bind ID plus, will be set by function. + * + * Takes as input analog key identifiers and converts + * them to corresponding bind IDs @ident_minus and @ident_plus. + **/ +void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, + unsigned *ident_minus, unsigned *ident_plus); + +/** + * input_joypad_pressed: + * @drv : Input device driver handle. + * @port : User number. + * @binds : Binds of user. + * @key : Identifier of key. + * + * Checks if key (@key) was being pressed by user + * with number @port with provided keybinds (@binds). + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_joypad_pressed(const input_device_driver_t *driver, + rarch_joypad_info_t joypad_info, + unsigned port, + const struct retro_keybind *binds, + unsigned key); + +/** + * input_joypad_analog: + * @drv : Input device driver handle. + * @port : User number. + * @idx : Analog key index. + * E.g.: + * - RETRO_DEVICE_INDEX_ANALOG_LEFT + * - RETRO_DEVICE_INDEX_ANALOG_RIGHT + * @ident : Analog key identifier. + * E.g.: + * - RETRO_DEVICE_ID_ANALOG_X + * - RETRO_DEVICE_ID_ANALOG_Y + * @binds : Binds of user. + * + * Gets analog value of analog key identifiers @idx and @ident + * from user with number @port with provided keybinds (@binds). + * + * Returns: analog value on success, otherwise 0. + **/ +int16_t input_joypad_analog(const input_device_driver_t *driver, + rarch_joypad_info_t joypad_info, + unsigned port, unsigned idx, unsigned ident, + const void *binds); + +/** + * input_joypad_set_rumble: + * @drv : Input device driver handle. + * @port : User number. + * @effect : Rumble effect to set. + * @strength : Strength of rumble effect. + * + * Sets rumble effect @effect with strength @strength. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool input_joypad_set_rumble(const input_device_driver_t *driver, + unsigned port, enum retro_rumble_effect effect, uint16_t strength); + +/** + * input_joypad_axis_raw: + * @drv : Input device driver handle. + * @port : Joystick number. + * @axis : Identifier of axis. + * + * Checks if axis (@axis) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if axis was pressed, otherwise + * false (0). + **/ +int16_t input_joypad_axis_raw(const input_device_driver_t *driver, + unsigned port, unsigned axis); + +/** + * input_joypad_button_raw: + * @drv : Input device driver handle. + * @port : Joystick number. + * @button : Identifier of key. + * + * Checks if key (@button) was being pressed by user + * with joystick number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_joypad_button_raw(const input_device_driver_t *driver, + unsigned port, unsigned button); + +bool input_joypad_hat_raw(const input_device_driver_t *driver, + unsigned joypad, unsigned hat_dir, unsigned hat); + +/** + * input_joypad_name: + * @drv : Input device driver handle. + * @port : Joystick number. + * + * Gets name of the joystick (@port). + * + * Returns: name of joystick #port. + **/ +const char *input_joypad_name(const input_device_driver_t *driver, + unsigned port); + +bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real); + +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 ps3_joypad; +extern input_device_driver_t psp_joypad; +extern input_device_driver_t ctr_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 null_joypad; +extern input_device_driver_t mfi_joypad; +extern input_device_driver_t dos_joypad; + extern input_driver_t input_android; extern input_driver_t input_sdl; extern input_driver_t input_dinput; diff --git a/input/input_joypad_driver.c b/input/input_joypad_driver.c deleted file mode 100644 index 39cf953688..0000000000 --- a/input/input_joypad_driver.c +++ /dev/null @@ -1,433 +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 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 . - */ - -#include -#include -#include - -#include - -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif - -#include "input_joypad_driver.h" - -#include "input_driver.h" -#include "input_keymaps.h" - -#include "../list_special.h" -#include "../verbosity.h" - -static input_device_driver_t *joypad_drivers[] = { -#ifdef __CELLOS_LV2__ - &ps3_joypad, -#endif -#ifdef HAVE_XINPUT - &xinput_joypad, -#endif -#ifdef GEKKO - &gx_joypad, -#endif -#ifdef WIIU - &wiiu_joypad, -#endif -#ifdef _XBOX - &xdk_joypad, -#endif -#if defined(PSP) || defined(VITA) - &psp_joypad, -#endif -#ifdef _3DS - &ctr_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 -#ifdef __QNX__ - &qnx_joypad, -#endif -#ifdef HAVE_MFI - &mfi_joypad, -#endif -#ifdef DJGPP - &dos_joypad, -#endif -#ifdef HAVE_HID - &hid_joypad, -#endif - &null_joypad, - NULL, -}; - -/** - * joypad_driver_find_handle: - * @idx : index of driver to get handle to. - * - * Returns: handle to joypad driver at index. Can be NULL - * if nothing found. - **/ -const void *joypad_driver_find_handle(int idx) -{ - const void *drv = joypad_drivers[idx]; - if (!drv) - return NULL; - return drv; -} - -/** - * joypad_driver_find_ident: - * @idx : index of driver to get handle to. - * - * Returns: Human-readable identifier of joypad driver at index. Can be NULL - * if nothing found. - **/ -const char *joypad_driver_find_ident(int idx) -{ - const input_device_driver_t *drv = joypad_drivers[idx]; - if (!drv) - return NULL; - return drv->ident; -} - -/** - * config_get_joypad_driver_options: - * - * Get an enumerated list of all joypad driver names, separated by '|'. - * - * Returns: string listing of all joypad driver names, separated by '|'. - **/ -const char* config_get_joypad_driver_options(void) -{ - return char_list_new_special(STRING_LIST_INPUT_JOYPAD_DRIVERS, NULL); -} - -/** - * input_joypad_init_driver: - * @ident : identifier of driver to initialize. - * - * Initialize a joypad driver of name @ident. - * - * If ident points to NULL or a zero-length string, - * equivalent to calling input_joypad_init_first(). - * - * Returns: joypad driver if found, otherwise NULL. - **/ -const input_device_driver_t *input_joypad_init_driver( - const char *ident, void *data) -{ - unsigned i; - if (!ident || !*ident) - return input_joypad_init_first(data); - - for (i = 0; joypad_drivers[i]; i++) - { - if (string_is_equal(ident, joypad_drivers[i]->ident) - && joypad_drivers[i]->init(data)) - { - RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n", - joypad_drivers[i]->ident); - return joypad_drivers[i]; - } - } - - return input_joypad_init_first(data); -} - -/** - * input_joypad_init_first: - * - * Finds first suitable joypad driver and initializes. - * - * Returns: joypad driver if found, otherwise NULL. - **/ -const input_device_driver_t *input_joypad_init_first(void *data) -{ - unsigned i; - - for (i = 0; joypad_drivers[i]; i++) - { - if (joypad_drivers[i]->init(data)) - { - RARCH_LOG("[Joypad]: Found joypad driver: \"%s\".\n", - joypad_drivers[i]->ident); - return joypad_drivers[i]; - } - } - - return NULL; -} - -/** - * input_joypad_name: - * @drv : Input device driver handle. - * @port : Joystick number. - * - * Gets name of the joystick (@port). - * - * Returns: name of joystick #port. - **/ -const char *input_joypad_name(const input_device_driver_t *drv, - unsigned port) -{ - if (!drv) - return NULL; - return drv->name(port); -} - -/** - * input_joypad_set_rumble: - * @drv : Input device driver handle. - * @port : User number. - * @effect : Rumble effect to set. - * @strength : Strength of rumble effect. - * - * Sets rumble effect @effect with strength @strength. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool input_joypad_set_rumble(const input_device_driver_t *drv, - unsigned port, enum retro_rumble_effect effect, uint16_t strength) -{ - unsigned joy_idx = 0; - - if (!input_config_get_bind_idx(port, &joy_idx)) - return false; - - if (!drv || !drv->set_rumble) - return false; - - return drv->set_rumble(joy_idx, effect, strength); -} - -/** - * input_joypad_is_pressed: - * @drv : Input device driver handle. - * @port : User number. - * @binds : Binds of user. - * @key : Identifier of key. - * - * Checks if key (@key) was being pressed by user - * with number @port with provided keybinds (@binds). - * - * Returns: true (1) if key was pressed, otherwise - * false (0). - **/ -bool input_joypad_pressed( - const input_device_driver_t *drv, - rarch_joypad_info_t joypad_info, - unsigned port, - const void *binds_data, - unsigned key) -{ - const struct retro_keybind *binds = (const struct retro_keybind*)binds_data; - /* Auto-binds are per joypad, not per user. */ - uint64_t joykey = (binds[key].joykey != NO_BTN) - ? binds[key].joykey : joypad_info.auto_binds[key].joykey; - - if ((uint16_t)joykey == NO_BTN || !drv->button(joypad_info.joy_idx, (uint16_t)joykey)) - { - uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) - ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; - int16_t axis = drv->axis(joypad_info.joy_idx, joyaxis); - float scaled_axis = (float)abs(axis) / 0x8000; - return scaled_axis > joypad_info.axis_threshold; - } - - return true; -} - -/** - * input_joypad_analog: - * @drv : Input device driver handle. - * @port : User number. - * @idx : Analog key index. - * E.g.: - * - RETRO_DEVICE_INDEX_ANALOG_LEFT - * - RETRO_DEVICE_INDEX_ANALOG_RIGHT - * @ident : Analog key identifier. - * E.g.: - * - RETRO_DEVICE_ID_ANALOG_X - * - RETRO_DEVICE_ID_ANALOG_Y - * @binds : Binds of user. - * - * Gets analog value of analog key identifiers @idx and @ident - * from user with number @port with provided keybinds (@binds). - * - * Returns: analog value on success, otherwise 0. - **/ -int16_t input_joypad_analog(const input_device_driver_t *drv, - rarch_joypad_info_t joypad_info, - unsigned port, unsigned idx, unsigned ident, - const void *binds_data) -{ - uint32_t axis_minus, axis_plus; - int16_t pressed_minus, pressed_plus, res; - unsigned ident_minus = 0; - unsigned ident_plus = 0; - const struct retro_keybind *bind_minus = NULL; - const struct retro_keybind *bind_plus = NULL; - const struct retro_keybind *binds = (const struct retro_keybind*) - binds_data; - - input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); - - bind_minus = &binds[ident_minus]; - bind_plus = &binds[ident_plus]; - - if (!bind_minus->valid || !bind_plus->valid) - return 0; - - axis_minus = bind_minus->joyaxis; - axis_plus = bind_plus->joyaxis; - - if (axis_minus == AXIS_NONE) - axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; - if (axis_plus == AXIS_NONE) - axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; - - pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); - pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); - res = pressed_plus - pressed_minus; - - if (res == 0) - { - int16_t digital_left = 0; - int16_t digital_right = 0; - uint64_t key_minus = bind_minus->joykey; - uint64_t key_plus = bind_plus->joykey; - - if (key_minus == NO_BTN) - key_minus = joypad_info.auto_binds[ident_minus].joykey; - if (key_plus == NO_BTN) - key_plus = joypad_info.auto_binds[ident_plus].joykey; - - if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) - digital_left = -0x7fff; - if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) - digital_right = 0x7fff; - return digital_right + digital_left; - } - - return res; -} - -/** - * input_joypad_axis_raw: - * @drv : Input device driver handle. - * @port : Joystick number. - * @axis : Identifier of axis. - * - * Checks if axis (@axis) was being pressed by user - * with joystick number @port. - * - * Returns: true (1) if axis was pressed, otherwise - * false (0). - **/ -int16_t input_joypad_axis_raw(const input_device_driver_t *drv, - unsigned port, unsigned axis) -{ - if (!drv) - return 0; - return drv->axis(port, AXIS_POS(axis)) + - drv->axis(port, AXIS_NEG(axis)); -} - -/** - * input_joypad_button_raw: - * @drv : Input device driver handle. - * @port : Joystick number. - * @button : Identifier of key. - * - * Checks if key (@button) was being pressed by user - * with joystick number @port. - * - * Returns: true (1) if key was pressed, otherwise - * false (0). - **/ -bool input_joypad_button_raw(const input_device_driver_t *drv, - unsigned port, unsigned button) -{ - if (!drv) - return false; - return drv->button(port, button); -} - -bool input_joypad_hat_raw(const input_device_driver_t *drv, - unsigned port, unsigned hat_dir, unsigned hat) -{ - if (!drv) - return false; - return drv->button(port, HAT_MAP(hat, hat_dir)); -} - -/** - * input_conv_analog_id_to_bind_id: - * @idx : Analog key index. - * E.g.: - * - RETRO_DEVICE_INDEX_ANALOG_LEFT - * - RETRO_DEVICE_INDEX_ANALOG_RIGHT - * @ident : Analog key identifier. - * E.g.: - * - RETRO_DEVICE_ID_ANALOG_X - * - RETRO_DEVICE_ID_ANALOG_Y - * @ident_minus : Bind ID minus, will be set by function. - * @ident_plus : Bind ID plus, will be set by function. - * - * Takes as input analog key identifiers and converts - * them to corresponding bind IDs @ident_minus and @ident_plus. - **/ -void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, - unsigned *ident_minus, unsigned *ident_plus) -{ - switch ((idx << 1) | ident) - { - case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_X: - *ident_minus = RARCH_ANALOG_LEFT_X_MINUS; - *ident_plus = RARCH_ANALOG_LEFT_X_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_LEFT << 1) | RETRO_DEVICE_ID_ANALOG_Y: - *ident_minus = RARCH_ANALOG_LEFT_Y_MINUS; - *ident_plus = RARCH_ANALOG_LEFT_Y_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_X: - *ident_minus = RARCH_ANALOG_RIGHT_X_MINUS; - *ident_plus = RARCH_ANALOG_RIGHT_X_PLUS; - break; - - case (RETRO_DEVICE_INDEX_ANALOG_RIGHT << 1) | RETRO_DEVICE_ID_ANALOG_Y: - *ident_minus = RARCH_ANALOG_RIGHT_Y_MINUS; - *ident_plus = RARCH_ANALOG_RIGHT_Y_PLUS; - break; - } -} diff --git a/input/input_joypad_driver.h b/input/input_joypad_driver.h index d9f8382f1a..c6491f511f 100644 --- a/input/input_joypad_driver.h +++ b/input/input_joypad_driver.h @@ -25,219 +25,6 @@ RETRO_BEGIN_DECLS -typedef struct rarch_joypad_driver input_device_driver_t; - -typedef struct rarch_joypad_info -{ - unsigned joy_idx; - const struct retro_keybind *auto_binds; - float axis_threshold; -} rarch_joypad_info_t; - -struct rarch_joypad_driver -{ - bool (*init)(void *data); - bool (*query_pad)(unsigned); - void (*destroy)(void); - bool (*button)(unsigned, uint16_t); - uint64_t (*get_buttons)(unsigned); - int16_t (*axis)(unsigned, uint32_t); - void (*poll)(void); - bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t); - const char *(*name)(unsigned); - - const char *ident; -}; - -/** - * joypad_driver_find_handle: - * @index : index of driver to get handle to. - * - * Returns: handle to joypad driver at index. Can be NULL - * if nothing found. - **/ -const void *joypad_driver_find_handle(int index); - -/** - * joypad_driver_find_ident: - * @index : index of driver to get handle to. - * - * Returns: Human-readable identifier of joypad driver at index. Can be NULL - * if nothing found. - **/ -const char *joypad_driver_find_ident(int index); - -/** - * config_get_joypad_driver_options: - * - * Get an enumerated list of all joypad driver names, separated by '|'. - * - * Returns: string listing of all joypad driver names, separated by '|'. - **/ -const char* config_get_joypad_driver_options(void); - -/** - * input_joypad_init_driver: - * @ident : identifier of driver to initialize. - * - * Initialize a joypad driver of name @ident. - * - * If ident points to NULL or a zero-length string, - * equivalent to calling input_joypad_init_first(). - * - * Returns: joypad driver if found, otherwise NULL. - **/ -const input_device_driver_t *input_joypad_init_driver(const char *ident, void *data); - -/** - * input_joypad_init_first: - * - * Finds first suitable joypad driver and initializes. - * - * Returns: joypad driver if found, otherwise NULL. - **/ -const input_device_driver_t *input_joypad_init_first(void *data); - -/** - * input_conv_analog_id_to_bind_id: - * @idx : Analog key index. - * E.g.: - * - RETRO_DEVICE_INDEX_ANALOG_LEFT - * - RETRO_DEVICE_INDEX_ANALOG_RIGHT - * @ident : Analog key identifier. - * E.g.: - * - RETRO_DEVICE_ID_ANALOG_X - * - RETRO_DEVICE_ID_ANALOG_Y - * @ident_minus : Bind ID minus, will be set by function. - * @ident_plus : Bind ID plus, will be set by function. - * - * Takes as input analog key identifiers and converts - * them to corresponding bind IDs @ident_minus and @ident_plus. - **/ -void input_conv_analog_id_to_bind_id(unsigned idx, unsigned ident, - unsigned *ident_minus, unsigned *ident_plus); - -/** - * input_joypad_pressed: - * @drv : Input device driver handle. - * @port : User number. - * @binds : Binds of user. - * @key : Identifier of key. - * - * Checks if key (@key) was being pressed by user - * with number @port with provided keybinds (@binds). - * - * Returns: true (1) if key was pressed, otherwise - * false (0). - **/ -bool input_joypad_pressed(const input_device_driver_t *driver, - rarch_joypad_info_t joypad_info, - unsigned port, const void *binds, unsigned key); - -/** - * input_joypad_analog: - * @drv : Input device driver handle. - * @port : User number. - * @idx : Analog key index. - * E.g.: - * - RETRO_DEVICE_INDEX_ANALOG_LEFT - * - RETRO_DEVICE_INDEX_ANALOG_RIGHT - * @ident : Analog key identifier. - * E.g.: - * - RETRO_DEVICE_ID_ANALOG_X - * - RETRO_DEVICE_ID_ANALOG_Y - * @binds : Binds of user. - * - * Gets analog value of analog key identifiers @idx and @ident - * from user with number @port with provided keybinds (@binds). - * - * Returns: analog value on success, otherwise 0. - **/ -int16_t input_joypad_analog(const input_device_driver_t *driver, - rarch_joypad_info_t joypad_info, - unsigned port, unsigned idx, unsigned ident, - const void *binds); - -/** - * input_joypad_set_rumble: - * @drv : Input device driver handle. - * @port : User number. - * @effect : Rumble effect to set. - * @strength : Strength of rumble effect. - * - * Sets rumble effect @effect with strength @strength. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool input_joypad_set_rumble(const input_device_driver_t *driver, - unsigned port, enum retro_rumble_effect effect, uint16_t strength); - -/** - * input_joypad_axis_raw: - * @drv : Input device driver handle. - * @port : Joystick number. - * @axis : Identifier of axis. - * - * Checks if axis (@axis) was being pressed by user - * with joystick number @port. - * - * Returns: true (1) if axis was pressed, otherwise - * false (0). - **/ -int16_t input_joypad_axis_raw(const input_device_driver_t *driver, - unsigned port, unsigned axis); - -/** - * input_joypad_button_raw: - * @drv : Input device driver handle. - * @port : Joystick number. - * @button : Identifier of key. - * - * Checks if key (@button) was being pressed by user - * with joystick number @port. - * - * Returns: true (1) if key was pressed, otherwise - * false (0). - **/ -bool input_joypad_button_raw(const input_device_driver_t *driver, - unsigned port, unsigned button); - -bool input_joypad_hat_raw(const input_device_driver_t *driver, - unsigned joypad, unsigned hat_dir, unsigned hat); - -/** - * input_joypad_name: - * @drv : Input device driver handle. - * @port : Joystick number. - * - * Gets name of the joystick (@port). - * - * Returns: name of joystick #port. - **/ -const char *input_joypad_name(const input_device_driver_t *driver, - unsigned port); - -bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real); - -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 ps3_joypad; -extern input_device_driver_t psp_joypad; -extern input_device_driver_t ctr_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 null_joypad; -extern input_device_driver_t mfi_joypad; -extern input_device_driver_t dos_joypad; - RETRO_END_DECLS #endif diff --git a/list_special.c b/list_special.c index a8123a6a6e..67995fc70c 100644 --- a/list_special.c +++ b/list_special.c @@ -49,7 +49,6 @@ #include "gfx/video_driver.h" #include "input/input_driver.h" #include "input/input_hid_driver.h" -#include "input/input_joypad_driver.h" #include "audio/audio_driver.h" #include "record/record_driver.h" #include "configuration.h"