/[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 82 by astrand, Tue Jul 30 07:18:48 2002 UTC revision 452 by astrand, Sun Aug 31 19:45:56 2003 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X keyboard mapping     User interface services - X keyboard mapping
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2002
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 12  Line 12 
12     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.     GNU General Public License for more details.
15      
16     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */  */
20    
21    #ifdef RDP2VNC
22    #include "vnc/x11stubs.h"
23    #else
24  #include <X11/Xlib.h>  #include <X11/Xlib.h>
25  #include <X11/keysym.h>  #include <X11/keysym.h>
26  #include <stdio.h>  #endif
27  #include <stdlib.h>  
 #include <string.h>  
28  #include <ctype.h>  #include <ctype.h>
29  #include <limits.h>  #include <limits.h>
30    #include <time.h>
31  #include "rdesktop.h"  #include "rdesktop.h"
32  #include "scancodes.h"  #include "scancodes.h"
33    
34  #define KEYMAP_SIZE 4096  #define KEYMAP_SIZE 0xffff+1
35  #define KEYMAP_MASK (KEYMAP_SIZE - 1)  #define KEYMAP_MASK 0xffff
36  #define KEYMAP_MAX_LINE_LENGTH 80  #define KEYMAP_MAX_LINE_LENGTH 80
37    
38  extern Display *display;  extern Display *g_display;
39  extern char keymapname[16];  extern char keymapname[16];
40  extern int keylayout;  extern int keylayout;
41  extern BOOL enable_compose;  extern int g_win_button_size;
42    extern BOOL g_enable_compose;
43    extern BOOL g_use_rdp5;
44    
45    static BOOL keymap_loaded;
46  static key_translation keymap[KEYMAP_SIZE];  static key_translation keymap[KEYMAP_SIZE];
47  static int min_keycode;  static int min_keycode;
48  static uint16 remote_modifier_state = 0;  static uint16 remote_modifier_state = 0;
49    static uint16 saved_remote_modifier_state = 0;
50    
51    static void update_modifier_state(uint8 scancode, BOOL pressed);
52    
53  static void  static void
54  add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname)  add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname)
# Line 49  add_to_keymap(char *keyname, uint8 scanc Line 58  add_to_keymap(char *keyname, uint8 scanc
58          keysym = XStringToKeysym(keyname);          keysym = XStringToKeysym(keyname);
59          if (keysym == NoSymbol)          if (keysym == NoSymbol)
60          {          {
61                  error("Bad keysym %s in keymap %s\n", keyname, mapname);                  DEBUG_KBD(("Bad keysym \"%s\" in keymap %s (ignoring)\n", keyname, mapname));
62                  return;                  return;
63          }          }
64    
65          DEBUG_KBD("Adding translation, keysym=0x%x, scancode=0x%x, "          DEBUG_KBD(("Adding translation, keysym=0x%x, scancode=0x%x, "
66                    "modifiers=0x%x\n", (unsigned int) keysym, scancode, modifiers);                     "modifiers=0x%x\n", (unsigned int) keysym, scancode, modifiers));
67    
68          keymap[keysym & KEYMAP_MASK].scancode = scancode;          keymap[keysym & KEYMAP_MASK].scancode = scancode;
69          keymap[keysym & KEYMAP_MASK].modifiers = modifiers;          keymap[keysym & KEYMAP_MASK].modifiers = modifiers;
# Line 67  static BOOL Line 76  static BOOL
76  xkeymap_read(char *mapname)  xkeymap_read(char *mapname)
77  {  {
78          FILE *fp;          FILE *fp;
79          char line[KEYMAP_MAX_LINE_LENGTH], path[PATH_MAX];          char line[KEYMAP_MAX_LINE_LENGTH];
80            char path[PATH_MAX], inplace_path[PATH_MAX];
81          unsigned int line_num = 0;          unsigned int line_num = 0;
82          unsigned int line_length = 0;          unsigned int line_length = 0;
83          char *keyname, *p;          char *keyname, *p;
# Line 82  xkeymap_read(char *mapname) Line 92  xkeymap_read(char *mapname)
92          fp = fopen(path, "r");          fp = fopen(path, "r");
93          if (fp == NULL)          if (fp == NULL)
94          {          {
95                  error("Failed to open keymap %s\n", path);                  /* in case we are running from the source tree */
96                  return False;                  strcpy(inplace_path, "keymaps/");
97                    strncat(inplace_path, mapname, sizeof(inplace_path) - sizeof("keymaps/"));
98    
99                    fp = fopen(inplace_path, "r");
100                    if (fp == NULL)
101                    {
102                            error("Failed to open keymap %s\n", path);
103                            return False;
104                    }
105          }          }
106    
107          /* FIXME: More tolerant on white space */          /* FIXME: More tolerant on white space */
# Line 116  xkeymap_read(char *mapname) Line 134  xkeymap_read(char *mapname)
134                  if (strncmp(line, "map ", 4) == 0)                  if (strncmp(line, "map ", 4) == 0)
135                  {                  {
136                          keylayout = strtol(line + 4, NULL, 16);                          keylayout = strtol(line + 4, NULL, 16);
137                          DEBUG_KBD("Keylayout 0x%x\n", keylayout);                          DEBUG_KBD(("Keylayout 0x%x\n", keylayout));
138                          continue;                          continue;
139                  }                  }
140    
141                  /* compose */                  /* compose */
142                  if (strncmp(line, "enable_compose", 15) == 0)                  if (strncmp(line, "enable_compose", 15) == 0)
143                  {                  {
144                          DEBUG_KBD("Enabling compose handling\n");                          DEBUG_KBD(("Enabling compose handling\n"));
145                          enable_compose = True;                          g_enable_compose = True;
146                          continue;                          continue;
147                  }                  }
148    
# Line 175  xkeymap_read(char *mapname) Line 193  xkeymap_read(char *mapname)
193                          MASK_ADD_BITS(modifiers, MapLocalStateMask);                          MASK_ADD_BITS(modifiers, MapLocalStateMask);
194                  }                  }
195    
196                    if (strstr(line_rest, "inhibit"))
197                    {
198                            MASK_ADD_BITS(modifiers, MapInhibitMask);
199                    }
200    
201                  add_to_keymap(keyname, scancode, modifiers, mapname);                  add_to_keymap(keyname, scancode, modifiers, mapname);
202    
203                  if (strstr(line_rest, "addupper"))                  if (strstr(line_rest, "addupper"))
# Line 182  xkeymap_read(char *mapname) Line 205  xkeymap_read(char *mapname)
205                          /* Automatically add uppercase key, with same modifiers                          /* Automatically add uppercase key, with same modifiers
206                             plus shift */                             plus shift */
207                          for (p = keyname; *p; p++)                          for (p = keyname; *p; p++)
208                                  *p = toupper(*p);                                  *p = toupper((int) *p);
209                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);                          MASK_ADD_BITS(modifiers, MapLeftShiftMask);
210                          add_to_keymap(keyname, scancode, modifiers, mapname);                          add_to_keymap(keyname, scancode, modifiers, mapname);
211                  }                  }
# Line 195  xkeymap_read(char *mapname) Line 218  xkeymap_read(char *mapname)
218    
219  /* Before connecting and creating UI */  /* Before connecting and creating UI */
220  void  void
221  xkeymap_init1(void)  xkeymap_init(void)
222  {  {
223          int i;          unsigned int max_keycode;
224            char *mapname_ptr;
225    
226          /* Zeroing keymap */          /* Make keymapname lowercase */
227          for (i = 0; i < KEYMAP_SIZE; i++)          mapname_ptr = keymapname;
228            while (*mapname_ptr)
229          {          {
230                  keymap[i].scancode = 0;                  *mapname_ptr = tolower((int) *mapname_ptr);
231                  keymap[i].modifiers = 0;                  mapname_ptr++;
232          }          }
233    
234          if (strcmp(keymapname, "none"))          if (strcmp(keymapname, "none"))
235          {          {
236                  xkeymap_read(keymapname);                  if (xkeymap_read(keymapname))
237                            keymap_loaded = True;
238          }          }
239    
240            XDisplayKeycodes(g_display, &min_keycode, (int *) &max_keycode);
241  }  }
242    
243  /* After connecting and creating UI */  static void
244  void  send_winkey(uint32 ev_time, BOOL pressed, BOOL leftkey)
 xkeymap_init2(void)  
245  {  {
246          unsigned int max_keycode;          uint8 winkey;
247          XDisplayKeycodes(display, &min_keycode, (int *) &max_keycode);  
248            if (leftkey)
249                    winkey = SCANCODE_CHAR_LWIN;
250            else
251                    winkey = SCANCODE_CHAR_RWIN;
252    
253            if (pressed)
254            {
255                    if (g_use_rdp5)
256                    {
257                            rdp_send_scancode(ev_time, RDP_KEYPRESS, winkey);
258                    }
259                    else
260                    {
261                            /* RDP4 doesn't support winkey. Fake with Ctrl-Esc */
262                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LCTRL);
263                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_ESC);
264                    }
265            }
266            else
267            {
268                    /* key released */
269                    if (g_use_rdp5)
270                    {
271                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, winkey);
272                    }
273                    else
274                    {
275                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_ESC);
276                            rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
277                    }
278            }
279    }
280    
281    /* Handles, for example, multi-scancode keypresses (which is not
282       possible via keymap-files) */
283    BOOL
284    handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, BOOL pressed)
285    {
286            switch (keysym)
287            {
288                    case XK_Return:
289                            if ((get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R))
290                                && (get_key_state(state, XK_Control_L)
291                                    || get_key_state(state, XK_Control_R)))
292                            {
293                                    /* Ctrl-Alt-Enter: toggle full screen */
294                                    if (pressed)
295                                            xwin_toggle_fullscreen();
296                                    return True;
297                            }
298                            break;
299    
300                    case XK_Break:
301                            /* Send Break sequence E0 46 E0 C6 */
302                            if (pressed)
303                            {
304                                    rdp_send_scancode(ev_time, RDP_KEYPRESS,
305                                                      (SCANCODE_EXTENDED | 0x46));
306                                    rdp_send_scancode(ev_time, RDP_KEYPRESS,
307                                                      (SCANCODE_EXTENDED | 0xc6));
308                            }
309                            /* No release sequence */
310                            return True;
311    
312                    case XK_Pause:
313                            /* According to MS Keyboard Scan Code
314                               Specification, pressing Pause should result
315                               in E1 1D 45 E1 9D C5. I'm not exactly sure
316                               of how this is supposed to be sent via
317                               RDP. The code below seems to work, but with
318                               the side effect that Left Ctrl stays
319                               down. Therefore, we release it when Pause
320                               is released. */
321                            if (pressed)
322                            {
323                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
324                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
325                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x45, 0);
326                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xe1, 0);
327                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x9d, 0);
328                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0xc5, 0);
329                            }
330                            else
331                            {
332                                    /* Release Left Ctrl */
333                                    rdp_send_input(ev_time, RDP_INPUT_SCANCODE, RDP_KEYRELEASE,
334                                                   0x1d, 0);
335                            }
336                            return True;
337    
338                    case XK_Meta_L: /* Windows keys */
339                    case XK_Super_L:
340                    case XK_Hyper_L:
341                            send_winkey(ev_time, pressed, True);
342                            return True;
343    
344                    case XK_Meta_R:
345                    case XK_Super_R:
346                    case XK_Hyper_R:
347                            send_winkey(ev_time, pressed, False);
348                            return True;
349    
350                    case XK_space:
351                            /* Prevent access to the Windows system menu in single app mode */
352                            if (g_win_button_size
353                                && (get_key_state(state, XK_Alt_L) || get_key_state(state, XK_Alt_R)))
354                                    return True;
355    
356            }
357            return False;
358  }  }
359    
360    
361  key_translation  key_translation
362  xkeymap_translate_key(KeySym keysym, unsigned int keycode, unsigned int state)  xkeymap_translate_key(uint32 keysym, unsigned int keycode, unsigned int state)
363  {  {
364          key_translation tr = { 0, 0 };          key_translation tr = { 0, 0 };
365    
366          tr = keymap[keysym & KEYMAP_MASK];          tr = keymap[keysym & KEYMAP_MASK];
367    
368            if (tr.modifiers & MapInhibitMask)
369            {
370                    DEBUG_KBD(("Inhibiting key\n"));
371                    tr.scancode = 0;
372                    return tr;
373            }
374    
375          if (tr.modifiers & MapLocalStateMask)          if (tr.modifiers & MapLocalStateMask)
376          {          {
377                  /* The modifiers to send for this key should be obtained                  /* The modifiers to send for this key should be obtained
# Line 241  xkeymap_translate_key(KeySym keysym, uns Line 384  xkeymap_translate_key(KeySym keysym, uns
384    
385          if (tr.scancode != 0)          if (tr.scancode != 0)
386          {          {
387                  DEBUG_KBD                  DEBUG_KBD(("Found key translation, scancode=0x%x, modifiers=0x%x\n",
388                          ("Found key translation, scancode=0x%x, modifiers=0x%x\n",                             tr.scancode, tr.modifiers));
                          tr.scancode, tr.modifiers);  
389                  return tr;                  return tr;
390          }          }
391    
392          printf("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));          if (keymap_loaded)
393                    warning("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym));
394    
395          /* not in keymap, try to interpret the raw scancode */          /* not in keymap, try to interpret the raw scancode */
396          if ((keycode >= min_keycode) && (keycode <= 0x60))          if (((int) keycode >= min_keycode) && (keycode <= 0x60))
397          {          {
398                  tr.scancode = keycode - min_keycode;                  tr.scancode = keycode - min_keycode;
399                  printf("Sending guessed scancode 0x%x\n", tr.scancode);  
400                    /* The modifiers to send for this key should be
401                       obtained from the local state. Currently, only
402                       shift is implemented. */
403                    if (state & ShiftMask)
404                    {
405                            tr.modifiers = MapLeftShiftMask;
406                    }
407    
408                    DEBUG_KBD(("Sending guessed scancode 0x%x\n", tr.scancode));
409          }          }
410          else          else
411          {          {
412                  printf("No good guess for keycode 0x%x found\n", keycode);                  DEBUG_KBD(("No good guess for keycode 0x%x found\n", keycode));
413          }          }
414    
415          return tr;          return tr;
# Line 284  xkeymap_translate_button(unsigned int bu Line 436  xkeymap_translate_button(unsigned int bu
436  }  }
437    
438  char *  char *
439  get_ksname(KeySym keysym)  get_ksname(uint32 keysym)
440  {  {
441          char *ksname = NULL;          char *ksname = NULL;
442    
# Line 296  get_ksname(KeySym keysym) Line 448  get_ksname(KeySym keysym)
448          return ksname;          return ksname;
449  }  }
450    
451  BOOL  void
452  inhibit_key(KeySym keysym)  save_remote_modifiers()
453  {  {
454          switch (keysym)          saved_remote_modifier_state = remote_modifier_state;
455          {  }
456                  case XK_Caps_Lock:  
457                          return True;  void
458                          break;  restore_remote_modifiers(uint32 ev_time)
459                  case XK_Multi_key:  {
460                          return True;          key_translation dummy;
461                          break;  
462                  default:          dummy.scancode = 0;
463                          break;          dummy.modifiers = saved_remote_modifier_state;
464          }          ensure_remote_modifiers(ev_time, dummy);
         return False;  
465  }  }
466    
467  void  void
# Line 333  ensure_remote_modifiers(uint32 ev_time, Line 484  ensure_remote_modifiers(uint32 ev_time,
484                          break;                          break;
485          }          }
486    
487          /* Shift */          /* NumLock */
488            if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)
489                != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))
490            {
491                    /* The remote modifier state is not correct */
492                    uint16 new_remote_state;
493    
494                    if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))
495                    {
496                            DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n"));
497                            new_remote_state = KBD_FLAG_NUMLOCK;
498                            remote_modifier_state = MapNumLockMask;
499                    }
500                    else
501                    {
502                            DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n"));
503                            new_remote_state = 0;
504                            remote_modifier_state = 0;
505                    }
506    
507                    rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0);
508            }
509    
510            /* Shift. Left shift and right shift are treated as equal; either is fine. */
511          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)          if (MASK_HAS_BITS(tr.modifiers, MapShiftMask)
512              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))              != MASK_HAS_BITS(remote_modifier_state, MapShiftMask))
513          {          {
514                  /* The remote modifier state is not correct */                  /* The remote modifier state is not correct */
515                  if (MASK_HAS_BITS(tr.modifiers, MapShiftMask))                  if (MASK_HAS_BITS(tr.modifiers, MapLeftShiftMask))
516                  {                  {
517                          /* Needs this modifier. Send down. */                          /* Needs left shift. Send down. */
518                          rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LSHIFT);                          rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_LSHIFT);
519                  }                  }
520                    else if (MASK_HAS_BITS(tr.modifiers, MapRightShiftMask))
521                    {
522                            /* Needs right shift. Send down. */
523                            rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_RSHIFT);
524                    }
525                  else                  else
526                  {                  {
527                          /* Should not use this modifier. Send up. */                          /* Should not use this modifier. Send up for shift currently pressed. */
528                          rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);                          if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask))
529                                    /* Left shift is down */
530                                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);
531                            else
532                                    /* Right shift is down */
533                                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);
534                  }                  }
535          }          }
536    
# Line 367  ensure_remote_modifiers(uint32 ev_time, Line 551  ensure_remote_modifiers(uint32 ev_time,
551                  }                  }
552          }          }
553    
         /* NumLock */  
         if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)  
             != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask))  
         {  
                 /* The remote modifier state is not correct */  
                 DEBUG_KBD("Remote NumLock state is incorrect. Toggling\n");  
                 if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask))  
                 {  
                         /* Needs this modifier. Toggle */  
                         rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK);  
                         rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK);  
                 }  
                 else  
                 {  
                         /* Should not use this modifier. Toggle */  
                         rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK);  
                         rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK);  
                 }  
         }  
554    
555  }  }
556    
557    
558    void
559    reset_modifier_keys(unsigned int state)
560    {
561            /* reset keys */
562            uint32 ev_time;
563            ev_time = time(NULL);
564    
565            if (MASK_HAS_BITS(remote_modifier_state, MapLeftShiftMask)
566                && !get_key_state(state, XK_Shift_L))
567                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT);
568    
569            if (MASK_HAS_BITS(remote_modifier_state, MapRightShiftMask)
570                && !get_key_state(state, XK_Shift_R))
571                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT);
572    
573            if (MASK_HAS_BITS(remote_modifier_state, MapLeftCtrlMask)
574                && !get_key_state(state, XK_Control_L))
575                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL);
576    
577            if (MASK_HAS_BITS(remote_modifier_state, MapRightCtrlMask)
578                && !get_key_state(state, XK_Control_R))
579                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL);
580    
581            if (MASK_HAS_BITS(remote_modifier_state, MapLeftAltMask) && !get_key_state(state, XK_Alt_L))
582                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT);
583    
584            if (MASK_HAS_BITS(remote_modifier_state, MapRightAltMask) &&
585                !get_key_state(state, XK_Alt_R) && !get_key_state(state, XK_Mode_switch))
586                    rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT);
587    }
588    
589    
590  static void  static void
591  update_modifier_state(uint16 modifiers, BOOL pressed)  update_modifier_state(uint8 scancode, BOOL pressed)
592  {  {
593    #ifdef WITH_DEBUG_KBD
594            uint16 old_modifier_state;
595    
596          DEBUG_KBD("Before updating modifier_state:0x%x, pressed=0x%x\n",          old_modifier_state = remote_modifier_state;
597                    remote_modifier_state, pressed);  #endif
598          switch (modifiers)  
599            switch (scancode)
600          {          {
601                  case SCANCODE_CHAR_LSHIFT:                  case SCANCODE_CHAR_LSHIFT:
602                          MASK_CHANGE_BIT(remote_modifier_state, MapLeftShiftMask, pressed);                          MASK_CHANGE_BIT(remote_modifier_state, MapLeftShiftMask, pressed);
# Line 436  update_modifier_state(uint16 modifiers, Line 636  update_modifier_state(uint16 modifiers,
636                          }                          }
637                          break;                          break;
638          }          }
639          DEBUG_KBD("After updating modifier_state:0x%x\n", remote_modifier_state);  
640    #ifdef WITH_DEBUG_KBD
641            if (old_modifier_state != remote_modifier_state)
642            {
643                    DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n",
644                               old_modifier_state, pressed));
645                    DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state));
646            }
647    #endif
648    
649  }  }
650    
651  /* Send keyboard input */  /* Send keyboard input */
652  void  void
653  rdp_send_scancode(uint32 time, uint16 flags, uint16 scancode)  rdp_send_scancode(uint32 time, uint16 flags, uint8 scancode)
654  {  {
655          update_modifier_state(scancode, !(flags & RDP_KEYRELEASE));          update_modifier_state(scancode, !(flags & RDP_KEYRELEASE));
656    
657          if (scancode & SCANCODE_EXTENDED)          if (scancode & SCANCODE_EXTENDED)
658          {          {
659                  DEBUG_KBD("Sending extended scancode=0x%x, flags=0x%x\n",                  DEBUG_KBD(("Sending extended scancode=0x%x, flags=0x%x\n",
660                            scancode & ~SCANCODE_EXTENDED, flags);                             scancode & ~SCANCODE_EXTENDED, flags));
661                  rdp_send_input(time, RDP_INPUT_SCANCODE, flags | KBD_FLAG_EXT,                  rdp_send_input(time, RDP_INPUT_SCANCODE, flags | KBD_FLAG_EXT,
662                                 scancode & ~SCANCODE_EXTENDED, 0);                                 scancode & ~SCANCODE_EXTENDED, 0);
663          }          }
664          else          else
665          {          {
666                  DEBUG_KBD("Sending scancode=0x%x, flags=0x%x\n", scancode, flags);                  DEBUG_KBD(("Sending scancode=0x%x, flags=0x%x\n", scancode, flags));
667                  rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0);                  rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0);
668          }          }
669  }  }

Legend:
Removed from v.82  
changed lines
  Added in v.452

  ViewVC Help
Powered by ViewVC 1.1.26