/[rdesktop]/sourceforge.net/trunk/rdesktop/xkeymap.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xkeymap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 84 by astrand, Tue Jul 30 07:30:12 2002 UTC revision 116 by astrand, Wed Sep 11 11:11:27 2002 UTC
# Line 41  static key_translation keymap[KEYMAP_SIZ Line 41  static key_translation keymap[KEYMAP_SIZ
41  static int min_keycode;  static int min_keycode;
42  static uint16 remote_modifier_state = 0;  static uint16 remote_modifier_state = 0;
43    
44    static void update_modifier_state(uint16 modifiers, BOOL pressed);
45    
46  static void  static void
47  add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname)  add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname)
48  {  {
# Line 175  xkeymap_read(char *mapname) Line 177  xkeymap_read(char *mapname)
177                          MASK_ADD_BITS(modifiers, MapLocalStateMask);                          MASK_ADD_BITS(modifiers, MapLocalStateMask);
178                  }                  }
179    
180                    if (strstr(line_rest, "inhibit"))
181                    {
182                            MASK_ADD_BITS(modifiers, MapInhibitMask);
183                    }
184    
185                  add_to_keymap(keyname, scancode, modifiers, mapname);                  add_to_keymap(keyname, scancode, modifiers, mapname);
186    
187                  if (strstr(line_rest, "addupper"))                  if (strstr(line_rest, "addupper"))
# Line 229  xkeymap_translate_key(KeySym keysym, uns Line 236  xkeymap_translate_key(KeySym keysym, uns
236    
237          tr = keymap[keysym & KEYMAP_MASK];          tr = keymap[keysym & KEYMAP_MASK];
238    
239            if (tr.modifiers & MapInhibitMask)
240            {
241                    DEBUG_KBD(("Inhibiting key\n"));
242                    tr.scancode = 0;
243                    return tr;
244            }
245    
246          if (tr.modifiers & MapLocalStateMask)          if (tr.modifiers & MapLocalStateMask)
247          {          {
248                  /* The modifiers to send for this key should be obtained                  /* The modifiers to send for this key should be obtained
# Line 247  xkeymap_translate_key(KeySym keysym, uns Line 261  xkeymap_translate_key(KeySym keysym, uns
261                  return tr;                  return tr;
262          }          }
263    
264          printf("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));          fprintf(stderr, "No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));
265    
266          /* not in keymap, try to interpret the raw scancode */          /* not in keymap, try to interpret the raw scancode */
267          if ((keycode >= min_keycode) && (keycode <= 0x60))          if ((keycode >= min_keycode) && (keycode <= 0x60))
268          {          {
269                  tr.scancode = keycode - min_keycode;                  tr.scancode = keycode - min_keycode;
270                  printf("Sending guessed scancode 0x%x\n", tr.scancode);                  fprintf(stderr, "Sending guessed scancode 0x%x\n", tr.scancode);
271          }          }
272          else          else
273          {          {
274                  printf("No good guess for keycode 0x%x found\n", keycode);                  fprintf(stderr, "No good guess for keycode 0x%x found\n", keycode);
275          }          }
276    
277          return tr;          return tr;
# Line 296  get_ksname(KeySym keysym) Line 310  get_ksname(KeySym keysym)
310          return ksname;          return ksname;
311  }  }
312    
 BOOL  
 inhibit_key(KeySym keysym)  
 {  
         switch (keysym)  
         {  
                 case XK_Caps_Lock:  
                         return True;  
                         break;  
                 case XK_Multi_key:  
                         return True;  
                         break;  
                 default:  
                         break;  
         }  
         return False;  
 }  
313    
314  void  void
315  ensure_remote_modifiers(uint32 ev_time, key_translation tr)  ensure_remote_modifiers(uint32 ev_time, key_translation tr)
# Line 372  ensure_remote_modifiers(uint32 ev_time, Line 370  ensure_remote_modifiers(uint32 ev_time,
370              != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))              != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))
371          {          {
372                  /* The remote modifier state is not correct */                  /* The remote modifier state is not correct */
373                  DEBUG_KBD(("Remote NumLock state is incorrect. Toggling\n"));                  uint16 new_remote_state = 0;
374    
375                  if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))                  if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))
376                  {                  {
377                          /* Needs this modifier. Toggle */                          DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));
378                          rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK);                          new_remote_state |= KBD_FLAG_NUMLOCK;
                         rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK);  
379                  }                  }
380                  else                  else
381                  {                  {
382                          /* Should not use this modifier. Toggle */                          DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));
                         rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK);  
                         rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK);  
383                  }                  }
         }  
384    
385                    rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);
386                    update_modifier_state(SCANCODE_CHAR_NUMLOCK, True);
387            }
388  }  }
389    
390    
391  static void  static void
392  update_modifier_state(uint16 modifiers, BOOL pressed)  update_modifier_state(uint16 modifiers, BOOL pressed)
393  {  {
394    #ifdef WITH_DEBUG_KBD
395            uint16 old_modifier_state;
396    
397            old_modifier_state = remote_modifier_state;
398    #endif
399    
         DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n",  
                    remote_modifier_state, pressed));  
400          switch (modifiers)          switch (modifiers)
401          {          {
402                  case SCANCODE_CHAR_LSHIFT:                  case SCANCODE_CHAR_LSHIFT:
# Line 436  update_modifier_state(uint16 modifiers, Line 437  update_modifier_state(uint16 modifiers,
437                          }                          }
438                          break;                          break;
439          }          }
440          DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state));  
441    #ifdef WITH_DEBUG_KBD
442            if (old_modifier_state != remote_modifier_state)
443            {
444                    DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n",
445                               old_modifier_state, pressed));
446                    DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state));
447            }
448    #endif
449    
450  }  }
451    
# Line 455  rdp_send_scancode(uint32 time, uint16 fl Line 464  rdp_send_scancode(uint32 time, uint16 fl
464          }          }
465          else          else
466          {          {
467                  DEBUG_KBD(("Sending scancode=0x%x, flags=0x%x\n", scancode, flags);                  DEBUG_KBD(("Sending scancode=0x%x, flags=0x%x\n", scancode, flags));
468                            rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0));                  rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0);
469          }          }
470  }  }

Legend:
Removed from v.84  
changed lines
  Added in v.116

  ViewVC Help
Powered by ViewVC 1.1.26