Skip to content

Commit

Permalink
sdl: fix many keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
hodefoting committed Aug 12, 2016
1 parent 8d49589 commit 18712e8
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions bin/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,17 @@ static int sdl_check_events (Host *host)
case SDL_KEYDOWN:
{
char buf[64] = "";
char *name = NULL;
char *name = buf;

buf[mmfb_unichar_to_utf8 (event.key.keysym.unicode, (void*)buf)]=0;
if (event.key.keysym.mod & (KMOD_CTRL))
{
buf[0] = event.key.keysym.unicode + 96;
buf[1] = 0;
}



switch (event.key.keysym.sym)
{
case SDLK_F1: name = "F1"; break;
Expand Down Expand Up @@ -367,37 +375,32 @@ static int sdl_check_events (Host *host)
case SDLK_PAGEDOWN: name = "page-down";break;
case SDLK_PAGEUP: name = "page-up"; break;

default:
if (event.key.keysym.unicode < 32)
{
buf[0] = event.key.keysym.unicode;
buf[1] = 0;
}
name = (void*)&buf[0];
default:;
}

if (event.key.keysym.mod & (KMOD_CTRL) ||
event.key.keysym.mod & (KMOD_ALT) ||
strlen (name) >= 3)
{

if (event.key.keysym.mod & (KMOD_CTRL))
{
char buf2[64] = "";
sprintf (buf2, "control-%c", event.key.keysym.sym);
name = buf2;
if (event.key.keysym.mod & (KMOD_SHIFT))
{
char buf2[64] = "";
sprintf (buf2, "shift-%c", event.key.keysym.sym);
name = buf2;
}
static char buf[64] = "";
sprintf (buf, "control-%s", name);
name = buf;
}
if (event.key.keysym.mod & (KMOD_ALT))
{
char buf2[64] = "";
sprintf (buf2, "alt-%c", event.key.keysym.sym);
name = buf2;
if (event.key.keysym.mod & (KMOD_SHIFT))
{
char buf2[64] = "";
sprintf (buf2, "shift-%c", event.key.keysym.sym);
name = buf2;
}
static char buf[64] = "";
sprintf (buf, "alt-%s", name);
name = buf;
}
if (event.key.keysym.mod & (KMOD_SHIFT))
{
static char buf[64] = "";
sprintf (buf, "shift-%s", name);
name = buf;
}
}
if (name)
if (host->focused)
Expand Down

0 comments on commit 18712e8

Please sign in to comment.