Add sensor function placeholders for all joypad drivers. (#16812)

In some cases, set_sensor_state and get_sensor_input are
more related to the joypad driver, e.g. in desktop platforms
where sensors are associated rather with the joypad.

If input driver supports the sensors, it is still preferred.
Placeholder inserted for all input drivers, no functionality
added yet.
This commit is contained in:
zoltanvb 2024-07-25 00:13:16 +02:00 committed by GitHub
parent efbfe3610a
commit e5e7e66199
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 107 additions and 38 deletions

View File

@ -252,7 +252,9 @@ input_device_driver_t android_joypad = {
android_joypad_axis,
android_joypad_poll,
android_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
android_joypad_name,
"android",
};

View File

@ -212,8 +212,10 @@ input_device_driver_t ctr_joypad = {
ctr_joypad_get_buttons,
ctr_joypad_axis,
ctr_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
ctr_joypad_name,
"ctr",
};

View File

@ -56,7 +56,9 @@ input_device_driver_t dinput_joypad = {
dinput_joypad_axis,
dinput_joypad_poll,
dinput_joypad_set_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
dinput_joypad_name,
"dinput",
};

View File

@ -254,8 +254,10 @@ input_device_driver_t dos_joypad = {
NULL,
dos_joypad_axis,
dos_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
dos_joypad_name,
"dos",
};

View File

@ -672,8 +672,10 @@ input_device_driver_t gx_joypad = {
gx_joypad_get_buttons,
gx_joypad_axis,
gx_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
gx_joypad_name,
"gx",
};

View File

@ -130,7 +130,9 @@ input_device_driver_t hid_joypad = {
hid_joypad_axis,
hid_joypad_poll,
hid_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
hid_joypad_name,
"hid"
};

View File

@ -405,8 +405,10 @@ input_device_driver_t linuxraw_joypad = {
linuxraw_joypad_get_buttons,
linuxraw_joypad_axis,
linuxraw_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
linuxraw_joypad_name,
"linuxraw",
};

View File

@ -834,6 +834,8 @@ input_device_driver_t mfi_joypad = {
apple_gamecontroller_joypad_poll,
apple_gamecontroller_joypad_set_rumble,
NULL,
NULL,
NULL,
apple_gamecontroller_joypad_name,
"mfi",
};

View File

@ -410,8 +410,10 @@ input_device_driver_t parport_joypad = {
parport_joypad_get_buttons,
parport_joypad_axis,
parport_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
parport_joypad_name,
"parport",
};

View File

@ -264,7 +264,9 @@ input_device_driver_t ps2_joypad = {
ps2_joypad_axis,
ps2_joypad_poll,
ps2_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
ps2_joypad_name,
"ps2",
};

View File

@ -305,7 +305,9 @@ input_device_driver_t ps3_joypad = {
ps3_joypad_axis,
ps3_joypad_poll,
ps3_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
ps3_joypad_name,
"ps3",
};

View File

@ -355,7 +355,9 @@ input_device_driver_t ps4_joypad = {
ps4_joypad_axis,
ps4_joypad_poll,
ps4_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
ps4_joypad_name,
"ps4",
};

View File

@ -424,7 +424,9 @@ input_device_driver_t psp_joypad = {
psp_joypad_axis,
psp_joypad_poll,
psp_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
psp_joypad_name,
#ifdef VITA
"vita",

View File

@ -169,8 +169,10 @@ input_device_driver_t qnx_joypad = {
NULL,
qnx_joypad_axis,
qnx_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
qnx_joypad_name,
"qnx",
};

View File

@ -210,8 +210,10 @@ input_device_driver_t rwebpad_joypad = {
rwebpad_joypad_get_buttons,
rwebpad_joypad_axis,
rwebpad_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
rwebpad_joypad_name,
"rwebpad",
};

View File

@ -808,6 +808,8 @@ input_device_driver_t sdl_dingux_joypad = {
NULL,
NULL,
#endif
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
sdl_dingux_joypad_name,
"sdl_dingux",
};

View File

@ -563,9 +563,11 @@ input_device_driver_t sdl_joypad = {
#ifdef HAVE_SDL2
sdl_joypad_set_rumble,
#else
NULL,
NULL, /* set_rumble */
#endif
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
sdl_joypad_name,
#ifdef HAVE_SDL2
"sdl2",

View File

@ -465,7 +465,9 @@ input_device_driver_t switch_joypad = {
#else
NULL, /* set_rumble */
#endif
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
switch_joypad_name,
"switch"
};

View File

@ -496,8 +496,10 @@ input_device_driver_t test_joypad = {
NULL, /* get_buttons */
test_joypad_axis,
test_joypad_poll,
NULL, /* rumble */
NULL, /* rumble_gain */
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
test_joypad_name,
"test",
};

View File

@ -795,8 +795,10 @@ input_device_driver_t udev_joypad = {
#ifndef HAVE_LAKKA_SWITCH
udev_set_rumble_gain,
#else
NULL,
NULL, /* set_rumble_gain */
#endif
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
udev_joypad_name,
"udev",
};

View File

@ -117,6 +117,8 @@ input_device_driver_t hidpad_driver =
hidpad_poll,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
hidpad_name,
"hid"
};

View File

@ -292,8 +292,10 @@ input_device_driver_t kpad_driver =
kpad_get_buttons,
kpad_axis,
kpad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
kpad_name,
"wiimote",
};

View File

@ -361,8 +361,10 @@ input_device_driver_t wpad_driver =
wpad_get_buttons,
wpad_axis,
wpad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
wpad_name,
"gamepad",
};

View File

@ -132,8 +132,10 @@ input_device_driver_t wiiu_joypad =
wiiu_joypad_get_buttons,
wiiu_joypad_axis,
wiiu_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
wiiu_joypad_name,
"wiiu",
};

View File

@ -322,8 +322,10 @@ input_device_driver_t xdk_joypad = {
NULL,
xdk_joypad_axis,
xdk_joypad_poll,
NULL,
NULL,
NULL, /* set_rumble */
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
xdk_joypad_name,
"xdk",
};

View File

@ -699,7 +699,9 @@ input_device_driver_t xinput_joypad = {
xinput_joypad_axis,
xinput_joypad_poll,
xinput_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
xinput_joypad_name,
"xinput",
};

View File

@ -394,7 +394,9 @@ input_device_driver_t xinput_joypad = {
xinput_joypad_axis,
xinput_joypad_poll,
xinput_joypad_rumble,
NULL,
NULL, /* set_rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
xinput_joypad_name,
"xinput",
};

View File

@ -170,6 +170,8 @@ static input_device_driver_t null_joypad = {
NULL, /* poll */
NULL, /* rumble */
NULL, /* rumble_gain */
NULL, /* set_sensor_state */
NULL, /* get_sensor_input */
NULL, /* name */
"null",
};
@ -518,7 +520,11 @@ bool input_driver_set_sensor(
return current_driver->set_sensor_state(current_data,
port, action, rate);
}
else if (input_driver_st.primary_joypad && input_driver_st.primary_joypad->set_sensor_state)
{
return input_driver_st.primary_joypad->set_sensor_state(NULL,
port, action, rate);
}
return false;
}
@ -535,6 +541,12 @@ float input_driver_get_sensor(
void *current_data = input_driver_st.current_data;
return current_driver->get_sensor_input(current_data, port, id);
}
else if (sensors_enable && input_driver_st.primary_joypad &&
input_driver_st.primary_joypad->get_sensor_input)
{
return input_driver_st.primary_joypad->get_sensor_input(NULL,
port, id);
}
}
return 0.0f;

View File

@ -465,6 +465,9 @@ struct rarch_joypad_driver
void (*poll)(void);
bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t);
bool (*set_rumble_gain)(unsigned, unsigned);
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);
const char *(*name)(unsigned);
const char *ident;