summaryrefslogtreecommitdiff
path: root/Source/Core/UICommon/USBUtils.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-23 19:15:52 -0500
committerLioncash <mathew1800@gmail.com>2019-11-23 19:41:40 -0500
commitb28db1d4e69c0a1011375f308198fde8e2f67d13 (patch)
tree6d33e27b3c20aadcb680badeb11bd45ace872668 /Source/Core/UICommon/USBUtils.cpp
parentec895f544cf23616483cea9fdb26a84d6264f844 (diff)
UICommon: Make use of fmt where applicable
Continues the migration to using fmt. Notably, this allows safely converting a map within USBUtils over to containing string view instances, rather than std::string instances, as fmt safely handles the formatting of string views.
Diffstat (limited to 'Source/Core/UICommon/USBUtils.cpp')
-rw-r--r--Source/Core/UICommon/USBUtils.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/Core/UICommon/USBUtils.cpp b/Source/Core/UICommon/USBUtils.cpp
index fe7ad51344..b9860636f1 100644
--- a/Source/Core/UICommon/USBUtils.cpp
+++ b/Source/Core/UICommon/USBUtils.cpp
@@ -2,19 +2,22 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "UICommon/USBUtils.h"
+
+#include <string_view>
+
+#include <fmt/format.h>
#ifdef __LIBUSB__
#include <libusb.h>
#endif
#include "Common/CommonTypes.h"
-#include "Common/StringUtil.h"
#include "Core/LibusbUtils.h"
-#include "UICommon/USBUtils.h"
// Because opening and getting the device name from devices is slow, especially on Windows
// with usbdk, we cannot do that for every single device. We should however still show
// device names for known Wii peripherals.
-static const std::map<std::pair<u16, u16>, std::string> s_wii_peripherals = {{
+static const std::map<std::pair<u16, u16>, std::string_view> s_wii_peripherals{{
{{0x046d, 0x0a03}, "Logitech Microphone"},
{{0x057e, 0x0308}, "Wii Speak"},
{{0x057e, 0x0309}, "Nintendo USB Microphone"},
@@ -54,7 +57,7 @@ std::map<std::pair<u16, u16>, std::string> GetInsertedDevices()
std::string GetDeviceName(const std::pair<u16, u16> vid_pid)
{
const auto iter = s_wii_peripherals.find(vid_pid);
- const std::string device_name = iter == s_wii_peripherals.cend() ? "Unknown" : iter->second;
- return StringFromFormat("%04x:%04x - %s", vid_pid.first, vid_pid.second, device_name.c_str());
+ const std::string_view device_name = iter == s_wii_peripherals.cend() ? "Unknown" : iter->second;
+ return fmt::format("{:04x}:{:04x} - {}", vid_pid.first, vid_pid.second, device_name);
}
} // namespace USBUtils