rosell@stolaf.edu (Rob Rosell) (04/23/91)
Hello, World. I know this is probably a dumb question... but I've researched it and haven't been able to solve the problem. The problem is that I can't get the number pad on my SPARCstation SLC to work under X-Windows. According to the Xterm manual page there is an appkeypad option under the vtMenu. This supposedly invodes the set-appkeypad action, which is a toggle. I tried choosing this option, but no luck, nothing changed, and the Number pad continued to give me garbage (control characters). Has anybody out there struggled with this problem? Has anybody out there solved it? (regardless of whether or not you strougled with it?) --------------------------------------------------------------------- Rob Rosell: rosell@thor.acc.stolaf.edu or Rob Rosell: St.Olaf College, Northfield, Mn 55057. ---------------------------------------------------------------------
mayoff@cs.utexas.edu (Robert Mayoff) (04/25/91)
In article <1991Apr23.034515.23327@news.stolaf.edu> rosell@stolaf.edu (Rob Rosell) writes: > I know this is probably a dumb question... but I've researched >it and haven't been able to solve the problem. The problem is that >I can't get the number pad on my SPARCstation SLC to work under >X-Windows. < Stuff about Application Keypad toggling not working > The Application Keypad toggle does not work for me, either. > Has anybody out there struggled with this problem? Has >anybody out there solved it? (regardless of whether or not you >strougled with it?) I am struggling with it. In fact, I have solved it, but my solution is, in my mind, unsatisfactory. Here's my solution. It requires using twm (or some other window manager that can grab keys and bind actions to them). First, I install this keymap file using xmodmap when I start up X. I store this file in "~/.xmodmap". ------------------------------------------------------------------------------- ! The Delete key should act just like the BackSpace key. keycode 73 = BackSpace ! The Scroll-Lock/Break key - there's no Scroll_Lock keysym. keycode 30 = Break ! The PrSc key. keycode 29 = Print ! The keypad =, /, and *. keycode 52 = equal keycode 53 = slash keycode 54 = asterisk ------------------------------------------------------------------------------- These keycodes should work on any Sun using a type 4 keyboard (this includes all SPARCs). I determined these with xev. After installing this file, I install this one, which I keep in "~/.xmodmap.nonumlock": ------------------------------------------------------------------------------- keycode 101 = Insert keycode 57 = BackSpace keycode 119 = End keycode 120 = Down keycode 121 = Next keycode 98 = Left keycode 99 = 5 keycode 100 = Right keycode 75 = Home keycode 76 = Up keycode 77 = Prior ------------------------------------------------------------------------------- The keys will now be mapped to reasonable keysyms. Instead of having the key clearly marked "Home" mapped to the keysym "F27" (also "R7"), it has the keysym "Home". PgUp and PgDn map to Prior and Next, respectively. I have a shell script called "toggle.numlock" which looks like this: ------------------------------------------------------------------------------- #!/bin/sh if /usr/local/bin/X11/xmodmap -pk | egrep -s Home ; then echo numlocking /usr/local/bin/X11/xmodmap /home/poe/mayoff/.xmodmap.numlock else echo unnumlocking /usr/local/bin/X11/xmodmap /home/poe/mayoff/.xmodmap.nonumlock fi ------------------------------------------------------------------------------- This script determines whether the keypad is in Keypad mode or Number mode. If it's in Keypad mode, it installs this third and final keymap, ".xmodmap.numlock": ------------------------------------------------------------------------------- keycode 101 = 0 keycode 57 = period keycode 119 = 1 keycode 120 = 2 keycode 121 = 3 keycode 98 = 4 keycode 99 = 5 keycode 100 = 6 keycode 75 = 7 keycode 76 = 8 keycode 77 = 9 ------------------------------------------------------------------------------- Which obviously maps the keys to the appropriate numbers and symbols. If the keypad is already in Number mode, toggle.numlock switches it back to Keypad mode by installing the .xmodmap.nonumlock file. To get this all working on the Num_Lock key, I have the following line in my .twmrc file: "Num_Lock" = : all : !"/home/poe/mayoff/bin/toggle.numlock" That's the entire setup. Now, the problem. I want to use PgUp and PgDn (mapped to Prior and Next) to scroll my xterm (like dragging the scroll bar would do), and have Home and End go to the top and bottom of the scrollbar. This I do by having these xterm translations: <Key>Prior: scroll-back(1, page)\n\ <Key>Next: scroll-forw(1, page)\n\ <Key>Home: scroll-back(100,page)\n\ <Key>End: scroll-forw(100,page)\n\ The problem is that when xterm starts up, it figures out which keys these are, and if they get remapped, still uses them for whatever function I bound them to in the translation table, instead of using the new keymap. So, the arrow keys get remapped to the number, but Home, End, PgUp, and PgDn don't - they still scroll the window. I'd assume (I haven't dug through the source this far yet) that it's because when xterm (or more likely the toolkit) reads the X resources, it applies XGrabKey for each key that an action is bound to. XGrabKey grabs on keycodes, not keysyms, hence if a keycode's associated keysym is changed, the grab is still active on the key. I'm thinking that perhaps if I could get xterm to redo its translations when it receives a MappingNotify the problem might be solved, but I'm not a toolkit person. I have tried variations on this, including have xterm catch the Num_Lock events and installing a new keymap, but I want numlock to be a global thing, and this solution doesn't provide that - each xterm will have its own numlock state. Unsatisfactory. Besides which, numlock would then only work in xterms, not in other clients (unless they too provide dynamic remapping of the keyboard). So, you can use the solution I present above if you don't want to use the keypad to scroll your xterm, or you can keep looking (like I am) if you do. Or you can try to patch xterm or the X toolkit (I'm not sure which would require patching) to fix the problem. -- /_ rob <mayoff@cs.utexas.edu> /_ Fun things to do with UNIX (#118 in a series): / tail -f super.grow | cat /etc/motd - >> super.grow