1.1 --- a/test/testwm.c Sun Jan 10 18:19:35 2010 +0000
1.2 +++ b/test/testwm.c Sun Jan 10 18:25:04 2010 +0000
1.3 @@ -175,6 +175,74 @@
1.4 SDL_PushEvent(&event);
1.5 }
1.6
1.7 +
1.8 +static void
1.9 +print_modifiers(void)
1.10 +{
1.11 + int mod;
1.12 + printf(" modifiers:");
1.13 + mod = SDL_GetModState();
1.14 + if(!mod) {
1.15 + printf(" (none)");
1.16 + return;
1.17 + }
1.18 + if(mod & KMOD_LSHIFT)
1.19 + printf(" LSHIFT");
1.20 + if(mod & KMOD_RSHIFT)
1.21 + printf(" RSHIFT");
1.22 + if(mod & KMOD_LCTRL)
1.23 + printf(" LCTRL");
1.24 + if(mod & KMOD_RCTRL)
1.25 + printf(" RCTRL");
1.26 + if(mod & KMOD_LALT)
1.27 + printf(" LALT");
1.28 + if(mod & KMOD_RALT)
1.29 + printf(" RALT");
1.30 + if(mod & KMOD_LMETA)
1.31 + printf(" LMETA");
1.32 + if(mod & KMOD_RMETA)
1.33 + printf(" RMETA");
1.34 + if(mod & KMOD_NUM)
1.35 + printf(" NUM");
1.36 + if(mod & KMOD_CAPS)
1.37 + printf(" CAPS");
1.38 + if(mod & KMOD_MODE)
1.39 + printf(" MODE");
1.40 +}
1.41 +
1.42 +static void PrintKey(const SDL_keysym *sym, int pressed)
1.43 +{
1.44 + /* Print the keycode, name and state */
1.45 + if ( sym->sym ) {
1.46 + printf("Key %s: %d-%s ", pressed ? "pressed" : "released",
1.47 + sym->sym, SDL_GetKeyName(sym->sym));
1.48 + } else {
1.49 + printf("Unknown Key (scancode = %d) %s ", sym->scancode,
1.50 + pressed ? "pressed" : "released");
1.51 + }
1.52 +
1.53 + /* Print the translated character, if one exists */
1.54 + if ( sym->unicode ) {
1.55 + /* Is it a control-character? */
1.56 + if ( sym->unicode < ' ' ) {
1.57 + printf(" (^%c)", sym->unicode+'@');
1.58 + } else {
1.59 +#ifdef UNICODE
1.60 + printf(" (%c)", sym->unicode);
1.61 +#else
1.62 + /* This is a Latin-1 program, so only show 8-bits */
1.63 + if ( !(sym->unicode & 0xFF00) )
1.64 + printf(" (%c)", sym->unicode);
1.65 + else
1.66 + printf(" (0x%X)", sym->unicode);
1.67 +#endif
1.68 + }
1.69 + }
1.70 + print_modifiers();
1.71 + printf("\n");
1.72 +}
1.73 +
1.74 +
1.75 static int (SDLCALL * old_filterfunc) (void *, SDL_Event *);
1.76 static void *old_filterdata;
1.77
1.78 @@ -230,6 +298,7 @@
1.79 return (0);
1.80
1.81 case SDL_KEYDOWN:
1.82 + PrintKey(&event->key.keysym, 1);
1.83 if (event->key.keysym.sym == SDLK_ESCAPE) {
1.84 HotKey_Quit();
1.85 }
1.86 @@ -247,6 +316,10 @@
1.87 }
1.88 return (0);
1.89
1.90 + case SDL_KEYUP:
1.91 + PrintKey(&event->key.keysym, 0);
1.92 + return(0);
1.93 +
1.94 /* Pass the video resize event through .. */
1.95 case SDL_VIDEORESIZE:
1.96 return (1);
1.97 @@ -355,9 +428,6 @@
1.98 SDL_GetEventFilter(&old_filterfunc, &old_filterdata);
1.99 SDL_SetEventFilter(FilterEvents, NULL);
1.100
1.101 - /* Ignore key up events, they don't even get filtered */
1.102 - SDL_EventState(SDL_KEYUP, SDL_IGNORE);
1.103 -
1.104 /* Loop, waiting for QUIT */
1.105 while (SDL_WaitEvent(&event)) {
1.106 switch (event.type) {