Index: trunk/src/defs/debug.h
===================================================================
--- trunk/src/defs/debug.h	(revision 5473)
+++ trunk/src/defs/debug.h	(revision 5474)
@@ -70,5 +70,5 @@
   // ENGINES
   #define DEBUG_MODULE_GRAPHICS              2
-  #define DEBUG_MODULE_EVENT                 2
+  #define DEBUG_MODULE_EVENT                 4
   #define DEBUG_MODULE_PHYSICS               2
   #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
Index: trunk/src/lib/event/event_handler.cc
===================================================================
--- trunk/src/lib/event/event_handler.cc	(revision 5473)
+++ trunk/src/lib/event/event_handler.cc	(revision 5474)
@@ -279,9 +279,10 @@
         case SDL_MOUSEBUTTONUP:
           ev.bPressed = false;
-          ev.type = event.button.button + SDLK_LAST;
+          ev.type = event.button.button + SDLK_LAST -1;
+	  printf(">>>>>>>>>>type = %i\n", ev.type);
           break;
         case SDL_MOUSEBUTTONDOWN:
           ev.bPressed = true;
-          ev.type = event.button.button + SDLK_LAST;
+          ev.type = event.button.button + SDLK_LAST -1;
           break;
         case SDL_JOYAXISMOTION:
Index: trunk/src/lib/event/key_mapper.cc
===================================================================
--- trunk/src/lib/event/key_mapper.cc	(revision 5473)
+++ trunk/src/lib/event/key_mapper.cc	(revision 5474)
@@ -133,6 +133,8 @@
   {
     PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
+    // map the name to an sdl index
     index = nameToIndex (iniParser->getCurrentValue());
-    this->mapKeys(iniParser->getCurrentName(), index[1]);
+    // map the index to a internal name
+    this->mapKeys(iniParser->getCurrentName(), index);
     iniParser->nextVar();
   }
@@ -151,5 +153,5 @@
     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     index = nameToIndex (iniParser->getCurrentValue());
-    this->mapKeys(iniParser->getCurrentName(), index[1]);
+    this->mapKeys(iniParser->getCurrentName(), index);
     iniParser->nextVar();
   }
@@ -165,11 +167,9 @@
   coord[1] = -1;
   int c;
-  if( (c = keynameToSDLK (name)) != -1)
-    {
+  if( (c = keynameToSDLK (name)) != -1) {
       coord[1] = c;
       coord[0] = 0;
     }
-  if( (c = buttonnameToSDLB (name)) != -1)
-    {
+  if( (c = buttonnameToSDLB (name)) != -1) {
       coord[1] = c;
       coord[0] = 1;
@@ -184,13 +184,21 @@
  * @param id of the key
 */
-void KeyMapper::mapKeys(const char* name, int keyID)
-{
-  for(int i = 0; map[i].pValue != NULL; ++i )
+void KeyMapper::mapKeys(const char* name, int* index)
+{
+  for( int i = 0; map[i].pValue != NULL; ++i )
     {
       if( !strcmp (name, map[i].pName))
       {
-        *map[i].pValue = keyID;
-        PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(keyID), keyID);
-        break;
+        if( index[0] == 0)
+	{
+          *map[i].pValue = index[1];
+          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(index[1]), index[1]);
+          break;
+	}
+	else { 
+          *map[i].pValue = index[1];
+          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLBToButtonname(index[1]), index[1]);
+          break;
+	}
       }
     }
Index: trunk/src/lib/event/key_mapper.h
===================================================================
--- trunk/src/lib/event/key_mapper.h	(revision 5473)
+++ trunk/src/lib/event/key_mapper.h	(revision 5474)
@@ -36,5 +36,5 @@
  private:
   int* nameToIndex (const char* name);
-  void mapKeys(const char* name, int keyID);
+  void mapKeys(const char* name, int* index);
 
  public:
Index: trunk/src/lib/event/key_names.cc
===================================================================
--- trunk/src/lib/event/key_names.cc	(revision 5473)
+++ trunk/src/lib/event/key_names.cc	(revision 5474)
@@ -15,4 +15,5 @@
 
 #include "key_names.h"
+#include "event_def.h"
 
 #include "stdincl.h"
@@ -24,5 +25,6 @@
 int buttonnameToSDLB(const char* name)
 {
-        if( !strcmp (name, "BUTTON_LEFT")) return SDL_BUTTON_LEFT;
+        if( !strcmp (name, "BUTTON_LEFT")) 
+	  return EV_MOUSE_BUTTON_LEFT;
         if( !strcmp (name, "BUTTON_MIDDLE")) return SDL_BUTTON_MIDDLE;
         if( !strcmp (name, "BUTTON_RIGHT")) return SDL_BUTTON_RIGHT;
@@ -32,7 +34,7 @@
 }
 
-char* SDLBToButtonname( int button)
+const char* SDLBToButtonname( int button)
 {
-        if( button == SDL_BUTTON_LEFT) return "BUTTON_LEFT";
+        if( button == EV_MOUSE_BUTTON_LEFT) return "BUTTON_LEFT";
         if( button == SDL_BUTTON_MIDDLE) return "BUTTON_MIDDLE";
         if( button == SDL_BUTTON_RIGHT) return "BUTTON_RIGHT";
@@ -180,5 +182,5 @@
 }
 
-char* SDLKToKeyname( int key)
+const char* SDLKToKeyname( int key)
 {
         if( key == SDLK_BACKSPACE) return "BACKSPACE";
Index: trunk/src/lib/event/key_names.h
===================================================================
--- trunk/src/lib/event/key_names.h	(revision 5473)
+++ trunk/src/lib/event/key_names.h	(revision 5474)
@@ -20,5 +20,5 @@
       * @return a pointer to a string containing the name of the mouse button
 */
-char* SDLBToButtonname( int button);
+const char* SDLBToButtonname( int button);
 
 /**
@@ -34,5 +34,5 @@
       * @return a pointer to a string containig the name of the key
 */
-char* SDLKToKeyname( int key);
+const char* SDLKToKeyname( int key);
 
 
