diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-28 19:05:09 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2024-02-02 08:44:55 -0800 |
commit | d29f532a5d9a05a6ad4f7063240ffe0e168438bb (patch) | |
tree | 6e19a4f51e4f6bc8da209a2bfccae3dbefb8ee4f | |
parent | bcca740f4de99c14b54ba4402755ab12cbf1bb5b (diff) |
[Android][Peripherals] Change push_back to emplace_back
-rw-r--r-- | xbmc/platform/android/peripherals/AndroidJoystickState.cpp | 58 | ||||
-rw-r--r-- | xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp | 4 |
2 files changed, 31 insertions, 31 deletions
diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp index 5d898698fc..bc860be5e5 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp @@ -54,15 +54,15 @@ static void MapAxisIds(int axisId, if (axisIds.empty()) { - axisIds.push_back(primaryAxisId); - axisIds.push_back(secondaryAxisId); + axisIds.emplace_back(primaryAxisId); + axisIds.emplace_back(secondaryAxisId); } if (axisIds.size() > 1) return; if (axisId == primaryAxisId) - axisIds.push_back(secondaryAxisId); + axisIds.emplace_back(secondaryAxisId); else if (axisId == secondaryAxisId) axisIds.insert(axisIds.begin(), primaryAxisId); } @@ -140,10 +140,10 @@ bool CAndroidJoystickState::Initialize(const CJNIViewInputDevice& inputDevice) MapAxisIds(axisId, AMOTION_EVENT_AXIS_LTRIGGER, AMOTION_EVENT_AXIS_BRAKE, axis.ids); MapAxisIds(axisId, AMOTION_EVENT_AXIS_RTRIGGER, AMOTION_EVENT_AXIS_GAS, axis.ids); - m_axes.push_back(axis); + m_axes.emplace_back(std::move(axis)); CLog::Log(LOGDEBUG, "CAndroidJoystickState: axis {} on input device \"{}\" with ID {} detected", - PrintAxisIds(axis.ids), deviceName, m_deviceId); + PrintAxisIds(m_axes.back().ids), deviceName, m_deviceId); } else CLog::Log(LOGWARNING, @@ -152,29 +152,29 @@ bool CAndroidJoystickState::Initialize(const CJNIViewInputDevice& inputDevice) } // add the usual suspects - m_buttons.push_back({{AKEYCODE_BUTTON_A}}); - m_buttons.push_back({{AKEYCODE_BUTTON_B}}); - m_buttons.push_back({{AKEYCODE_BUTTON_C}}); - m_buttons.push_back({{AKEYCODE_BUTTON_X}}); - m_buttons.push_back({{AKEYCODE_BUTTON_Y}}); - m_buttons.push_back({{AKEYCODE_BUTTON_Z}}); - m_buttons.push_back({{AKEYCODE_BACK}}); - m_buttons.push_back({{AKEYCODE_MENU}}); - m_buttons.push_back({{AKEYCODE_HOME}}); - m_buttons.push_back({{AKEYCODE_BUTTON_SELECT}}); - m_buttons.push_back({{AKEYCODE_BUTTON_MODE}}); - m_buttons.push_back({{AKEYCODE_BUTTON_START}}); - m_buttons.push_back({{AKEYCODE_BUTTON_L1}}); - m_buttons.push_back({{AKEYCODE_BUTTON_R1}}); - m_buttons.push_back({{AKEYCODE_BUTTON_L2}}); - m_buttons.push_back({{AKEYCODE_BUTTON_R2}}); - m_buttons.push_back({{AKEYCODE_BUTTON_THUMBL}}); - m_buttons.push_back({{AKEYCODE_BUTTON_THUMBR}}); - m_buttons.push_back({{AKEYCODE_DPAD_UP}}); - m_buttons.push_back({{AKEYCODE_DPAD_RIGHT}}); - m_buttons.push_back({{AKEYCODE_DPAD_DOWN}}); - m_buttons.push_back({{AKEYCODE_DPAD_LEFT}}); - m_buttons.push_back({{AKEYCODE_DPAD_CENTER}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_A}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_B}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_C}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_X}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_Y}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_Z}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BACK}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_MENU}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_HOME}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_SELECT}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_MODE}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_START}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_L1}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_R1}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_L2}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_R2}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_THUMBL}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_BUTTON_THUMBR}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_DPAD_UP}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_DPAD_RIGHT}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_DPAD_DOWN}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_DPAD_LEFT}}); + m_buttons.emplace_back(JoystickAxis{{AKEYCODE_DPAD_CENTER}}); // check if there are no buttons or axes at all if (GetButtonCount() == 0 && GetAxisCount() == 0) @@ -237,7 +237,7 @@ bool CAndroidJoystickState::ProcessEvent(const AInputEvent* event) // get all potential values std::vector<float> values; for (const auto& axisId : axis.ids) - values.push_back(AMotionEvent_getAxisValue(event, axisId, pointer)); + values.emplace_back(AMotionEvent_getAxisValue(event, axisId, pointer)); // remove all zero values values.erase(std::remove(values.begin(), values.end(), 0.0f), values.end()); diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp index 74b78849e5..739d501861 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp @@ -208,7 +208,7 @@ void CPeripheralBusAndroid::OnInputDeviceAdded(int deviceId) PeripheralScanResult result; if (!ConvertToPeripheralScanResult(device, result)) return; - m_scanResults.m_results.push_back(result); + m_scanResults.m_results.emplace_back(std::move(result)); } CLog::Log(LOGDEBUG, "CPeripheralBusAndroid: input device with ID {} added", deviceId); @@ -345,7 +345,7 @@ PeripheralScanResults CPeripheralBusAndroid::GetInputDevices() continue; CLog::Log(LOGINFO, "CPeripheralBusAndroid: added input device"); - results.m_results.push_back(result); + results.m_results.emplace_back(std::move(result)); } return results; |