diff --git a/src/window/input.cpp b/src/window/input.cpp index 93554449..c305def4 100644 --- a/src/window/input.cpp +++ b/src/window/input.cpp @@ -84,12 +84,12 @@ int keycode::RIGHT_BRACKET = GLFW_KEY_RIGHT_BRACKET; #include #endif // _WIN32 -const char* keycode::name(int code) { +const std::string keycode::name(int code) { #ifdef _WIN32 char name[64]; int result = GetKeyNameTextA(glfwGetKeyScancode(code) << 16, name, 64); if (result == NULL) return "Unknown"; - return name; + return std::string(name); #else const char* name = glfwGetKeyName(code, glfwGetKeyScancode(code)); if (name == nullptr) { @@ -138,7 +138,7 @@ const char* keycode::name(int code) { return "Unknown"; } } - return name; + return std::string(name); #endif // _WIN32 } @@ -146,7 +146,7 @@ int mousecode::BUTTON_1 = GLFW_MOUSE_BUTTON_1; int mousecode::BUTTON_2 = GLFW_MOUSE_BUTTON_2; int mousecode::BUTTON_3 = GLFW_MOUSE_BUTTON_3; -const char* mousecode::name(int code) { +const std::string mousecode::name(int code) { switch (code) { case GLFW_MOUSE_BUTTON_1: return "LMB"; case GLFW_MOUSE_BUTTON_2: return "RMB"; diff --git a/src/window/input.h b/src/window/input.h index afc27935..289cd6ea 100644 --- a/src/window/input.h +++ b/src/window/input.h @@ -1,6 +1,8 @@ #ifndef WINDOW_INPUT_H_ #define WINDOW_INPUT_H_ +#include + namespace keycode { extern int ENTER; extern int TAB; @@ -81,7 +83,7 @@ namespace keycode { extern int LEFT_BRACKET; extern int RIGHT_BRACKET; - extern const char* name(int code); + extern const std::string name(int code); } namespace mousecode { @@ -89,7 +91,7 @@ namespace mousecode { extern int BUTTON_2; extern int BUTTON_3; - extern const char* name(int code); + extern const std::string name(int code); } enum class inputtype { @@ -111,7 +113,7 @@ struct Binding { return state && justChange; } - const char* text() const { + const std::string text() const { switch (type) { case inputtype::keyboard: return keycode::name(code); case inputtype::mouse: return mousecode::name(code);