diff --git a/input/drivers_joypad/android_joypad.c b/input/drivers_joypad/android_joypad.c index 12cb98d2aec..e7d33330a8a 100644 --- a/input/drivers_joypad/android_joypad.c +++ b/input/drivers_joypad/android_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index d063b2f3a41..efe26f3fc70 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index cfddb301816..6063d6eeafc 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/dos_joypad.c b/input/drivers_joypad/dos_joypad.c index 8a90499259a..6803a658be5 100644 --- a/input/drivers_joypad/dos_joypad.c +++ b/input/drivers_joypad/dos_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 8a3dfef8d28..9fb75383e80 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/hid_joypad.c b/input/drivers_joypad/hid_joypad.c index fd6e22b8800..2861f6a555d 100644 --- a/input/drivers_joypad/hid_joypad.c +++ b/input/drivers_joypad/hid_joypad.c @@ -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" }; diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index de30bc53bdf..369c1dbc9b4 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index b3287d245ca..028417c5f3f 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -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", }; diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index da7ad0bfcfb..204a8b04841 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/ps2_joypad.c b/input/drivers_joypad/ps2_joypad.c index 0698843f8d2..6c61abbf4d9 100644 --- a/input/drivers_joypad/ps2_joypad.c +++ b/input/drivers_joypad/ps2_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index 8e579062a6a..cd0d5fbf9fb 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/ps4_joypad.c b/input/drivers_joypad/ps4_joypad.c index d8f9e0e1491..a847d9da77e 100644 --- a/input/drivers_joypad/ps4_joypad.c +++ b/input/drivers_joypad/ps4_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index ab35c188d8a..7ce3597ccbc 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -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", diff --git a/input/drivers_joypad/qnx_joypad.c b/input/drivers_joypad/qnx_joypad.c index 07dfea34bd5..08f04a343cc 100644 --- a/input/drivers_joypad/qnx_joypad.c +++ b/input/drivers_joypad/qnx_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/rwebpad_joypad.c b/input/drivers_joypad/rwebpad_joypad.c index 349841b33ed..1c63cf690fe 100644 --- a/input/drivers_joypad/rwebpad_joypad.c +++ b/input/drivers_joypad/rwebpad_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/sdl_dingux_joypad.c b/input/drivers_joypad/sdl_dingux_joypad.c index 543fe5b630f..b110b9d121c 100644 --- a/input/drivers_joypad/sdl_dingux_joypad.c +++ b/input/drivers_joypad/sdl_dingux_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index fb9c78ef829..5f1a706990f 100644 --- a/input/drivers_joypad/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -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", diff --git a/input/drivers_joypad/switch_joypad.c b/input/drivers_joypad/switch_joypad.c index c06cc13a7d5..7b543be5431 100644 --- a/input/drivers_joypad/switch_joypad.c +++ b/input/drivers_joypad/switch_joypad.c @@ -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" }; diff --git a/input/drivers_joypad/test_joypad.c b/input/drivers_joypad/test_joypad.c index 9c7dcf1fcfa..a1a704c6479 100644 --- a/input/drivers_joypad/test_joypad.c +++ b/input/drivers_joypad/test_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index ff4b55dcf03..716e6db5949 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/wiiu/hidpad_driver.c b/input/drivers_joypad/wiiu/hidpad_driver.c index 490182ea11e..95076368e6b 100644 --- a/input/drivers_joypad/wiiu/hidpad_driver.c +++ b/input/drivers_joypad/wiiu/hidpad_driver.c @@ -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" }; diff --git a/input/drivers_joypad/wiiu/kpad_driver.c b/input/drivers_joypad/wiiu/kpad_driver.c index a5c9da957b3..dd4cd80e66a 100644 --- a/input/drivers_joypad/wiiu/kpad_driver.c +++ b/input/drivers_joypad/wiiu/kpad_driver.c @@ -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", }; diff --git a/input/drivers_joypad/wiiu/wpad_driver.c b/input/drivers_joypad/wiiu/wpad_driver.c index 717b1e4a522..902bce6f3b2 100644 --- a/input/drivers_joypad/wiiu/wpad_driver.c +++ b/input/drivers_joypad/wiiu/wpad_driver.c @@ -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", }; diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 6c4c972159e..5bd588ba369 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index d6fb3cde5c8..9647d9803fe 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/xinput_hybrid_joypad.c b/input/drivers_joypad/xinput_hybrid_joypad.c index fa43b2970ad..86baa055409 100644 --- a/input/drivers_joypad/xinput_hybrid_joypad.c +++ b/input/drivers_joypad/xinput_hybrid_joypad.c @@ -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", }; diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 922ef92bba7..3c0086ed252 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -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", }; diff --git a/input/input_driver.c b/input/input_driver.c index 7e7b441239e..b2e8d216da6 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -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; diff --git a/input/input_driver.h b/input/input_driver.h index 50eb5d4ee69..563ceeb7746 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -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;