[retro-gtk/wip/aplazas/core-view-joypad: 6/7] retro-demo: Add joypad support from CoreView
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/core-view-joypad: 6/7] retro-demo: Add joypad support from CoreView
- Date: Fri, 4 Aug 2017 19:41:17 +0000 (UTC)
commit 22f8677ea687f69169548f7c31b179c2833e66fc
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Jul 30 12:50:50 2017 +0100
retro-demo: Add joypad 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..1ad258a 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_JOYPAD);
+ 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]