aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker1996-01-21 00:30:47 +0000
committerGeoff Voelker1996-01-21 00:30:47 +0000
commitdaf3806631cc516b09c804b156610a0d722314fe (patch)
treed72d28eba246b32ddce683997e239c176532080a /src
parentb47278e10c0825f8fd4eb694e512fb5fe7456c11 (diff)
downloademacs-daf3806631cc516b09c804b156610a0d722314fe.tar.gz
emacs-daf3806631cc516b09c804b156610a0d722314fe.zip
(WIN32_KEY_SHIFTED): Macro undefined.
(win32_number_shift_map): Array undefined. (win32_kbd_patch_key): Properly handle virtual keys for arbitrary keyboards. (map_virt_key, key_event, win32_mouse_position, do_mouse_event, win32_read_socket): Support for MULE.
Diffstat (limited to 'src')
-rw-r--r--src/w32inevt.c123
1 files changed, 72 insertions, 51 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c
index e599c3ca151..beeaae630b6 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -120,62 +120,37 @@ win32_kbd_mods_to_emacs (DWORD mods)
120 return retval; 120 return retval;
121} 121}
122 122
123/* Patch up NT keyboard events when info is missing that should be there, 123/* The return code indicates key code size. */
124 assuming that map_virt_key says that the key is a valid ASCII char. */ 124static int
125static char win32_number_shift_map[] = {
126 ')', '!', '@', '#', '$', '%', '^', '&', '*', '('
127};
128
129#define WIN32_KEY_SHIFTED(mods, no, yes) \
130 ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) ? yes : no)
131
132static void
133win32_kbd_patch_key (KEY_EVENT_RECORD *event) 125win32_kbd_patch_key (KEY_EVENT_RECORD *event)
134{ 126{
135 unsigned int key_code = event->wVirtualKeyCode; 127 unsigned int key_code = event->wVirtualKeyCode;
136 unsigned int mods = event->dwControlKeyState; 128 unsigned int mods = event->dwControlKeyState;
137 int mapped_punct = 0; 129 BYTE keystate[256];
138 130 static BYTE ansi_code[4];
139 /* map_virt_key says its a valid key, but the uChar.AsciiChar field 131 static int isdead;
140 is empty. patch up the uChar.AsciiChar field using wVirtualKeyCode. */ 132
141 if (event->uChar.AsciiChar == 0 133 if (isdead == 2)
142 && ((key_code >= '0' && key_code <= '9') 134 {
143 || (key_code >= 'A' && key_code <= 'Z') 135 event->uChar.AsciiChar = ansi_code[2];
144 || (key_code >= 0xBA && key_code <= 0xC0) 136 isdead = 0;
145 || (key_code >= 0xDB && key_code <= 0xDE) 137 return 1;
146 )) {
147 if (key_code >= '0' && key_code <= '9') {
148 event->uChar.AsciiChar =
149 WIN32_KEY_SHIFTED (mods, key_code,
150 win32_number_shift_map[key_code - '0']);
151 return;
152 }
153 switch (key_code) {
154 case 0xBA: mapped_punct = WIN32_KEY_SHIFTED (mods, ';', ':'); break;
155 case 0xBB: mapped_punct = WIN32_KEY_SHIFTED (mods, '=', '+'); break;
156 case 0xBC: mapped_punct = WIN32_KEY_SHIFTED (mods, ',', '<'); break;
157 case 0xBD: mapped_punct = WIN32_KEY_SHIFTED (mods, '-', '_'); break;
158 case 0xBE: mapped_punct = WIN32_KEY_SHIFTED (mods, '.', '>'); break;
159 case 0xBF: mapped_punct = WIN32_KEY_SHIFTED (mods, '/', '?'); break;
160 case 0xC0: mapped_punct = WIN32_KEY_SHIFTED (mods, '`', '~'); break;
161 case 0xDB: mapped_punct = WIN32_KEY_SHIFTED (mods, '[', '{'); break;
162 case 0xDC: mapped_punct = WIN32_KEY_SHIFTED (mods, '\\', '|'); break;
163 case 0xDD: mapped_punct = WIN32_KEY_SHIFTED (mods, ']', '}'); break;
164 case 0xDE: mapped_punct = WIN32_KEY_SHIFTED (mods, '\'', '"'); break;
165 default:
166 mapped_punct = 0;
167 break;
168 }
169 if (mapped_punct) {
170 event->uChar.AsciiChar = mapped_punct;
171 return;
172 } 138 }
173 /* otherwise, it's a letter. */ 139 if (event->uChar.AsciiChar != 0)
174 event->uChar.AsciiChar = WIN32_KEY_SHIFTED (mods, key_code - 'A' + 'a', 140 return 1;
175 key_code); 141 memset (keystate, 0, sizeof (keystate));
176 } 142 if (mods & SHIFT_PRESSED)
143 keystate[VK_SHIFT] = 0x80;
144 if (mods & CAPSLOCK_ON)
145 keystate[VK_CAPITAL] = 1;
146 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode,
147 keystate, (LPWORD) ansi_code, 0);
148 if (isdead == 0)
149 return 0;
150 event->uChar.AsciiChar = ansi_code[0];
151 return isdead;
177} 152}
178 153
179/* Map virtual key codes into: 154/* Map virtual key codes into:
180 -1 - Ignore this key 155 -1 - Ignore this key
181 -2 - ASCII char 156 -2 - ASCII char
@@ -187,7 +162,11 @@ win32_kbd_patch_key (KEY_EVENT_RECORD *event)
187 162
188static int map_virt_key[256] = 163static int map_virt_key[256] =
189{ 164{
165#ifdef MULE
166 -3,
167#else
190 -1, 168 -1,
169#endif
191 -1, /* VK_LBUTTON */ 170 -1, /* VK_LBUTTON */
192 -1, /* VK_RBUTTON */ 171 -1, /* VK_RBUTTON */
193 0x69, /* VK_CANCEL */ 172 0x69, /* VK_CANCEL */
@@ -294,10 +273,13 @@ static int map_virt_key[256] =
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */ 273 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */
295}; 274};
296 275
276/* return code -1 means that event_queue_ptr won't be incremented.
277 In other word, this event makes two key codes. (by himi) */
297static int 278static int
298key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) 279key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev)
299{ 280{
300 int map; 281 int map;
282 int key_flag = 0;
301 static BOOL map_virt_key_init_done; 283 static BOOL map_virt_key_init_done;
302 284
303 /* Skip key-up events. */ 285 /* Skip key-up events. */
@@ -337,9 +319,28 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev)
337 { 319 {
338 /* ASCII */ 320 /* ASCII */
339 emacs_ev->kind = ascii_keystroke; 321 emacs_ev->kind = ascii_keystroke;
340 win32_kbd_patch_key (event); 322 key_flag = win32_kbd_patch_key (event); /* 95.7.25 by himi */
323 if (key_flag == 0)
324 return 0;
341 XSETINT (emacs_ev->code, event->uChar.AsciiChar); 325 XSETINT (emacs_ev->code, event->uChar.AsciiChar);
342 } 326 }
327#ifdef MULE
328 /* for IME */
329 else if (map == -3)
330 {
331 if ((event->dwControlKeyState & NLS_IME_CONVERSION)
332 && !(event->dwControlKeyState & RIGHT_ALT_PRESSED)
333 && !(event->dwControlKeyState & LEFT_ALT_PRESSED)
334 && !(event->dwControlKeyState & RIGHT_CTRL_PRESSED)
335 && !(event->dwControlKeyState & LEFT_CTRL_PRESSED))
336 {
337 emacs_ev->kind = ascii_keystroke;
338 XSETINT (emacs_ev->code, event->uChar.AsciiChar);
339 }
340 else
341 return 0;
342 }
343#endif
343 else 344 else
344 { 345 {
345 /* non-ASCII */ 346 /* non-ASCII */
@@ -351,16 +352,24 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev)
351 map |= 0xff00; 352 map |= 0xff00;
352 XSETINT (emacs_ev->code, map); 353 XSETINT (emacs_ev->code, map);
353 } 354 }
355/* for Mule 2.2 (Based on Emacs 19.28) */
356#ifdef MULE
357 XSET (emacs_ev->frame_or_window, Lisp_Frame, get_frame ());
358#else
354 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); 359 XSETFRAME (emacs_ev->frame_or_window, get_frame ());
360#endif
355 emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState); 361 emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState);
356 emacs_ev->timestamp = GetTickCount (); 362 emacs_ev->timestamp = GetTickCount ();
363 if (key_flag == 2) return -1; /* 95.7.25 by himi */
357 return 1; 364 return 1;
358} 365}
359 366
360/* Mouse position hook. */ 367/* Mouse position hook. */
361void 368void
362win32_mouse_position (FRAME_PTR *f, 369win32_mouse_position (FRAME_PTR *f,
370#ifndef MULE
363 int insist, 371 int insist,
372#endif
364 Lisp_Object *bar_window, 373 Lisp_Object *bar_window,
365 enum scroll_bar_part *part, 374 enum scroll_bar_part *part,
366 Lisp_Object *x, 375 Lisp_Object *x,
@@ -369,7 +378,9 @@ win32_mouse_position (FRAME_PTR *f,
369{ 378{
370 BLOCK_INPUT; 379 BLOCK_INPUT;
371 380
381#ifndef MULE
372 insist = insist; 382 insist = insist;
383#endif
373 384
374 *f = get_frame (); 385 *f = get_frame ();
375 *bar_window = Qnil; 386 *bar_window = Qnil;
@@ -459,7 +470,12 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
459 470
460 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); 471 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X);
461 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); 472 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y);
473/* for Mule 2.2 (Based on Emacs 19.28 */
474#ifdef MULE
475 XSET (emacs_ev->frame_or_window, Lisp_Frame, get_frame ());
476#else
462 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); 477 XSETFRAME (emacs_ev->frame_or_window, get_frame ());
478#endif
463 479
464 return 1; 480 return 1;
465} 481}
@@ -507,6 +523,11 @@ win32_read_socket (int sd, struct input_event *bufp, int numchars,
507 { 523 {
508 case KEY_EVENT: 524 case KEY_EVENT:
509 add = key_event (&queue_ptr->Event.KeyEvent, bufp); 525 add = key_event (&queue_ptr->Event.KeyEvent, bufp);
526 if (add == -1) /* 95.7.25 by himi */
527 {
528 queue_ptr--;
529 add = 1;
530 }
510 bufp += add; 531 bufp += add;
511 ret += add; 532 ret += add;
512 numchars -= add; 533 numchars -= add;