From 3fb587cb82a0facfd8370f46c6f85b66ce43f50d Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki <lubosz.sarnecki@collabora.com> Date: Thu, 20 Oct 2022 12:31:14 +0200 Subject: [PATCH] example/actions: Fix sample. --- examples/actions.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/actions.c b/examples/actions.c index dff8c5f..adc7a36 100644 --- a/examples/actions.c +++ b/examples/actions.c @@ -6,8 +6,7 @@ */ #include <glib-unix.h> - -#include "gxr.h" +#include <gxr.h> enum { @@ -40,6 +39,12 @@ _poll_events_cb (gpointer _self) { Example *self = (Example *) _self; + if (!gxr_context_begin_frame (self->context)) + return FALSE; + + gxr_context_end_frame (self->context); + gxr_context_poll_events (self->context); + if (!gxr_action_sets_poll (self->action_sets, 2)) { g_print ("Failed to poll events\n"); @@ -65,10 +70,8 @@ _digital_cb (GxrAction *action, GxrDigitalEvent *event, Example *self) self->haptic, 0.0f, .2f, 160.f, 1.0f, gxr_device_get_handle (GXR_DEVICE (event->controller))); } - - g_free (event); } -#include <stdio.h> + static void _hand_pose_cb (GxrAction *action, GxrPoseEvent *event, Example *self) { @@ -85,8 +88,6 @@ _hand_pose_cb (GxrAction *action, GxrPoseEvent *event, Example *self) graphene_vec3_get_z (&event->angular_velocity)); graphene_matrix_print (&event->pose); - - g_free (event); } static void @@ -138,6 +139,8 @@ main () "/actions/mouse_synth/in/left_click", (GCallback) _digital_cb, &self); + gxr_context_attach_action_sets (self.context, self.action_sets, 2); + g_timeout_add (20, _poll_events_cb, &self); g_unix_signal_add (SIGINT, _sigint_cb, &self); -- GitLab