ma179abl@sdcc3.ucsd.EDU (David Yip) (04/20/87)
Does anyone know how the keyboard is detected and whether it is possible to fool the machine into thinking a keyboard is attached even though one isn't? thanks
chris@mimsy.UUCP (Chris Torek) (06/15/88)
In article <5042@sdcsvax.UCSD.EDU> hutch@net1.ucsd.edu (Jim Hutchison) writes: [spelling edited :-)] >By the way, is there a fix for the parallelogram keyboard problem? >I mean the one where I type nice too fast, and pick up the comma to go with >the "ice". I am not sure what this is. Whether and how this happens depends on the keyboard arrangement. Many keyboard scanners make a matrix from the keyboard: d0 d1 d2 d3 d4 d5 d6 d7 | | | | | | | | a0---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]--- | | | | | | | | a1---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]--- | | | | | | | | a2---[@]---[A]---[B]---[C]---[D]---[E]---[F]---[G]--- | | | | | | | | a3---[H]---[I]---[J]---[K]---[L]---[M]---[N]---[O]--- | | | | | | | | a4---[P]---[Q]---[R]---[S]---[T]---[U]---[V]---[W]--- | | | | | | | | a5---[X]---[Y]---[Z]---[ ]---[ ]---[ ]---[ ]---[ ]--- | | | | | | | | a6---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]--- | | | | | | | | a7---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]---[ ]--- | | | | | | | | (The exact placement of the keys varies.) This conveniently produces 64 keys (enough for 56 key keyboards) arranged on an eight(-data)-bit by eight(-address)-bit grid. If each keyswitch simply shorts the address line to the data line, the keyboard can be scanned with a loop like the following: #define KEYBOARD ((char *)0x3800) /* on a TRS-80, eg */ for (r = 0; r < 8; r++) for (c = 0; c < 8; c++) if (KEYBOARD[1 << r] & (1 << c)) /* the key at (r,c) is down */; (Of course, the scan loop must account for keys that are held down for some time, and possibly do debouncing, and all sorts of other grungy work. But none of that matters in regard to the `parallelogram problem'.) Now, given the keyboard arrangement shown above, if push down A, I, and M to type `aim', I have shorted the following pairs: (a2,d1) [A] (a3,d1) [I] (a3,d5) [M]. By so doing I have effectively also shorted (a2,d5): current can flow from a2 via d1 to a3 ([A] then [I]), then from a3 to d5 ([M]). Even though I only put current directly on a2, it `leaks' to a3 and from there it gets to d5, so my scanner sees [E] down and I wind up typing `aiem'. There are two ways to fix it. As usual, it can be done in either software or hardware. The software solution is uglier: scan the whole keyboard before deciding that any given key is down. If keys are down in a parallelogram (as defined by the actual arrangement, which is often not alphabetical), wait for enough of those keys to be released to be sure as to which ones are really down. (An easy variation is to wait whenever more than two keys are down.) The hardware solution is more expensive: add diodes at the keyswitches, so that current cannot flow across the parallelogram. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris