Mercurial > emacs
comparison src/w32inevt.c @ 23804:aa5a4d0b1591
(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.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Wed, 02 Dec 1998 23:54:14 +0000 |
parents | 3d02c8b4b525 |
children | 4582b492a651 |
comparison
equal
deleted
inserted
replaced
23803:f112aa8f8f5d | 23804:aa5a4d0b1591 |
---|---|
58 extern Lisp_Object Vw32_enable_caps_lock; | 58 extern Lisp_Object Vw32_enable_caps_lock; |
59 extern Lisp_Object Vw32_enable_num_lock; | 59 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; |
66 extern Lisp_Object Vw32_scroll_lock_modifier; | 67 extern Lisp_Object Vw32_scroll_lock_modifier; |
67 extern unsigned int w32_key_to_modifier (int key); | 68 extern unsigned int w32_key_to_modifier (int key); |
268 } | 269 } |
269 | 270 |
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 |
282 *isdead = 0; | 284 *isdead = 0; |
283 | 285 |
315 /* Prevent system from acting on keyup (which opens the Start | 317 /* Prevent system from acting on keyup (which opens the Start |
316 menu if no other key was pressed) by simulating a press of | 318 menu if no other key was pressed) by simulating a press of |
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; |
325 if (!NILP (Vw32_lwindow_modifier)) | 330 if (!NILP (Vw32_lwindow_modifier)) |
326 return 0; | 331 return 0; |
328 case VK_RWIN: | 333 case VK_RWIN: |
329 if (NILP (Vw32_pass_rwindow_to_system)) | 334 if (NILP (Vw32_pass_rwindow_to_system)) |
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; |
338 if (!NILP (Vw32_rwindow_modifier)) | 346 if (!NILP (Vw32_rwindow_modifier)) |
339 return 0; | 347 return 0; |
377 break; | 385 break; |
378 case VK_MENU: | 386 case VK_MENU: |
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. */ |
385 event->dwControlKeyState |= mod_key_state; | 410 event->dwControlKeyState |= mod_key_state; |
386 | 411 |
442 event->wVirtualKeyCode); | 467 event->wVirtualKeyCode); |
443 emacs_ev->timestamp = GetTickCount (); | 468 emacs_ev->timestamp = GetTickCount (); |
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, |
450 #ifndef MULE | 501 #ifndef MULE |
451 int insist, | 502 int insist, |