[retro-gtk/wip/aplazas/core-view: 7/8] retro-demo: Add pointer support from CoreView



commit 368821272213d84db38944c22d7137d3c1796e4f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Jul 30 12:50:50 2017 +0100

    retro-demo: Add pointer support from CoreView

 demos/retro-demo.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/demos/retro-demo.c b/demos/retro-demo.c
index 28091b7..8093da8 100644
--- a/demos/retro-demo.c
+++ b/demos/retro-demo.c
@@ -13,6 +13,7 @@ struct _RetroDemoApplication
   GtkApplicationWindow *window;
 
   RetroCore *core;
+  RetroInputDeviceManager *input;
   RetroMainLoop *loop;
   RetroCoreView *view;
   RetroPaPlayer *pa_player;
@@ -53,6 +54,9 @@ retro_demo_open (GApplication  *application,
     return;
   }
 
+  self->input = retro_input_device_manager_new ();
+  retro_core_set_input_interface (self->core, RETRO_INPUT (self->input));
+
   g_application_activate (application);
 }
 
@@ -70,6 +74,9 @@ retro_demo_application_finalize (GObject *object)
   if (self->core != NULL)
     g_object_unref (self->core);
 
+  if (self->input != NULL)
+    g_object_unref (self->input);
+
   if (self->loop != NULL)
     g_object_unref (self->loop);
 
@@ -85,6 +92,7 @@ retro_demo_activate (GApplication *application)
 {
   RetroDemoApplication *self;
   GtkWidget *window;
+  RetroInputDevice *input_device;
 
   self = RETRO_DEMO_APPLICATION (application);
 
@@ -93,6 +101,11 @@ retro_demo_activate (GApplication *application)
   self->view = retro_core_view_new ();
   retro_core_view_set_core (self->view, self->core);
 
+  retro_input_device_manager_set_keyboard (self->input, GTK_WIDGET (self->view));
+  input_device = retro_core_view_as_input_device (self->view, RETRO_DEVICE_TYPE_POINTER);
+  retro_input_device_manager_set_controller_device (self->input, 0, input_device);
+  g_object_unref (input_device);
+
   self->pa_player = retro_pa_player_new ();
   retro_pa_player_set_core (self->pa_player, self->core);
 


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