mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-21 00:05:30 +00:00
Move device enums outside of driver.h - and create new callback
for 'getting' the number of 'devices' the input driver supports
This commit is contained in:
parent
4e2572bbfe
commit
569de131a0
@ -2110,6 +2110,11 @@ static float android_input_get_sensor_input(void *data, unsigned port, unsigned
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned android_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_android = {
|
||||
android_input_init,
|
||||
android_input_poll,
|
||||
@ -2120,5 +2125,6 @@ const input_driver_t input_android = {
|
||||
android_input_set_sensor_state,
|
||||
android_input_get_sensor_input,
|
||||
android_input_get_capabilities,
|
||||
android_input_devices_size,
|
||||
"android_input",
|
||||
};
|
||||
|
@ -96,6 +96,72 @@ enum {
|
||||
AKEYCODE_ASSIST = 219,
|
||||
};
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_NONE = 0,
|
||||
DEVICE_LOGITECH_RUMBLEPAD2,
|
||||
DEVICE_LOGITECH_DUAL_ACTION,
|
||||
DEVICE_LOGITECH_PRECISION_GAMEPAD,
|
||||
DEVICE_ICONTROLPAD_HID_JOYSTICK,
|
||||
DEVICE_ICONTROLPAD_BLUEZ_IME,
|
||||
DEVICE_TTT_THT_ARCADE,
|
||||
DEVICE_TOMMO_NEOGEOX_ARCADE,
|
||||
DEVICE_MADCATZ_PC_USB_STICK,
|
||||
DEVICE_LOGICOOL_RUMBLEPAD2,
|
||||
DEVICE_IDROID_X360,
|
||||
DEVICE_ZEEMOTE_STEELSERIES,
|
||||
DEVICE_HUIJIA_USB_SNES,
|
||||
DEVICE_SUPER_SMARTJOY,
|
||||
DEVICE_SAITEK_RUMBLE_P480,
|
||||
DEVICE_MS_SIDEWINDER_DUAL_STRIKE,
|
||||
DEVICE_MS_SIDEWINDER,
|
||||
DEVICE_MS_XBOX,
|
||||
DEVICE_WISEGROUP_PLAYSTATION2,
|
||||
DEVICE_JCPS102_PLAYSTATION2,
|
||||
DEVICE_GENERIC_PLAYSTATION2_CONVERTER,
|
||||
DEVICE_PSMOVE_NAVI,
|
||||
DEVICE_JXD_S7300B,
|
||||
DEVICE_JXD_S7800B,
|
||||
DEVICE_IDROID_CON,
|
||||
DEVICE_GENIUS_MAXFIRE_G08XU,
|
||||
DEVICE_USB_2_AXIS_8_BUTTON_GAMEPAD,
|
||||
DEVICE_BUFFALO_BGC_FC801,
|
||||
DEVICE_RETROUSB_RETROPAD,
|
||||
DEVICE_RETROUSB_SNES_RETROPORT,
|
||||
DEVICE_CYPRESS_USB,
|
||||
DEVICE_MAYFLASH_WII_CLASSIC,
|
||||
DEVICE_SZMY_POWER_DUAL_BOX_WII,
|
||||
DEVICE_ARCHOS_GAMEPAD,
|
||||
DEVICE_JXD_S5110,
|
||||
DEVICE_JXD_S5110_SKELROM,
|
||||
DEVICE_XPERIA_PLAY,
|
||||
DEVICE_BROADCOM_BLUETOOTH_HID,
|
||||
DEVICE_THRUST_PREDATOR,
|
||||
DEVICE_DRAGONRISE,
|
||||
DEVICE_PLAYSTATION3_VERSION1,
|
||||
DEVICE_PLAYSTATION3_VERSION2,
|
||||
DEVICE_MOGA_IME,
|
||||
DEVICE_NYKO_PLAYPAD_PRO,
|
||||
DEVICE_TOODLES_2008_CHIMP,
|
||||
DEVICE_MOGA,
|
||||
DEVICE_SEGA_VIRTUA_STICK_HIGH_GRADE,
|
||||
DEVICE_CCPCREATIONS_WIIUSE_IME,
|
||||
DEVICE_KEYBOARD_RETROPAD,
|
||||
DEVICE_OUYA,
|
||||
DEVICE_ONLIVE_WIRELESS_CONTROLLER,
|
||||
DEVICE_TOMEE_NES_USB,
|
||||
DEVICE_THRUSTMASTER_T_MINI,
|
||||
DEVICE_GAMEMID,
|
||||
DEVICE_DEFENDER_GAME_RACER_CLASSIC,
|
||||
DEVICE_HOLTEK_JC_U912F,
|
||||
DEVICE_NVIDIA_SHIELD,
|
||||
DEVICE_MUCH_IREADGO_I5,
|
||||
DEVICE_WIKIPAD,
|
||||
DEVICE_FC30_GAMEPAD,
|
||||
DEVICE_SAMSUNG_GAMEPAD_EIGP20,
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
#define LAST_KEYCODE AKEYCODE_ASSIST
|
||||
|
||||
void input_autodetect_setup(void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source, bool *primary);
|
||||
|
@ -24,6 +24,16 @@
|
||||
|
||||
#include "keycode.inc"
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_NONE = 0,
|
||||
#if defined(IOS)
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_SIXAXIS,
|
||||
#endif
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
extern const rarch_joypad_driver_t apple_joypad;
|
||||
static const rarch_joypad_driver_t* const g_joydriver = &apple_joypad;
|
||||
|
||||
@ -432,9 +442,14 @@ static uint64_t apple_input_get_capabilities(void *data)
|
||||
return caps;
|
||||
}
|
||||
|
||||
unsigned apple_get_device_last_idx(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t *apple_get_joypad_driver(void *data)
|
||||
{
|
||||
return g_joydriver;
|
||||
return g_joydriver;
|
||||
}
|
||||
|
||||
const input_driver_t input_apple = {
|
||||
@ -447,6 +462,8 @@ const input_driver_t input_apple = {
|
||||
NULL,
|
||||
NULL,
|
||||
apple_input_get_capabilities,
|
||||
NULL,
|
||||
apple_get_device_last_idx,
|
||||
"apple_input",
|
||||
NULL,
|
||||
apple_input_set_rumble,
|
||||
|
@ -30,6 +30,17 @@
|
||||
#define MAX_TOUCH 4
|
||||
#endif
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_NONE,
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_KEYBOARD,
|
||||
DEVICE_IPEGA,
|
||||
DEVICE_KEYPAD,
|
||||
DEVICE_UNKNOWN,
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
struct touches
|
||||
{
|
||||
int16_t x, y;
|
||||
@ -854,6 +865,11 @@ static uint64_t qnx_input_get_capabilities(void *data)
|
||||
return caps;
|
||||
}
|
||||
|
||||
unsigned qnx_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_qnx = {
|
||||
qnx_input_init,
|
||||
qnx_input_poll,
|
||||
@ -864,5 +880,6 @@ const input_driver_t input_qnx = {
|
||||
NULL,
|
||||
NULL,
|
||||
qnx_input_get_capabilities,
|
||||
qnx_input_devices_size,
|
||||
"qnx_input",
|
||||
};
|
||||
|
96
driver.h
96
driver.h
@ -232,101 +232,6 @@ typedef struct audio_driver
|
||||
#define GET_HAT_DIR(x) (x & HAT_MASK)
|
||||
#define GET_HAT(x) (x & (~HAT_MASK))
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
#if defined(ANDROID)
|
||||
DEVICE_NONE = 0,
|
||||
DEVICE_LOGITECH_RUMBLEPAD2,
|
||||
DEVICE_LOGITECH_DUAL_ACTION,
|
||||
DEVICE_LOGITECH_PRECISION_GAMEPAD,
|
||||
DEVICE_ICONTROLPAD_HID_JOYSTICK,
|
||||
DEVICE_ICONTROLPAD_BLUEZ_IME,
|
||||
DEVICE_TTT_THT_ARCADE,
|
||||
DEVICE_TOMMO_NEOGEOX_ARCADE,
|
||||
DEVICE_MADCATZ_PC_USB_STICK,
|
||||
DEVICE_LOGICOOL_RUMBLEPAD2,
|
||||
DEVICE_IDROID_X360,
|
||||
DEVICE_ZEEMOTE_STEELSERIES,
|
||||
DEVICE_HUIJIA_USB_SNES,
|
||||
DEVICE_SUPER_SMARTJOY,
|
||||
DEVICE_SAITEK_RUMBLE_P480,
|
||||
DEVICE_MS_SIDEWINDER_DUAL_STRIKE,
|
||||
DEVICE_MS_SIDEWINDER,
|
||||
DEVICE_MS_XBOX,
|
||||
DEVICE_WISEGROUP_PLAYSTATION2,
|
||||
DEVICE_JCPS102_PLAYSTATION2,
|
||||
DEVICE_GENERIC_PLAYSTATION2_CONVERTER,
|
||||
DEVICE_PSMOVE_NAVI,
|
||||
DEVICE_JXD_S7300B,
|
||||
DEVICE_JXD_S7800B,
|
||||
DEVICE_IDROID_CON,
|
||||
DEVICE_GENIUS_MAXFIRE_G08XU,
|
||||
DEVICE_USB_2_AXIS_8_BUTTON_GAMEPAD,
|
||||
DEVICE_BUFFALO_BGC_FC801,
|
||||
DEVICE_RETROUSB_RETROPAD,
|
||||
DEVICE_RETROUSB_SNES_RETROPORT,
|
||||
DEVICE_CYPRESS_USB,
|
||||
DEVICE_MAYFLASH_WII_CLASSIC,
|
||||
DEVICE_SZMY_POWER_DUAL_BOX_WII,
|
||||
DEVICE_ARCHOS_GAMEPAD,
|
||||
DEVICE_JXD_S5110,
|
||||
DEVICE_JXD_S5110_SKELROM,
|
||||
DEVICE_XPERIA_PLAY,
|
||||
DEVICE_BROADCOM_BLUETOOTH_HID,
|
||||
DEVICE_THRUST_PREDATOR,
|
||||
DEVICE_DRAGONRISE,
|
||||
DEVICE_PLAYSTATION3_VERSION1,
|
||||
DEVICE_PLAYSTATION3_VERSION2,
|
||||
DEVICE_MOGA_IME,
|
||||
DEVICE_NYKO_PLAYPAD_PRO,
|
||||
DEVICE_TOODLES_2008_CHIMP,
|
||||
DEVICE_MOGA,
|
||||
DEVICE_SEGA_VIRTUA_STICK_HIGH_GRADE,
|
||||
DEVICE_CCPCREATIONS_WIIUSE_IME,
|
||||
DEVICE_KEYBOARD_RETROPAD,
|
||||
DEVICE_OUYA,
|
||||
DEVICE_ONLIVE_WIRELESS_CONTROLLER,
|
||||
DEVICE_TOMEE_NES_USB,
|
||||
DEVICE_THRUSTMASTER_T_MINI,
|
||||
DEVICE_GAMEMID,
|
||||
DEVICE_DEFENDER_GAME_RACER_CLASSIC,
|
||||
DEVICE_HOLTEK_JC_U912F,
|
||||
DEVICE_NVIDIA_SHIELD,
|
||||
DEVICE_MUCH_IREADGO_I5,
|
||||
DEVICE_WIKIPAD,
|
||||
DEVICE_FC30_GAMEPAD,
|
||||
DEVICE_SAMSUNG_GAMEPAD_EIGP20,
|
||||
#elif defined(GEKKO)
|
||||
DEVICE_GAMECUBE = 0,
|
||||
#ifdef HW_RVL
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_NUNCHUK,
|
||||
DEVICE_CLASSIC,
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
DEVICE_SIXAXIS,
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(_XBOX)
|
||||
DEVICE_XBOX_PAD = 0,
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
DEVICE_SIXAXIS = 0,
|
||||
#elif defined(PSP)
|
||||
DEVICE_PSP = 0,
|
||||
#elif defined(__BLACKBERRY_QNX__)
|
||||
DEVICE_NONE,
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_KEYBOARD,
|
||||
DEVICE_IPEGA,
|
||||
DEVICE_KEYPAD,
|
||||
DEVICE_UNKNOWN,
|
||||
#elif defined(IOS)
|
||||
DEVICE_NONE,
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_SIXAXIS,
|
||||
#endif
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
enum analog_dpad_mode
|
||||
{
|
||||
ANALOG_DPAD_NONE = 0,
|
||||
@ -362,6 +267,7 @@ typedef struct input_driver
|
||||
bool (*set_sensor_state)(void *data, unsigned port, enum retro_sensor_action action, unsigned rate);
|
||||
float (*get_sensor_input)(void *data, unsigned port, unsigned id);
|
||||
uint64_t (*get_capabilities)(void *data);
|
||||
unsigned (*devices_size)(void *data);
|
||||
const char *ident;
|
||||
|
||||
void (*grab_mouse)(void *data, bool state);
|
||||
|
@ -900,9 +900,10 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
||||
case RGUI_SETTINGS_BIND_DEVICE:
|
||||
// If set_keybinds is supported, we do it more fancy, and scroll through
|
||||
// a list of supported devices directly.
|
||||
if (driver.input->set_keybinds)
|
||||
if (driver.input->set_keybinds && driver.input->devices_size)
|
||||
{
|
||||
g_settings.input.device[port] += DEVICE_LAST;
|
||||
unsigned device_last = driver.input->devices_size(driver.input_data);
|
||||
g_settings.input.device[port] += device_last;
|
||||
if (action == RGUI_ACTION_START)
|
||||
g_settings.input.device[port] = 0;
|
||||
else if (action == RGUI_ACTION_LEFT)
|
||||
@ -910,12 +911,12 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
||||
else if (action == RGUI_ACTION_RIGHT)
|
||||
g_settings.input.device[port]++;
|
||||
|
||||
// DEVICE_LAST can be 0, avoid modulo.
|
||||
if (g_settings.input.device[port] >= DEVICE_LAST)
|
||||
g_settings.input.device[port] -= DEVICE_LAST;
|
||||
// device_last can be 0, avoid modulo.
|
||||
if (g_settings.input.device[port] >= device_last)
|
||||
g_settings.input.device[port] -= device_last;
|
||||
// needs to be checked twice, in case we go right past the end of the list
|
||||
if (g_settings.input.device[port] >= DEVICE_LAST)
|
||||
g_settings.input.device[port] -= DEVICE_LAST;
|
||||
if (g_settings.input.device[port] >= device_last)
|
||||
g_settings.input.device[port] -= device_last;
|
||||
|
||||
unsigned keybind_action = (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS);
|
||||
|
||||
|
@ -38,6 +38,18 @@
|
||||
|
||||
#define MAX_PADS 4
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_GAMECUBE = 0,
|
||||
#ifdef HW_RVL
|
||||
DEVICE_WIIMOTE,
|
||||
DEVICE_NUNCHUK,
|
||||
DEVICE_CLASSIC,
|
||||
#ifdef HAVE_LIBSICKSAXIS
|
||||
DEVICE_SIXAXIS,
|
||||
#endif
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
typedef struct gx_input
|
||||
{
|
||||
@ -880,6 +892,11 @@ static const rarch_joypad_driver_t *gx_input_get_joypad_driver(void *data)
|
||||
return &gx_joypad;
|
||||
}
|
||||
|
||||
static unsigned gx_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_gx = {
|
||||
gx_input_init,
|
||||
gx_input_poll,
|
||||
@ -890,6 +907,7 @@ const input_driver_t input_gx = {
|
||||
NULL,
|
||||
NULL,
|
||||
gx_input_get_capabilities,
|
||||
gx_input_devices_size,
|
||||
"gx",
|
||||
|
||||
NULL,
|
||||
|
@ -558,6 +558,7 @@ const input_driver_t input_dinput = {
|
||||
NULL,
|
||||
NULL,
|
||||
dinput_get_capabilities,
|
||||
NULL,
|
||||
"dinput",
|
||||
|
||||
dinput_grab_mouse,
|
||||
|
@ -243,6 +243,7 @@ const input_driver_t input_linuxraw = {
|
||||
NULL,
|
||||
NULL,
|
||||
linuxraw_get_capabilities,
|
||||
NULL,
|
||||
"linuxraw",
|
||||
NULL,
|
||||
linuxraw_set_rumble,
|
||||
|
@ -157,6 +157,7 @@ const input_driver_t input_rwebinput = {
|
||||
NULL,
|
||||
NULL,
|
||||
rwebinput_get_capabilities,
|
||||
NULL,
|
||||
"rwebinput",
|
||||
rwebinput_grab_mouse,
|
||||
};
|
||||
|
@ -283,6 +283,7 @@ const input_driver_t input_sdl = {
|
||||
NULL,
|
||||
NULL,
|
||||
sdl_get_capabilities,
|
||||
NULL,
|
||||
"sdl",
|
||||
NULL,
|
||||
sdl_set_rumble,
|
||||
|
@ -816,6 +816,7 @@ const input_driver_t input_udev = {
|
||||
NULL,
|
||||
NULL,
|
||||
udev_input_get_capabilities,
|
||||
NULL,
|
||||
"udev",
|
||||
udev_input_grab_mouse,
|
||||
udev_input_set_rumble,
|
||||
|
@ -320,6 +320,7 @@ const input_driver_t input_x = {
|
||||
NULL,
|
||||
NULL,
|
||||
x_input_get_capabilities,
|
||||
NULL,
|
||||
"x",
|
||||
x_grab_mouse,
|
||||
x_set_rumble,
|
||||
|
@ -39,6 +39,12 @@
|
||||
#define DEADZONE_LOW 105
|
||||
#define DEADZONE_HIGH 145
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_SIXAXIS = 0,
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
@ -511,6 +517,11 @@ static const rarch_joypad_driver_t *ps3_input_get_joypad_driver(void *data)
|
||||
return &ps3_joypad;
|
||||
}
|
||||
|
||||
static unsigned ps3_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_ps3 = {
|
||||
ps3_input_init,
|
||||
ps3_input_poll,
|
||||
@ -521,6 +532,7 @@ const input_driver_t input_ps3 = {
|
||||
ps3_input_set_sensor_state,
|
||||
NULL,
|
||||
ps3_input_get_capabilities,
|
||||
ps3_input_devices_size,
|
||||
"ps3",
|
||||
|
||||
NULL,
|
||||
|
@ -37,6 +37,12 @@
|
||||
|
||||
#define MAX_PADS 1
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_PSP = 0,
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
const struct platform_bind platform_keys[] = {
|
||||
{ PSP_GAMEPAD_CIRCLE, "Circle button" },
|
||||
{ PSP_GAMEPAD_CROSS, "Cross button" },
|
||||
@ -336,6 +342,11 @@ static const rarch_joypad_driver_t *psp_input_get_joypad_driver(void *data)
|
||||
return &psp_joypad;
|
||||
}
|
||||
|
||||
static unsigned psp_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_psp = {
|
||||
psp_input_initialize,
|
||||
psp_input_poll,
|
||||
@ -346,6 +357,7 @@ const input_driver_t input_psp = {
|
||||
NULL,
|
||||
NULL,
|
||||
psp_input_get_capabilities,
|
||||
psp_input_devices_size,
|
||||
"psp",
|
||||
|
||||
NULL,
|
||||
|
@ -21,13 +21,18 @@
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
#define MAX_PADS 4
|
||||
#define DEADZONE (16000)
|
||||
|
||||
#include "../driver.h"
|
||||
#include "../general.h"
|
||||
#include "../libretro.h"
|
||||
|
||||
#define MAX_PADS 4
|
||||
|
||||
enum input_devices
|
||||
{
|
||||
DEVICE_XBOX_PAD = 0,
|
||||
DEVICE_LAST
|
||||
};
|
||||
|
||||
typedef struct xdk_input
|
||||
{
|
||||
uint64_t pad_state[MAX_PADS];
|
||||
@ -432,6 +437,11 @@ static const rarch_joypad_driver_t *xdk_input_get_joypad_driver(void *data)
|
||||
return &xdk_joypad;
|
||||
}
|
||||
|
||||
static unsigned xdk_input_devices_size(void *data)
|
||||
{
|
||||
return DEVICE_LAST;
|
||||
}
|
||||
|
||||
const input_driver_t input_xinput =
|
||||
{
|
||||
xdk_input_init,
|
||||
@ -443,6 +453,7 @@ const input_driver_t input_xinput =
|
||||
NULL,
|
||||
NULL,
|
||||
xdk_input_get_capabilities,
|
||||
xdk_input_devices_size,
|
||||
"xinput",
|
||||
|
||||
NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user