Num Lock key in X, PF keys, involves xmodmap, xev

Polytropon freebsd at edvax.de
Sun Jul 5 20:49:52 UTC 2009


Dear list,

since I moved to a new keyboard, I have some trouble. Everything except
the Num Lock functionality works fine. Let me explain:

The keyboard is a BOSCOM PS/2 keyboard (with 122 keys, intended for
5250 operations on a PC) that contains a keyboard controller, so the
keyboard can simply be attached to the PC.

THis is how the keyboard looks like:

	http://www.ioconnections.com/images/products/bos_5250keyboard_black.jpg

It's a very nice one, so I want to use it instead of my Sun USB keyboard
because it has more and better keys. Think about the IBM model M. Same
mechanics.

The keyboard can operate in two different modes, which are selected by a
jumper inside the keyboard (where the LEDs are located).

In "jumper mode", keys operate like their caption (the key cap) indicates
it. For example, the keys on the left generate SysRq, Print, Escape and
so on. Some of them generate composed characters, this means when I press
a key, the keyboard sends a key combination, such as Alt+F3 for the
key or Shift+F1 for F13. Quite useless.

In "no jumper mode", each key sends a unique keycode. Some keys do not
do what their key cap says, but that's no problem because the caps can
be re-arranged. And I've got enough space keycaps with very nice
captions from other keyboards, so it's no problem to make my own
layout be represented correctly by the key caps.

This is the mode I need.

Using the xev program, I could easily find out which keys generate which
keycode, so I made a .xmodmaprc and assigned names to the different keys
according to what I intended them to use. For example, F13 .. F24 now are
described as F13 .. F24, so they can be assigned several actions by the
means of the window manager, i. e. WindowMaker - easy game, e. g. starting
programs or issuing a window arrangement command (front, background, roll
up, hide, lock screen and so on). On the numerical keypad, I have a comma
as well as a dot - in Germany, the comma is the decimal delimiter, so it's
not possible to type IPs on the numeric keypad only. But now, I can do
things like "192.168.1.1,192.168.1.2" all within the numerical keypad.

Now my problem: I can't get the Num Lock to work. First of all, I checked
which keycode would be generated when I press the key I want to have as
Num Lock - it's the one placed where it should be on the standard 102
keys model, numerical keypad, upper left.

This is the xev output when the key is pressed:

	KeyPress event, serial 27, synthetic NO, window 0x1800001,
	    root 0x73, subw 0x0, time 1285024705, (76,91), root:(355,651),
	    state 0x0, keycode 9 (keysym 0xff7f, Num_Lock), same_screen YES,
	    XLookupString gives 0 bytes: 
	    XmbLookupString gives 0 bytes: 
	    XFilterEvent returns: False	

The keycode 9 (former Escape, I think) has been assigned to the
key symbol Num_Lock by this entry in .xmodmaprc (file attached,
I hope):

	! Num
	keycode 9 = Num_Loc

The comment, preceeded by "!", states what is on the key cap, to make
finding them easier.

The problem is: Pressing this key doesn't change the Num state. So I
checked "man xmodmap" and found out that there are modes that can be
changed by certain keys.

	% xmodmap
	xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):
	shift       Shift_L (0x32),  Shift_R (0x3e)
	lock        Caps_Lock (0x42)
	control     Control_L (0x25),  Control_R (0x6d)
	mod1        Alt_L (0x40),  Meta_L (0x9c)
	mod2        Num_Lock (0x4d)
	mod3      
	mod4        Super_L (0x7f),  Hyper_L (0x80)
	mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x71),  ISO_Level3_Shift (0x7c)

This output states that Num_Lock toggles "mod2" - is this the Num mode?
I checked it through this command:

	% xmodmap -e "add mod2 = Num_Lock"

Ha! Pressing this key toggles Num now. Fine. No, not fine. Problem: The
keys on the left as well as the 2nd row of function keys does not work
anymore. If I switch off Num, they work again. Huh? I didn't have that
on the Sun keyboard, there using the keys on the left (which I assigned
F13 .. F27) always worked, no matter if Num was on or off.

However, xev tells me that the correct symbols are emitted when I press
the key, but the actions that have been assigned don't work anymore. So,
for example, F13 doesn't launch Opera anymore.

	KeyPress event, serial 27, synthetic NO, window 0x1800001,
	    root 0x73, subw 0x0, time 1285459063, (175,3), root:(362,537),
	    state 0x10, keycode 181 (keysym 0xffca, F13), same_screen YES,
	    XLookupString gives 0 bytes: 
	    XmbLookupString gives 0 bytes: 
	    XFilterEvent returns: False

But when I turn Num off and press F13, it works again. And as I said, I
didn't have such kind of behaviour with the Sun model. Basically, I'm
doing the same.

What am I doing wrong here? What am I missing? Ideas, anyone? =^_^=



PS. Follow-up question: What xmodmap is for X, that is WHAT for the
    console (text mode)? Would be nice to make the keyboard work
    properly at VTs, too.


-- 
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...Fr
-------------- next part --------------
! ESC / DefF
keycode 134 = Escape

! A-Abf / Abruf
keycode 210 = F25

! PsAus
keycode 219 = F26

! Linie / Pos1
keycode 111 = F27

! Pause / E-Lö
keycode 220 = F28

! bSDef / DrDef
keycode 221 = F29

! Eing Lösch
keycode 110 = F30

! Bed-hilfe / Hex
keycode 205 = F31

! Aufz Mode / Pause
keycode 207 = F32

! Wiedgabe / Test
keycode 204 = F33

! ^a
keycode 170 = Insert

! I<- / Zoom
keycode 99 = Home

! Bild ^
keycode 105 = Prior

! a° / aaa°
keycode 103 = Delete

! ->I
keycode 106 = End

! Bild v
keycode 107 = Next

! ^
keycode 98 = Up

! <-
keycode 100 = Left

! v
keycode 97 = Down

! ->
keycode 102 = Right

! 
keycode 104 = Down

! Num
keycode 9 = Num_Lock

! /
keycode 78 = KP_Divide

! *
keycode 63 = KP_Multiply

! -
keycode 112 = KP_Subtract

! .
keycode 82 = period

! <-J
keycode 86 = KP_Add

! Daten Freigabe
keycode 108 = KP_Enter

! Anford / Ungült
keycode 181 = F13

! Nachricht / Antw
keycode 126 = F14

! Fmt Wechs / Instr
keycode 182 = F15

! Zeile just
keycode 190 = F16

! Druck / S-Abf
keycode 191 = Print

! FAusW Ausw Roll / Test
keycode 192 = Scroll_Lock

! Pause / Untbr
keycode 193 = Pause

! Dup
keycode 198 = F20

! Such
keycode 199 = F21

! Vers / Kop
keycode 200 = F22

! Holen
keycode 201 = F23

! Zu
keycode 203 = F24




More information about the freebsd-questions mailing list