diff options
| author | Karl Heuer | 1995-04-12 02:23:35 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-04-12 02:23:35 +0000 |
| commit | b02466e81ca092d687fd9e1f32272b7060e1c2d3 (patch) | |
| tree | 0f502bdbb011a132e3323a36496f996c290838e2 | |
| parent | 488e9a54a55f82fb7bbf709460f148659b4fa64c (diff) | |
| download | emacs-b02466e81ca092d687fd9e1f32272b7060e1c2d3.tar.gz emacs-b02466e81ca092d687fd9e1f32272b7060e1c2d3.zip | |
(do_mouse_event): Use XSETFASTINT.
(SET_FRAME): Undefined.
(select): Renamed to sys_select to correspond to routine in sysdep.c
(sys_select): Support struct timeval.
(key_event): Support German keyboard.
Replace SET_FRAME with XSETFRAME.
(nt_kbd_mods_to_emacs): Renamed to win32_kbd_mods_to_emacs.
(win32_kbd_mods_to_emacs): Support AltGr on German keyboards.
(win32_number_shift_map): Defined.
(WIN32_KEY_SHIFTED): Defined.
(win32_patch_key): Defined.
(map_virt_key): Support VK_OEM_102 for German keyboards.
(win32_mouse_position): Add arg insist.
(do_mouse_event): Replace SET_FRAME with XSETFRAME.
Use win32_kbd_mods_to_emacs.
| -rw-r--r-- | src/w32inevt.c | 127 |
1 files changed, 106 insertions, 21 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c index 98b608d9404..f9e8a07cd60 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Input event support for Windows NT port of GNU Emacs. | 1 | /* Input event support for Windows NT port of GNU Emacs. |
| 2 | Copyright (C) 1992, 1993 Free Software Foundation, Inc. | 2 | Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -92,22 +92,90 @@ get_frame (void) | |||
| 92 | return selected_frame; | 92 | return selected_frame; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | #ifdef MULTI_FRAME | 95 | /* Translate console modifiers to emacs modifiers. |
| 96 | #define SET_FRAME(o, f) XSETFRAME (o, f) | 96 | German keyboard support (Kai Morgan Zeise 2/18/95). */ |
| 97 | #else | ||
| 98 | #define SET_FRAME(o, f) ((o) = Qnil) | ||
| 99 | #endif | ||
| 100 | |||
| 101 | /* Translate console modifiers to emacs modifiers. */ | ||
| 102 | static int | 97 | static int |
| 103 | nt_kbd_mods_to_emacs (DWORD mods) | 98 | win32_kbd_mods_to_emacs (DWORD mods) |
| 104 | { | 99 | { |
| 105 | return ((mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) ? | 100 | int retval = 0; |
| 106 | meta_modifier : 0) | | 101 | |
| 107 | ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) ? | 102 | /* If AltGr has been pressed, remove it. */ |
| 108 | ctrl_modifier : 0) | | 103 | if ((mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
| 109 | ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) ? | 104 | == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
| 110 | shift_modifier : 0); | 105 | mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED); |
| 106 | |||
| 107 | if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) | ||
| 108 | retval = meta_modifier; | ||
| 109 | |||
| 110 | if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) | ||
| 111 | { | ||
| 112 | retval |= ctrl_modifier; | ||
| 113 | if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) | ||
| 114 | == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) | ||
| 115 | retval |= meta_modifier; | ||
| 116 | } | ||
| 117 | |||
| 118 | if (((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == SHIFT_PRESSED) | ||
| 119 | || ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == CAPSLOCK_ON)) | ||
| 120 | retval |= shift_modifier; | ||
| 121 | |||
| 122 | return retval; | ||
| 123 | } | ||
| 124 | |||
| 125 | /* Patch up NT keyboard events when info is missing that should be there, | ||
| 126 | assuming that map_virt_key says that the key is a valid ASCII char. */ | ||
| 127 | static char win32_number_shift_map[] = { | ||
| 128 | ')', '!', '@', '#', '$', '%', '^', '&', '*', '(' | ||
| 129 | }; | ||
| 130 | |||
| 131 | #define WIN32_KEY_SHIFTED(mods, no, yes) \ | ||
| 132 | ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) ? yes : no) | ||
| 133 | |||
| 134 | static void | ||
| 135 | win32_kbd_patch_key (KEY_EVENT_RECORD *event) | ||
| 136 | { | ||
| 137 | unsigned int key_code = event->wVirtualKeyCode; | ||
| 138 | unsigned int mods = event->dwControlKeyState; | ||
| 139 | int mapped_punct = 0; | ||
| 140 | |||
| 141 | /* map_virt_key says its a valid key, but the uChar.AsciiChar field | ||
| 142 | is empty. patch up the uChar.AsciiChar field using wVirtualKeyCode. */ | ||
| 143 | if (event->uChar.AsciiChar == 0 | ||
| 144 | && ((key_code >= '0' && key_code <= '9') | ||
| 145 | || (key_code >= 'A' && key_code <= 'Z') | ||
| 146 | || (key_code >= 0xBA && key_code <= 0xC0) | ||
| 147 | || (key_code >= 0xDB && key_code <= 0xDE) | ||
| 148 | )) { | ||
| 149 | if (key_code >= '0' && key_code <= '9') { | ||
| 150 | event->uChar.AsciiChar = | ||
| 151 | WIN32_KEY_SHIFTED (mods, key_code, | ||
| 152 | win32_number_shift_map[key_code - '0']); | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | switch (key_code) { | ||
| 156 | case 0xBA: mapped_punct = WIN32_KEY_SHIFTED (mods, ';', ':'); break; | ||
| 157 | case 0xBB: mapped_punct = WIN32_KEY_SHIFTED (mods, '=', '+'); break; | ||
| 158 | case 0xBC: mapped_punct = WIN32_KEY_SHIFTED (mods, ',', '<'); break; | ||
| 159 | case 0xBD: mapped_punct = WIN32_KEY_SHIFTED (mods, '-', '_'); break; | ||
| 160 | case 0xBE: mapped_punct = WIN32_KEY_SHIFTED (mods, '.', '>'); break; | ||
| 161 | case 0xBF: mapped_punct = WIN32_KEY_SHIFTED (mods, '/', '?'); break; | ||
| 162 | case 0xC0: mapped_punct = WIN32_KEY_SHIFTED (mods, '`', '~'); break; | ||
| 163 | case 0xDB: mapped_punct = WIN32_KEY_SHIFTED (mods, '[', '{'); break; | ||
| 164 | case 0xDC: mapped_punct = WIN32_KEY_SHIFTED (mods, '\\', '|'); break; | ||
| 165 | case 0xDD: mapped_punct = WIN32_KEY_SHIFTED (mods, ']', '}'); break; | ||
| 166 | case 0xDE: mapped_punct = WIN32_KEY_SHIFTED (mods, '\'', '"'); break; | ||
| 167 | default: | ||
| 168 | mapped_punct = 0; | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | if (mapped_punct) { | ||
| 172 | event->uChar.AsciiChar = mapped_punct; | ||
| 173 | return; | ||
| 174 | } | ||
| 175 | /* otherwise, it's a letter. */ | ||
| 176 | event->uChar.AsciiChar = WIN32_KEY_SHIFTED (mods, key_code - 'A' + 'a', | ||
| 177 | key_code); | ||
| 178 | } | ||
| 111 | } | 179 | } |
| 112 | 180 | ||
| 113 | /* Map virtual key codes into: | 181 | /* Map virtual key codes into: |
| @@ -223,7 +291,8 @@ static int map_virt_key[256] = | |||
| 223 | -2, /* ] */ | 291 | -2, /* ] */ |
| 224 | -2, /* ' */ | 292 | -2, /* ' */ |
| 225 | -1, /* 0xdf */ | 293 | -1, /* 0xdf */ |
| 226 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xef */ | 294 | -1, -1, -2, /* VK_OEM_102 */ |
| 295 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xef */ | ||
| 227 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */ | 296 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */ |
| 228 | }; | 297 | }; |
| 229 | 298 | ||
| @@ -231,6 +300,7 @@ static int | |||
| 231 | key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | 300 | key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) |
| 232 | { | 301 | { |
| 233 | int map; | 302 | int map; |
| 303 | static BOOL map_virt_key_init_done; | ||
| 234 | 304 | ||
| 235 | /* Skip key-up events. */ | 305 | /* Skip key-up events. */ |
| 236 | if (event->bKeyDown == FALSE) | 306 | if (event->bKeyDown == FALSE) |
| @@ -241,6 +311,17 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | |||
| 241 | printf ("Unknown key code %d\n", event->wVirtualKeyCode); | 311 | printf ("Unknown key code %d\n", event->wVirtualKeyCode); |
| 242 | return 0; | 312 | return 0; |
| 243 | } | 313 | } |
| 314 | |||
| 315 | /* Patch needed for German keyboard. Ulrich Leodolter (1/11/95). */ | ||
| 316 | if (! map_virt_key_init_done) | ||
| 317 | { | ||
| 318 | short vk; | ||
| 319 | |||
| 320 | if ((vk = VkKeyScan (0x3c)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* less */ | ||
| 321 | if ((vk = VkKeyScan (0x3e)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* greater */ | ||
| 322 | |||
| 323 | map_virt_key_init_done = TRUE; | ||
| 324 | } | ||
| 244 | 325 | ||
| 245 | /* BUGBUG - Ignores the repeat count | 326 | /* BUGBUG - Ignores the repeat count |
| 246 | It's questionable whether we want to obey the repeat count anyway | 327 | It's questionable whether we want to obey the repeat count anyway |
| @@ -258,6 +339,7 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | |||
| 258 | { | 339 | { |
| 259 | /* ASCII */ | 340 | /* ASCII */ |
| 260 | emacs_ev->kind = ascii_keystroke; | 341 | emacs_ev->kind = ascii_keystroke; |
| 342 | win32_kbd_patch_key (event); | ||
| 261 | XSETINT (emacs_ev->code, event->uChar.AsciiChar); | 343 | XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
| 262 | } | 344 | } |
| 263 | else | 345 | else |
| @@ -271,15 +353,16 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | |||
| 271 | map |= 0xff00; | 353 | map |= 0xff00; |
| 272 | XSETINT (emacs_ev->code, map); | 354 | XSETINT (emacs_ev->code, map); |
| 273 | } | 355 | } |
| 274 | SET_FRAME (emacs_ev->frame_or_window, get_frame ()); | 356 | XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
| 275 | emacs_ev->modifiers = nt_kbd_mods_to_emacs (event->dwControlKeyState); | 357 | emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState); |
| 276 | emacs_ev->timestamp = GetTickCount (); | 358 | emacs_ev->timestamp = GetTickCount (); |
| 277 | return 1; | 359 | return 1; |
| 278 | } | 360 | } |
| 279 | 361 | ||
| 280 | /* Mouse position hook. */ | 362 | /* Mouse position hook. */ |
| 281 | void | 363 | void |
| 282 | win32_mouse_position (FRAME_PTR *f, int insist, | 364 | win32_mouse_position (FRAME_PTR *f, |
| 365 | int insist, | ||
| 283 | Lisp_Object *bar_window, | 366 | Lisp_Object *bar_window, |
| 284 | enum scroll_bar_part *part, | 367 | enum scroll_bar_part *part, |
| 285 | Lisp_Object *x, | 368 | Lisp_Object *x, |
| @@ -288,6 +371,8 @@ win32_mouse_position (FRAME_PTR *f, int insist, | |||
| 288 | { | 371 | { |
| 289 | BLOCK_INPUT; | 372 | BLOCK_INPUT; |
| 290 | 373 | ||
| 374 | insist = insist; | ||
| 375 | |||
| 291 | *f = get_frame (); | 376 | *f = get_frame (); |
| 292 | *bar_window = Qnil; | 377 | *bar_window = Qnil; |
| 293 | *part = 0; | 378 | *part = 0; |
| @@ -371,12 +456,12 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, | |||
| 371 | 456 | ||
| 372 | button_state = event->dwButtonState; | 457 | button_state = event->dwButtonState; |
| 373 | emacs_ev->timestamp = GetTickCount (); | 458 | emacs_ev->timestamp = GetTickCount (); |
| 374 | emacs_ev->modifiers = nt_kbd_mods_to_emacs (event->dwControlKeyState) | | 459 | emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState) | |
| 375 | ((event->dwButtonState & mask) ? down_modifier : up_modifier); | 460 | ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
| 376 | 461 | ||
| 377 | XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); | 462 | XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); |
| 378 | XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); | 463 | XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
| 379 | SET_FRAME (emacs_ev->frame_or_window, get_frame ()); | 464 | XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
| 380 | 465 | ||
| 381 | return 1; | 466 | return 1; |
| 382 | } | 467 | } |