From 1ac763405f15934beb156a9db67337de84a68755 Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Thu, 1 Jul 2010 15:19:49 +0200 Subject: add dbus method to retry joystick detection --- linden/indra/newview/llappviewerlinux.cpp | 23 +++++++++++++++++++++++ linden/indra/newview/llappviewerlinux.h | 1 + linden/indra/newview/llappviewerlinux_api.h | 8 +++++--- 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/llappviewerlinux.cpp b/linden/indra/newview/llappviewerlinux.cpp index 4372053..39c2692 100644 --- a/linden/indra/newview/llappviewerlinux.cpp +++ b/linden/indra/newview/llappviewerlinux.cpp @@ -65,6 +65,7 @@ #if LL_DBUS_ENABLED #include "llappviewerlinux_api.h" +#include "llviewerjoystick.h" #endif namespace @@ -452,6 +453,28 @@ gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **succ return TRUE; // the invokation succeeded, even if the actual dispatch didn't. } +gboolean viewer_app_api_HotplugJoystick(ViewerAppAPI *obj, gchar *dummy, gboolean **success_rtn, GError **error) +{ + + llinfos << "Joystick plugged in: " << dummy << llendl; + bool success = false; + bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized(); + + if (!joystick_inited) + { + success = LLViewerJoystick::getInstance()->init(false); + } + + *success_rtn = g_new (gboolean, 1); + (*success_rtn)[0] = (gboolean)success; + + return TRUE; // the invokation succeeded, even if the actual dispatch didn't. + + // TODO: fire this by the spacenavi udev rule. + // for testing plug in joystick while Imprudence is running and type in a + // console: dbus-send --type=method_call --dest=com.secondlife.ViewerAppAPIService /com/secondlife/ViewerAppAPI com.secondlife.ViewerAppAPI.HotplugJoystick string:'dummy' +} + /// //virtual diff --git a/linden/indra/newview/llappviewerlinux.h b/linden/indra/newview/llappviewerlinux.h index d757639..84074ec 100644 --- a/linden/indra/newview/llappviewerlinux.h +++ b/linden/indra/newview/llappviewerlinux.h @@ -84,6 +84,7 @@ typedef struct extern "C" { gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **success_rtn, GError **error); + gboolean viewer_app_api_HotplugJoystick(ViewerAppAPI *obj, gchar *dummy, gboolean **success_rtn, GError **error); } #define VIEWERAPI_SERVICE "com.secondlife.ViewerAppAPIService" diff --git a/linden/indra/newview/llappviewerlinux_api.h b/linden/indra/newview/llappviewerlinux_api.h index 56b88fb..812f38c 100644 --- a/linden/indra/newview/llappviewerlinux_api.h +++ b/linden/indra/newview/llappviewerlinux_api.h @@ -134,16 +134,18 @@ G_END_DECLS #endif /* __dbus_glib_marshal_viewerapp_MARSHAL_H__ */ #include +//read http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/DBus/Using_GLib_Wrappers_For_D-Bus static const DBusGMethodInfo dbus_glib_viewerapp_methods[] = { { (GCallback) viewer_app_api_GoSLURL, dbus_glib_marshal_viewerapp_BOOLEAN__STRING_POINTER_POINTER, 0 }, + { (GCallback) viewer_app_api_HotplugJoystick, dbus_glib_marshal_viewerapp_BOOLEAN__STRING_POINTER_POINTER, 70 },// at position 70 chars offset, counting from 0 }; const DBusGObjectInfo dbus_glib_viewerapp_object_info = { 0, dbus_glib_viewerapp_methods, - 1, -"com.secondlife.ViewerAppAPI\0GoSLURL\0S\0slurl\0I\0s\0success_ret\0O\0F\0N\0b\0\0\0", + 2, //number of methods (counting from 1) +"com.secondlife.ViewerAppAPI\0GoSLURL\0S\0slurl\0I\0s\0success_ret\0O\0F\0N\0b\0\0\0" //no comma; this is where the 70 chars are from ... see above ... counting from 0, yeah without quotes and escape +"com.secondlife.ViewerAppAPI\0HotplugJoystick\0S\0dummy\0I\0s\0success_ret\0O\0F\0N\0b\0\0\0", "\0", "\0" }; - -- cgit v1.1