From 31191d0c0118f6abfccd7bf3ecc13bbfef3fa335 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sat, 17 Dec 2016 20:42:12 +0100 Subject: [PATCH] Fixes #62 fixed button names display MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Note that this cause problem because of the incomplete font we use: I mapped the key «é» to draw weapon and it can’t be shown in the menu. We should switch to a more complete font --- Source/Utils/Input.cpp | 20 +------------------- Source/Utils/Input.hpp | 1 - 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Source/Utils/Input.cpp b/Source/Utils/Input.cpp index 30667c7..04efb4b 100644 --- a/Source/Utils/Input.cpp +++ b/Source/Utils/Input.cpp @@ -56,7 +56,7 @@ bool Input::isKeyPressed(int k) const char* Input::keyToChar(unsigned short i) { if (i < SDL_NUM_SCANCODES) - return SDL_GetScancodeName(SDL_Scancode(i)); + return SDL_GetKeyName(SDL_GetKeyFromScancode(SDL_Scancode(i))); else if (i == MOUSEBUTTON1) return "mouse1"; else if (i == MOUSEBUTTON2) @@ -67,24 +67,6 @@ const char* Input::keyToChar(unsigned short i) return "unknown"; } -unsigned short Input::CharToKey(const char* which) -{ - for (unsigned short i = 0; i < SDL_NUM_SCANCODES; i++) { - if (!strcasecmp(which, SDL_GetScancodeName(SDL_Scancode(i)))) - return i; - } - if (!strcasecmp(which, "mouse1")) { - return MOUSEBUTTON1; - } - if (!strcasecmp(which, "mouse2")) { - return MOUSEBUTTON2; - } - if (!strcasecmp(which, "mouse3")) { - return MOUSEBUTTON3; - } - return SDL_NUM_SCANCODES; -} - bool Input::MouseClicked() { return isKeyPressed(SDL_NUM_SCANCODES + SDL_BUTTON_LEFT); diff --git a/Source/Utils/Input.hpp b/Source/Utils/Input.hpp index af83cb1..66a896d 100644 --- a/Source/Utils/Input.hpp +++ b/Source/Utils/Input.hpp @@ -38,7 +38,6 @@ public: static bool isKeyDown(int k); static bool isKeyPressed(int k); static const char* keyToChar(unsigned short which); - static unsigned short CharToKey(const char* which); static bool MouseClicked(); }; -- 2.39.5