Here is a patch to the sdl system that adds support for fake scancode support.
This is needed to support GTK keybindings and probably useful for other reasons.

Index: sdlinput.c
===================================================================
RCS file: /cvs/directfb/DirectFB/systems/sdl/sdlinput.c,v
retrieving revision 1.4
diff -u -r1.4 sdlinput.c
--- sdlinput.c  20 Nov 2004 23:57:56 -0000      1.4
+++ sdlinput.c  3 Mar 2005 17:56:12 -0000
@@ -383,18 +383,20 @@
  
                     case SDL_KEYUP:
                     case SDL_KEYDOWN:
+                       //XXX sdl does not give us the keymap
+                        evt.key_code=event.key.keysym.scancode;
                          if (event.type == SDL_KEYDOWN)
                               evt.type = DIET_KEYPRESS;
                          else
                               evt.type = DIET_KEYRELEASE;
-
                          if (translate_key( event.key.keysym.sym, &evt )) {
+                             evt.key_code=evt.key_id;
                               dfb_input_dispatch( data->device, &evt );
                          }
                          else if (event.key.keysym.unicode) {
                               evt.flags      = DIEF_KEYSYMBOL;
                               evt.key_symbol = event.key.keysym.unicode;
-
+                             evt.key_code=evt.key_id;
                               dfb_input_dispatch( data->device, &evt );
                          }
  
@@ -503,6 +505,10 @@
  
      /* set capabilities */
      info->desc.caps   = DICAPS_ALL;
+     /* enable translation of fake raw hardware keycodes */
+     info->desc.min_keycode = DIKI_A;
+     info->desc.max_keycode = DIKI_KP_9;
+
  
  
      /* allocate and fill private data */
@@ -520,15 +526,200 @@
      return DFB_OK;
 }
  
+
+static DFBInputDeviceKeySymbol
+id_to_symbol( DFBInputDeviceKeyIdentifier id,
+              DFBInputDeviceModifierMask  modifiers)
+{
+     bool shift = (modifiers & DIMM_SHIFT);
+
+     if (id >= DIKI_A && id <= DIKI_Z)
+          return (shift ? DIKS_CAPITAL_A : DIKS_SMALL_A) + id - DIKI_A;
+
+     if (id >= DIKI_0 && id <= DIKI_9)
+          return DIKS_0 + id - DIKI_0;
+
+     if (id >= DIKI_KP_0 && id <= DIKI_KP_9)
+          return DIKS_0 + id - DIKI_KP_0;
+
+     if (id >= DIKI_F1 && id <= DIKI_F12)
+          return DIKS_F1 + id - DIKI_F1;
+
+     switch (id) {
+          case DIKI_ESCAPE:
+               return DIKS_ESCAPE;
+
+          case DIKI_LEFT:
+               return DIKS_CURSOR_LEFT;
+
+          case DIKI_RIGHT:
+               return DIKS_CURSOR_RIGHT;
+
+          case DIKI_UP:
+               return DIKS_CURSOR_UP;
+
+          case DIKI_DOWN:
+               return DIKS_CURSOR_DOWN;
+
+          case DIKI_ALTGR:
+               return DIKS_ALTGR;
+
+          case DIKI_CONTROL_L:
+          case DIKI_CONTROL_R:
+               return DIKS_CONTROL;
+
+          case DIKI_SHIFT_L:
+          case DIKI_SHIFT_R:
+               return DIKS_SHIFT;
+
+          case DIKI_ALT_L:
+          case DIKI_ALT_R:
+               return DIKS_ALT;
+
+          case DIKI_META_L:
+          case DIKI_META_R:
+               return DIKS_META;
+
+          case DIKI_SUPER_L:
+          case DIKI_SUPER_R:
+               return DIKS_SUPER;
+
+          case DIKI_HYPER_L:
+          case DIKI_HYPER_R:
+               return DIKS_HYPER;
+
+          case DIKI_TAB:
+               return DIKS_TAB;
+
+          case DIKI_ENTER:
+               return DIKS_ENTER;
+
+          case DIKI_SPACE:
+               return DIKS_SPACE;
+
+          case DIKI_BACKSPACE:
+               return DIKS_BACKSPACE;
+
+          case DIKI_INSERT:
+               return DIKS_INSERT;
+
+          case DIKI_DELETE:
+               return DIKS_DELETE;
+
+          case DIKI_HOME:
+               return DIKS_HOME;
+
+          case DIKI_END:
+               return DIKS_END;
+
+          case DIKI_PAGE_UP:
+               return DIKS_PAGE_UP;
+
+          case DIKI_PAGE_DOWN:
+               return DIKS_PAGE_DOWN;
+
+          case DIKI_CAPS_LOCK:
+               return DIKS_CAPS_LOCK;
+
+          case DIKI_NUM_LOCK:
+               return DIKS_NUM_LOCK;
+
+          case DIKI_SCROLL_LOCK:
+               return DIKS_SCROLL_LOCK;
+
+          case DIKI_PRINT:
+               return DIKS_PRINT;
+
+          case DIKI_PAUSE:
+               return DIKS_PAUSE;
+
+          case DIKI_KP_DIV:
+               return DIKS_SLASH;
+
+          case DIKI_KP_MULT:
+               return DIKS_ASTERISK;
+
+          case DIKI_KP_MINUS:
+               return DIKS_MINUS_SIGN;
+
+          case DIKI_KP_PLUS:
+               return DIKS_PLUS_SIGN;
+
+          case DIKI_KP_ENTER:
+               return DIKS_ENTER;
+
+          case DIKI_KP_SPACE:
+               return DIKS_SPACE;
+
+          case DIKI_KP_TAB:
+               return DIKS_TAB;
+
+          case DIKI_KP_EQUAL:
+               return DIKS_EQUALS_SIGN;
+
+          case DIKI_KP_DECIMAL:
+               return DIKS_PERIOD;
+
+          case DIKI_KP_SEPARATOR:
+               return DIKS_COMMA;
+
+          case DIKI_BACKSLASH:
+               return DIKS_BACKSLASH;
+
+          case DIKI_EQUALS_SIGN:
+               return DIKS_EQUALS_SIGN;
+
+          case DIKI_LESS_SIGN:
+               return DIKS_LESS_THAN_SIGN;
+
+          case DIKI_MINUS_SIGN:
+               return DIKS_MINUS_SIGN;
+
+          case DIKI_PERIOD:
+               return DIKS_PERIOD;
+
+          case DIKI_QUOTE_LEFT:
+          case DIKI_QUOTE_RIGHT:
+               return DIKS_QUOTATION;
+
+          case DIKI_SEMICOLON:
+               return DIKS_SEMICOLON;
+
+          case DIKI_SLASH:
+               return DIKS_SLASH;
+
+          default:
+               ;
+     }
+
+     return DIKS_NULL;
+}
 /*
  * Fetch one entry from the device's keymap if supported.
+ * this does a fake mapping based on the orginal DFB code
  */
 static DFBResult
 driver_get_keymap_entry( CoreInputDevice           *device,
                          void                      *driver_data,
                          DFBInputDeviceKeymapEntry *entry )
 {
-     return DFB_UNSUPPORTED;
+     int                         code = entry->code;
+     entry->identifier=code;
+
+     /* is CapsLock effective? */
+     if (code >= DIKI_A && code <= DIKI_Z)
+               entry->locks |= DILS_CAPS;
+
+     /* is NumLock effective? */
+     if (entry->identifier >= DIKI_KP_DECIMAL && entry->identifier <=
DIKI_KP_9)
+          entry->locks |= DILS_NUM;
+
+     entry->symbols[DIKSI_BASE]=id_to_symbol(entry->identifier,0);
+     
entry->symbols[DIKSI_BASE_SHIFT]=id_to_symbol(entry->identifier,DIMM_SHIFT);
+     entry->symbols[DIKSI_ALT]=entry->symbols[DIKSI_BASE];
+     entry->symbols[DIKSI_ALT_SHIFT]=entry->symbols[DIKSI_BASE_SHIFT];
+     return DFB_OK;
+
 }

_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to