/[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 39 by matthewc, Fri Apr 5 07:57:43 2002 UTC revision 50 by matthewc, Sat Apr 20 09:41:03 2002 UTC
# Line 29  Line 29 
29  #define KEYMAP_SIZE 4096  #define KEYMAP_SIZE 4096
30  #define KEYMAP_MASK (KEYMAP_SIZE - 1)  #define KEYMAP_MASK (KEYMAP_SIZE - 1)
31    
32    extern Display *display;
33  extern char keymapname[16];  extern char keymapname[16];
34  extern int keylayout;  extern int keylayout;
35    
# Line 42  static BOOL xkeymap_read(char *mapname) Line 43  static BOOL xkeymap_read(char *mapname)
43          char *keyname, *p;          char *keyname, *p;
44          KeySym keysym;          KeySym keysym;
45          unsigned char keycode;          unsigned char keycode;
         unsigned int mapcode = 0;  
46    
47          strcpy(path, KEYMAP_PATH);          strcpy(path, KEYMAP_PATH);
48          strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH));          strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH));
# Line 98  static BOOL xkeymap_read(char *mapname) Line 98  static BOOL xkeymap_read(char *mapname)
98          return True;          return True;
99  }  }
100    
101  void xkeymap_init(Display *display)  void xkeymap_init(void)
102  {  {
103          unsigned int max_keycode;          unsigned int max_keycode;
104    
# Line 108  void xkeymap_init(Display *display) Line 108  void xkeymap_init(Display *display)
108                  xkeymap_read(keymapname);                  xkeymap_read(keymapname);
109  }  }
110    
111  uint8 xkeymap_translate_key(KeySym keysym, unsigned int keycode)  uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags)
112  {  {
113          uint8 scancode;          uint8 scancode;
114    
115          scancode = keymap[keysym & KEYMAP_MASK];          scancode = keymap[keysym & KEYMAP_MASK];
116          if (scancode != 0)          if (scancode != 0)
117                  return scancode;          {
118                    if (scancode & 0x80)
119                            *flags |= KBD_FLAG_EXT;
120    
121                    return (scancode & 0x7f);
122            }
123    
124          /* not in keymap, try to interpret the raw scancode */          /* not in keymap, try to interpret the raw scancode */
125    
126          if ((keycode >= min_keycode) && (keycode <= 0x60))          if ((keycode >= min_keycode) && (keycode <= 0x60))
127                  return (uint8)(keycode - min_keycode);                  return (uint8)(keycode - min_keycode);
128    
129            *flags |= KBD_FLAG_EXT;
130    
131          switch (keycode)          switch (keycode)
132          {          {
133                  case 0x61:      /* home */                  case 0x61:      /* home */
134                          return 0x47 | 0x80;                          return 0x47;
135                  case 0x62:      /* up arrow */                  case 0x62:      /* up arrow */
136                          return 0x48 | 0x80;                          return 0x48;
137                  case 0x63:      /* page up */                  case 0x63:      /* page up */
138                          return 0x49 | 0x80;                          return 0x49;
139                  case 0x64:      /* left arrow */                  case 0x64:      /* left arrow */
140                          return 0x4b | 0x80;                          return 0x4b;
141                  case 0x66:      /* right arrow */                  case 0x66:      /* right arrow */
142                          return 0x4d | 0x80;                          return 0x4d;
143                  case 0x67:      /* end */                  case 0x67:      /* end */
144                          return 0x4f | 0x80;                          return 0x4f;
145                  case 0x68:      /* down arrow */                  case 0x68:      /* down arrow */
146                          return 0x50 | 0x80;                          return 0x50;
147                  case 0x69:      /* page down */                  case 0x69:      /* page down */
148                          return 0x51 | 0x80;                          return 0x51;
149                  case 0x6a:      /* insert */                  case 0x6a:      /* insert */
150                          return 0x52 | 0x80;                          return 0x52;
151                  case 0x6b:      /* delete */                  case 0x6b:      /* delete */
152                          return 0x53 | 0x80;                          return 0x53;
153                  case 0x6c:      /* keypad enter */                  case 0x6c:      /* keypad enter */
154                          return 0x1c | 0x80;                          return 0x1c;
155                  case 0x6d:      /* right ctrl */                  case 0x6d:      /* right ctrl */
156                          return 0x1d | 0x80;                          return 0x1d;
157                  case 0x6f:      /* ctrl - print screen */                  case 0x6f:      /* ctrl - print screen */
158                          return 0x37 | 0x80;                          return 0x37;
159                  case 0x70:      /* keypad '/' */                  case 0x70:      /* keypad '/' */
160                          return 0x35 | 0x80;                          return 0x35;
161                  case 0x71:      /* right alt */                  case 0x71:      /* right alt */
162                          return 0x38 | 0x80;                          return 0x38;
163                  case 0x72:      /* ctrl break */                  case 0x72:      /* ctrl break */
164                          return 0x46 | 0x80;                          return 0x46;
165                  case 0x73:      /* left window key */                  case 0x73:      /* left window key */
166                          return 0x5b | 0x80;                          return 0x5b;
167                  case 0x74:      /* right window key */                  case 0x74:      /* right window key */
168                          return 0x5c | 0x80;                          return 0x5c;
169                  case 0x75:      /* menu key */                  case 0x75:      /* menu key */
170                          return 0x5d | 0x80;                          return 0x5d;
171          }          }
172    
173          return 0;          return 0;

Legend:
Removed from v.39  
changed lines
  Added in v.50

  ViewVC Help
Powered by ViewVC 1.1.26