summaryrefslogtreecommitdiffstats
path: root/game/client/config/gamepad_button.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
committeruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
commitaaed751bf4430bf4b9b30cef532b8753b9f639ce (patch)
tree16bc751c272ba27ad53ec48dbdd3a6d9e6a8d4c2 /game/client/config/gamepad_button.cc
parent96bd73ae020ecca1f94698744c77498a89ad19f7 (diff)
downloadvoxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2
voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip
Replace most of C strings with string_view
Diffstat (limited to 'game/client/config/gamepad_button.cc')
-rw-r--r--game/client/config/gamepad_button.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/game/client/config/gamepad_button.cc b/game/client/config/gamepad_button.cc
index b983baa..07e4457 100644
--- a/game/client/config/gamepad_button.cc
+++ b/game/client/config/gamepad_button.cc
@@ -6,9 +6,9 @@
#include "client/io/gamepad.hh"
-constexpr static const char* UNKNOWN_BUTTON_NAME = "UNKNOWN";
+constexpr static std::string_view UNKNOWN_BUTTON_NAME = "UNKNOWN";
-static const std::pair<int, const char*> button_names[] = {
+static const std::pair<int, std::string_view> button_names[] = {
{ GLFW_GAMEPAD_BUTTON_A, "A" },
{ GLFW_GAMEPAD_BUTTON_B, "B" },
{ GLFW_GAMEPAD_BUTTON_X, "X" },
@@ -26,7 +26,7 @@ static const std::pair<int, const char*> button_names[] = {
{ GLFW_GAMEPAD_BUTTON_DPAD_LEFT, "DPAD_LEFT" },
};
-static const char* get_button_name(int button)
+static std::string_view get_button_name(int button)
{
for(const auto& it : button_names) {
if(it.first == button) {
@@ -49,15 +49,15 @@ config::GamepadButton::GamepadButton(int button)
m_name = get_button_name(button);
}
-const char* config::GamepadButton::get(void) const
+std::string_view config::GamepadButton::get(void) const
{
return m_name;
}
-void config::GamepadButton::set(const char* value)
+void config::GamepadButton::set(std::string_view value)
{
for(const auto& it : button_names) {
- if(!std::strcmp(it.second, value)) {
+ if(0 == it.second.compare(value)) {
m_gamepad_button = it.first;
m_name = it.second;
return;