| @@ -41,27 +41,31 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. | | | @@ -41,27 +41,31 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. |
41 | ********************************************************/ | | 41 | ********************************************************/ |
42 | /* $XFree86: xc/programs/Xserver/hw/sun/sunKbd.c,v 1.9 2003/11/17 22:20:36 dawes Exp $ */ | | 42 | /* $XFree86: xc/programs/Xserver/hw/sun/sunKbd.c,v 1.9 2003/11/17 22:20:36 dawes Exp $ */ |
43 | | | 43 | |
44 | #define NEED_EVENTS | | 44 | #define NEED_EVENTS |
45 | #include "sun.h" | | 45 | #include "sun.h" |
46 | #include <X11/keysym.h> | | 46 | #include <X11/keysym.h> |
47 | #include <X11/Sunkeysym.h> | | 47 | #include <X11/Sunkeysym.h> |
48 | #include "mi.h" | | 48 | #include "mi.h" |
49 | | | 49 | |
50 | #include <X11/extensions/XKB.h> | | 50 | #include <X11/extensions/XKB.h> |
51 | #include "xkbsrv.h" | | 51 | #include "xkbsrv.h" |
52 | #include "xkbstr.h" | | 52 | #include "xkbstr.h" |
53 | | | 53 | |
| | | 54 | #ifdef __sun |
54 | #define SUN_LED_MASK 0x0f | | 55 | #define SUN_LED_MASK 0x0f |
| | | 56 | #else |
| | | 57 | #define SUN_LED_MASK 0x07 |
| | | 58 | #endif |
55 | #define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */ | | 59 | #define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */ |
56 | #define MAX_KEYCODE 255 /* limited by the protocol */ | | 60 | #define MAX_KEYCODE 255 /* limited by the protocol */ |
57 | #ifndef KB_SUN4 | | 61 | #ifndef KB_SUN4 |
58 | #define KB_SUN4 4 | | 62 | #define KB_SUN4 4 |
59 | #endif | | 63 | #endif |
60 | | | 64 | |
61 | #define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \ | | 65 | #define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \ |
62 | if ((tv1).tv_usec < (tv2).tv_usec) { \ | | 66 | if ((tv1).tv_usec < (tv2).tv_usec) { \ |
63 | (tv1).tv_usec += 1000000; \ | | 67 | (tv1).tv_usec += 1000000; \ |
64 | (tv1).tv_sec -= 1; \ | | 68 | (tv1).tv_sec -= 1; \ |
65 | } \ | | 69 | } \ |
66 | (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \ | | 70 | (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \ |
67 | (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec; | | 71 | (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec; |
| @@ -134,43 +138,61 @@ void SwapLKeys(KeySymsRec* keysyms) | | | @@ -134,43 +138,61 @@ void SwapLKeys(KeySymsRec* keysyms) |
134 | /* yes, I could have done a clever two line swap! */ | | 138 | /* yes, I could have done a clever two line swap! */ |
135 | k = keysyms->map[i - 2]; | | 139 | k = keysyms->map[i - 2]; |
136 | keysyms->map[i - 2] = keysyms->map[i]; | | 140 | keysyms->map[i - 2] = keysyms->map[i]; |
137 | keysyms->map[i] = k; | | 141 | keysyms->map[i] = k; |
138 | } | | 142 | } |
139 | } | | 143 | } |
140 | | | 144 | |
141 | static void | | 145 | static void |
142 | SetLights(KeybdCtrl* ctrl, int fd) | | 146 | SetLights(KeybdCtrl* ctrl, int fd) |
143 | { | | 147 | { |
144 | #ifdef KIOCSLED | | 148 | #ifdef KIOCSLED |
145 | static unsigned char led_tab[16] = { | | 149 | static unsigned char led_tab[16] = { |
146 | 0, | | 150 | 0, |
| | | 151 | #ifdef __sun |
147 | LED_NUM_LOCK, | | 152 | LED_NUM_LOCK, |
148 | LED_SCROLL_LOCK, | | 153 | LED_SCROLL_LOCK, |
149 | LED_SCROLL_LOCK | LED_NUM_LOCK, | | 154 | LED_SCROLL_LOCK | LED_NUM_LOCK, |
150 | LED_COMPOSE, | | 155 | LED_COMPOSE, |
151 | LED_COMPOSE | LED_NUM_LOCK, | | 156 | LED_COMPOSE | LED_NUM_LOCK, |
152 | LED_COMPOSE | LED_SCROLL_LOCK, | | 157 | LED_COMPOSE | LED_SCROLL_LOCK, |
153 | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK, | | 158 | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK, |
154 | LED_CAPS_LOCK, | | 159 | LED_CAPS_LOCK, |
155 | LED_CAPS_LOCK | LED_NUM_LOCK, | | 160 | LED_CAPS_LOCK | LED_NUM_LOCK, |
156 | LED_CAPS_LOCK | LED_SCROLL_LOCK, | | 161 | LED_CAPS_LOCK | LED_SCROLL_LOCK, |
157 | LED_CAPS_LOCK | LED_SCROLL_LOCK | LED_NUM_LOCK, | | 162 | LED_CAPS_LOCK | LED_SCROLL_LOCK | LED_NUM_LOCK, |
158 | LED_CAPS_LOCK | LED_COMPOSE, | | 163 | LED_CAPS_LOCK | LED_COMPOSE, |
159 | LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK, | | 164 | LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK, |
160 | LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK, | | 165 | LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK, |
161 | LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK | | 166 | LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK |
| | | 167 | #else |
| | | 168 | LED_CAPS_LOCK, |
| | | 169 | LED_NUM_LOCK, |
| | | 170 | LED_NUM_LOCK | LED_CAPS_LOCK, |
| | | 171 | LED_SCROLL_LOCK, |
| | | 172 | LED_SCROLL_LOCK | LED_CAPS_LOCK, |
| | | 173 | LED_SCROLL_LOCK | LED_NUM_LOCK, |
| | | 174 | LED_SCROLL_LOCK | LED_NUM_LOCK | LED_CAPS_LOCK, |
| | | 175 | LED_COMPOSE, |
| | | 176 | LED_COMPOSE | LED_CAPS_LOCK, |
| | | 177 | LED_COMPOSE | LED_NUM_LOCK, |
| | | 178 | LED_COMPOSE | LED_NUM_LOCK | LED_CAPS_LOCK, |
| | | 179 | LED_COMPOSE | LED_SCROLL_LOCK, |
| | | 180 | LED_COMPOSE | LED_SCROLL_LOCK | LED_CAPS_LOCK, |
| | | 181 | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK, |
| | | 182 | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK | LED_CAPS_LOCK, |
| | | 183 | #endif |
162 | }; | | 184 | }; |
163 | if (ioctl (fd, KIOCSLED, (caddr_t)&led_tab[ctrl->leds & 0x0f]) == -1) | | 185 | if (ioctl (fd, KIOCSLED, (caddr_t)&led_tab[ctrl->leds & SUN_LED_MASK]) == -1) |
164 | ErrorF("Failed to set keyboard lights"); | | 186 | ErrorF("Failed to set keyboard lights"); |
165 | #endif | | 187 | #endif |
166 | } | | 188 | } |
167 | | | 189 | |
168 | | | 190 | |
169 | /*- | | 191 | /*- |
170 | *----------------------------------------------------------------------- | | 192 | *----------------------------------------------------------------------- |
171 | * sunBell -- | | 193 | * sunBell -- |
172 | * Ring the terminal/keyboard bell | | 194 | * Ring the terminal/keyboard bell |
173 | * | | 195 | * |
174 | * Results: | | 196 | * Results: |
175 | * Ring the keyboard bell for an amount of time proportional to | | 197 | * Ring the keyboard bell for an amount of time proportional to |
176 | * "loudness." | | 198 | * "loudness." |
| @@ -213,30 +235,37 @@ void | | | @@ -213,30 +235,37 @@ void |
213 | DDXRingBell(int volume, int pitch, int duration) | | 235 | DDXRingBell(int volume, int pitch, int duration) |
214 | { | | 236 | { |
215 | DeviceIntPtr pKeyboard; | | 237 | DeviceIntPtr pKeyboard; |
216 | sunKbdPrivPtr pPriv; | | 238 | sunKbdPrivPtr pPriv; |
217 | | | 239 | |
218 | pKeyboard = sunKeyboardDevice; | | 240 | pKeyboard = sunKeyboardDevice; |
219 | if (pKeyboard != NULL) { | | 241 | if (pKeyboard != NULL) { |
220 | pPriv = (sunKbdPrivPtr)pKeyboard->public.devicePrivate; | | 242 | pPriv = (sunKbdPrivPtr)pKeyboard->public.devicePrivate; |
221 | bell(pPriv->fd, duration * 1000); | | 243 | bell(pPriv->fd, duration * 1000); |
222 | } | | 244 | } |
223 | } | | 245 | } |
224 | | | 246 | |
225 | | | 247 | |
| | | 248 | #ifdef __sun |
226 | #define XLED_NUM_LOCK 0x1 | | 249 | #define XLED_NUM_LOCK 0x1 |
227 | #define XLED_COMPOSE 0x4 | | 250 | #define XLED_COMPOSE 0x4 |
228 | #define XLED_SCROLL_LOCK 0x2 | | 251 | #define XLED_SCROLL_LOCK 0x2 |
229 | #define XLED_CAPS_LOCK 0x8 | | 252 | #define XLED_CAPS_LOCK 0x8 |
| | | 253 | #else |
| | | 254 | #define XLED_NUM_LOCK 0x2 |
| | | 255 | #define XLED_COMPOSE 0x8 |
| | | 256 | #define XLED_SCROLL_LOCK 0x4 |
| | | 257 | #define XLED_CAPS_LOCK 0x1 |
| | | 258 | #endif |
230 | | | 259 | |
231 | static KeyCode | | 260 | static KeyCode |
232 | LookupKeyCode(KeySym keysym, XkbDescPtr xkb, KeySymsPtr syms) | | 261 | LookupKeyCode(KeySym keysym, XkbDescPtr xkb, KeySymsPtr syms) |
233 | { | | 262 | { |
234 | KeyCode i; | | 263 | KeyCode i; |
235 | int ii, index = 0; | | 264 | int ii, index = 0; |
236 | | | 265 | |
237 | for (i = xkb->min_key_code; i < xkb->max_key_code; i++) | | 266 | for (i = xkb->min_key_code; i < xkb->max_key_code; i++) |
238 | for (ii = 0; ii < syms->mapWidth; ii++) | | 267 | for (ii = 0; ii < syms->mapWidth; ii++) |
239 | if (syms->map[index++] == keysym) | | 268 | if (syms->map[index++] == keysym) |
240 | return i; | | 269 | return i; |
241 | return 0; | | 270 | return 0; |
242 | } | | 271 | } |
| @@ -314,27 +343,27 @@ DoLEDs( | | | @@ -314,27 +343,27 @@ DoLEDs( |
314 | | | 343 | |
315 | if (!(ctrl->leds & XLED_SCROLL_LOCK) && (pPriv->leds & XLED_SCROLL_LOCK)) | | 344 | if (!(ctrl->leds & XLED_SCROLL_LOCK) && (pPriv->leds & XLED_SCROLL_LOCK)) |
316 | pseudoKey(device, FALSE, | | 345 | pseudoKey(device, FALSE, |
317 | LookupKeyCode(XK_Scroll_Lock, xkb, syms)); | | 346 | LookupKeyCode(XK_Scroll_Lock, xkb, syms)); |
318 | | | 347 | |
319 | if ((ctrl->leds & XLED_COMPOSE) && !(pPriv->leds & XLED_COMPOSE)) | | 348 | if ((ctrl->leds & XLED_COMPOSE) && !(pPriv->leds & XLED_COMPOSE)) |
320 | pseudoKey(device, TRUE, | | 349 | pseudoKey(device, TRUE, |
321 | LookupKeyCode(SunXK_Compose, xkb, syms)); | | 350 | LookupKeyCode(SunXK_Compose, xkb, syms)); |
322 | | | 351 | |
323 | if (!(ctrl->leds & XLED_COMPOSE) && (pPriv->leds & XLED_COMPOSE)) | | 352 | if (!(ctrl->leds & XLED_COMPOSE) && (pPriv->leds & XLED_COMPOSE)) |
324 | pseudoKey(device, FALSE, | | 353 | pseudoKey(device, FALSE, |
325 | LookupKeyCode(SunXK_Compose, xkb, syms)); | | 354 | LookupKeyCode(SunXK_Compose, xkb, syms)); |
326 | | | 355 | |
327 | pPriv->leds = ctrl->leds & 0x0f; | | 356 | pPriv->leds = ctrl->leds & SUN_LED_MASK; |
328 | SetLights (ctrl, pPriv->fd); | | 357 | SetLights (ctrl, pPriv->fd); |
329 | free(syms->map); | | 358 | free(syms->map); |
330 | free(syms); | | 359 | free(syms); |
331 | } | | 360 | } |
332 | | | 361 | |
333 | /*- | | 362 | /*- |
334 | *----------------------------------------------------------------------- | | 363 | *----------------------------------------------------------------------- |
335 | * sunKbdCtrl -- | | 364 | * sunKbdCtrl -- |
336 | * Alter some of the keyboard control parameters | | 365 | * Alter some of the keyboard control parameters |
337 | * | | 366 | * |
338 | * Results: | | 367 | * Results: |
339 | * None. | | 368 | * None. |
340 | * | | 369 | * |
| @@ -349,27 +378,27 @@ sunKbdCtrl(DeviceIntPtr device, KeybdCtr | | | @@ -349,27 +378,27 @@ sunKbdCtrl(DeviceIntPtr device, KeybdCtr |
349 | { | | 378 | { |
350 | sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate; | | 379 | sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate; |
351 | | | 380 | |
352 | if (pPriv->fd < 0) return; | | 381 | if (pPriv->fd < 0) return; |
353 | | | 382 | |
354 | if (ctrl->click != pPriv->click) { | | 383 | if (ctrl->click != pPriv->click) { |
355 | int kbdClickCmd; | | 384 | int kbdClickCmd; |
356 | | | 385 | |
357 | pPriv->click = ctrl->click; | | 386 | pPriv->click = ctrl->click; |
358 | kbdClickCmd = pPriv->click ? KBD_CMD_CLICK : KBD_CMD_NOCLICK; | | 387 | kbdClickCmd = pPriv->click ? KBD_CMD_CLICK : KBD_CMD_NOCLICK; |
359 | if (ioctl (pPriv->fd, KIOCCMD, &kbdClickCmd) == -1) | | 388 | if (ioctl (pPriv->fd, KIOCCMD, &kbdClickCmd) == -1) |
360 | ErrorF("Failed to set keyclick"); | | 389 | ErrorF("Failed to set keyclick"); |
361 | } | | 390 | } |
362 | if ((pPriv->type == KB_SUN4) && (pPriv->leds != (ctrl->leds & 0x0f))) | | 391 | if ((pPriv->type == KB_SUN4) && (pPriv->leds != (ctrl->leds & SUN_LED_MASK))) |
363 | DoLEDs(device, ctrl, pPriv); | | 392 | DoLEDs(device, ctrl, pPriv); |
364 | } | | 393 | } |
365 | | | 394 | |
366 | /*- | | 395 | /*- |
367 | *----------------------------------------------------------------------- | | 396 | *----------------------------------------------------------------------- |
368 | * sunInitKbdNames -- | | 397 | * sunInitKbdNames -- |
369 | * Handle the XKB initialization | | 398 | * Handle the XKB initialization |
370 | * | | 399 | * |
371 | * Results: | | 400 | * Results: |
372 | * None. | | 401 | * None. |
373 | * | | 402 | * |
374 | * Comments: | | 403 | * Comments: |
375 | * This function needs considerable work, in conjunctions with | | 404 | * This function needs considerable work, in conjunctions with |