diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-08-08 14:59:41 +0300 | 
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-08-08 19:06:25 +0300 | 
| commit | 77d50cad495511a91ca1461d9e6f43a7e8656965 (patch) | |
| tree | ef39c565d6fe6a6b792f525ea0cb0b2cf294a624 /indra | |
| parent | 810d11c625cc71a0fbc15bb28cc770d5ea1670fd (diff) | |
viewer#2225 Fix Joystick Floater's FPS drops
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llfloaterjoystick.cpp | 33 | ||||
| -rw-r--r-- | indra/newview/llfloaterjoystick.h | 2 | 
2 files changed, 28 insertions, 7 deletions
| diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index 7db3621a4b..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();      } @@ -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() diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h index b94223a738..c7e727635d 100644 --- a/indra/newview/llfloaterjoystick.h +++ b/indra/newview/llfloaterjoystick.h @@ -95,6 +95,8 @@ private:      LLComboBox      *mJoysticksCombo;      bool mHasDeviceList; +    bool mJoystickInitialized; +    LLUUID mCurrentDeviceId;      // stats view      LLStatBar* mAxisStatsBar[6]; | 
