small fix
This commit is contained in:
parent
0a196b0090
commit
9629135791
@ -84,12 +84,12 @@ int keycode::RIGHT_BRACKET = GLFW_KEY_RIGHT_BRACKET;
|
||||
#include <windows.h>
|
||||
#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";
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef WINDOW_INPUT_H_
|
||||
#define WINDOW_INPUT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user