diff options
| author | Geoff Voelker | 1998-12-02 23:54:14 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-12-02 23:54:14 +0000 |
| commit | 9ddef9c4de640e72c02c732b035522782d0440b5 (patch) | |
| tree | 966ab0a7362fc39cf4999fb5c846d5d8fe12649a /src | |
| parent | adcc38092facc5b5de19c467d71863106cae7b57 (diff) | |
| download | emacs-9ddef9c4de640e72c02c732b035522782d0440b5.tar.gz emacs-9ddef9c4de640e72c02c732b035522782d0440b5.zip | |
(key_event): Use Vw32_phantom_key_code. Undo the
mapping of Ctrl-Pause into cancel, and Ctrl-NumLock into pause.
(w32_console_toggle_lock_key): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32inevt.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c index f31f88edf09..ce20bd452d8 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -60,6 +60,7 @@ extern Lisp_Object Vw32_enable_num_lock; | |||
| 60 | extern Lisp_Object Vw32_recognize_altgr; | 60 | extern Lisp_Object Vw32_recognize_altgr; |
| 61 | extern Lisp_Object Vw32_pass_lwindow_to_system; | 61 | extern Lisp_Object Vw32_pass_lwindow_to_system; |
| 62 | extern Lisp_Object Vw32_pass_rwindow_to_system; | 62 | extern Lisp_Object Vw32_pass_rwindow_to_system; |
| 63 | extern Lisp_Object Vw32_phantom_key_code; | ||
| 63 | extern Lisp_Object Vw32_lwindow_modifier; | 64 | extern Lisp_Object Vw32_lwindow_modifier; |
| 64 | extern Lisp_Object Vw32_rwindow_modifier; | 65 | extern Lisp_Object Vw32_rwindow_modifier; |
| 65 | extern Lisp_Object Vw32_apps_modifier; | 66 | extern Lisp_Object Vw32_apps_modifier; |
| @@ -270,12 +271,13 @@ w32_kbd_patch_key (KEY_EVENT_RECORD *event) | |||
| 270 | 271 | ||
| 271 | extern char *lispy_function_keys[]; | 272 | extern char *lispy_function_keys[]; |
| 272 | 273 | ||
| 274 | static int faked_key = 0; | ||
| 275 | |||
| 273 | /* return code -1 means that event_queue_ptr won't be incremented. | 276 | /* return code -1 means that event_queue_ptr won't be incremented. |
| 274 | In other word, this event makes two key codes. (by himi) */ | 277 | In other word, this event makes two key codes. (by himi) */ |
| 275 | int | 278 | int |
| 276 | key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | 279 | key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) |
| 277 | { | 280 | { |
| 278 | static int faked_key = 0; | ||
| 279 | static int mod_key_state = 0; | 281 | static int mod_key_state = 0; |
| 280 | int wParam; | 282 | int wParam; |
| 281 | 283 | ||
| @@ -317,8 +319,11 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | |||
| 317 | Space which we will ignore. */ | 319 | Space which we will ignore. */ |
| 318 | if ((mod_key_state & LEFT_WIN_PRESSED) == 0) | 320 | if ((mod_key_state & LEFT_WIN_PRESSED) == 0) |
| 319 | { | 321 | { |
| 320 | faked_key = VK_SPACE; | 322 | if (NUMBERP (Vw32_phantom_key_code)) |
| 321 | keybd_event (VK_SPACE, (BYTE) MapVirtualKey (VK_SPACE, 0), 0, 0); | 323 | faked_key = XUINT (Vw32_phantom_key_code) & 255; |
| 324 | else | ||
| 325 | faked_key = VK_SPACE; | ||
| 326 | keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0); | ||
| 322 | } | 327 | } |
| 323 | } | 328 | } |
| 324 | mod_key_state |= LEFT_WIN_PRESSED; | 329 | mod_key_state |= LEFT_WIN_PRESSED; |
| @@ -330,8 +335,11 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | |||
| 330 | { | 335 | { |
| 331 | if ((mod_key_state & RIGHT_WIN_PRESSED) == 0) | 336 | if ((mod_key_state & RIGHT_WIN_PRESSED) == 0) |
| 332 | { | 337 | { |
| 333 | faked_key = VK_SPACE; | 338 | if (NUMBERP (Vw32_phantom_key_code)) |
| 334 | keybd_event (VK_SPACE, (BYTE) MapVirtualKey (VK_SPACE, 0), 0, 0); | 339 | faked_key = XUINT (Vw32_phantom_key_code) & 255; |
| 340 | else | ||
| 341 | faked_key = VK_SPACE; | ||
| 342 | keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0); | ||
| 335 | } | 343 | } |
| 336 | } | 344 | } |
| 337 | mod_key_state |= RIGHT_WIN_PRESSED; | 345 | mod_key_state |= RIGHT_WIN_PRESSED; |
| @@ -379,6 +387,23 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | |||
| 379 | case VK_CONTROL: | 387 | case VK_CONTROL: |
| 380 | case VK_SHIFT: | 388 | case VK_SHIFT: |
| 381 | return 0; | 389 | return 0; |
| 390 | case VK_CANCEL: | ||
| 391 | /* Windows maps Ctrl-Pause (aka Ctrl-Break) into VK_CANCEL, | ||
| 392 | which is confusing for purposes of key binding; convert | ||
| 393 | VK_CANCEL events into VK_PAUSE events. */ | ||
| 394 | event->wVirtualKeyCode = VK_PAUSE; | ||
| 395 | break; | ||
| 396 | case VK_PAUSE: | ||
| 397 | /* Windows maps Ctrl-NumLock into VK_PAUSE, which is confusing | ||
| 398 | for purposes of key binding; convert these back into | ||
| 399 | VK_NUMLOCK events, at least when we want to see NumLock key | ||
| 400 | presses. (Note that there is never any possibility that | ||
| 401 | VK_PAUSE with Ctrl really is C-Pause as per above.) */ | ||
| 402 | if (NILP (Vw32_enable_num_lock) | ||
| 403 | && (event->dwControlKeyState | ||
| 404 | & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0) | ||
| 405 | event->wVirtualKeyCode = VK_NUMLOCK; | ||
| 406 | break; | ||
| 382 | } | 407 | } |
| 383 | 408 | ||
| 384 | /* Recognize state of Windows and Apps keys. */ | 409 | /* Recognize state of Windows and Apps keys. */ |
| @@ -444,6 +469,32 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) | |||
| 444 | return 1; | 469 | return 1; |
| 445 | } | 470 | } |
| 446 | 471 | ||
| 472 | int | ||
| 473 | w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state) | ||
| 474 | { | ||
| 475 | int cur_state = (GetKeyState (vk_code) & 1); | ||
| 476 | |||
| 477 | if (NILP (new_state) | ||
| 478 | || (NUMBERP (new_state) | ||
| 479 | && (XUINT (new_state)) & 1 != cur_state)) | ||
| 480 | { | ||
| 481 | faked_key = vk_code; | ||
| 482 | |||
| 483 | keybd_event ((BYTE) vk_code, | ||
| 484 | (BYTE) MapVirtualKey (vk_code, 0), | ||
| 485 | KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); | ||
| 486 | keybd_event ((BYTE) vk_code, | ||
| 487 | (BYTE) MapVirtualKey (vk_code, 0), | ||
| 488 | KEYEVENTF_EXTENDEDKEY | 0, 0); | ||
| 489 | keybd_event ((BYTE) vk_code, | ||
| 490 | (BYTE) MapVirtualKey (vk_code, 0), | ||
| 491 | KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); | ||
| 492 | cur_state = !cur_state; | ||
| 493 | } | ||
| 494 | |||
| 495 | return cur_state; | ||
| 496 | } | ||
| 497 | |||
| 447 | /* Mouse position hook. */ | 498 | /* Mouse position hook. */ |
| 448 | void | 499 | void |
| 449 | w32_console_mouse_position (FRAME_PTR *f, | 500 | w32_console_mouse_position (FRAME_PTR *f, |