diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index c067b78a7..2795ce016 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -126,7 +126,7 @@ BOOL LLFloaterJoystick::postBuild() mCheckFlycamEnabled = getChild("JoystickFlycamEnabled"); childSetCommitCallback("JoystickFlycamEnabled",onCommitJoystickEnabled,this); - childSetAction("SpaceNavigatorDefaults", onClickRestoreSNDefaults, this); + getChild("Default")->setCommitCallback(boost::bind(&LLFloaterJoystick::onClickDefault, this, _2)); childSetAction("cancel_btn", onClickCancel, this); childSetAction("ok_btn", onClickOK, this); @@ -301,9 +301,14 @@ void LLFloaterJoystick::onCommitJoystickEnabled(LLUICtrl*, void *joy_panel) } } -void LLFloaterJoystick::onClickRestoreSNDefaults(void *joy_panel) +S32 get_joystick_type(); +void LLFloaterJoystick::onClickDefault(const LLSD& val) { - setSNDefaults(); + S32 type(val.asInteger()); + if (val.isUndefined()) // If button portion, set to default for device. + if ((type = get_joystick_type()) == -1) // Invalid/No device + return; + LLViewerJoystick::getInstance()->setSNDefaults(type); } void LLFloaterJoystick::onClickCancel(void *joy_panel) @@ -332,8 +337,3 @@ void LLFloaterJoystick::onClickOK(void *joy_panel) } } } - -void LLFloaterJoystick::setSNDefaults() -{ - LLViewerJoystick::getInstance()->setSNDefaults(); -} diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h index 3ce647e5b..07b4b49c7 100644 --- a/indra/newview/llfloaterjoystick.h +++ b/indra/newview/llfloaterjoystick.h @@ -49,11 +49,10 @@ public: virtual void apply(); // Apply the changed values. virtual void cancel(); // Cancel the changed values. virtual void draw(); - static void setSNDefaults(); private: static void onCommitJoystickEnabled(LLUICtrl*, void*); - static void onClickRestoreSNDefaults(void*); + void onClickDefault(const LLSD& val); static void onClickCancel(void*); static void onClickOK(void*); diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 8113310a0..c30a3af80 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -109,6 +109,15 @@ enum DS3Keys DS3_START_KEY, DS3_LOGO_KEY }; + +S32 get_joystick_type() +{ + if (sType == SPACE_NAV) return 0; + if (sType == XBOX) return isOUYA(LLViewerJoystick::getInstance()->getDescription()) ? 1 : 2; + if (sType == DS3) return 3; + + return -1; // sType == NONE || sType == UNKNOWN +} // // These constants specify the maximum absolute value coming in from the device. @@ -312,11 +321,12 @@ void LLViewerJoystick::init(bool autoenable) { sType = XBOX; // It's an Xbox controller, we have defaults for it. - std::string controller = isOUYA(desc) ? "OUYA" : "XboxController"; + bool ouya(isOUYA(desc)); + std::string controller = ouya ? "OUYA" : "XboxController"; if (gSavedSettings.getString("JoystickInitialized") != controller) { // Only set the defaults if we haven't already (in case they were overridden) - setSNDefaults(); + setSNDefaults(ouya ? 1 : 2); gSavedSettings.setString("JoystickInitialized", controller); } } @@ -327,7 +337,7 @@ void LLViewerJoystick::init(bool autoenable) if (gSavedSettings.getString("JoystickInitialized") != "DualShock3") { // Only set the defaults if we haven't already (in case they were overridden) - setSNDefaults(); + setSNDefaults(3); gSavedSettings.setString("JoystickInitialized", "DualShock3"); } } @@ -1366,7 +1376,7 @@ bool LLViewerJoystick::isLikeSpaceNavigator() const } // ----------------------------------------------------------------------------- -void LLViewerJoystick::setSNDefaults() +void LLViewerJoystick::setSNDefaults(S32 type) { #if LL_DARWIN || LL_LINUX const float platformScale = 20.f; @@ -1380,9 +1390,9 @@ void LLViewerJoystick::setSNDefaults() #endif //gViewerWindow->alertXml("CacheWillClear"); - const bool xbox = sType == XBOX; - const bool ouya = xbox && isOUYA(getDescription()); - const bool ds3 = sType == DS3; + const bool ouya = type == 1; + const bool xbox = ouya || type == 2; + const bool ds3 = type == 3; llinfos << "restoring " << (xbox ? ouya ? "OUYA Game Controller" : "Xbox Controller" : ds3 ? "Dual Shock 3" : "SpaceNavigator") << " defaults..." << llendl; /* diff --git a/indra/newview/llviewerjoystick.h b/indra/newview/llviewerjoystick.h index 308f52bc6..058821bcd 100644 --- a/indra/newview/llviewerjoystick.h +++ b/indra/newview/llviewerjoystick.h @@ -67,7 +67,7 @@ public: bool getOverrideCamera() { return mOverrideCamera; } void setOverrideCamera(bool val); bool toggleFlycam(); - void setSNDefaults(); + void setSNDefaults(S32 type = 0); std::string getDescription(); protected: diff --git a/indra/newview/skins/default/xui/en-us/floater_joystick.xml b/indra/newview/skins/default/xui/en-us/floater_joystick.xml index d8a068948..5b32f1780 100644 --- a/indra/newview/skins/default/xui/en-us/floater_joystick.xml +++ b/indra/newview/skins/default/xui/en-us/floater_joystick.xml @@ -92,8 +92,13 @@ Zoom Dead Zone -