Re: for comment: multi-keyboard patch

Pavel Machek (pavel@bug.ucw.cz)
Wed, 4 Nov 1998 23:34:48 +0100


Hi!

> At present input from all keyboards goes to the current foreground
> VC. Ultimately it would be nice to be able to bind a keyboard, screen
> and mouse together into a "console" which would have its own set of
> VCs.

It would be very nice, but as of now, you are not able to do anything
like that with mouse, because mice are completely userspace. (Which is
broken, because two programs on different vc's can not share mouse too
well - there will be races with console switching there).

Anyway, I've merged this patch with my work (key for console blanking,
possibility to plug PS/2 keyboard into mouse port and hook for
keylink). Incremental diff is attached, please take a look. (Any
chance of merging?)

Pavel

--- ./pc_keyb.c Wed Nov 4 23:31:49 1998
+++ /usr/src/multikey.linux/drivers/char/pc_keyb.c Wed Nov 4 23:10:41 1998
@@ -12,6 +12,10 @@
*
*/

+/* Uncomment this if you have keyboard in ps/2 port, not mouse */
+
+#define KEYBOARD_IN_PSAUX
+
#include <linux/config.h>

#include <asm/spinlock.h>
@@ -446,6 +450,52 @@
return 0200;
}

+#ifdef KEYBOARD_IN_PSAUX
+static void *psaux_id;
+
+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 );
+#if 0
+ else
+ printk( "Known strangecode %x = %x\n", c, i );
+#endif
+ kbd_handle_scancode( psaux_id, i|or );
+ or = 0;
+}
+#endif
+
+
static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
unsigned long flags;
@@ -467,6 +517,9 @@
if (aux_count) {
int head = queue->head;
queue->buf[head] = scancode;
+#ifdef KEYBOARD_IN_PSAUX
+ handle_strangecode (scancode);
+#else
add_mouse_randomness(scancode);
head = (head + 1) & (AUX_BUF_SIZE-1);
if (head != queue->tail) {
@@ -475,6 +528,7 @@
kill_fasync(queue->fasync, SIGIO);
wake_up_interruptible(&queue->proc_list);
}
+#endif
}
#endif
} else {
@@ -819,9 +873,9 @@
}
queue->head = queue->tail = 0; /* Flush input queue */
#ifdef CONFIG_MCA
- if (request_irq(AUX_IRQ, keyboard_interrupt, MCA_bus ? SA_SHIRQ : 0, "PS/2 Mouse", inode)) {
+ if (request_irq(AUX_IRQ, keyboard_interrupt, MCA_bus ? SA_SHIRQ : 0, "PS/2 Auxiliary", inode)) {
#else
- if (request_irq(AUX_IRQ, keyboard_interrupt, 0, "PS/2 Mouse", NULL)) {
+ if (request_irq(AUX_IRQ, keyboard_interrupt, 0, "PS/2 Auxiliary", NULL)) {
#endif
aux_count--;
return -EBUSY;
@@ -935,8 +989,12 @@

static int __init psaux_init(void)
{
+#ifndef KEYBOARD_IN_PSAUX
+ /* This is wrong: if mouse is not present at boot, we'll
+ refuse to use it even after hotplug. BAD. */
if (aux_device_present != 0xaa)
return -EIO;
+#endif

printk(KERN_INFO "PS/2 auxiliary pointing device detected -- driver installed.\n");
misc_register(&psaux_mouse);
@@ -956,6 +1014,12 @@
kbd_write(KBD_CCMD_MOUSE_DISABLE, KBD_CNTL_REG); /* Disable aux device. */
kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */

+#ifdef KEYBOARD_IN_PSAUX
+ open_aux(NULL, NULL);
+ psaux_id = register_keyboard(&pckbd_operations, NULL, key_maps);
+ if (psaux_id == NULL)
+ printk(KERN_ERR "Couldn't register keyboard in PS/2 mouse port!\n");
+#endif
return 0;
}

-- 
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/