[mutter] clutter: Add clutter_event_get_pad_event_details()



commit ead6556b500af975b7f1aa8b4e955c1e31a6eec5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jul 14 21:17:46 2017 +0200

    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(+), 0 deletions(-)
---
diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c
index 0c1b703..10b6c00 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 3f8f68e..eacdb54 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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]