KEYFUNC(OPCSDEFS)        Optical Printer Control System       KEYFUNC(OPCSDEFS)

    NAME
        keyfunc - lets user define keys in KEY(OPCS) and JOG(OPCS)

    USAGE
        keyfunc -clear "function"
        keyfunc -add   "function" port mask test port mask test
	                          -------------- --------------
	                                |              |
	                                |              Button release
	                                Button down

	"function" is either the name of an internal function (see below)
	or an opcs command string. In the case of -clear, "function" can
	be "all", to clear all previously defined functions.

	When binding a port/bit mask to an OPCS function or OPCS command 
	string, one specifies the port/bits for both 'button down' and 
	'button release'.

    DESCRIPTION
        This command allows the user to define the keyboard keys used in
        KEY(OPCS) mode. The user can actually assign the operations to 
	not only any keys on the keyboard, but any bit on any port on 
	the IBM PC.
        
        This allows for external buttons to control bits on the parallel port
        (or whatever ports are available) and thus control any of the functions
        supported by the KEY(OPCS) command.

        A maximum of 200 keyboard functions can be defined with 'keyfunc'.

        The following is a list of all functions the KEY(OPCS) command 
        currently supports, plus some custom definitions. Normally, these
	commands would appear in the OPCSDEFS.OPC setup file:

	The following shows all the built-in functions, and show examples
	of how to define custom commands.
        
	    # CLEAR ALL FUNCTIONS FIRST
	    #     Start with a completely clean slate.
	    #
	    keyfunc -clear "all"

	    # DEFINE ALL THE 'BUILTIN' OPCS FUNCTIONS
	    #     These names are the names of built in operations in OPCS,
	    #     whose operation should be obvious. These are all assigned
	    #     to keyboard scan codes. Comments at right describe what the
	    #     scan codes are.
	    #
	    #            OPCS FUNCTION      KEY DOWN      KEY RELEASE
	    #            -------------      ----------    -----------
	    keyfunc -add "quit"             0060 ff 01    0060 80 80	# ESC
	    keyfunc -add "pro2fwdslew"      0060 ff 3b    0060 80 80	# F1
	    keyfunc -add "pro1fwdslew"      0060 ff 3f    0060 80 80	# F5
	    keyfunc -add "camfwdslew"       0060 ff 43    0060 80 80	# F9
	    keyfunc -add "pro2revslew"      0060 ff 3c    0060 80 80	# F2
	    keyfunc -add "pro1revslew"      0060 ff 40    0060 80 80	# F6
	    keyfunc -add "camrevslew"       0060 ff 44    0060 80 80	# F10
	    keyfunc -add "pro2fwd1"         0060 ff 3d    0060 80 80	# F3
	    keyfunc -add "pro1fwd1"         0060 ff 41    0060 80 80	# F7
	    keyfunc -add "camfwd1"          0060 ff 57    0060 80 80	# F11
	    keyfunc -add "pro2rev1"         0060 ff 3e    0060 80 80	# F4
	    keyfunc -add "pro1rev1"         0060 ff 42    0060 80 80	# F8
	    keyfunc -add "camrev1"          0060 ff 58    0060 80 80	# F12
	    keyfunc -add "rep+1"            0060 ff 02    0060 80 80	# 1
	    keyfunc -add "rep-1"            0060 ff 03    0060 80 80	# 2
	    keyfunc -add "repset"           0060 ff 04    0060 80 80	# 3
	    keyfunc -add "pro2set"          0060 ff 05    0060 80 80	# 4
	    keyfunc -add "pro1set"          0060 ff 06    0060 80 80	# 5
	    keyfunc -add "camset"           0060 ff 07    0060 80 80	# 6
	    keyfunc -add "fdiset"           0060 ff 08    0060 80 80	# 7
	    keyfunc -add "fdoset"           0060 ff 09    0060 80 80	# 8
	    keyfunc -add "dxiset"           0060 ff 0a    0060 80 80	# 9
	    keyfunc -add "dxoset"           0060 ff 0b    0060 80 80	# 0
	    keyfunc -add "cls"              0060 ff 0c    0060 80 80	# -
	    keyfunc -add "opn"              0060 ff 0d    0060 80 80	# =
	    keyfunc -add "seek"             0060 ff 0e    0060 80 80	# BS

	    # DEFINE SOME CUSTOM OPCS COMMANDS
	    #     These are not builtin functions, but are simply free form
	    #     opcs command strings that are assigned to keys. Even DOS
	    #     commands can be invoked via keystroks or external buttons.
	    #
	    keyfunc -add "home a b c"       0060 ff 47    0060 80 80	#HOME
	    keyfunc -add "load"             0060 ff 49    0060 80 80	#PGUP
	    keyfunc -add "lineup"           0060 ff 52    0060 80 80	#INS
	    keyfunc -add "! mydoscmd 12 34" 0060 ff 53    0060 80 80	#DEL

    MONITORING THE KEYBOARD
	Since the entire keyboard is mapped into port 0060, any key on the
	keyboard can be bound to a function. 
	
	To detect a KEY DOWN, use a mask of FF, and the keyboard scan code 
	as the test value. To test for KEY RELEASE, use 80 as the mask, 
	and test for 80.

	Several port/bit combinations can be assigned to a single function.
	This allows for several ways to access the same function. For example,
	you may want to have both keyboard keys and external buttons located
	on the printer to control a particular operation.

	For a list of all the keyboard scan codes, refer to an IBM PC technical
	manual, or use quit out of OPCS and invoke the 'KEY.EXE' program. 
	KEY.EXE prints the hexadecimal scancodes whenever you hit a key. 
	Hit ESC to exit the KEY.EXE program.

    CONTINUOUS SWITCH
        The 'BUTTON RELEASE' port/mask/test definitions define the IBM PC port
        to monitor to determine when the key is released. This can optionally
        be defined to monitor a 'continuous' switch, so that the motors will
        stop when the continuous switch is released:

                keyfunc -add "profwd1"  03bd 40 40  03bd 41 00

        The above monitors port 0x03bd for the 0x40 bit. When set, the motor
        will run until the 0x40 and the 0x01 bit of the same port are zero.
        In this case, the 0x40 bit is probably the invoking button, and the
        0x01 bit is the 'continuous' switch; if on, the motor will run until
        the continuous switch is turned off, even if the 0x40 bit is released.

    BUGS/CAVEATS
        If you use keyfunc -clear "all", you must at LEAST declare the
	quit key. If you don't, you will have no way to break out of the
	KEY(OPCS) or JOG(OPCS) modes.

        When using keyfunc to invoke an OPCS command string, the command
	should not exceed 256 characters. If you want a single keystroke 
	to invoke many commands, make a script, then have the keyfunc 
	definition run the script, ie:

	    keyfunc -add "run fancy.run"  0379 80 80  0379 80 00

    SEE ALSO
        KEY(OPCS) - use keys to run motors
	JOG(OPCS) - jog motors interactivly
        DEENERGIZE(OPCSDEFS)  - define port/bit to deenergize motors
        ALLSTOP(OPDSDEFS)     - define port/bit to detect the allstop key
        BUCKLE(OPCSDEFS)      - define port/bit to detect film buckles
        VIEWER(OPCSDEFS)      - define port/bit to detect viewer open
        TRIPSWITCH(OPCSDEFS)  - define port/bit to detect trip switches
        SETBIT(OPCSDEFS)      - set bit(s) on a port
        CLRBIT(OPCSDEFS)      - clear bit(s) on a port
        XORBIT(OPCSDEFS)      - invert bit(s) on a port

    ORIGIN
        Gregory Ercolano, Venice California 04/18/98
© Copyright 1997 Greg Ercolano. All rights reserved.