From ead6556b500af975b7f1aa8b4e955c1e31a6eec5 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 14 Jul 2017 21:17:46 +0200 Subject: [PATCH] clutter: Add clutter_event_get_pad_event_details() This function extracts pad event information, and more importantly exposes it for gobject introspection. https://bugzilla.gnome.org/show_bug.cgi?id=782033 --- clutter/clutter/clutter-event.c | 58 +++++++++++++++++++++++++++++++++ clutter/clutter/clutter-event.h | 6 ++++ 2 files changed, 64 insertions(+) diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 0c1b703bb..10b6c0082 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -2179,3 +2179,61 @@ clutter_event_get_mode_group (const ClutterEvent *event) return 0; } } + +/** + * clutter_event_get_pad_event_details: + * @event: a pad event + * @number: (out) (optional): ring/strip/button number + * @mode: (out) (optional): pad mode as per the event + * @value: (out) (optional): event axis value + * + * Returns the details of a pad event. + * + * Returns: #TRUE if event details could be obtained + **/ +gboolean +clutter_event_get_pad_event_details (const ClutterEvent *event, + guint *number, + guint *mode, + gdouble *value) +{ + guint n, m; + gdouble v; + + g_return_val_if_fail (event != NULL, FALSE); + g_return_val_if_fail (event->type == CLUTTER_PAD_BUTTON_PRESS || + event->type == CLUTTER_PAD_BUTTON_RELEASE || + event->type == CLUTTER_PAD_RING || + event->type == CLUTTER_PAD_STRIP, FALSE); + + switch (event->type) + { + case CLUTTER_PAD_BUTTON_PRESS: + case CLUTTER_PAD_BUTTON_RELEASE: + n = event->pad_button.button; + m = event->pad_button.mode; + v = 0.0; + break; + case CLUTTER_PAD_RING: + n = event->pad_ring.ring_number; + m = event->pad_ring.mode; + v = event->pad_ring.angle; + break; + case CLUTTER_PAD_STRIP: + n = event->pad_strip.strip_number; + m = event->pad_strip.mode; + v = event->pad_strip.value; + break; + default: + return FALSE; + } + + if (number) + *number = n; + if (mode) + *mode = m; + if (value) + *value = v; + + return TRUE; +} diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 3f8f68e44..eacdb54e6 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -778,6 +778,12 @@ ClutterScrollFinishFlags clutter_event_get_scroll_finish_flags (const Clut CLUTTER_AVAILABLE_IN_ALL guint clutter_event_get_mode_group (const ClutterEvent *event); +CLUTTER_AVAILABLE_IN_MUTTER +gboolean clutter_event_get_pad_event_details (const ClutterEvent *event, + guint *number, + guint *mode, + gdouble *value); + G_END_DECLS