ipochto / stratagus

The Stratagus strategy game engine
GNU General Public License v2.0
0 stars 0 forks source link

the move to SDL2 seemingly caused certain button hotkeys (e.g. "pagedown") to be broken #35

Open ipochto opened 2 years ago

ipochto commented 2 years ago

https://discord.com/channels/780082494447288340/780082494447288344/905536724980072458

Andrettin:

the problem are these lines in video/sdl.cpp:

for (i = SDLK_F1; i <= SDLK_F15; ++i) {
snprintf(str, sizeof(str), "f%d", i - SDLK_F1 + 1);
Key2Str[i] = str;
snprintf(str, sizeof(str), "F%d", i - SDLK_F1 + 1);
Str2Key[str] = i;
}

SDLK_F13 to SDLK_F15 no longer have values adjacent to SDLK_F12 so we need two loops instead:

    for (i = SDLK_F1; i <= SDLK_F12; ++i) {
        snprintf(str.data(), sizeof(str), "f%d", i - SDLK_F1 + 1);
        Key2Str[i] = str.data();
        snprintf(str.data(), sizeof(str), "F%d", i - SDLK_F1 + 1);
        Str2Key[str.data()] = i;
    }

    for (i = SDLK_F13; i <= SDLK_F24; ++i) {
        snprintf(str.data(), sizeof(str), "f%d", i - SDLK_F13 + 13);
        Key2Str[i] = str.data();
        snprintf(str.data(), sizeof(str), "F%d", i - SDLK_F13 + 13);
        Str2Key[str.data()] = i;
    }

relevant wyrmgus commit: https://github.com/Andrettin/Wyrmgus/commit/de74fe71de3954e1730e87a25605d4cc62e53fbb