summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterjoystick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterjoystick.cpp')
-rw-r--r--indra/newview/llfloaterjoystick.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index 128cf56be0..68b11ec92b 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -93,8 +93,9 @@ BOOL CALLBACK di8_list_devices_callback(LPCDIDEVICEINSTANCE device_instance_ptr,
#endif
LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
- : LLFloater(data),
- mHasDeviceList(false)
+ : LLFloater(data)
+ , mHasDeviceList(false)
+ , mJoystickInitialized(false)
{
if (!LLViewerJoystick::getInstance()->isJoystickInitialized())
{
@@ -108,7 +109,10 @@ void LLFloaterJoystick::draw()
{
LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
bool joystick_inited = joystick->isJoystickInitialized();
- if (joystick_inited != mHasDeviceList)
+ if (!mHasDeviceList
+ || mJoystickInitialized != joystick_inited
+ || (joystick->isDeviceUUIDSet() && joystick->getDeviceUUID().asUUID() != mCurrentDeviceId)
+ || (!joystick->isDeviceUUIDSet() && mCurrentDeviceId.notNull()))
{
refreshListOfDevices();
}
@@ -132,7 +136,7 @@ void LLFloaterJoystick::draw()
LLFloater::draw();
}
-BOOL LLFloaterJoystick::postBuild()
+bool LLFloaterJoystick::postBuild()
{
center();
F32 range = gSavedSettings.getBOOL("Cursor3D") ? 128.f : 2.f;
@@ -160,7 +164,7 @@ BOOL LLFloaterJoystick::postBuild()
refresh();
refreshListOfDevices();
- return TRUE;
+ return true;
}
LLFloaterJoystick::~LLFloaterJoystick()
@@ -290,15 +294,16 @@ void LLFloaterJoystick::refreshListOfDevices()
mHasDeviceList = true;
}
- bool is_device_id_set = LLViewerJoystick::getInstance()->isDeviceUUIDSet();
+ LLViewerJoystick* joystick = LLViewerJoystick::getInstance();
+ bool is_device_id_set = joystick->isDeviceUUIDSet();
- if (LLViewerJoystick::getInstance()->isJoystickInitialized() &&
+ if (joystick->isJoystickInitialized() &&
(!mHasDeviceList || !is_device_id_set))
{
#if LL_WINDOWS && !LL_MESA_HEADLESS
LL_WARNS() << "NDOF connected to device without using SL provided handle" << LL_ENDL;
#endif
- std::string desc = LLViewerJoystick::getInstance()->getDescription();
+ std::string desc = joystick->getDescription();
if (!desc.empty())
{
LLSD value = LLSD::Integer(1); // value for selection
@@ -311,11 +316,13 @@ void LLFloaterJoystick::refreshListOfDevices()
{
if (is_device_id_set)
{
- LLSD guid = LLViewerJoystick::getInstance()->getDeviceUUID();
+ LLSD guid = joystick->getDeviceUUID();
+ mCurrentDeviceId = guid.asUUID();
mJoysticksCombo->selectByValue(guid);
}
else
{
+ mCurrentDeviceId.setNull();
mJoysticksCombo->selectByValue(LLSD::Integer(1));
}
}
@@ -323,6 +330,18 @@ void LLFloaterJoystick::refreshListOfDevices()
{
mJoysticksCombo->selectByValue(LLSD::Integer(0));
}
+
+ // Update tracking
+ if (is_device_id_set)
+ {
+ LLSD guid = joystick->getDeviceUUID();
+ mCurrentDeviceId = guid.asUUID();
+ }
+ else
+ {
+ mCurrentDeviceId.setNull();
+ }
+ mJoystickInitialized = joystick->isJoystickInitialized();
}
void LLFloaterJoystick::cancel()
@@ -416,7 +435,7 @@ void LLFloaterJoystick::onCommitJoystickEnabled(LLUICtrl*, void *joy_panel)
joystick_enabled = true;
}
gSavedSettings.setBOOL("JoystickEnabled", joystick_enabled);
- BOOL flycam_enabled = self->mCheckFlycamEnabled->get();
+ bool flycam_enabled = self->mCheckFlycamEnabled->get();
if (!joystick_enabled || !flycam_enabled)
{