Big leap for key rebinding and crossplatform-ness.

This commit is contained in:
iProgramInCpp
2023-08-22 17:25:24 +03:00
parent f3fc78e151
commit d3ef629471
10 changed files with 248 additions and 279 deletions

View File

@@ -107,7 +107,22 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
break;
}
#else
char chr = '\0';
// here we'll just use the raw key codes...
#ifdef _WIN32
#define AKEYCODE_FORWARD_DEL VK_DELETE
#define AKEYCODE_ARROW_LEFT VK_LEFT
#define AKEYCODE_ARROW_RIGHT VK_RIGHT
#define AKEYCODE_DEL VK_BACK
#elif defined(USE_SDL)
#define AKEYCODE_FORWARD_DEL SDLK_DELETE
#define AKEYCODE_ARROW_LEFT SDLK_LEFT
#define AKEYCODE_ARROW_RIGHT SDLK_RIGHT
#define AKEYCODE_DEL SDLK_BACKSPACE
#endif
switch (key)
{
case AKEYCODE_FORWARD_DEL:
@@ -127,6 +142,15 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
}
#endif
#ifdef AKEYCODE_FORWARD_DEL
#undef AKEYCODE_FORWARD_DEL
#undef AKEYCODE_ARROW_LEFT
#undef AKEYCODE_ARROW_RIGHT
#endif
#ifdef AKEYCODE_DEL
#undef AKEYCODE_DEL
#endif
if (chr)
charPressed(chr);
}