Re: Keyboard handling on non-x86
Michael <[email protected]>
| Newsgroups | gmane.comp.xfree86.devel |
|---|---|
| Message-ID | <20050522204041.22599498@inishowen> |
Hello, here's the patch. > If older versions of NetBSD (x86 at least) don't have wscons, there > should at least be a check that it is available. Did that. X -configure with wscons support / NetBSD it will try to open /dev/wskbd, if it succeeds it will write driver kbd, protocol wskbd and device /dev/wskbd into XF86Config, if not it falls back to driver keyboard. > I suggested using the xfree86 XKB rules/keycodes for consistency of > features across platforms and because they are the best-supported ones > within XFree86. In the past, diverging from this has resulted in > unnecessary feature and functionality differences between platforms. > Also, the set of XKB key tokens (the <XXXX> objects mapped to raw > keycodes by the keycodes files) would ideally be platform-independent > to avoid the unnecessary need to have multiple copies of the XKB > symbol mappings. I added the Sun-specific keynames found in atKeynames.h to the Sun map in bsd_KbdMap.c and changed both the legacy driver and the modular keyboard driver to drop anything that's no sane scancode ( like KEY_NOTUSED ) and in case of the legacy driver anything that translates to something >0x7f because xf86PostKbdEvent() uses 0x80 as up/down indicator. This way everything is fine and the extra keys are (almost) all usable with kbd while the legacy driver behaves the same as before - extra keys don't work, some scancodes get mangled ( like most cursor keys ). > The symbols mappings in xkbcomp/symbols/pc are the most full-featured > that we have, and they're not really PC-specific. In fact, it is > probably a good time to promote them out of their pc/ subdirectory. They don't contain mappings for Sun extra keys like audio up/down and the extra function keys. Then there's nothing to do for the compose key. > That would just leave the issue of whether the raw keyboard codes are > mapped to a consistent set of X keycodes within the driver, or whether > that is handled by using different XKB keycodes files. I don't see a > great advantage to doing this mapping at the XKB level. The Sun map had a minor mistake (or feature?)- Props/L3 and ScrollLock were swapped. have fun Michael
xfree_kbd.patch
(application/octet-stream, 5.4 KB)
Index: common/xf86Configure.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v
retrieving revision 1.6
diff -u -r1.6 xf86Configure.c
--- common/xf86Configure.c 18 Mar 2005 14:55:14 -0000 1.6
+++ common/xf86Configure.c 22 May 2005 21:41:22 -0000
@@ -257,6 +257,7 @@
NewDevice.GDev.identifier = NewDevice.sVideo->descr;
if (sparcPromInit() >= 0) {
promPath = sparcPromNode2Pathname(&NewDevice.sVideo->node);
+
sparcPromClose();
}
if (promPath) {
@@ -307,7 +308,25 @@
configPrologue(XF86ConfInputPtr)
ptr->inp_identifier = "Keyboard0";
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+ /* check for /dev/wskbd */
+ {
+ int fd = open("/dev/wskbd", 0);
+ if (fd > 0) {
+ close(fd);
+ ptr->inp_driver = "kbd";
+ ptr->inp_option_lst =
+ xf86addNewOption(ptr->inp_option_lst, "Protocol", "wskbd");
+ ptr->inp_option_lst =
+ xf86addNewOption(ptr->inp_option_lst, "Device", "/dev/wskbd");
+ } else {
+ /* no /dev/wskbd - fall back to legacy driver */
+ ptr->inp_driver = "keyboard";
+ }
+ }
+#else
ptr->inp_driver = "keyboard";
+#endif
ptr->list.next = NULL;
/* Crude mechanism to auto-detect mouse (os dependent) */
Index: common/xf86Events.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v
retrieving revision 1.5
diff -u -r1.5 xf86Events.c
--- common/xf86Events.c 18 Mar 2005 14:55:14 -0000 1.5
+++ common/xf86Events.c 22 May 2005 21:41:24 -0000
@@ -1638,11 +1638,13 @@
/* map the scancodes to standard XFree86 scancode */
keycode = WSKbdToKeycode(value);
- if (!down) keycode |= 0x80;
- /* It seems better to block SIGIO there */
- blocked = xf86BlockSIGIO();
- xf86PostKbdEvent(keycode);
- xf86UnblockSIGIO(blocked);
+ if ((keycode != KEY_NOTUSED) && ((keycode & 0x80) == 0)) {
+ if (!down) keycode |= 0x80;
+ /* It seems better to block SIGIO there */
+ blocked = xf86BlockSIGIO();
+ xf86PostKbdEvent(keycode);
+ xf86UnblockSIGIO(blocked);
+ }
}
}
#endif /* WSCONS_SUPPORT */
Index: input/keyboard/kbd.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/input/keyboard/kbd.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 kbd.c
--- input/keyboard/kbd.c 5 Mar 2004 14:29:13 -0000 1.1.1.2
+++ input/keyboard/kbd.c 22 May 2005 21:41:33 -0000
@@ -580,6 +580,8 @@
/*
* Now map the scancodes to real X-keycodes ...
*/
+ if (scanCode == KEY_NOTUSED) return;
+
keycode = scanCode + MIN_KEYCODE;
keysym = (keyc->curKeySyms.map +
keyc->curKeySyms.mapWidth *
Index: os-support/bsd/bsd_KbdMap.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c,v
retrieving revision 1.2
diff -u -r1.2 bsd_KbdMap.c
--- os-support/bsd/bsd_KbdMap.c 11 Nov 2004 19:16:33 -0000 1.2
+++ os-support/bsd/bsd_KbdMap.c 22 May 2005 21:41:34 -0000
@@ -678,10 +678,10 @@
static CARD8 wsSunMap[] = {
/* 0x00 */ KEY_NOTUSED,
- /* 0x01 */ KEY_NOTUSED, /* stop */
- /* 0x02 */ KEY_NOTUSED, /* BrightnessDown / S-VolumeDown */
- /* 0x03 */ KEY_NOTUSED, /* again */
- /* 0x04 */ KEY_NOTUSED, /* BridgtnessUp / S-VolumeUp */
+ /* 0x01 */ KEY_L1, /* stop */
+ /* 0x02 */ KEY_AudioLower, /* BrightnessDown / S-VolumeDown */
+ /* 0x03 */ KEY_L2, /* again */
+ /* 0x04 */ KEY_AudioRaise, /* BridgtnessUp / S-VolumeUp */
/* 0x05 */ KEY_F1,
/* 0x06 */ KEY_F2,
/* 0x07 */ KEY_F10,
@@ -700,10 +700,10 @@
/* 0x14 */ KEY_Up,
/* 0x15 */ KEY_Pause,
/* 0x16 */ KEY_Print,
- /* 0x17 */ KEY_NOTUSED, /* props */
+ /* 0x17 */ KEY_ScrollLock,
/* 0x18 */ KEY_Left,
- /* 0x19 */ KEY_ScrollLock,
- /* 0x1a */ KEY_NOTUSED, /* undo */
+ /* 0x19 */ KEY_L3, /* props */
+ /* 0x1a */ KEY_L4, /* undo */
/* 0x1b */ KEY_Down,
/* 0x1c */ KEY_Right,
/* 0x1d */ KEY_Escape,
@@ -726,9 +726,9 @@
/* 0x2e */ KEY_KP_Divide,
/* 0x2f */ KEY_KP_Multiply,
/* 0x30 */ KEY_NOTUSED,
- /* 0x31 */ KEY_NOTUSED, /* front */
+ /* 0x31 */ KEY_L5, /* front */
/* 0x32 */ KEY_KP_Decimal,
- /* 0x33 */ KEY_NOTUSED, /* copy */
+ /* 0x33 */ KEY_L6, /* copy */
/* 0x34 */ KEY_Home,
/* 0x35 */ KEY_Tab,
/* 0x36 */ KEY_Q,
@@ -749,8 +749,8 @@
/* 0x45 */ KEY_KP_8,
/* 0x46 */ KEY_KP_9,
/* 0x47 */ KEY_KP_Minus,
- /* 0x48 */ KEY_NOTUSED, /* open */
- /* 0x49 */ KEY_NOTUSED, /* paste */
+ /* 0x48 */ KEY_L7, /* open */
+ /* 0x49 */ KEY_L8, /* paste */
/* 0x4a */ KEY_End,
/* 0x4b */ KEY_NOTUSED,
/* 0x4c */ KEY_LCtrl,
@@ -772,9 +772,9 @@
/* 0x5c */ KEY_KP_5,
/* 0x5d */ KEY_KP_6,
/* 0x5e */ KEY_KP_0,
- /* 0x5f */ KEY_NOTUSED, /* find */
+ /* 0x5f */ KEY_L9, /* find */
/* 0x60 */ KEY_PgUp,
- /* 0x61 */ KEY_NOTUSED, /* cut */
+ /* 0x61 */ KEY_L10, /* cut */
/* 0x62 */ KEY_NumLock,
/* 0x63 */ KEY_ShiftL,
/* 0x64 */ KEY_Z,
@@ -1061,10 +1061,13 @@
break;
#endif
#ifdef WSKBD_TYPE_SUN
+#ifdef WSKBD_TYPE_SUN5
+ case WSKBD_TYPE_SUN5:
+#endif /* WSKBD_TYPE_SUN5 */
case WSKBD_TYPE_SUN:
pKbd->scancodeMap = &wsSun;
break;
-#endif
+#endif /* WSKBD_TYPE_SUN */
default:
pKbd->RemapScanCode = ATScancode;
break;
signature.asc
(application/pgp-signature, 478 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (NetBSD) iQEVAwUBQpEmicpnzkX8Yg2nAQLZqQf/X9Kyii1lEevVTqE2UcVNvQ3a22wgzmpG nsT1C4J4hvm2NvXOaOemc00O2ItFNsF/DAyBW06nGFaXTzxieHjwFzM1bNnGJbMS QKdodeRd0CHXx4uallmn0oPASoaxAHlTabUyrLVmwRQIaliqyZloE+ftoU4LzbAS RFM2QktsYaRJ6iIH5JBpVfso5uKnufd7mKK11ikdTNbFS1pYzTGKPhOzQpyQpp9R izPcyTNys9F5a7PkMZ76sU2gxbeUYi2p4zp8AGFajuxwZzkGX3LzjjCD/bfGLdw8 pvUxpQ3ZBd1WthkZKpwY2wuBpjhQefBCgE7BIFmSt7DfmOQU9wnT3Q== =2bql -----END PGP SIGNATURE-----