Download raw body.
equal '=' key on numpad
Hello, typists!
The equal '=' key on a number pad almost never works in OpenBSD.
This rare key exists on Apple Mac keyboards; I have 2,
- my macppc PowerBook's internal ADB keyboard, akbd(4)
- an external Apple USB keyboard, ubkd(4)
Outside X11 on ttyC4 (Control + Alt + F4), the ADB numpad '=' works,
the USB one fails. The fix is to map USB scancode 103 to '=' in the
kernel, by moving 103 from the fr.apple layout to the us layout (in
makemap.awk, ukbdmap.c).
Inside X11, the ADB numpad '=' fails because the OpenBSD and Xorg
use different XT scancodes,
XT => xev
[OpenBSD ADB] 0x76 => 0xd5 + 8 = 221
[OpenBSD USB] 0x59 => 0x95 + 8 = 157 [xkb macintosh]
0x5c => 118 + 8 = 126 [xkb xfree86]
(The XT => xev translation is in xf86-input-keyboard, where
at_scancode.c maps 0x76 to KEY_0x76 = 0xD5; but kbd.c does
scanCode + MIN_KEYCODE, so xev(1) gets 0xd5 + 8 = 221.)
This diff changes OpenBSD to send 0x5c, so xev(1) gets 126, which is
KP_Equal in xkb's xfree86 keycodes. The change is in hidkbd.c for USB
and wskbdraw.h for ADB, but wskbdraw.h also affects some luna88k and
sparc64 keyboards.
If you have an ADB keyboard, then xserver/config/wscons.c might change
xkb's keycodes from xfree86 to macintosh, which moves KP_Equal from
126 to 157 (which was wrong; the keyboard sent 221). To fix this,
after booting the diff, run $ setxkbmap -keycodes xfree86
Is this ok to commit?
--gkoehler
Index: dev/hid/hidkbd.c
===================================================================
RCS file: /cvs/src/sys/dev/hid/hidkbd.c,v
diff -u -p -r1.13 hidkbd.c
--- dev/hid/hidkbd.c 2 Jul 2024 05:50:02 -0000 1.13
+++ dev/hid/hidkbd.c 6 Jul 2024 03:36:38 -0000
@@ -85,7 +85,7 @@ const u_int8_t hidkbd_trtab[256] = {
0x7f, 0xd2, 0xc7, 0xc9, 0xd3, 0xcf, 0xd1, 0xcd, /* 48 - 4f */
0xcb, 0xd0, 0xc8, 0x45, 0xb5, 0x37, 0x4a, 0x4e, /* 50 - 57 */
0x9c, 0x4f, 0x50, 0x51, 0x4b, 0x4c, 0x4d, 0x47, /* 58 - 5f */
- 0x48, 0x49, 0x52, 0x53, 0x56, 0xdd, 0xde, 0x59, /* 60 - 67 */
+ 0x48, 0x49, 0x52, 0x53, 0x56, 0xdd, 0xde, 0x5c, /* 60 - 67 */
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* 68 - 6f */
0x6c, 0x6d, 0x6e, 0x76, 0x97, NN, 0x93, 0x95, /* 70 - 77 */
0x91, 0x92, 0x94, 0x9a, 0x96, 0x98, 0x99, 0xa0, /* 78 - 7f */
Index: dev/usb/makemap.awk
===================================================================
RCS file: /cvs/src/sys/dev/usb/makemap.awk,v
diff -u -p -r1.17 makemap.awk
--- dev/usb/makemap.awk 22 Nov 2023 18:19:25 -0000 1.17
+++ dev/usb/makemap.awk 6 Jul 2024 03:36:48 -0000
@@ -330,6 +330,7 @@ $1 == "#define" || $1 == "#undef" {
#
if (nmaps++ == 0) {
lines[102] = " KC(102),\tKS_Cmd_Sleep,"
+ lines[103] = " KC(103),\tKS_KP_Equal,"
lines[116] = " KC(116),\tKS_Open,"
lines[117] = " KC(117),\tKS_Help,"
lines[118] = " KC(118),\tKS_Props,"
@@ -399,7 +400,6 @@ $1 == "#define" || $1 == "#undef" {
print " KC(53),\tKS_at,\t\tKS_numbersign,"
print " KC(55),\tKS_colon,\tKS_slash,\tKS_voidSymbol,\tKS_backslash,"
print " KC(56),\tKS_equal,\tKS_plus,"
- print " KC(103),\tKS_KP_Equal,"
print " KC(231),\tKS_Mode_switch,\tKS_Multi_key,"
} else
if (mapname == "ukbd_keydesc_pt[]") {
Index: dev/usb/ukbdmap.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ukbdmap.c,v
diff -u -p -r1.49 ukbdmap.c
--- dev/usb/ukbdmap.c 22 Nov 2023 18:22:53 -0000 1.49
+++ dev/usb/ukbdmap.c 6 Jul 2024 03:36:48 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbdmap.c,v 1.49 2023/11/22 18:22:53 tobhe Exp $ */
+/* $OpenBSD$ */
/*
* THIS FILE IS AUTOMAGICALLY GENERATED. DO NOT EDIT.
@@ -151,6 +151,7 @@ static const keysym_t ukbd_keydesc_us[]
KC(99), KS_KP_Delete, KS_KP_Decimal,
KC(101), KS_Menu,
KC(102), KS_Cmd_Sleep,
+ KC(103), KS_KP_Equal,
KC(104), KS_f13,
KC(105), KS_f14,
KC(106), KS_f15,
@@ -365,7 +366,6 @@ static const keysym_t ukbd_keydesc_fr_ap
KC(53), KS_at, KS_numbersign,
KC(55), KS_colon, KS_slash, KS_voidSymbol, KS_backslash,
KC(56), KS_equal, KS_plus,
- KC(103), KS_KP_Equal,
KC(231), KS_Mode_switch, KS_Multi_key,
};
Index: dev/wscons/wskbdraw.h
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wskbdraw.h,v
diff -u -p -r1.4 wskbdraw.h
--- dev/wscons/wskbdraw.h 24 Jul 2023 19:28:40 -0000 1.4
+++ dev/wscons/wskbdraw.h 6 Jul 2024 03:36:48 -0000
@@ -120,10 +120,10 @@
#define RAWKEY_less 0x56 /* < > on European keyboards */
#define RAWKEY_f11 0x57
#define RAWKEY_f12 0x58
+#define RAWKEY_KP_Equal 0x5c
#define RAWKEY_Pause 0x6a
#define RAWKEY_Meta_L 0x73
#define RAWKEY_Meta_R 0x74
-#define RAWKEY_KP_Equal 0x76
#define RAWKEY_KP_Enter 0x9c
#define RAWKEY_Control_R 0x9d
#define RAWKEY_KP_Divide 0xb5
equal '=' key on numpad