Mercurial > emacs
annotate src/w32inevt.c @ 14191:a340d3b95455 libc-960116 libc-960117
(sco5): New case.
author | Richard Kenner <kenner@gnu.org> |
---|---|
date | Tue, 16 Jan 1996 01:58:43 +0000 |
parents | ee40177f6c68 |
children | 59d24d42958a |
rev | line source |
---|---|
9907 | 1 /* Input event support for Windows NT port of GNU Emacs. |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
2 Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc. |
9907 | 3 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
4 This file is part of GNU Emacs. |
9907 | 5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
9 any later version. |
9907 | 10 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
14 GNU General Public License for more details. |
9907 | 15 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
9907 | 20 |
21 Drew Bliss 01-Oct-93 | |
22 Adapted from ntkbd.c by Tim Fleehart | |
23 */ | |
24 | |
25 | |
26 #include "config.h" | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "lisp.h" | |
33 #include "frame.h" | |
34 #include "blockinput.h" | |
35 #include "termhooks.h" | |
36 | |
37 /* stdin, from ntterm */ | |
38 extern HANDLE keyboard_handle; | |
39 | |
40 /* Info for last mouse motion */ | |
41 static COORD movement_pos; | |
42 static DWORD movement_time; | |
43 | |
44 /* from keyboard.c */ | |
45 extern void reinvoke_input_signal (void); | |
46 | |
47 /* from dispnew.c */ | |
48 extern int change_frame_size (FRAME_PTR, int, int, int, int); | |
49 | |
50 /* Event queue */ | |
51 #define EVENT_QUEUE_SIZE 50 | |
52 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; | |
53 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; | |
54 | |
55 static int | |
56 fill_queue (BOOL block) | |
57 { | |
58 BOOL rc; | |
59 DWORD events_waiting; | |
60 | |
61 if (queue_ptr < queue_end) | |
62 return queue_end-queue_ptr; | |
63 | |
64 if (!block) | |
65 { | |
66 /* Check to see if there are some events to read before we try | |
67 because we can't block. */ | |
68 if (!GetNumberOfConsoleInputEvents (keyboard_handle, &events_waiting)) | |
69 return -1; | |
70 if (events_waiting == 0) | |
71 return 0; | |
72 } | |
73 | |
74 rc = ReadConsoleInput (keyboard_handle, event_queue, EVENT_QUEUE_SIZE, | |
75 &events_waiting); | |
76 if (!rc) | |
77 return -1; | |
78 queue_ptr = event_queue; | |
79 queue_end = event_queue + events_waiting; | |
80 return (int) events_waiting; | |
81 } | |
82 | |
83 /* In a generic, multi-frame world this should take a console handle | |
84 and return the frame for it | |
85 | |
86 Right now, there's only one frame so return it. */ | |
87 static FRAME_PTR | |
88 get_frame (void) | |
89 { | |
90 return selected_frame; | |
91 } | |
92 | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
93 /* Translate console modifiers to emacs modifiers. |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
94 German keyboard support (Kai Morgan Zeise 2/18/95). */ |
9907 | 95 static int |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
96 win32_kbd_mods_to_emacs (DWORD mods) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
97 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
98 int retval = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
99 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
100 /* If AltGr has been pressed, remove it. */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
101 if ((mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
102 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
103 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
104 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
105 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
106 retval = meta_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
107 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
108 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
109 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
110 retval |= ctrl_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
111 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
112 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
113 retval |= meta_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
114 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
115 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
116 if (((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == SHIFT_PRESSED) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
117 || ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == CAPSLOCK_ON)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
118 retval |= shift_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
119 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
120 return retval; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
121 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
122 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
123 /* Patch up NT keyboard events when info is missing that should be there, |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
124 assuming that map_virt_key says that the key is a valid ASCII char. */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
125 static char win32_number_shift_map[] = { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
126 ')', '!', '@', '#', '$', '%', '^', '&', '*', '(' |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
127 }; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
128 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
129 #define WIN32_KEY_SHIFTED(mods, no, yes) \ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
130 ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) ? yes : no) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
131 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
132 static void |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
133 win32_kbd_patch_key (KEY_EVENT_RECORD *event) |
9907 | 134 { |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
135 unsigned int key_code = event->wVirtualKeyCode; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
136 unsigned int mods = event->dwControlKeyState; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
137 int mapped_punct = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
138 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
139 /* map_virt_key says its a valid key, but the uChar.AsciiChar field |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
140 is empty. patch up the uChar.AsciiChar field using wVirtualKeyCode. */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
141 if (event->uChar.AsciiChar == 0 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
142 && ((key_code >= '0' && key_code <= '9') |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
143 || (key_code >= 'A' && key_code <= 'Z') |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
144 || (key_code >= 0xBA && key_code <= 0xC0) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
145 || (key_code >= 0xDB && key_code <= 0xDE) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
146 )) { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
147 if (key_code >= '0' && key_code <= '9') { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
148 event->uChar.AsciiChar = |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
149 WIN32_KEY_SHIFTED (mods, key_code, |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
150 win32_number_shift_map[key_code - '0']); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
151 return; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
152 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
153 switch (key_code) { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
154 case 0xBA: mapped_punct = WIN32_KEY_SHIFTED (mods, ';', ':'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
155 case 0xBB: mapped_punct = WIN32_KEY_SHIFTED (mods, '=', '+'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
156 case 0xBC: mapped_punct = WIN32_KEY_SHIFTED (mods, ',', '<'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
157 case 0xBD: mapped_punct = WIN32_KEY_SHIFTED (mods, '-', '_'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
158 case 0xBE: mapped_punct = WIN32_KEY_SHIFTED (mods, '.', '>'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
159 case 0xBF: mapped_punct = WIN32_KEY_SHIFTED (mods, '/', '?'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
160 case 0xC0: mapped_punct = WIN32_KEY_SHIFTED (mods, '`', '~'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
161 case 0xDB: mapped_punct = WIN32_KEY_SHIFTED (mods, '[', '{'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
162 case 0xDC: mapped_punct = WIN32_KEY_SHIFTED (mods, '\\', '|'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
163 case 0xDD: mapped_punct = WIN32_KEY_SHIFTED (mods, ']', '}'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
164 case 0xDE: mapped_punct = WIN32_KEY_SHIFTED (mods, '\'', '"'); break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
165 default: |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
166 mapped_punct = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
167 break; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
168 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
169 if (mapped_punct) { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
170 event->uChar.AsciiChar = mapped_punct; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
171 return; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
172 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
173 /* otherwise, it's a letter. */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
174 event->uChar.AsciiChar = WIN32_KEY_SHIFTED (mods, key_code - 'A' + 'a', |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
175 key_code); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
176 } |
9907 | 177 } |
178 | |
179 /* Map virtual key codes into: | |
180 -1 - Ignore this key | |
181 -2 - ASCII char | |
182 Other - Map non-ASCII keys into X keysyms so that they are looked up | |
183 correctly in keyboard.c | |
184 | |
185 Return, escape and tab are mapped to ASCII rather than coming back | |
186 as non-ASCII to be more compatible with old-style keyboard support. */ | |
187 | |
188 static int map_virt_key[256] = | |
189 { | |
190 -1, | |
191 -1, /* VK_LBUTTON */ | |
192 -1, /* VK_RBUTTON */ | |
193 0x69, /* VK_CANCEL */ | |
194 -1, /* VK_MBUTTON */ | |
195 -1, -1, -1, | |
196 8, /* VK_BACK */ | |
197 -2, /* VK_TAB */ | |
198 -1, -1, | |
199 11, /* VK_CLEAR */ | |
200 -2, /* VK_RETURN */ | |
201 -1, -1, | |
202 -1, /* VK_SHIFT */ | |
203 -1, /* VK_CONTROL */ | |
204 -1, /* VK_MENU */ | |
205 0x13, /* VK_PAUSE */ | |
206 -1, /* VK_CAPITAL */ | |
207 -1, -1, -1, -1, -1, -1, | |
208 -2, /* VK_ESCAPE */ | |
209 -1, -1, -1, -1, | |
210 -2, /* VK_SPACE */ | |
211 0x55, /* VK_PRIOR */ | |
212 0x56, /* VK_NEXT */ | |
213 0x57, /* VK_END */ | |
214 0x50, /* VK_HOME */ | |
215 0x51, /* VK_LEFT */ | |
216 0x52, /* VK_UP */ | |
217 0x53, /* VK_RIGHT */ | |
218 0x54, /* VK_DOWN */ | |
219 0x60, /* VK_SELECT */ | |
220 0x61, /* VK_PRINT */ | |
221 0x62, /* VK_EXECUTE */ | |
222 -1, /* VK_SNAPSHOT */ | |
223 0x63, /* VK_INSERT */ | |
224 0xff, /* VK_DELETE */ | |
225 0x6a, /* VK_HELP */ | |
226 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0 - 9 */ | |
227 -1, -1, -1, -1, -1, -1, -1, | |
228 -2, -2, -2, -2, -2, -2, -2, -2, /* A - Z */ | |
229 -2, -2, -2, -2, -2, -2, -2, -2, | |
230 -2, -2, -2, -2, -2, -2, -2, -2, | |
231 -2, -2, | |
232 -1, -1, -1, -1, -1, | |
233 0xb0, /* VK_NUMPAD0 */ | |
234 0xb1, /* VK_NUMPAD1 */ | |
235 0xb2, /* VK_NUMPAD2 */ | |
236 0xb3, /* VK_NUMPAD3 */ | |
237 0xb4, /* VK_NUMPAD4 */ | |
238 0xb5, /* VK_NUMPAD5 */ | |
239 0xb6, /* VK_NUMPAD6 */ | |
240 0xb7, /* VK_NUMPAD7 */ | |
241 0xb8, /* VK_NUMPAD8 */ | |
242 0xb9, /* VK_NUMPAD9 */ | |
243 0xaa, /* VK_MULTIPLY */ | |
244 0xab, /* VK_ADD */ | |
245 0xac, /* VK_SEPARATOR */ | |
246 0xad, /* VK_SUBTRACT */ | |
247 0xae, /* VK_DECIMAL */ | |
248 0xaf, /* VK_DIVIDE */ | |
249 0xbe, /* VK_F1 */ | |
250 0xbf, /* VK_F2 */ | |
251 0xc0, /* VK_F3 */ | |
252 0xc1, /* VK_F4 */ | |
253 0xc2, /* VK_F5 */ | |
254 0xc3, /* VK_F6 */ | |
255 0xc4, /* VK_F7 */ | |
256 0xc5, /* VK_F8 */ | |
257 0xc6, /* VK_F9 */ | |
258 0xc7, /* VK_F10 */ | |
259 0xc8, /* VK_F11 */ | |
260 0xc9, /* VK_F12 */ | |
261 0xca, /* VK_F13 */ | |
262 0xcb, /* VK_F14 */ | |
263 0xcc, /* VK_F15 */ | |
264 0xcd, /* VK_F16 */ | |
265 0xce, /* VK_F17 */ | |
266 0xcf, /* VK_F18 */ | |
267 0xd0, /* VK_F19 */ | |
268 0xd1, /* VK_F20 */ | |
269 0xd2, /* VK_F21 */ | |
270 0xd3, /* VK_F22 */ | |
271 0xd4, /* VK_F23 */ | |
272 0xd5, /* VK_F24 */ | |
273 -1, -1, -1, -1, -1, -1, -1, -1, | |
274 0x7f, /* VK_NUMLOCK */ | |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
275 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9f */ |
9907 | 276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xaf */ |
277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb9 */ | |
278 -2, /* ; */ | |
279 -2, /* = */ | |
280 -2, /* , */ | |
281 -2, /* \ */ | |
282 -2, /* . */ | |
283 -2, /* / */ | |
284 -2, /* ` */ | |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xcf */ |
9907 | 286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xda */ |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
287 -2, -2, -2, -2, -2, /* 0xdf */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
288 -2, -2, -2, -2, -2, |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
289 -1, /* 0xe5 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
290 -2, /* oxe6 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
291 -1, -1, /* 0xe8 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
292 -2, -2, -2, -2, -2, -2, -2, /* 0xef */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
293 -2, -2, -2, -2, -2, -2, |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */ |
9907 | 295 }; |
296 | |
297 static int | |
298 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | |
299 { | |
300 int map; | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
301 static BOOL map_virt_key_init_done; |
9907 | 302 |
303 /* Skip key-up events. */ | |
304 if (event->bKeyDown == FALSE) | |
305 return 0; | |
306 | |
307 if (event->wVirtualKeyCode > 0xff) | |
308 { | |
309 printf ("Unknown key code %d\n", event->wVirtualKeyCode); | |
310 return 0; | |
311 } | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
312 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
313 /* Patch needed for German keyboard. Ulrich Leodolter (1/11/95). */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
314 if (! map_virt_key_init_done) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
315 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
316 short vk; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
317 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
318 if ((vk = VkKeyScan (0x3c)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* less */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
319 if ((vk = VkKeyScan (0x3e)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* greater */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
320 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
321 map_virt_key_init_done = TRUE; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
322 } |
9907 | 323 |
324 /* BUGBUG - Ignores the repeat count | |
325 It's questionable whether we want to obey the repeat count anyway | |
326 since keys usually aren't repeated unless key events back up in | |
327 the queue. If they're backing up then we don't generally want | |
328 to honor them later since that leads to significant slop in | |
329 cursor motion when the system is under heavy load. */ | |
330 | |
331 map = map_virt_key[event->wVirtualKeyCode]; | |
332 if (map == -1) | |
333 { | |
334 return 0; | |
335 } | |
336 else if (map == -2) | |
337 { | |
338 /* ASCII */ | |
339 emacs_ev->kind = ascii_keystroke; | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
340 win32_kbd_patch_key (event); |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
341 XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
9907 | 342 } |
343 else | |
344 { | |
345 /* non-ASCII */ | |
346 emacs_ev->kind = non_ascii_keystroke; | |
347 /* | |
348 * make_lispy_event () now requires non-ascii codes to have | |
349 * the full X keysym values (2nd byte is 0xff). add it on. | |
350 */ | |
351 map |= 0xff00; | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
352 XSETINT (emacs_ev->code, map); |
9907 | 353 } |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
354 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
355 emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState); |
9907 | 356 emacs_ev->timestamp = GetTickCount (); |
357 return 1; | |
358 } | |
359 | |
360 /* Mouse position hook. */ | |
361 void | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
362 win32_mouse_position (FRAME_PTR *f, |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
363 int insist, |
9907 | 364 Lisp_Object *bar_window, |
365 enum scroll_bar_part *part, | |
366 Lisp_Object *x, | |
367 Lisp_Object *y, | |
368 unsigned long *time) | |
369 { | |
370 BLOCK_INPUT; | |
371 | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
372 insist = insist; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
373 |
9907 | 374 *f = get_frame (); |
375 *bar_window = Qnil; | |
376 *part = 0; | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
377 selected_frame->mouse_moved = 0; |
9907 | 378 |
379 *x = movement_pos.X; | |
380 *y = movement_pos.Y; | |
381 *time = movement_time; | |
382 | |
383 UNBLOCK_INPUT; | |
384 } | |
385 | |
386 /* Remember mouse motion and notify emacs. */ | |
387 static void | |
388 mouse_moved_to (int x, int y) | |
389 { | |
390 /* If we're in the same place, ignore it */ | |
391 if (x != movement_pos.X || y != movement_pos.Y) | |
392 { | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
393 selected_frame->mouse_moved = 1; |
9907 | 394 movement_pos.X = x; |
395 movement_pos.Y = y; | |
396 movement_time = GetTickCount (); | |
397 } | |
398 } | |
399 | |
400 /* Consoles return button bits in a strange order: | |
401 least significant - Leftmost button | |
402 next - Rightmost button | |
403 next - Leftmost+1 | |
404 next - Leftmost+2... | |
405 | |
406 Assume emacs likes three button mice, so | |
407 Left == 0 | |
408 Middle == 1 | |
409 Right == 2 | |
410 Others increase from there. */ | |
411 | |
412 static int emacs_button_translation[NUM_MOUSE_BUTTONS] = | |
413 { | |
414 0, 2, 1, 3, 4, | |
415 }; | |
416 | |
417 static int | |
418 do_mouse_event (MOUSE_EVENT_RECORD *event, | |
419 struct input_event *emacs_ev) | |
420 { | |
421 static DWORD button_state = 0; | |
422 DWORD but_change, mask; | |
423 int i; | |
424 | |
425 if (event->dwEventFlags == MOUSE_MOVED) | |
426 { | |
427 /* For movement events we just note that the mouse has moved | |
428 so that emacs will generate drag events. */ | |
429 mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); | |
430 return 0; | |
431 } | |
432 | |
433 /* It looks like the console code sends us a mouse event with | |
434 dwButtonState == 0 when a window is activated. Ignore this case. */ | |
435 if (event->dwButtonState == button_state) | |
436 return 0; | |
437 | |
438 emacs_ev->kind = mouse_click; | |
439 | |
440 /* Find out what button has changed state since the last button event. */ | |
441 but_change = button_state ^ event->dwButtonState; | |
442 mask = 1; | |
443 for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1) | |
444 if (but_change & mask) | |
445 { | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
446 XSETINT (emacs_ev->code, emacs_button_translation[i]); |
9907 | 447 break; |
448 } | |
449 | |
450 /* If the changed button is out of emacs' range (highly unlikely) | |
451 ignore this event. */ | |
452 if (i == NUM_MOUSE_BUTTONS) | |
453 return 0; | |
454 | |
455 button_state = event->dwButtonState; | |
456 emacs_ev->timestamp = GetTickCount (); | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
457 emacs_ev->modifiers = win32_kbd_mods_to_emacs (event->dwControlKeyState) | |
9907 | 458 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
459 | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
460 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); |
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
461 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
462 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
9907 | 463 |
464 return 1; | |
465 } | |
466 | |
467 static void | |
468 resize_event (WINDOW_BUFFER_SIZE_RECORD *event) | |
469 { | |
470 FRAME_PTR f = get_frame (); | |
471 | |
472 change_frame_size (f, event->dwSize.Y, event->dwSize.X, 0, 1); | |
473 SET_FRAME_GARBAGED (f); | |
474 } | |
475 | |
476 int | |
477 win32_read_socket (int sd, struct input_event *bufp, int numchars, | |
478 int waitp, int expected) | |
479 { | |
480 BOOL no_events = TRUE; | |
481 int nev, ret = 0, add; | |
482 | |
483 if (interrupt_input_blocked) | |
484 { | |
485 interrupt_input_pending = 1; | |
486 return -1; | |
487 } | |
488 | |
489 interrupt_input_pending = 0; | |
490 BLOCK_INPUT; | |
491 | |
492 for (;;) | |
493 { | |
494 nev = fill_queue (waitp != 0); | |
495 if (nev <= 0) | |
496 { | |
497 /* If nev == -1, there was some kind of error | |
498 If nev == 0 then waitp must be zero and no events were available | |
499 so return. */ | |
500 UNBLOCK_INPUT; | |
501 return nev; | |
502 } | |
503 | |
504 while (nev > 0 && numchars > 0) | |
505 { | |
506 switch (queue_ptr->EventType) | |
507 { | |
508 case KEY_EVENT: | |
509 add = key_event (&queue_ptr->Event.KeyEvent, bufp); | |
510 bufp += add; | |
511 ret += add; | |
512 numchars -= add; | |
513 break; | |
514 | |
515 case MOUSE_EVENT: | |
516 add = do_mouse_event (&queue_ptr->Event.MouseEvent, bufp); | |
517 bufp += add; | |
518 ret += add; | |
519 numchars -= add; | |
520 break; | |
521 | |
522 case WINDOW_BUFFER_SIZE_EVENT: | |
523 resize_event (&queue_ptr->Event.WindowBufferSizeEvent); | |
524 break; | |
525 | |
526 case MENU_EVENT: | |
527 case FOCUS_EVENT: | |
528 /* Internal event types, ignored. */ | |
529 break; | |
530 } | |
531 | |
532 queue_ptr++; | |
533 nev--; | |
534 } | |
535 | |
536 if (ret > 0 || expected == 0) | |
537 break; | |
538 } | |
539 | |
540 UNBLOCK_INPUT; | |
541 return ret; | |
542 } |