Support Enter key on keypad.

Honour the Caps Lock state (inverted).

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-02-20 16:14:03 +00:00
parent 4137238cd7
commit b78a2224d0

View file

@ -41,6 +41,7 @@ namespace
switch (key.keysym.sym)
{
case SDLK_RETURN:
case SDLK_KP_ENTER:
{
ch = 0x0d;
break;
@ -83,18 +84,29 @@ namespace
}
case SDLK_a ... SDLK_z:
{
/*
It looks to me this is very similar to AW,
except the meaning of CAPS_LOCK is inverted.
I would like to flip the CAPS state when this apps starts,
so it defaults to upper case until manually changed,
but i was not able to do so.
*/
const SDL_Keymod keymod = SDL_GetModState();
const bool lower = (keymod & KMOD_CAPS) && !(key.keysym.mod & KMOD_SHIFT);
ch = (key.keysym.sym - SDLK_a) + 0x01;
if (key.keysym.mod & KMOD_CTRL)
{
// ok
}
else if (key.keysym.mod & KMOD_SHIFT)
else if (lower)
{
ch += 0x60;
ch += 0x60; // lower case
}
else
{
ch += 0x40;
ch += 0x40; // upper case
}
break;
}