From 6860294dd9e7f27e6479e45892e9e328f53d6c19 Mon Sep 17 00:00:00 2001 From: Manoj Bhatta Date: Fri, 4 Oct 2024 18:39:58 +0000 Subject: [PATCH] button values from 0.0 to 1.0 --- include/wpe/gamepad.h | 16 +++++++++++++++- src/gamepad.c | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/wpe/gamepad.h b/include/wpe/gamepad.h index 506f0b06..fd6cbfaa 100644 --- a/include/wpe/gamepad.h +++ b/include/wpe/gamepad.h @@ -142,7 +142,7 @@ struct wpe_gamepad_client_interface { void (*axis_changed)(void*, enum wpe_gamepad_axis, double); /*< private >*/ - void (*_wpe_reserved1)(void); + void (*analog_button_changed)(void*, enum wpe_gamepad_button, double); void (*_wpe_reserved2)(void); void (*_wpe_reserved3)(void); }; @@ -358,6 +358,20 @@ void wpe_gamepad_set_client(struct wpe_gamepad*, const struct wpe_gamepad_client WPE_EXPORT const char* wpe_gamepad_get_id(struct wpe_gamepad*); +/** + * wpe_gamepad_dispatch_analog_button_changed: + * @gamepad: opaque gamepad object. + * @button: the analog button that changed its value. + * @value: the new analog @button value. + * + * Method called by application (gamepad implementator). It reports to + * WPEWebkit a change in the value of analog @button. + * + * Since: 1.15 + */ +WPE_EXPORT +void wpe_gamepad_dispatch_analog_button_changed(struct wpe_gamepad*, enum wpe_gamepad_button, double); + /** * wpe_gamepad_dispatch_button_changed: * @gamepad: opaque gamepad object. diff --git a/src/gamepad.c b/src/gamepad.c index 355636aa..64bfe481 100644 --- a/src/gamepad.c +++ b/src/gamepad.c @@ -161,6 +161,13 @@ wpe_gamepad_get_id(struct wpe_gamepad* gamepad) return "Unknown device"; } +void +wpe_gamepad_dispatch_analog_button_changed(struct wpe_gamepad* gamepad, enum wpe_gamepad_button button, double value) +{ + if (gamepad && gamepad->client_interface && gamepad->client_interface->analog_button_changed) + gamepad->client_interface->analog_button_changed(gamepad->client_data, button, value); +} + void wpe_gamepad_dispatch_button_changed(struct wpe_gamepad* gamepad, enum wpe_gamepad_button button, bool pressed) {