test/checkkeys.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 8149 681eb46b8ac4
--- a/test/checkkeys.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/checkkeys.c	Wed Aug 14 23:30:10 2013 -0700
@@ -117,13 +117,13 @@
 static void
 PrintText(char *text)
 {
-    unsigned char *spot, expanded[1024];
+    char *spot, expanded[1024];
 
     expanded[0] = '\0';
     for ( spot = text; *spot; ++spot )
     {
         size_t length = SDL_strlen(expanded);
-        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
+        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
     }
     SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
 }
@@ -134,10 +134,13 @@
     SDL_Window *window;
     SDL_Event event;
     int done;
+	
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     /* Initialize SDL */
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -146,7 +149,7 @@
                               SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                               640, 480, 0);
     if (!window) {
-        fprintf(stderr, "Couldn't create 640x480 window: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
                 SDL_GetError());
         quit(2);
     }
@@ -166,7 +169,7 @@
         switch (event.type) {
         case SDL_KEYDOWN:
         case SDL_KEYUP:
-            PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
+			PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
             break;
         case SDL_TEXTINPUT:
             PrintText(event.text.text);