From 25272eefcc875e86597dd9c856e1af40d68ab1e0 Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Mon, 5 Jul 2010 19:15:29 +0200 Subject: revamp autoenable joystick --- linden/indra/newview/app_settings/settings.xml | 11 +++++++++++ linden/indra/newview/llappviewer.cpp | 8 +++++++- linden/indra/newview/llappviewerlinux.cpp | 2 +- linden/indra/newview/llfloaterjoystick.cpp | 16 +++++++++++++++- linden/indra/newview/llfloaterjoystick.h | 1 + linden/indra/newview/llviewerjoystick.cpp | 20 ++++++++++---------- linden/indra/newview/llviewerjoystick.h | 2 +- linden/indra/newview/llviewerwindow.cpp | 2 +- .../skins/default/xui/en-us/floater_joystick.xml | 3 ++- 9 files changed, 49 insertions(+), 16 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 1f4e16b..6fd76ac 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -6122,6 +6122,17 @@ Value 0 + JoystickAutoEnable + + Comment + Enables the Joystick at startup if plugged in. + Persist + 1 + Type + Boolean + Value + 0 + JoystickAvatarEnabled Comment diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index 7d2dac8..0c643b9 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -873,8 +873,14 @@ bool LLAppViewer::init() gSimLastTime = gRenderStartTime.getElapsedTimeF32(); gSimFrames = (F32)gFrameCount; - +/* +#if LL_DARWIN //on mac the mouse gets misdetected as joystick; don't autoenable LLViewerJoystick::getInstance()->init(false); +#else + LLViewerJoystick::getInstance()->init(true); +#endif +*/ + LLViewerJoystick::getInstance()->init(); return true; } diff --git a/linden/indra/newview/llappviewerlinux.cpp b/linden/indra/newview/llappviewerlinux.cpp index 39c2692..bb6cf9f 100644 --- a/linden/indra/newview/llappviewerlinux.cpp +++ b/linden/indra/newview/llappviewerlinux.cpp @@ -462,7 +462,7 @@ gboolean viewer_app_api_HotplugJoystick(ViewerAppAPI *obj, gchar *dummy, gboolea if (!joystick_inited) { - success = LLViewerJoystick::getInstance()->init(false); + success = LLViewerJoystick::getInstance()->init(); } *success_rtn = g_new (gboolean, 1); diff --git a/linden/indra/newview/llfloaterjoystick.cpp b/linden/indra/newview/llfloaterjoystick.cpp index 05e0564..960eebb 100644 --- a/linden/indra/newview/llfloaterjoystick.cpp +++ b/linden/indra/newview/llfloaterjoystick.cpp @@ -59,7 +59,7 @@ void LLFloaterJoystick::draw() bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized(); if (!joystick_inited) { - joystick_inited = LLViewerJoystick::getInstance()->init(false); + joystick_inited = LLViewerJoystick::getInstance()->init(); } childSetEnabled("enable_joystick", joystick_inited); childSetEnabled("joystick_type", joystick_inited); @@ -147,8 +147,21 @@ void LLFloaterJoystick::refresh() { LLFloater::refresh(); + bool joystick_inited = LLViewerJoystick::getInstance()->isJoystickInitialized(); + if (!joystick_inited) + { + joystick_inited = LLViewerJoystick::getInstance()->init(); + } + + mJoystickAutoEnable = gSavedSettings.getBOOL("JoystickAutoEnable"); + if (mJoystickAutoEnable && joystick_inited) + { + gSavedSettings.setBOOL("JoystickEnabled",true); + } + mJoystickEnabled = gSavedSettings.getBOOL("JoystickEnabled"); + mJoystickAxis[0] = gSavedSettings.getS32("JoystickAxis0"); mJoystickAxis[1] = gSavedSettings.getS32("JoystickAxis1"); mJoystickAxis[2] = gSavedSettings.getS32("JoystickAxis2"); @@ -217,6 +230,7 @@ void LLFloaterJoystick::refresh() void LLFloaterJoystick::cancel() { gSavedSettings.setBOOL("JoystickEnabled", mJoystickEnabled); + gSavedSettings.setBOOL("JoystickAutoEnable", mJoystickAutoEnable); gSavedSettings.setS32("JoystickAxis0", mJoystickAxis[0]); gSavedSettings.setS32("JoystickAxis1", mJoystickAxis[1]); diff --git a/linden/indra/newview/llfloaterjoystick.h b/linden/indra/newview/llfloaterjoystick.h index 3ce647e..7f6f34d 100644 --- a/linden/indra/newview/llfloaterjoystick.h +++ b/linden/indra/newview/llfloaterjoystick.h @@ -60,6 +60,7 @@ private: private: // Device prefs bool mJoystickEnabled; + bool mJoystickAutoEnable; S32 mJoystickAxis[7]; bool m3DCursor; bool mAutoLeveling; diff --git a/linden/indra/newview/llviewerjoystick.cpp b/linden/indra/newview/llviewerjoystick.cpp index 617ef13..4e509c7 100644 --- a/linden/indra/newview/llviewerjoystick.cpp +++ b/linden/indra/newview/llviewerjoystick.cpp @@ -82,7 +82,7 @@ void LLViewerJoystick::updateEnabled(bool autoenable) } else { - if (isLikeSpaceNavigator() && autoenable) + if (autoenable) { gSavedSettings.setBOOL("JoystickEnabled", TRUE ); } @@ -175,11 +175,13 @@ LLViewerJoystick::~LLViewerJoystick() } // ----------------------------------------------------------------------------- -bool LLViewerJoystick::init(bool autoenable) +bool LLViewerJoystick::init() { static bool libinit = false; #if LIB_NDOF + bool autoenable = gSavedSettings.getBOOL("JoystickAutoEnable"); + mDriverState = JDS_INITIALIZING; if (libinit == false) @@ -240,12 +242,7 @@ bool LLViewerJoystick::init(bool autoenable) } } - // Autoenable the joystick for recognized devices if nothing was connected previously - if (!autoenable) - { - autoenable = gSavedSettings.getString("JoystickInitialized").empty() ? true : false; - } - updateEnabled(autoenable); + if (mDriverState == JDS_INITIALIZED) { @@ -265,8 +262,11 @@ bool LLViewerJoystick::init(bool autoenable) // It's not a Space Navigator gSavedSettings.setString("JoystickInitialized", "UnknownDevice"); } - - gSavedSettings.setBOOL("JoystickEnabled", TRUE ); + // Autoenable the joystick for recognized devices if nothing was connected previously + if (autoenable) + { + updateEnabled(autoenable); + } } else { diff --git a/linden/indra/newview/llviewerjoystick.h b/linden/indra/newview/llviewerjoystick.h index 3718831..25a3e99 100644 --- a/linden/indra/newview/llviewerjoystick.h +++ b/linden/indra/newview/llviewerjoystick.h @@ -55,7 +55,7 @@ public: LLViewerJoystick(); virtual ~LLViewerJoystick(); - bool init(bool autoenable); + bool init(); void updateStatus(); void scanJoystick(); void moveObjects(bool reset = false); diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index f8953c0..c89e0c5 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp @@ -1166,7 +1166,7 @@ BOOL LLViewerWindow::handleDeviceChange(LLWindow *window) // give a chance to use a joystick after startup (hot-plugging) if (!LLViewerJoystick::getInstance()->isJoystickInitialized() ) { - LLViewerJoystick::getInstance()->init(true); + LLViewerJoystick::getInstance()->init(); return TRUE; } return FALSE; diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_joystick.xml b/linden/indra/newview/skins/default/xui/en-us/floater_joystick.xml index 88e364e..c7a97f0 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_joystick.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_joystick.xml @@ -3,8 +3,9 @@ name="Joystick" title="Joystick Configuration" width="550"> Enable Joystick: + - + Auto-Enable Joystick -- cgit v1.1