summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-06-19 02:18:30 +0200
committerGitHub <noreply@github.com>2023-06-19 02:18:30 +0200
commit5d7b5822c97285a1b45f54b2ae8046808cbe54d2 (patch)
tree341d0c17ea3ea9e364cac57ebb1b86270e904528 /Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
parent9e06b6964b04829d526609b3cf98bca58f80c318 (diff)
parentffabb6c57b59c6ceafd154681c2cde1bd1a65904 (diff)
Merge pull request #11972 from Minty-Meeo/string-improvements-part-1c
Replace std::ostringstream usage with fmt::format
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index abef48f157..eb60721b2f 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -7,9 +7,10 @@
#include <limits>
#include <mutex>
#include <set>
-#include <sstream>
#include <type_traits>
+#include <fmt/format.h>
+
#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
@@ -266,37 +267,21 @@ void Joystick::UpdateInput()
std::string Joystick::Button::GetName() const
{
- std::ostringstream ss;
- ss << "Button " << (int)m_index;
- return ss.str();
+ return fmt::format("Button {}", m_index);
}
std::string Joystick::Axis::GetName() const
{
- std::ostringstream ss;
- // axis
- if (m_index < 6)
- {
- ss << "Axis " << (char)('X' + (m_index % 3));
- if (m_index > 2)
- ss << 'r';
- }
- // slider
- else
- {
- ss << "Slider " << (int)(m_index - 6);
- }
-
- ss << (m_range < 0 ? '-' : '+');
- return ss.str();
+ const char sign = m_range < 0 ? '-' : '+';
+ if (m_index < 6) // axis
+ return fmt::format("Axis {:c}{}{:c}", 'X' + m_index % 3, m_index > 2 ? "r" : "", sign);
+ else // slider
+ return fmt::format("Slider {}{:c}", m_index - 6, sign);
}
std::string Joystick::Hat::GetName() const
{
- char tmpstr[] = "Hat . .";
- tmpstr[4] = (char)('0' + m_index);
- tmpstr[6] = "NESW"[m_direction];
- return tmpstr;
+ return fmt::format("Hat {} {:c}", m_index, "NESW"[m_direction]);
}
// get / set state