[AD] scancode_to_name change

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here's a change that I already made while porting scancode_to_name to the new_api_branch. It makes scancode_to_name never return NULL by defaulting the the _keyboard_common_names if the keyboard_driver's scancode_to_name method returns NULL for a given scancode.

Peter
? ChangeLog
? allegro.log
? blitdemo.c
? cscope.out
? examples-yield.diff
? link-command
? mingw.log
? tgacrash
? todo2.txt
? xwin-unbgman-1.diff
? examples/example-changes.diff
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/keyboard.c,v
retrieving revision 1.11
diff -u -r1.11 keyboard.c
--- src/keyboard.c	3 Dec 2004 20:56:26 -0000	1.11
+++ src/keyboard.c	9 Dec 2004 08:43:09 -0000
@@ -589,8 +589,6 @@
       return keyboard_driver->scancode_to_ascii(scancode);
    else
       return common_ascii[scancode];
-
-   return 0;
 }
 
 
@@ -600,13 +598,20 @@
  */
 AL_CONST char *scancode_to_name(int scancode)
 {
-   ASSERT (scancode >= 0 && scancode < KEY_MAX);
+   AL_CONST char *name = NULL;
+
+   ASSERT(keyboard_driver);
+   ASSERT((scancode >= 0) && (scancode < KEY_MAX));
+
    if (keyboard_driver->scancode_to_name)
-      return keyboard_driver->scancode_to_name(scancode);
-   else
-      return _keyboard_common_names[scancode];
+      name = keyboard_driver->scancode_to_name(scancode);
 
-   return 0;
+   if (!name)
+      name = _keyboard_common_names[scancode];
+
+   ASSERT(name);
+
+   return name;
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/