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 ffff 01 0060 80 80 # ESC
keyfunc -add "pro2fwdslew" 0060 ffff 3b 0060 80 80 # F1
keyfunc -add "pro2revslew" 0060 ffff 3c 0060 80 80 # F2
keyfunc -add "pro2fwd1" 0060 ffff 3d 0060 80 80 # F3
keyfunc -add "pro2rev1" 0060 ffff 3e 0060 80 80 # F4
keyfunc -add "pro1fwdslew" 0060 ffff 3f 0060 80 80 # F5
keyfunc -add "pro1revslew" 0060 ffff 40 0060 80 80 # F6
keyfunc -add "pro1fwd1" 0060 ffff 41 0060 80 80 # F7
keyfunc -add "pro1rev1" 0060 ffff 42 0060 80 80 # F8
keyfunc -add "camfwdslew" 0060 ffff 43 0060 80 80 # F9
keyfunc -add "camrevslew" 0060 ffff 44 0060 80 80 # F10
keyfunc -add "camfwd1" 0060 ffff 57 0060 80 80 # F11
keyfunc -add "camrev1" 0060 ffff 58 0060 80 80 # F12
keyfunc -add "rep+1" 0060 ffff 02 0060 80 80 # 1
keyfunc -add "rep-1" 0060 ffff 03 0060 80 80 # 2
keyfunc -add "repset" 0060 ffff 04 0060 80 80 # 3
keyfunc -add "pro2set" 0060 ffff 05 0060 80 80 # 4
keyfunc -add "pro1set" 0060 ffff 06 0060 80 80 # 5
keyfunc -add "camset" 0060 ffff 07 0060 80 80 # 6
keyfunc -add "fdiset" 0060 ffff 08 0060 80 80 # 7
keyfunc -add "fdoset" 0060 ffff 09 0060 80 80 # 8
keyfunc -add "dxiset" 0060 ffff 0a 0060 80 80 # 9
keyfunc -add "dxoset" 0060 ffff 0b 0060 80 80 # 0
keyfunc -add "cls" 0060 ffff 0c 0060 80 80 # -
keyfunc -add "opn" 0060 ffff 0d 0060 80 80 # =
keyfunc -add "seek" 0060 ffff 0e 0060 80 80 # BS
# DEFINE SOME CUSTOM OPCS COMMANDS
# These are not builtin functions, but are simply run as opcs commands.
# You can run OPCS scripts, and invoke DOS commands (if prefaced with "!")
#
keyfunc -add "home" 0060 ffff 004e 0060 0080 0080 # Num +
keyfunc -add "load" 0060 ffff 0037 0060 0080 0080 # Num *
keyfunc -add "run myscript.run" 0060 ffff 004a 0060 0080 0080 # Num -
MONITORING THE KEYBOARD
Since the keyboard is mapped to port 0060, any key on the keyboard
can be bound to an OPCS function, e.g.
keyfunc "function_name" 0060 <mask> <test> 0060 <mask> <test>
------------------ ------------------
Detect Key Press Detect Key Release
The <port>, <mask>, and <test> values are all specified in hexadecimal.
(New in K2.20TC): To support extended keycodes, the <mask> and <test>
values can now be 16 bit (4 digit hex) values. OPCS now treats the
keyboard (port 0060) as a special case, where extended keycodes have
the high byte set to E0 (e.g. E0##), and regular keycodes have
the high byte set to 00 (e.g. 00##) for "normal" keys.
To detect a KEY DOWN, use FFFF as the 'mask', and the 16bit scan code
value as the 'test' value. Single byte scancodes will be 00##,
extended scancodes will be E0##.
To test for KEY RELEASE, use 0080 as both 'mask' and 'test' value,
since all key release codes have the 0080h bit set.
So for example, to program the "F1" key which generates 003B on press
and 00BB on release:
# OPCS FUNCTION PORT MASK TEST PORT MASK TEST
# -------------- ---- ---- ---- ---- ---- ----
keyfunc -add "pro2fwdslew" 0060 ffff 003b 0060 0080 0080
..and to detect e.g. the "PrntScrn" key which generates E0 4A
when a key is pressed, and E0 CA on release, this works:
# OPCS FUNCTION PORT MASK TEST PORT MASK TEST
# -------------- ---- ---- ---- ---- ---- ----
keyfunc -add "load" 0060 ffff e04a 0060 0080 0080
\__/
16bit extended scancode
with E0 in high byte
GENERAL PORT MONITORING
A single function, such as "pro1fwdslew", can be assigned to more
than one port/bit combination, allowing several ways to access the
same function. For example, you may want to have both keyboard and
external buttons to slew the projector forward.
For a list of all the keyboard scan codes, refer to an IBM PC technical
manual, or run "! key" from the DOS prompt to run the KEY.EXE program,
which prints the hexadecimal scancodes for any key you hit.
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, e.g.:
keyfunc -add "run fancy.run" 0379 80 80 0379 80 00
SEE ALSO
KEY(OPCS) - use keys to run motors
JOG(OPCS) - jog motors interactively
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