Multiple keyboards

Pavel Machek (pavel@bug.ucw.cz)
Sun, 11 Oct 1998 01:34:11 +0200


Hi!

Here's a patch which will allow youy to plug ps/2 keyboard into ps/2
mouse port, and use it in same way you use primary keyboard. (That two
keyboards look like one to the rest of the system - but they do NOT have
to! - still, it would mean redesign of input systems and it is 2.2
time).

Pavel

PS: Does anyone have an idea how to work without such a ugly table?

--- clean//drivers/char/psaux.c Thu Oct 1 14:01:15 1998
+++ linux/drivers/char/psaux.c Sun Oct 4 22:57:23 1998
@@ -39,6 +39,10 @@
* Linus
*/

+/* Uncomment this if you have keyboard in ps/2 port, not mouse */
+
+#define KEYBOARD
+
/* Uncomment the following line if your mouse needs initialization. */

/* #define INITIALIZE_DEVICE */
@@ -213,6 +217,47 @@
up(&aux_sema4);
}

+#ifdef KEYBOARD
+static char strange_xlat[ 256 ] = {
+/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
+/* 0 */ 0x00,0x43,0x00,0x3f,0x3d,0x3b,0x3c,0x58,0x00,0x44,0x42,0x40,0x3e,0x0f,0x29,0x00,
+/* 1 */ 0x00, 56,0x2a,0x00, 29,0x10,0x02,0x00,0x00,0x00,0x2c,0x1f,0x1e,0x11,0x03,0x00,
+/* 2 */ 0x00,0x2e,0x2d,0x20,0x12,0x05,0x04,0x00,0x00, 57,0x2f,0x21,0x14,0x13,0x06,0x00,
+/* 3 */ 0x00,0x31,0x30,0x23,0x22,0x15,0x07,0x00,0x00,0x00,0x32,0x24,0x16,0x08,0x09,0x00,
+/* 4 */ 0x00,0x33,0x25,0x17,0x18,0x0b,0x0a,0x00,0x00,0x34,0x35,0x26,0x27,0x19,0x0c,0x00,
+/* 5 */ 0x00,0x00,0x28,0x00,0x1a,0x0d,0x00,0x00,0x3a,0x36,0x1c,0x1b,0x00,0x2b,0x00,0x00,
+/* 6 */ 0x00,0x00,0x00,0x00,0x00,0x00, 14,0x00,0x00,0x4f,0x00,0x4b,0x47,0x00,0x00,0x00,
+/* 7 */ 0x52,0x53,0x50,0x00,0x4d,0x48,0x01,0x00,0x57,0x00,0x51,0x00,0x37,0x49,0x46,0x00,
+/* 8 */ 0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* 9 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* a */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* b */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* c */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* d */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* e */ 0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* f */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+static void handle_strangecode(int c)
+{
+ static int or = 0, i;
+
+ switch (c) {
+ case 0xf0:
+ or = 0x80;
+ return;
+ }
+
+ i = strange_xlat[c];
+ if (!i)
+ printk( "Unknown strangecode %x\n", c );
+ else
+ printk( "Known strangecode %x = %x\n", c, i );
+ handle_scancode( i|or );
+ or = 0;
+}
+#endif
+
/*
* Interrupt from the auxiliary device: a character
* is waiting in the keyboard/aux controller.
@@ -227,6 +272,9 @@
return;

add_mouse_randomness(queue->buf[head] = inb(KBD_DATA_REG));
+#ifdef KEYBOARD
+ handle_strangecode(queue->buf[head]);
+#endif
if (head != maxhead) {
head++;
head &= AUX_BUF_SIZE-1;
@@ -407,8 +455,10 @@

__initfunc(int psaux_init(void))
{
+#ifndef KEYBOARD
if (aux_device_present != 0xaa)
return -EIO;
+#endif

printk(KERN_INFO "PS/2 auxiliary pointing device detected -- driver installed.\n");
misc_register(&psaux_mouse);

-- 
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/