(Reprinted from Volume 1, 1994 CTOS Systems User Newsletter)

REMAPPING PC KEYBOARD HARD FUNCTION KEYS TO MATCH CTOS SOFTKEY DISPLAY

By Valentine J. Miller, Manager Solution Sets, San Jose, CA

If you have a SuperGen CTOS workstation with a PC style keyboard (SG-102-K or PCK101-KBD) you may get frustrated using CTOS applications where the function keys are displayed as softkeys This is because the 12 function keys on the PC style keyboards are not mapped to correspond visually with the softkey positions This article will show you a way to change the keyboard tables for PC keyboards so their function keys will map to the softkey display in CTOS applications.
Some CTOS applications display a softkey representation of the function keys labeled with user directions.  Figure 1 shows an example from OFIS Graphics.  Note that the physical grouping of the softkeys is the same as the function hardkeys on the Kx keyboard.
 ------------------  -----------------------  ----------------
|      |    |      ||     |     |     |     ||      |     |   |
|Redraw|Undo|Set Up||Files|Print|Views|Tools||Cancel|Clear|Go |
|      |    |      ||     |     |     |     ||      |     |   |
 ------------------  -----------------------  ----------------
Figure 1
A user will:
o	determine which of the three groupings has the key to be pressed,
o	press the hardkey on the keyboard that corresponds to the displayed softkey on the screen
For example, if you select the Files softkey, you will press the leftmost hardkey in the middle grouping. 
The PC Keyboard is currently mapped to the first ten function keys on the Kx style keyboards as shown in Figure 2.
 ------------------  -----------------------  ----------------
|      |    |      ||     |     |     |     ||      |     |   |
|Redraw|Undo|Set Up||Files|Print|Views|Tools||Cancel|Clear|Go |
|      |    |      ||     |     |     |     ||      |     |   |
 ------------------  -----------------------  ----------------
  |      |    |       /     /      /     /      /     /    /
  |      |    |      /     /      /     /      /     /    /
 F1     F2   F3     F4    F5    F6    F7      F8    F9 F10 F11 F12
Figure 2

In this example, if you select the middle grouping and press the leftmost key, you'll get Print instead of Files.  This is annoying, but in applications such as Mail where the File and Discard softkeys are next to each other, you can also lose important information.
The ideal solution is to modify the CTOS applications to determine which keyboard is attached and then show the correct function key strip for each keyboard.  However, this requires significant modifications to the programs.
Another solution is to change the mapping of the function keys on the PC style keyboard which will increase your chances of pressing the correct hardkey when using CTOS applications.
Figure 3 shows the proposed mapping of PC style keyboard function keys to CTOS application softkey displays.

 ------------------  -----------------------  ----------------
|      |    |      ||     |     |     |     ||      |     |   |
|Redraw|Undo|Set Up||Files|Print|Views|Tools||Cancel|Clear|Go |
|      |    |      ||     |     |     |     ||      |     |   |
 ------------------  -----------------------  ----------------
    |    /|\   |       |    |     |     |      |      /|\    |
    |   / | \  |       |    |     |     |      |     / | \   |
   F1   F2 F3 F4      F5    F6    F7    F8     F9   F10 F11 F12

Figure 3

The advantages of this mapping are:
all hardkeys in a group of function keys on the PC style keyboard are mapped to softkeys displayed in CTOS applications in the same group,
a softkey at one end of a group is selected by pressing a hardkey at the same end of the corresponding group on the PC keyboard,
the two softkeys in the middle of the middle group are selected by pressing the corresponding hardkeys in the middle group on the PC keyboard.
This remapping solution is implemented by creating a new version of NlsKbd.Sys that has a SuperSet keyboard emulation table with the new mapping in it.  There are two ways to accomplish this task:
1.	replace the existing SuperSet keyboard emulation table in NlsKbd.Sys with the table that has the new mapping or,
2.	create a NlsKbd.Sys with both the SuperSet keyboard emulation table and the SuperSet keyboard emulation table with the new mapping.  In this case, the table with the new mapping would have a different IBus ID.


OPTION 1:  REPLACING THE EXISTING SUPERSET KEYBOARD EMULATION TABLE
The following steps will create a new version of NlsKbd.Sys in which the existing SuperSet keyboard emulation table is replaced with a new mapping table.  (Before modifying any files, be sure to back up the original.)
1.	Install the keyboard customizing tool from the Development Utilities diskettes as well as the linker
2.	Copy the keyboard data files from the Development Utilities diskettes.  If you use Install Manager, it puts the files in the <sys> directory.  I recommend creating a separate directory on your hard disk and copying the files in the "KbdTables" directory(s) from the diskette into this directory.  The KbdTables directory is on the last diskette of the 3-1/2" set and it is on the last two diskettes of the 5-1/4" set.  You should have the following 10 files in the directory:
	k1.kbd_data	41.kbd_data
	51.kbd_data	61.kbd_data
	ssk1.kbd_data	k4nonfin.kbd_data
	k0.kbd_data	pik1.kbd_data
	sg1kemul.kbd_data	sg1ktrans.kbd_datacre
3	Use the Editor and open "ssk1.kbd_data".
4.	Make the following changes in the file:
A.  Search for the following string	"FF:17      ;   017   f3"
                                                   ------ ---   ---
                                                      |    |     |
                             spaces   ---------------------'     |
                            tab   -------------------------------'
Change the "FF:17" to "FF:16".  
This makes the PC <F3> key emulate the "K1" <F2> key.
B.  Search for the following string	"FF:18      ;   01F   f4"
                                                   ------ ---   ---
                                                      |    |     |
                              spaces  ---------------------'     |
                             tab  -------------------------------'
Change the "FF:18" to "FF:17".  
This makes the PC <F4> key emulate the "K1" <F3> key.


C. Continue the above process for all the other strings in the following table:
Search for	Change	Effect
FF:19	;	027 f5	FF:19 to FF:18	PC F5 emulates K1 F4
FF:1A	;	02F f6	FF:1A to FF:19	PC F6 emulates K1 F5
FF:1C	;	037 f7	FF:1C to FF:1A	PC F7 emulates K1 F6
FF:1D	;	03F f8	FF:1D to FF:1C	PC F8 emulates K1 F7
FF:1E	;	047 f9	FF:1E to FF:1D	PC F9 emulates K1 F8
FF:1F	;	04F f10	FF:1F to FF:1E	PC F10 emulates K1 F9
FF:FF	;	056 f11	FF:FF to FF:1E	PC F11 emulates K1 F9
FF:FF	;	05E f12	FF:FF to FF:1F	PC F12 emulates K1 F10
5.	Finish out of the Editor
6.	Execute the following command for each file ending in "kbd_data" in the directory (the following is an example for the "ssK1.kbd_data" file:
	Create Keyboard Data Block
	[Keyboard datafile name]    ssK1.kbd_data
	[Output is object module?]  y
	[Output is binary table?]
When the menu comes up, press the function key that corresponds to "All Data".
If a warning is displayed asking if you want to overwrite an existing file, press the "Confirm Action" function key.
7.	 You should have generated the following object modules:
	K0KbdTables.obj	K1KbdTables.obj
	K2KbdTables.obj	K4KbdTables.obj
	KfNonFinKbdTables.obj	K5KbdTables.obj
	K6KbdTables.obj	PC1EmulTables.obj
	PIEmulTables.obj	PIEmulTablesSpcl.obj
	SS1EmulTables.obj	SS1EmulTablesSpcl.obj
	SG1KTransTables.obj	SG1KEmulTables.obj
	SG1KEmulTablesSpcl.obj

8.	Link all of the object modules together as follows:
Link V6
Object modules	(Object modules listed in step 7)
Run file	NlsKbd.sys
[Map file]
[Publics?]
[Line numbers?]
[Stack size]
[Max array, data]	0 0
[Min array, data]
[Run file mode]	protected
[Version]	version
[Libraries]	none
[DS allocation?]
[Symbol file]
[Copyright notice?]
[File to append]
[Linker config file]
9.	Copy the new N1sKbd.sys to [Sys]<Sys> and reboot.


OPTION 2:  ADDING A SECOND SUPERSET KEYBOARD EMULATION TABLE

Create a new keyboard data file (the name used below is "ssk1New.kbd_data") from which a new object module, "SS1EmulTablesNew.obj" will be created with a separate IBus ID. The advantage is that you can continue to have the current mode of operation for those people that want it.
The following are steps to create a new version of N1sKbd.Sys in which the existing SuperSet keyboard emulation table and a new mapped version of the SuperSet keyboard are both present.
1.	Install the keyboard customizing tool from the Development Utilities diskettes as well as the linker
2.	Copy the keyboard data files from the Development Utilities diskettes.  If you use Install Manager, it puts the files in the <sys> directory.  I recommend creating a separate directory on your hard disk and copying the files in the "KbdTables" directory(s) from the diskette into this directory.  The KbdTables directory is on the last diskette of the 3-1/2" set and it is on the last two diskettes of the 5-1/4" set.  You should have the following 10 files in the directory:
k1.kbd_data	41.kbd_data
51.kbd_data	61.kbd_data
ssk1.kbd_data	k4nonfin.kbd_data
k0.kbd_data	pik1.kbd_data
sg1kemul.kbd_data	sg1ktrans.kbd_datacre

3.	Use the Editor and open "ssk1New.kbd_data".  Open the file "SSk1.kbd_data", copy the contents into "ssk1New.kbd_data" and close "ssk1.kbd_data".  The following instructions are for editing the file "ssk1New.kbd_data".
4.	Make the following changes in the file:
A.  Search for the following string	"FF:17      ;   017   f3"
                                                   ------ ---   ---
                                                      |    |     |
                              spaces  ---------------------'     |
                             tab  -------------------------------'
Change the "FF:17" to "FF:16".  
This makes the PC <F3> key emulate the "K1" <F2> key.
B.  Search for the following string	"FF:18      ;   01F   f4"
                                                   ------ ---   ---
                                                      |    |     |
                              spaces  ---------------------'     |
                             tab  -------------------------------'
Change the "FF:18" to "FF:17".  
This makes the PC <F4> key emulate the "K1" <F3> key.
C. Continue the above process for all the other strings in the following table:
Search for	Change	Effect
FF:19	;	027 f5	FF:19 to FF:18	PC F5 emulates K1 F4
FF:1A	;	02F f6	FF:1A to FF:19	PC F6 emulates K1 F5
FF:1C	;	037 f7	FF:1C to FF:1A	PC F7 emulates K1 F6
FF:1D	;	03F f8	FF:1D to FF:1C	PC F8 emulates K1 F7
FF:1E	;	047 f9	FF:1E to FF:1D	PC F9 emulates K1 F8
FF:1F	;	04F f10	FF:1F to FF:1E	PC F10 emulates K1 F9
FF:FF	;	056 f11	FF:FF to FF:1E	PC F11 emulates K1 F9
FF:FF	;	05E f12	FF:FF to FF:1F	PC F12 emulates K1 F10
D. Go to the beginning of the file and search for the following string:  "Output file name."
Change the name of the object module on the following line from "SS1EmulTables.obj" to "SS1EmulTablesNew.obj"
E. Search for the string "target translation table in hex".  On the same line as the string is an  array of five numbers, one of which is 65.  Change the "65" to "05".  This makes "05" the IBus ID for this table.
5.	Finish out of the Editor

6.	The following command "Create Keyboard Data Block" must be executed on every ".kbd_data" file copied from the Development Utilities diskettes PLUS the newly created file.  The following is an example for the "K1.kbd_data" file:
Create Keyboard Data Block
[Keyboard datafile name]    K1.kbd_data
[Output is object module?]  y
[Output is binary table?]
When the menu comes up, press the function key that corresponds to "All Data".
If a warning is displayed asking if you want to overwrite an existing file, press the "Confirm Action" function key.
7.	You should have generated the following object modules:
K0KbdTables.obj	K1KbdTables.obj
K2KbdTables.obj	K4KbdTables.obj
KfNonFinKbdTables.obj	K5KbdTables.obj
K6KbdTables.obj	PC1EmulTables.obj
PIEmulTables.obj	PIEmulTablesSpcl.obj
SS1EmulTables.obj	SS1EmulTablesSpcl.obj
SG1KTransTables.obj	SG1KEmulTables.obj
SG1KEmulTablesSpcl	objSS1EmulTablesNew.obj
8.	Link all of the object modules together as follows:
Link V6
Object modules	(Object modules listed in step 7)
Run file	NlsKbd.sys
[Map file]
[Publics?]
[Line numbers?]
[Stack size]
[Max array, data]	0 0
[Min array, data]
[Run file mode]	protected
[Version]	version
[Libraries]	none
[DS allocation?]
[Symbol file]
[Copyright notice?]
[File to append]
[Linker config file]
9.	Reconfigure your system:

A. copy the new N1sKbd.sys to [Sys]<Sys>

B. edit "Config.sys" to add the following entry:
	:MAPKEYBOARDID:(SOURCE=65,TARGET=05)
This means that when your PC keyboard is recognized and the ID of 65 is specified for it, the table with an ID of 05 is used.
C. reboot.