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
const char* Input::keyToChar(unsigned short i)
{
if (i < SDL_NUM_SCANCODES)
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)
else if (i == MOUSEBUTTON1)
return "mouse1";
else if (i == MOUSEBUTTON2)
-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);
bool Input::MouseClicked()
{
return isKeyPressed(SDL_NUM_SCANCODES + SDL_BUTTON_LEFT);
static bool isKeyDown(int k);
static bool isKeyPressed(int k);
static const char* keyToChar(unsigned short which);
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();
};
static bool MouseClicked();
};