Skip to content

Commit

Permalink
Add sensor function placeholders for all joypad drivers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zoltanvb committed Jul 24, 2024
1 parent 6b8025f commit 419939c
Show file tree
Hide file tree
Showing 29 changed files with 107 additions and 38 deletions.
4 changes: 3 additions & 1 deletion input/drivers_joypad/android_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/ctr_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/dinput_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/dos_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/gx_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/hid_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/linuxraw_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
2 changes: 2 additions & 0 deletions input/drivers_joypad/mfi_joypad.m
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ static bool apple_gamecontroller_joypad_query_pad(unsigned pad)
apple_gamecontroller_joypad_poll,
apple_gamecontroller_joypad_set_rumble,
NULL,
NULL,
NULL,
apple_gamecontroller_joypad_name,
"mfi",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/parport_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/ps2_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/ps3_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/ps4_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/psp_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions input/drivers_joypad/qnx_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/rwebpad_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
2 changes: 2 additions & 0 deletions input/drivers_joypad/sdl_dingux_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/sdl_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion input/drivers_joypad/switch_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/test_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/udev_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
2 changes: 2 additions & 0 deletions input/drivers_joypad/wiiu/hidpad_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/wiiu/kpad_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/wiiu/wpad_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/wiiu_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 4 additions & 2 deletions input/drivers_joypad/xdk_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/xinput_hybrid_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
4 changes: 3 additions & 1 deletion input/drivers_joypad/xinput_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
14 changes: 13 additions & 1 deletion input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions input/input_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 419939c

Please sign in to comment.