From: hernande@cs.tulane.edu (Oliver Hernandez)
Newsgroups: comp.unix.admin,comp.unix.questions
Subject: keymapping
Date: 24 Jul 92 20:01:08 GMT
Organization: Computer Science Dept., Tulane Univ., New Orleans, LA
Status: OR
To: hernande@rex.cs.tulane.edu
Nntp-Posting-Host-[nntpd-8061]: okeanos


    About two weeks ago, I saw some postings asking about keymapping.  The
person asking got many responses e-mailed to him, and later posted to the net
to e-mail him for the responses he received about keymapping.  I mailed him,
but haven't gotten a response from him yet.  I include the message that I
sent him asking him about my keymapping problem hoping that someone here
could answer my question.  I am a student at Tulane working for TI this sum-
mer and I'm using the newsgroup service on the systems at Tulane because I
don't have access to the newsgroup services here.  So my inquiry is serious.
I would greatly appreciate any help and I thank you in advance.  Please send
e-mail to hernande@lobby.ti.com.\
[appended file]

     I see that you've gotten some responses as to how to map a keypad
to an EDT keypad.  I had to work on the same problem here at TI in
Lewisville, TX, and the following was my solution.  There are 2 problems
with it, though, that makes it less that ideal for our users.  One, I
had to map the numlock key as a shift key in order to give the keys on
the keypad a second function, since the requirements were to be able to
use the arrows keys as well as EDT functions on a Sun type4 keyboard.  (
I see that you were mapping the keypad on an RS6000, right?  Well I'm
hoping that you got a response that has a solution for Sun keyboards.)
So this obviously was not accepted well as users had to constanly turn
numlock on and off so that they wouldn't get letters in all caps while
typing.  My second problem was that one could not get any menus with the
mouse while the numlock key was on.  But if the numlock key was off and
one holds down a shift key, the menus work fine.  *Very Strange*.  There
probably isn't a solution to my second bug, and I'm sure it's due to my
solution to mapping the keypad.  So David, if you know of any way to
give keys a second function while numlock is on (not shiftlock) from the
solutions to keymapping that were e-mailed to you, I would greatly
appreciate any help that you can give me.  The following is a summary
of my solution, and if you could, modify the example keymap file in it
to show me what to do.  Use the Internet address hernande@lobby.ti.com,
not the address you see at the head of this message because mail sent to
the return address will bounce back.  Thank you in advance for your time
and help.
**
 Oliver Hernandez                       |  Voice: (214) 462-4099
 Texas Instruments, Inc.                |  FAX: (214) 462-3375
 DSEG Computer Services, Denton County  |  Pager: (817) 432-7237
 Workstation Engineer                   |  Internet: hernande@lobby.ti.com


MSG #_ 02351028 Pg 01 05           MSG - EDIT             07/07/92 12:22 AUMIMA

   To: DCS Eng. WKST  Support     *ENGW     DCS Eng. VAX Support       *ENGV

 Cc: Anil Keswani      ANK        Margie Delaughter     MDEL

 From: Oliver Hernandez           OCH

 Subj: Unix to VAX/EDT keymapping

 FYI.

 I have worked on this problem and found how to map the keypad on a Sun type
 keyboard to a VT* type keyboard when connected to a VAX from a workstation.
 The following is my documented solution:


 MAPPING SUN KEYBOARDS TO VAX/VT* KEYBOARDS
 ------------------------------------------

      The tools needed to accomplish this compatibility between the two types
 of keyboards are the "xmodmap" and "xterm" utilities in the Unix/X-Windows
 system.  The xmodmap utility modifies the keys on the Sun keyboard, allowing
 them to execute different functions.  The xterm utility is the terminal emu-
 lator for the X-Windowing system, used for connecting to remote machines via
 a pop-up window.  Both work together to make the Sun keymapping possible.
      To map the keypad on a Sun keyboard to function as a VT* style keypad,
 a file has to be created with the new keypad assignments.  The file must
 follow the syntax that xmodmap requires for reading and executing.  See the
 man pages for more details on the syntax used by xmodmap.  The following is
 the file that I created for xmodmap:

		     keycode 52 = KP_F1
		     keycode 53 = KP_F2
		     keycode 54 = KP_F3
		     keycode 17 = KP_F4
		     keycode 77 = F29 KP_9
		     keycode 76 = Up KP_8
		     keycode 75 = F27 KP_7
		     keycode 100 = Right KP_6
		     keycode 99 = F31 KP_5
		     keycode 98 = Left KP_4
		     keycode 121 = F35 KP_3
		     keycode 120 = Down KP_2
		     keycode 119 = R13 KP_1
		     keycode 101 = KP_0
		     keycode 78 = KP_Subtract
		     keycode 132 = KP_Add KP_Separator
		     keycode 57 = Delete KP_Decimal
		     add shift = Num_Lock

 This file can be given any arbitrary name, but it is usually named
 ".xmodmaprc" by convention.  The keymapping consists of assigning "keycodes"
 to certain functions called "keysyms."  The keycodes refer to the actual
 physical key on the keyboard.  The keys on every keyboard generate a certain
 keycode by which they are identified.  The function, or keysym, that is
 assigned to a key is looked up in a keymap table, and xmodmap is used to
 change the key assignments in this table.  Run the "xev" event tester in the
 X-Windowing system to find the keycodes generated by the keyboard, and run
 xmodmap with the -pk option to print the default keymap table that has all
 of the keysyms.  Refer to the man pages for more on xev.
      To put the new keymappings into effect, type the following at the
 command line prompt:
		    %  xmodmap <filename> <ENTER>

 To pop-up the xterm terminal emulator, type the following at the command
 line prompt:
		    %  xterm +sf -tn vt100 & <ENTER>

 A window should appear with the xterm title on it.  In the window is a
 command shell, from which a remote login can be initiated.  The +sf option
 allows the function keys to act as standard function keys instead of Sun
 function keys.  The -tn option specifies the terminal type, which in this
 case is vt100.  There is also an option to automatically run a command that
 starts a remote login in the xterm window.  See the man pages for more info
 on all of the xterm options.
      The keymap file above allows the Sun keypad to toggle between VT* mode
 and standard Sun functions and arrow keys.  Turning Numlock on switches the
 keypad to VT* mode, and turning Numlock off switches to standard mode.  In
 VT* mode, keys R4-6 function as the PF1-3 keys.  The F4 key functions as the
 PF4 key.  The keypad "plus" key functions as the keypad comma.  The remain-
 ing keys on the keypad correspond to the VT* keypad, allowing the use of
 "hotkey" commands such as in the EDT editor.  When Numlock is off, the use
 of the arrow keys is enabled, allowing cursor movement when editing files.
      The Sun keyboard compatibility with VT* type keyboards will only work
 in the xterm terminal emulator.  The new keymappings will not be recognized
 by the remote host if logged on through any other window.

 BUGS:

      The bugs that are known in this keymapping solution are due to the
 way that it is implemented.  The numlock key on the Sun keyboard is
 actually mapped as a shift-lock key.  So while numlock is on when VAX/
 EDT functions are being used, all the other character keys are in caps.
 In order for the Sun keypad to have the dual function of an EDT keypad
 and arrow keys, the keys had to be modified in a way that they would
 function differently when numlock is on.  In reading all of the docu-
 mentation on xmodmap that I found, I have not learned how to modify the
 function of a key while the numlock key is enabled.  The only example
 of such a modification that I found is mapping a second function to a
 key when it is shifted.  From that example, I was able to map second
 functions to the keys on the Sun keypad by mapping the numlock key as a
 shift key.  The other bug with this solution has to do with the menuing
 system under the OpenWindows window manager.  For some reason unknown,
 while numlock is on, the ability to get pop-up menus with the mouse is
 lost.  I have tried getting the menus with numlock off and holding down
 a shift key, and that works fine, so the problem has to do with the
 mapping of numlock as a shift key.

      For all other details and specifics, please refer to the man pages.  If
 there are any other questions, comments, or suggestions, feel free to con-
 tact me at x4099, via MSGid OCH, or in person.  Thank you.
Newsgroups: comp.unix.admin