2 # Dual-head dual-user patch for xorg-x11 (or multi-head multi-user, if you
3 # prefer that). Based on the work of Miguel Freitas and others.
4 # Look at http://cambuca.ldhs.cetuc.puc-rio.br/multiuser/ for detailed
5 # information on how to use this.
7 # Modified for xorg-x11-6.8.1 by Jan "Yenya" Kasprzak <kas@fi.muni.cz>
10 # - Keyboard LED support is still buggy and unfinished.
11 # - on my setup it destroys font on the text console or something like that.
12 # I have no time to investigate this and I don't use text console on this
13 # box (except for booting).
14 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Config.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
15 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Config.c 2004-08-16 22:17:51.000000000 +0200
16 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Config.c 2004-11-19 21:49:47.000000000 +0100
17 @@ -1195,6 +1195,16 @@
21 + } else if (xf86NameCmp(s, "usbev") == 0) {
22 + xf86Info.kbdProc = xf86KbdProc;
23 + xf86Info.kbdEvents = xf86USBKbdEvents;
24 + xf86Msg(X_CONFIG, "Keyboard: Protocol: usbev\n");
25 + s = xf86SetStrOption(inputp->commonOptions, "Device", "/dev/input/event0");
26 + xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
27 + if (xf86Info.kbdFd == -1) {
28 + xf86ConfigError("Keyboard device: cannot open \"%s\"", s);
32 xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
34 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
35 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c 2004-07-06 16:37:47.000000000 +0200
36 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c 2004-11-19 21:49:47.000000000 +0100
38 * only to be used when using dlopen() modules for debugging purposes.
42 +Bool xf86NoVTSwitches = FALSE;
43 +Bool xf86NoPCIAccessDisable = FALSE;
44 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Init.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
45 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Init.c 2004-11-18 22:19:31.000000000 +0100
46 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Init.c 2004-11-19 21:49:47.000000000 +0100
47 @@ -1429,6 +1429,28 @@
51 + if (!strcmp(argv[i],"-delay"))
55 + if (!argv[i + 1] || (delay = atoi(argv[i + 1])) <= 0) {
59 + sleep((unsigned) delay);
63 + if (!strcmp(argv[i],"-novtswitches"))
65 + xf86NoVTSwitches = TRUE;
68 + if (!strcmp(argv[i],"-nopciaccessdisable"))
70 + xf86NoPCIAccessDisable = TRUE;
73 if (!strcmp(argv[i],"-flipPixels"))
75 xf86FlipPixels = TRUE;
76 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
77 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c 2004-11-18 22:19:29.000000000 +0100
78 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c 2004-11-19 21:49:47.000000000 +0100
81 pciIoAccessDisable(void* arg)
83 + if (xf86NoPCIAccessDisable)
87 ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
91 pciIo_MemAccessDisable(void* arg)
93 + if (xf86NoPCIAccessDisable)
97 ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
101 pciMemAccessDisable(void* arg)
103 + if (xf86NoPCIAccessDisable)
107 ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
109 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
110 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h 2004-01-29 09:08:26.000000000 +0100
111 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h 2004-11-19 21:49:47.000000000 +0100
114 extern RootWinPropPtr *xf86RegisteredPropertiesTable;
116 +extern Bool xf86NoVTSwitches;
117 +extern Bool xf86NoPCIAccessDisable;
119 #ifndef DEFAULT_VERBOSE
120 #define DEFAULT_VERBOSE 0
122 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
123 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h 2004-01-29 09:08:26.000000000 +0100
124 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h 2004-11-19 21:49:47.000000000 +0100
133 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c
134 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c 2004-04-23 21:54:08.000000000 +0200
135 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c 2004-11-19 21:49:47.000000000 +0100
136 @@ -121,22 +121,35 @@
138 "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
140 - if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
141 - (xf86Info.vtno == -1)) {
142 - FatalError("xf86OpenConsole: Cannot find a free VT\n");
144 + if (xf86NoVTSwitches) {
145 + if (ioctl(fd, VT_GETSTATE, &vts) == 0)
147 + xf86Info.vtno = vts.v_active;
149 + FatalError("xf86OpenConsole: Cannot find the current VT\n");
152 + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
153 + (xf86Info.vtno == -1)) {
154 + FatalError("xf86OpenConsole: Cannot find a free VT\n");
162 - fb_dev_name=getenv("FRAMEBUFFER");
164 - fb_dev_name="/dev/fb0current";
165 - if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
166 - FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
167 - fb_dev_name, strerror(errno));
168 - if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
169 - FatalError("xf86OpenConsole: Unable to get screen info\n");
170 + if (!xf86NoVTSwitches) {
171 + fb_dev_name=getenv("FRAMEBUFFER");
173 + fb_dev_name="/dev/fb0current";
174 + if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
175 + FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
176 + fb_dev_name, strerror(errno));
177 + if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
178 + FatalError("xf86OpenConsole: Unable to get screen info\n");
181 xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
184 "xf86OpenConsole: Could not save ownership of VT\n");
187 - /* change ownership of the vt */
188 - chown(vtname, getuid(), getgid());
189 + /* humm, not a good idea if we don't really use this vt, chowning it would
190 + probably mess with the first XFree instance. Right? i don't know! */
191 + if (!xf86NoVTSwitches) {
192 + /* change ownership of the vt */
193 + chown(vtname, getuid(), getgid());
197 * the current VT device we're running on is not "console", we want
198 @@ -213,37 +230,42 @@
200 xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
202 - SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
205 - FatalError("xf86OpenConsole: VT_GETMODE failed\n");
208 - signal(SIGUSR1, xf86VTRequest);
209 + if (xf86NoVTSwitches) {
210 + close(xf86Info.consoleFd);
212 + SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
215 + FatalError("xf86OpenConsole: VT_GETMODE failed\n");
218 - VT.mode = VT_PROCESS;
219 - VT.relsig = SIGUSR1;
220 - VT.acqsig = SIGUSR1;
221 - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
223 - FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
225 - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
227 - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
229 + signal(SIGUSR1, xf86VTRequest);
231 + VT.mode = VT_PROCESS;
232 + VT.relsig = SIGUSR1;
233 + VT.acqsig = SIGUSR1;
234 + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
236 + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
238 + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
240 + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
243 - /* we really should have a InitOSInputDevices() function instead
244 - * of Init?$#*&Device(). So I just place it here */
246 + /* we really should have a InitOSInputDevices() function instead
247 + * of Init?$#*&Device(). So I just place it here */
250 - /* copy info to new console */
253 - if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
254 - FatalError("Unable to set screen info\n");
256 + /* copy info to new console */
259 + if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
260 + FatalError("Unable to set screen info\n");
267 @@ -251,16 +273,18 @@
271 - SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
274 - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
277 - ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
280 - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
281 + if (!xf86NoVTSwitches) {
282 + SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
285 + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
288 + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
291 + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
296 @@ -275,22 +299,23 @@
297 ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
298 ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
300 - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
301 - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
304 - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
307 - * Perform a switch back to the active VT when we were started
311 - ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
313 + if (!xf86NoVTSwitches) {
314 + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
315 + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
318 + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
321 + * Perform a switch back to the active VT when we were started
325 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
328 + close(xf86Info.consoleFd); /* make the vt-manager happy */
330 - close(xf86Info.consoleFd); /* make the vt-manager happy */
332 restoreVtPerms(); /* restore the permissions */
335 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
336 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c 2004-04-23 21:54:08.000000000 +0200
337 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c 2004-11-19 21:49:47.000000000 +0100
340 #include "xf86Priv.h"
341 #include "xf86_OSlib.h"
342 +#include <linux/input.h>
343 +#include <linux/kd.h>
345 #define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
348 xf86SoundKbdBell(int loudness, int pitch, int duration)
350 + /* i guess it should be safe to beep even on a diferent keyboard (?) */
351 + /* the beep will be on the system speaker anyway... */
352 + if (xf86Info.kbdEvents == xf86USBKbdEvents)
355 if (loudness && pitch)
357 ioctl(xf86Info.consoleFd, KDMKTONE,
360 xf86SetKbdLeds(int leds)
362 - ioctl(xf86Info.consoleFd, KDSETLED, leds);
363 + struct s_output_event {
364 + struct timeval time;
365 + unsigned short type;
366 + unsigned short code;
367 + unsigned int value;
370 + fprintf(stderr, "xf86SetKbdLeds(0x%x) called\n", leds);
371 + if (xf86Info.kbdEvents != xf86USBKbdEvents) {
372 + ioctl(xf86Info.consoleFd, KDSETLED, leds);
376 + output_event.type = EV_LED;
377 + output_event.code = LED_NUML;
378 + output_event.value = (leds&(LED_NUM)) ? 1 : 0;
379 + write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
381 + output_event.type = EV_LED;
382 + output_event.code = LED_CAPSL;
383 + output_event.value = (leds&(LED_CAP)) ? 1 : 0;
384 + write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
386 + output_event.type = EV_LED;
387 + output_event.code = LED_SCROLLL;
388 + output_event.value = (leds&(LED_SCR)) ? 1 : 0;
389 + write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
391 + xf86Info.ledsave = leds;
399 - ioctl(xf86Info.consoleFd, KDGETLED, &leds);
400 + if (xf86Info.kbdEvents == xf86USBKbdEvents) {
401 + leds = xf86Info.ledsave;
403 + ioctl(xf86Info.consoleFd, KDGETLED, &leds);
406 + fprintf(stderr, "xf86GetKbdLeds called, returing 0x%x\n", leds);
411 if (xf86Info.kbdDelay >= 0)
412 delay = xf86Info.kbdDelay;
414 + /* FIXME: just returning so we don't mess with any other keyboards... */
415 + if (xf86Info.kbdEvents == xf86USBKbdEvents)
418 if(KDKBDREP_ioctl_ok(rate, delay)) /* m68k? */
421 @@ -223,14 +268,24 @@
425 - ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
426 - tcgetattr (xf86Info.consoleFd, &kbdtty);
427 + if (xf86Info.kbdEvents == xf86USBKbdEvents) {
430 + if (ioctl(xf86Info.kbdFd, EVIOCGRAB, &data) == 0)
431 + printf("exclusive access granted");
433 + ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
434 + tcgetattr (xf86Info.consoleFd, &kbdtty);
443 + if (xf86Info.kbdEvents == xf86USBKbdEvents)
444 + return(xf86Info.kbdFd);
447 if (xf86Info.kbdCustomKeycodes)
452 + if (xf86Info.kbdEvents == xf86USBKbdEvents)
453 + return(xf86Info.kbdFd);
455 ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
456 tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
457 return(xf86Info.consoleFd);
458 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c
459 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c 2004-04-23 21:54:08.000000000 +0200
460 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c 2004-11-19 21:49:47.000000000 +0100
462 #include "xf86OSKbd.h"
463 #include "atKeynames.h"
465 +#include <linux/input.h>
467 #define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
469 static KbdProtocolRec protocols[] = {
470 {"standard", PROT_STD },
471 + {"usbev", PROT_USB },
472 { NULL, PROT_UNKNOWN_KBD }
476 ioctl(pInfo->fd, KDSETLED, real_leds);
480 +SetUSBKbdLeds(InputInfoPtr pInfo, int leds)
482 + struct s_output_event {
483 + struct timeval time;
484 + unsigned short type;
485 + unsigned short code;
486 + unsigned int value;
489 + fprintf(stderr, "SetUSBKbdLeds called with leds=0x%x\n", leds);
490 + fprintf(stderr, "CAP=0x%x, NUM=0x%x, SCR=0x%x\n", LED_CAP, LED_NUM, LED_SCR);
492 + if (leds & XLED1) real_leds |= LED_CAP;
493 + if (leds & XLED2) real_leds |= LED_NUM;
494 + if (leds & XLED3) real_leds |= LED_SCR;
496 + if (leds & XLED4) real_leds |= LED_COMP;
498 + if (leds & XLED4) real_leds |= LED_SCR;
501 + output_event.type = EV_LED;
502 + output_event.code = LED_NUML;
503 + output_event.value = (leds&(LED_NUM)) ? 1 : 0;
504 + write(pInfo->fd, (char *)&output_event, sizeof(output_event));
506 + output_event.type = EV_LED;
507 + output_event.code = LED_CAPSL;
508 + output_event.value = (leds&(LED_CAP)) ? 1 : 0;
509 + write(pInfo->fd, (char *)&output_event, sizeof(output_event));
511 + output_event.type = EV_LED;
512 + output_event.code = LED_SCROLLL;
513 + output_event.value = (leds&(LED_SCR)) ? 1 : 0;
514 + write(pInfo->fd, (char *)&output_event, sizeof(output_event));
516 + xf86Info.ledsave = leds;
519 GetKbdLeds(InputInfoPtr pInfo)
522 if (real_leds & LED_NUM) leds |= XLED2;
523 if (real_leds & LED_SCR) leds |= XLED3;
525 + fprintf(stderr, "GetKbdLeds called, returing 0x%x\n", leds);
533 +static unsigned short x86_keycodes[256] =
534 + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
535 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
536 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
537 + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
538 + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
539 + 80, 81, 82, 83, 43, 85, 86, 87, 88,115,119,120,121,375,123, 90,
540 + 284,285,309,311,312, 91,327,328,329,331,333,335,336,337,338,339,
541 + 367,294,293,286,350, 92,334,512,116,377,109,111,373,347,348,349,
542 + 360, 93, 94, 95, 98,376,100,101,357,316,354,304,289,102,351,355,
543 + 103,104,105,275,281,272,306,106,274,107,288,364,358,363,362,361,
544 + 291,108,381,290,287,292,279,305,280, 99,112,257,258,113,270,114,
545 + 118,117,125,374,379,259,260,261,262,263,264,265,266,267,268,269,
546 + 271,273,276,277,278,282,283,295,296,297,299,300,301,302,303,307,
547 + 308,310,313,314,315,317,318,319,320,321,322,323,324,325,326,330,
548 + 332,340,341,342,343,344,345,346,356,359,365,368,369,370,371,372 };
550 +static void handle_scancode(InputInfoPtr pInfo, int code, int down)
552 + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
553 + pKbd->PostEvent(pInfo, code & 0x7f, down);
558 +usbReadInput(InputInfoPtr pInfo)
560 + struct input_event {
561 + struct timeval time;
562 + unsigned short type;
563 + unsigned short code;
564 + unsigned int value;
568 + if ((nBytes = read( pInfo->fd, (char *)&ev, sizeof(ev))) > 0) {
569 + if (ev.type == EV_KEY) {
570 + unsigned int keycode = ev.code;
572 + if (keycode > 255 || !x86_keycodes[keycode])
575 + if (keycode == KEY_PAUSE) {
576 + handle_scancode(pInfo, 0xe1, 1);
577 + handle_scancode(pInfo, 0x1d, ev.value);
578 + handle_scancode(pInfo, 0x45, ev.value);
581 + if (x86_keycodes[keycode] & 0x100)
582 + handle_scancode(pInfo, 0xe0, 1);
584 + handle_scancode(pInfo, x86_keycodes[keycode] & 0x7f, ev.value);
590 OpenKeyboard(InputInfoPtr pInfo)
594 KbdProtocolId prot = PROT_UNKNOWN_KBD;
596 + int flag = O_RDONLY;
598 s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
599 for (i = 0; protocols[i].name; i++) {
603 pInfo->read_input = stdReadInput;
604 + pKbd->SetLeds = SetKbdLeds;
607 + pInfo->read_input = usbReadInput;
608 + pKbd->SetLeds = SetUSBKbdLeds;
612 xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
614 pInfo->fd = xf86Info.consoleFd;
615 pKbd->isConsole = TRUE;
617 - pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
618 + pInfo->fd = open(s, flag | O_NONBLOCK | O_EXCL);
619 if (pInfo->fd == -1) {
620 xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
624 pKbd->KbdOff = KbdOff;
625 pKbd->Bell = SoundBell;
626 - pKbd->SetLeds = SetKbdLeds;
627 pKbd->GetLeds = GetKbdLeds;
628 pKbd->SetKbdRepeat = SetKbdRepeat;
629 pKbd->KbdGetMapping = KbdGetMapping;
630 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c
631 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c 2004-04-23 21:54:12.000000000 +0200
632 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c 2004-11-19 21:49:47.000000000 +0100
635 /* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
637 +/* 2001/01/14 Miguel Freitas <miguel@cetuc.puc-rio.br>
639 + * USB Keyboard to PC-AT Keyboard HACK
641 + * Included routines from Linux Kernel to handle usb keyboard events.
642 + * I don't know if there are any license issues here. Any code written
643 + * by me in this file is under the terms of the GNU General Public
644 + * License as described below.
651 + * Copyright (c) 1999-2000 Vojtech Pavlik
653 + * Input driver to keyboard driver binding.
655 + * Sponsored by SuSE
659 + * This program is free software; you can redistribute it and/or modify
660 + * it under the terms of the GNU General Public License as published by
661 + * the Free Software Foundation; either version 2 of the License, or
662 + * (at your option) any later version.
664 + * This program is distributed in the hope that it will be useful,
665 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
666 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
667 + * GNU General Public License for more details.
669 + * You should have received a copy of the GNU General Public License
670 + * along with this program; if not, write to the Free Software
671 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
673 + * Should you need to contact me, the author, you can do so either by
674 + * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
675 + * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
681 #include "xf86Priv.h"
682 #include "xf86_OSlib.h"
683 +#include <linux/input.h>
691 +static unsigned short x86_keycodes[256] =
692 + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
693 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
694 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
695 + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
696 + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
697 + 80, 81, 82, 83, 43, 85, 86, 87, 88,115,119,120,121,375,123, 90,
698 + 284,285,309,298,312, 91,327,328,329,331,333,335,336,337,338,339,
699 + 367,294,293,286,350, 92,334,512,116,377,109,111,373,347,348,349,
700 + 360, 93, 94, 95, 98,376,100,101,357,316,354,304,289,102,351,355,
701 + 103,104,105,275,281,272,306,106,274,107,288,364,358,363,362,361,
702 + 291,108,381,290,287,292,279,305,280, 99,112,257,258,113,270,114,
703 + 118,117,125,374,379,259,260,261,262,263,264,265,266,267,268,269,
704 + 271,273,276,277,278,282,283,295,296,297,299,300,301,302,303,307,
705 + 308,310,313,314,315,317,318,319,320,321,322,323,324,325,326,330,
706 + 332,340,341,342,343,344,345,346,356,359,365,368,369,370,371,372 };
708 +static void handle_scancode(unsigned char scancode, int down)
710 + char up_flag = down ? 0 : 0200;
712 + xf86PostKbdEvent(scancode | up_flag);
715 +static int emulate_raw(unsigned int keycode, int down)
717 + if (keycode > 255 || !x86_keycodes[keycode])
720 + if (keycode == KEY_PAUSE) {
721 + handle_scancode(0xe1, 1);
722 + handle_scancode(0x1d, down);
723 + handle_scancode(0x45, down);
727 + if (x86_keycodes[keycode] & 0x100)
728 + handle_scancode(0xe0, 1);
730 + handle_scancode(x86_keycodes[keycode] & 0x7f, down);
732 + if (keycode == KEY_SYSRQ) {
733 + handle_scancode(0xe0, 1);
734 + handle_scancode(0x37, down);
743 + struct input_event {
744 + struct timeval time;
745 + unsigned short type;
746 + unsigned short code;
747 + unsigned int value;
752 + while ((nBytes = read(xf86Info.kbdFd, (char *)&ev, sizeof(ev))) > 0)
753 + if (ev.type == EV_KEY)
754 + emulate_raw(ev.code, ev.value);
756 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c
757 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c 2004-04-23 21:54:12.000000000 +0200
758 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c 2004-11-19 21:49:47.000000000 +0100
761 xf86VTRequest(int sig)
763 + if (xf86NoVTSwitches)
766 signal(sig, (void(*)(int))xf86VTRequest);
767 xf86Info.vtRequestsPending = TRUE;
771 xf86VTSwitchPending()
773 - return(xf86Info.vtRequestsPending ? TRUE : FALSE);
774 + return(!xf86NoVTSwitches && xf86Info.vtRequestsPending ? TRUE : FALSE);
780 + if (xf86NoVTSwitches)
783 xf86Info.vtRequestsPending = FALSE;
784 if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
790 + if (xf86NoVTSwitches)
793 xf86Info.vtRequestsPending = FALSE;
794 if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
796 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
797 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h 2004-04-23 21:54:07.000000000 +0200
798 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h 2004-11-19 21:49:47.000000000 +0100
800 extern int xf86KbdOn(void);
801 extern int xf86KbdOff(void);
802 extern void xf86KbdEvents(void);
803 +extern void xf86USBKbdEvents(void);
805 extern int xf86XqueKbdProc(DeviceIntPtr, int);
806 extern void xf86XqueEvents(void);