Date: Thu, 20 May 93 05:41:46 CDT From: erb@fullfeed.com (David Erb) Subject: keyboard footswitch GOAL ---- Add footswitch to PC keyboard and use X on Sun4 with it. HARDWARE -------- I have a true-blue IBM PC-XT that I bought off the net for $85. It came with a true-blue IBM 84-key keyboard which I like because it has a nice loud click. (I have also bought an identical keyboard for backup from a used-computer company in Louisiana for $26.) I opened up the keyboard casing and bent the metal tabs back to free up the internal key cage. Watch out, the keycaps will fall off. Near the protruding back part of the printed circuit board you will see the leads from the keyboard rows and columns scan matrix. The rest of this hardwar a friend did, so I can only vaguely explain it. Find the row and column of the key you want by counting. Solder a wire to the row and the column leads. Make a circuit like: row lead - 100pF capacitor - normally-open (N.O.) lead of relay - common lead of relay - column lead Make a second circuit like: 5 V on keyboard - relay 5V input lead - relay ground lead - footswitch input lead via 5 foot long coax cable - footswitch output lead via same cable - keyboard ground Footswitch I got from a discarded medical EMG machine. (My revenge for all EMG studies!) Relay is of Radio Shack variety. Normally-closed (N.C.) lead on relay is unconnected. When pressing footswitch completes second circuit, 5V goes to relay which gives a small click and closes, causing some kind of capacative action across the matrix point you selected. This fools the on-keyboard scanner to thinking that the key was pressed. I chose to use F2, figuring if they key position got trashed in the operation, it wouldn't be a disaster. My end target was to have the footswitch simulate the control key, but I wasn't sure and also wanted the option of trying shift. Anyway, the way I wrote the software, any scan code can map to any X KeySym. SOFTWARE -------- I wrote a program in Microsoft C and Microsoft Assembler to run on the PC and pick up INT9 events. This is the keyboard event which gives the scan code and state whether the key was pressed or released. No combining of keys is done by DOS, for example, the control key gives a scan code just like any other. The PC program I wrote sends each scan code to the standard output, which I normally redirect to COM2. On the Sun4 (SunOS 4.1.1) I wrote a program which reads the /dev/tty serial input port, translates what it finds to my pleasure, and sends keypress and keyrelease events to the X server. The X server handles these events as normal keyboard keystrokes. In this way, I handle an F2 scancode as an X keyboard control key. Or shift. This program is a modification of my kt software which is on soda.berkeley.edu. As a byproduct, I can change keys like PgUp into something X and/or Emacs can do something useful with.