Idea!: Set to defaults flyout button with options for all styles of joystick controller

The button portion does nothing if there is an unknown or no controller connected, otherwise it sets defaults for the controller's identified type.

Joystick buttons are still configured based on identification, however.
DS3 users will likely find that using Motion in Joy switchboards is much more effective, however.
This commit is contained in:
Inusaito Sayori
2014-07-10 22:38:30 -04:00
parent ed8416ea10
commit 8583a2f4f7
9 changed files with 40 additions and 27 deletions

View File

@@ -126,7 +126,7 @@ BOOL LLFloaterJoystick::postBuild()
mCheckFlycamEnabled = getChild<LLCheckBoxCtrl>("JoystickFlycamEnabled");
childSetCommitCallback("JoystickFlycamEnabled",onCommitJoystickEnabled,this);
childSetAction("SpaceNavigatorDefaults", onClickRestoreSNDefaults, this);
getChild<LLUICtrl>("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();
}

View File

@@ -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*);

View File

@@ -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
}
// </Singu>
// 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;
/*

View File

@@ -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:

View File

@@ -92,8 +92,13 @@
<text bottom="-450" left="20" width="94" halign="right" name="ZoomDeadZone">Zoom Dead Zone</text>
<spinner bottom="-450" left="265" width="56" label_width="0" control_name="FlycamAxisDeadZone6" name="FlycamAxisDeadZone6" decimal_digits="2" increment="0.01" min_val="0" max_val="1"/>
<button bottom="-451" left="340" height="22" label="SpaceNavigator Defaults" name="SpaceNavigatorDefaults" scale_image="true" width="184"/>
<flyout_button bottom="-451" left="340" height="22" label="Set to Defaults" name="Default" width="184">
<flyout_button_item value="0" name="Space Navigator" label="Space Navigator"/>
<flyout_button_item value="1" name="OUYA" label="OUYA Controller"/>
<flyout_button_item value="2" name="XBOX" label="XBOX Controller"/>
<flyout_button_item value="3" name="DS3" label="DualShock 3"/>
</flyout_button>
<button bottom="-480" left="340" height="20" label="OK" label_selected="OK" name="ok_btn" width="90"/>
<button bottom="-480" left_delta="94" height="20" label="Cancel" label_selected="Cancel" name="cancel_btn" width="90"/>
</floater>

View File

@@ -79,7 +79,6 @@
<text name="ZoomDeadZone">
Zona Muerta de Zoom
</text>
<button label="Predeterminado SpaceNavigator" name="SpaceNavigatorDefaults" left="330" width="210"/>
<button label="OK" label_selected="OK" name="ok_btn"/>
<button label="Cancelar" label_selected="Cancelar" name="cancel_btn"/>
</floater>

View File

@@ -11,10 +11,13 @@
</string>
<string name="NoDevice">
aucun joystick détecté
</string>
<spinner name="JoystickAxis1" label="Mapping axe des X "/>
</string>
<spinner name="JoystickAxis1" label="Mapping axe des X "/>
<spinner name="JoystickAxis4" label="Mapping du tangage" label_width="111" left="8" width="152"/>
<spinner name="JoystickAxis6" label="Mapping du zoom"/>
<spinner name="JoystickAxis2" label="Mapping axe des Y"/>
<spinner name="JoystickAxis6" label="Mapping du zoom"/>
<spinner name="JoystickAxis5" label="Mapping du lacet"/>
<spinner name="JoystickAxis0" label="Mapping axe des Z"/>
<spinner name="JoystickAxis3" label="Mapping du roulis"/>
<check_box label="Zoom direct" name="ZoomDirect"/>
<check_box label="Curseur 3D" name="Cursor3D"/>
@@ -76,7 +79,6 @@
<text name="ZoomDeadZone" left="6" width="110">
Zone neutre du zoom
</text>
<text name="ZoomDeadZone" left="6" width="110">
<button label="OK" label_selected="OK" name="ok_btn"/>
<button label="Annuler" label_selected="Annuler" name="cancel_btn"/>
</floater>

View File

@@ -71,7 +71,6 @@
<text name="ZoomDeadZone" width="135" left="6">
Angolo morto dello zoom
</text>
<button label="SpaceNavigator Defaults" name="SpaceNavigatorDefaults"/>
<button label="OK" label_selected="OK" name="ok_btn"/>
<button label="Annulla" label_selected="Annulla" name="cancel_btn"/>
<string name="JoystickMonitor">

View File

@@ -71,7 +71,6 @@
<text name="ZoomDeadZone" width="110" left="4">
Zona Morta de Zoom
</text>
<button label="Padrões do SpaceNavigator" name="SpaceNavigatorDefaults" font="SansSerifSmall"/>
<button label="OK" label_selected="OK" name="ok_btn"/>
<button label="Cancelar" label_selected="Cancelar" name="cancel_btn"/>
<string name="JoystickMonitor">