home *** CD-ROM | disk | FTP | other *** search
- Getting to Know DOS 2.0: The
- Extended Keyboard Control Device
- Driver
-
- Josiah C. Hoskins
- Central Texas IBM PC Users Group
-
- One of the advanced features offered
- by DOS 2.0 is the extended keyboard
- control device driver (KCDD). This
- feature allows the user to reassign
- the meaning of any key on the
- keyboard. An example program
- (PCKEY.BAS) which permits the user
- to assign character strings to 20
- different function keys (the 10 base
- keys and the 10 shift function keys)
- is shown below. This program exists
- in a separate file as PCKEY.BAS and
- may be copied to your work disk.
- This program can be used as is by
- the novice, or as a model for
- setting up key reassignment programs
- for advanced programmers. A
- discussion is also included to aid
- in initializing the KCDD; a step
- which is necessary before using
- PCKEY.
-
- First, let's ask ourselves, what is
- a device driver? The DOS manual
- states that a device driver is a
- file which identifies a device
- (i.e., keyboard, printer, virtual or
- RAM disk, etc.), defines the
- strategy and interrupt entry points,
- and defines various attributes of
- the device. For our purposes we
- shall use a device driver that is
- provided with the DOS 2.0 diskette,
- ANSI.SYS, which contains the
- character device driver. This file
- follows the American National
- Standards Institute (ANSI) for the
- sequences of special character
- strings for terminal control
- functions (i.e., cursor positioning,
- clearing the display, etc.). It is
- one of these functions defined by
- ANSI that allows keyboard key
- reassignment.
-
- Now, let's briefly examine the code
- of PCKEY.BAS. Lines 20 through 100
- turn off the key prompts, clear the
- screen, and print a logo for the
- program. Lines 110 through 130
- undefine the ten function keys
- normally used by IBM BASIC. Lines
- 140 through 290 set up the string
- assignment for key redefinition.
- Lines 300 to 410 create the file
- KEYON which is used to activate the
- key definitions you have chosen.
- Lines 420 to 450 create the file
- KEYOFF which turns off the key
- definitions. Lines 460 through 510
- set up a help file called KEYHELP
- which contains the key definitions
- you have chosen. Lines 520 to 540
- redefine the normal IBM BASIC
- function keys.
-
- We are now ready to set up the files
- needed to perform our key
- reassignments under DOS 2.0. First,
- we must configure our system. To do
- this we create a file called
- CONFIG.SYS (note: this file must be
- in the root directory) in the
- following manner, enter
-
- A>COPY CON: CONFIG.SYS
- DEVICE=ANSI.SYS
-
- now press F6 then press Enter. DOS
- will respond with the message "1
- File(s) copied". Next, copy the DOS
- file ANSI.SYS to the root directory
- if it is not already there. Run the
- PCKEY program in BASIC. When the
- prompt "Press key to be defined or
- <end> to stop" appears, either press
- any of the base function keys or
- shift function keys or the End key
- (i.e., the 1 key in the edit mode).
- If you press an allowed function key
- (for example, F1), the following
- prompt "Enter string to be assigned
- to F1 ?" will appear. You may enter
- any string up to 68 characters long.
- If you include <CR> at the end of
- your chosen string, a carriage
- return will occur automatically
- after the chosen string is typed.
- After defining the desired function
- keys, press the End key. The files
- KEYON, KEYOFF, and KEYHELP will be
- created (if they are not created in
- the root directory you should put
- them there). Now return to DOS by
- entering SYSTEM. To activate the
- new key definitions, enter TYPE
- KEYON. To see the key definitions
- at any time, enter TYPE KEYHELP. To
- turn off the key definitions, enter
- TYPE KEYOFF (you should turn off
- your key definitions when you use
- any software that defines any of the
- keys that you defined).
-
- PC-KEY HELPER
- Present Key Definitions are:
-
- F 1=type keyhelp<cr>
- F 2=cls<cr>
- F 3=type
- F 4=copy
- F 5=
- F 6=
- F 7=
- F 8=
- F 9=
- F10=type keyoff<cr>
- s-F 1=dir
- s-F 2=
- s-F 3=
- s-F 4=
- s-F 5=
- s-F 6=
- s-F 7=
- s-F 8=
- s-F 9=
- s-F10=chkdsk<cr>
-
- 10 REM ***** PC - KEY *****
- 20 KEY OFF : CLS
- 30 LOCATE 5,21 : PRINT CHR$(201)+
- STRING$(38,205)+CHR$(187) :
- LOCATE 6,21 : PRINT CHR$(186)
- +STRING$(38," ")+CHR$(186)
- 40 LOCATE 7,21 : PRINT CHR$(186)+
- STRING$(15," ")+"PC - KEY"+
- STRING$(15," ")+CHR$(186) :
- LOCATE8,21
- 50 PRINT CHR$(186)+STRING$(38," ")
- +CHR$(186) : LOCATE 9,21 :
- PRINT CHR$(186)+" Key
- Definition Program For DOS
- 2.0 "+CHR$(186)
- 60 LOCATE 10,21 : PRINT CHR$(186)+
- STRING$(38," ")+CHR$(186) :
- LOCATE 11,21
- 70 PRINT CHR$(186)+"
- Version 1.00 "+
- CHR$(186) : LOCATE 12,21 : PRINT
- CHR$(186)+STRING$(38," ")+
- CHR$(186)
- 80 LOCATE 13,21: PRINT CHR$(200)+
- STRING$(38,205)+CHR$(188) :
- LOCATE 17,36 : PRINT "Written
- By"
- 90 LOCATE 19,30: PRINT "Josiah
- Collier Hoskins" : LOCATE 23,26
- : PRINT "Press space bar to
- continue..."
- 100 A$=INKEY$ : IF A$="" THEN 100
- 110 CLS : DIM K$(20),KN$(20)
- 120 FOR I=1 TO 10 : KEY I,"" :
- NEXT I 'kill softkeys defined
- in Basic
- 130 FOR I=1 TO 20 : K$(I)="" :
- NEXT I
- 140 PRINT "Key definitions:"
- 150 FOR I=1 TO 20 : IF I>10
- THEN 170
- 160 LOCATE 2+I,10 : PRINT "F"+
- STRING$(68," "); : LOCATE 2+I,
- 11 : PRINT RIGHT$(STR$(I),2)+
- "="; : GOTO 180
- 170 LOCATE 2+I,8 : PRINT "s-F"+
- STRING$(68," "); : LOCATE 2+I,
- 11 : PRINT RIGHT$(STR(I-10),2)
- +"=";
- 180 PRINT K$(I) : NEXT I
- 190 LOCATE 23,1 : PRINT STRING$
- (79," ") : LOCATE 23,1 : PRINT
- "Press to key to be defined
- or<End> to stop"
- 200 R$=INKEY$ : IF R$ ="" THEN 200
- ELSE IF LEN(R$)<>2 THEN 200
- 210 IF ASC(LEFT$(R$,1))<>0 THEN 200
- ELSE R=ASC(RIGHT$(R$,1))
- 220 IF R >= 59 AND R <= 68 THEN 250
- 'base function keys
- 230 IF R> = 84 AND R <= 93 THEN 270
- 'shift function keys
- 240 IF R = 79 THEN 300 ELSE GOTO
- 190 'end key
- 250 R = R - 58 : LOCATE 23,1 :
- PRINT STRING$(79," ") : LOCATE
- 23,1
- 260 PRINT "Enter string to be
- assigned to F";R; : GOTO 290
- 270 R = R-83 : LOCATE 23,1 : PRINT
- STRING$(79," ") : LOCATE 23,1
- 280 PRINT "Enter string to be
- assigned to s-F";R; : R = R +
- 10
- 290 R$="" : INPUT R$ : K$(R)=R$ :
- GOTO 150
- 300 KEYDEF$ = "KEYON" :
- OPEN KEYDEF$ FOR OUTPUT AS #1
- 'create file to turn on keys
- 310 CR$ = "<CR>" : CR2$ = "<cr>" :
- FOR I=1 TO 20 : IF K$(I)=""
- THEN 390
- 320 IF CR$ = RIGHT$(K$(I),4) OR
- CR2$ = RIGHT$(K$(I),4) THEN
- 360
- 330 IF I > 10 THEN 350
- 340 PRINT #1,CHR$(27)+"[0;"+RIGHT$
- (STR$(I+58),2)+";"+CHR$(34)+K$
- (I)+CHR$(34)+";"+32p" : GOTO
- 410
- 350 PRINT #1,CHR$(27)+"[0;"+RIGHT$
- (STR$(I-10+83),2)+";"+CHR$(34)+
- K$(I)+CHR$(34)+";"+"32p" : GOTO
- 410
- 360 NOL = LEN(K$(I)) :N = NOL - 4 :
- KN$(I) = LEFT$(K$(I),N) : IF I
- > 10 THEN 380
- 370 PRINT #1,CHR$(27)+"[0;"+RIGHT$
- (STR$(I+58),2)+";"+CHR$(34)+
- KN$(I)+CHR$(34)+";+"13p" : GOTO
- 410
- 380 PRINT #1,CHR$(27)+"[0;"+RIGHT$
- (STR$(I-10+83),2)+";"+CHR$(34)+
- KN$(I)+CHR$(34)+";"+13p" : GOTO
- 410
- 390 IF I>10 THEN 400 : PRINT #1,
- CHR$(27)+"[0;"+RIGHT$(STR$
- (I+58),2)+";0;"+RIGHT$(STR$
- (I+58),2)+"p" "GOTO 410
- 400 PRINT #1,CHR$(27)+"[0;"+RIGHT$
- (STR$(I-10+83),2)+";0;"+RIGHT$
- (STR$(I-10+83),2)+"p"
- 410 NEXT I : CLOSE #1
- 420 KEYNOT$ = "KEYOFF" : OPEN
- KEYNOT$ FOR OUTPUT AS #2 :
- FOR I=1 TO 20 : IF I>10 THEN
- 440 'create file to turn off
- keys
- 430 PRINT #2,CHR$(27)+"[0;"+RIGHT$
- (STR$(I+58),2)+";0;"+RIGHT$
- (STR$(I+58),2)+"p" :GOTO 450
- 440 PRINT #2,CHR$(27)+"[0;"+RIGHT$
- (STR$(I-10+83),2)+";0;"+"RIGHT$
- (STR$(I-10+83),2)+"p"
- 450 NEXT I : CLOSE #2
- 460 HELPER$ = "KEYHELP" : OPEN
- HELPER$ FOR OUTPUT AS #3
- 'create help file
- 470 PRINT #3, "PC - KEY HELPER =>
- Present Key Definitions are:"
- 480 FOR I=1 TO 20 : IF I>10 THEN
- 500
- 490 PRINT #3," F"+RIGHT$
- (STR$(I),2)+K$(I) : GOTO 510
- 500 PRINT #3," s-F"+RIGHT$
- (STR$(I-10),2)+"="+K$(I)
- 510 NEXT I : CLOSE #3
- 520 KEY 1,"LIST"+CHR$(32) : KEY 2,
- "RUN"+CHR$(13) : KEY 3,"LOAD"+
- CHR$(34) : KEY 4,"SAVE"+
- CHR$(34) : KEY 5,"CONT"+
- CHR$(13)
- 530 KEY 6,","+CHR$(32)+"LPT1"+
- CHR$(13) : KEY 7,"TRON"+
- CHR$(13) : KEY 8,"TROFF"+
- CHR$(13) : KEY 9,"KEY"+CHR$(32)
- 540 KEY 10,"SCREEN 0,0,0"+CHR$(13)
- 'normal basic softkeys turned
- back on
- 550 END