Advertisement
theosib

Programming key table

Feb 8th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.18 KB | None | 0 0
  1. // Key table source excerpt
  2.  
  3. KeySym CortronKeyMap[] = {
  4.     XK_KP_Space,    NoSymbol,   NoSymbol,   NoSymbol,   // 00   // 11 80
  5.     XK_Help,    NoSymbol,   NoSymbol,   NoSymbol,       // 71 81
  6.     XK_Execute, NoSymbol,   NoSymbol,   NoSymbol,       // 71 82
  7. // ...
  8.     XK_Delete,  NoSymbol,   NoSymbol,   NoSymbol,       // 10 FF
  9. };
  10.  
  11. #define Alt_Mask Mod3Mask
  12. CARD8 ctrnModmap[][2] = {
  13.         {94,     ShiftMask},
  14.         {95,     ShiftMask},
  15.         {15,     ControlMask},
  16.         {10,     Alt_Mask},
  17.          {0,     0}
  18. };
  19. KeySymsRec ctrnKeySyms[] = {    {CortronKeyMap, 0, 0x7f, 4}   };
  20.  
  21.  
  22. // Code to program key table
  23.  
  24. static CARD8 *ctrn_workingModMap = NULL;
  25. static KeySymsRec *ctrn_workingKeySyms = NULL;
  26.  
  27. static Bool decinput_set_cortron_keymap_cb(ClientPtr client, pointer closure)
  28. {
  29.     set_keymap_t *pc = closure;
  30.     XkbApplyMappingChange(pc->dev, ctrn_workingKeySyms,
  31.             ctrn_workingKeySyms->minKeyCode,
  32.             ctrn_workingKeySyms->maxKeyCode - ctrn_workingKeySyms->minKeyCode + 1,
  33.             ctrn_workingModMap, serverClient);
  34.    free(pc);
  35.    return TRUE;
  36. }
  37.  
  38.  
  39. static int decinput_set_cortron_keymap(InputInfoPtr pInfo)
  40. {
  41.     int i;
  42.     DeviceIntPtr dev = pInfo->dev;
  43.     set_keymap_t *pc = calloc(1, sizeof(set_keymap_t));
  44.     if (!pc) return !Success;
  45.    
  46.     if (!ctrn_workingKeySyms) {
  47.         ctrn_workingKeySyms = &ctrnKeySyms[0];
  48.  
  49.         if (ctrn_workingKeySyms->minKeyCode < MIN_KEYCODE) {
  50.             ctrn_workingKeySyms->minKeyCode += MIN_KEYCODE;
  51.             ctrn_workingKeySyms->maxKeyCode += MIN_KEYCODE;
  52.         }
  53.         if (ctrn_workingKeySyms->maxKeyCode > MAX_KEYCODE)
  54.             ctrn_workingKeySyms->maxKeyCode = MAX_KEYCODE;
  55.     }
  56.     if (!ctrn_workingModMap) {
  57.         ctrn_workingModMap=(CARD8 *)malloc(MAP_LENGTH);
  58.         if (!ctrn_workingModMap) {
  59.             //ErrorF("ctrnKbdProc failed: could not alloc modmap \n");
  60.             return (!Success);
  61.         }
  62.         (void) memset(ctrn_workingModMap, 0, MAP_LENGTH);
  63.         for(i=0; ctrnModmap[i][0] != 0; i++) {
  64.             ctrn_workingModMap[(ctrnModmap[i][0]) + MIN_KEYCODE] = ctrnModmap[i][1];
  65.         }
  66.     }
  67.  
  68.     pc->dev = dev;
  69.     QueueWorkProc(decinput_set_cortron_keymap_cb, serverClient, pc);
  70.     return Success;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement