Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Apr 2009 20:10:14 GMT
From:      YAMASHIRO Jun <yamajun@ofug.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/134005: Cannot type underscore and other key on JP106 USB keyboard on Xorg
Message-ID:  <200904252010.n3PKAEkh014114@www.freebsd.org>
Resent-Message-ID: <200904252020.n3PKK1k1085422@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         134005
>Category:       kern
>Synopsis:       Cannot type underscore and other key on JP106 USB keyboard on Xorg
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 25 20:20:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     YAMASHIRO Jun
>Release:        FreeBSD 8.0-CURRENT
>Organization:
Okinawa FreeBSD Users Group
>Environment:
CURRENT:
FreeBSD  8.0-CURRENT FreeBSD 8.0-CURRENT #36: Sat Apr 25 17:27:10 JST 2009     y
amajun@:/usr/obj/usr/src/sys/GENERIC  i386

7.x:
FreeBSD  7.2-RC2 FreeBSD 7.2-RC2 #0: Sat Apr 26 03:09:34 JST 2009     yamajun@:/
usr/obj/usr/src/sys/GENERIC  i386
>Description:
In Xorg on FreeBSD, these keys on 106/109 Japanese keyboard aren't work.

1) backslash / underscore (Keyboard International 1)
2) Hiragana_Katakana (Keyboard International 2)
3) Henkan (Keyboard International 4)

In past, two(or more) reports posted for this bug, 
as ports bug(ports/116443 and ports/119037).  But,
I found cause of this bug at ukbd(4). No necessary 
change of x11-drivers/xf86-input-keyboard.

This bug make inconvenience to Japanese FreeBSD users 
in several years.  Please fix it rapidly.

Cause:
Add support for Sun Type 6 keyboard sys/dev/usb/ukbd.c in revision 1.46.
But, Type 6 support code caused crash keycode value of some keys
on Japanese keyboard.
This patch solved this bug without change behavior of Sun Type 6/7 
support code.

This patch no harm US 101 keyboard layout.  But, special key on 
Sun Type 6/7 keyboard(Stop, Copy, etc.) cannot work with old and new ukbd.c
(Only work with SPARC architecture workstation?)

Tested with:
109 Japanese USB keyboard
101 US USB keyboard
Sun Type 7 Japanese USB keyboard
(Cannot work special key on Type 6/7 keyboard)

Note:
* Same problem reported in ports/116443 and ports/119037.
* On console, fixed similarly bug(Report in kern/99090 and kern/112214).

Reference:
USB HID to PS/2 Scan Code Translation Table
http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456
c/translate.pdf



>How-To-Repeat:
1. Run Xorg.
2. X keymap setting for Japanese keyboard
% setxkbmap -layout jp
% setxkbmap -model jp106
3. Type "backslash / underscore" key

>Fix:
1. Extract shar archive.
2. Apply patch in archive.
(Current)
# cd /usr/src/sys/dev/usb/input
# patch < /path/to/ukbd.c.diff.current
# cd /usr/src/sys/legacy/dev/usb
# patch < /path/to/ukbd.c.diff.7

(7.x)
# cd /usr/src/sys/dev/usb
# patch < /path/to/ukbd.c.diff.7

3. rebuild kernel and reboot
# cd /usr/src
# make buildkernel
# make installkernel
# shutdown -r now


Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	ukbd.c.diff.7
#	ukbd.c.diff.current
#
echo x - ukbd.c.diff.7
sed 's/^X//' >ukbd.c.diff.7 << 'f8be75896e0e3b4b145846774568e271'
X--- ukbd.c.orig	2009-04-26 00:30:53.000000000 +0900
X+++ ukbd.c	2009-04-26 00:30:41.000000000 +0900
X@@ -320,8 +320,8 @@
X           NN,  NN,  NN,  NN,  NN,  NN,  NN,  NN, /* 68 - 6F */
X           NN,  NN,  NN,  NN, 115, 108, 111, 113, /* 70 - 77 */
X          109, 110, 112, 118, 114, 116, 117, 119, /* 78 - 7F */
X-         121, 120,  NN,  NN,  NN,  NN,  NN, 115, /* 80 - 87 */
X-         112, 125, 121, 123,  NN,  NN,  NN,  NN, /* 88 - 8F */
X+         121, 120,  NN,  NN,  NN,  NN,  NN, 123, /* 80 - 87 */
X+         124, 125, 126, 127, 128,  NN,  NN,  NN, /* 88 - 8F */
X           NN,  NN,  NN,  NN,  NN,  NN,  NN,  NN, /* 90 - 97 */
X           NN,  NN,  NN,  NN,  NN,  NN,  NN,  NN, /* 98 - 9F */
X           NN,  NN,  NN,  NN,  NN,  NN,  NN,  NN, /* A0 - A7 */
X@@ -1498,22 +1498,61 @@
X keycode2scancode(int keycode, int shift, int up)
X {
X 	static int scan[] = {
X-		0x1c, 0x1d, 0x35,
X-		0x37 | SCAN_PREFIX_SHIFT, /* PrintScreen */
X-		0x38, 0x47, 0x48, 0x49, 0x4b, 0x4d, 0x4f,
X-		0x50, 0x51, 0x52, 0x53,
X-		0x46, 	/* XXX Pause/Break */
X-		0x5b, 0x5c, 0x5d,
X-		/* SUN TYPE 6 USB KEYBOARD */
X-		0x68, 0x5e, 0x5f, 0x60,	0x61, 0x62, 0x63,
X-		0x64, 0x65, 0x66, 0x67, 0x25, 0x1f, 0x1e,
X-		0x20, 
X+		/* 89 */
X+		0x11c,	/* Enter */
X+		/* 90-99 */
X+		0x11d,	/* Ctrl-R */
X+		0x135,	/* Divide */
X+		0x137 | SCAN_PREFIX_SHIFT,	/* PrintScreen */
X+		0x138,	/* Alt-R */
X+		0x147,	/* Home */
X+		0x148,	/* Up */
X+		0x149,	/* PageUp */
X+		0x14b,	/* Left */
X+		0x14d,	/* Right */
X+		0x14f,	/* End */
X+		/* 100-109 */
X+		0x150,	/* Down */
X+		0x151,	/* PageDown */
X+		0x152,	/* Insert */
X+		0x153,	/* Delete */
X+		0x146,	/* XXX Pause/Break */
X+		0x15b,	/* Win_L(Super_L) */
X+		0x15c,	/* Win_R(Super_R) */
X+		0x15d,	/* Application(Menu) */
X+
X+ 		/* SUN TYPE 6 USB KEYBOARD */
X+		0x168,	/* Sun Type 6 Help */
X+		0x15e,	/* Sun Type 6 Stop */
X+		/* 110 - 119 */
X+		0x15f,	/* Sun Type 6 Again */
X+		0x160,	/* Sun Type 6 Props */
X+		0x161,	/* Sun Type 6 Undo */
X+		0x162,	/* Sun Type 6 Front */
X+		0x163,	/* Sun Type 6 Copy */
X+		0x164,	/* Sun Type 6 Open */
X+		0x165,	/* Sun Type 6 Paste */
X+		0x166,	/* Sun Type 6 Find */
X+		0x167,	/* Sun Type 6 Cut */
X+		0x125,	/* Sun Type 6 Mute */
X+		/* 120 - 128 */
X+		0x11f,	/* Sun Type 6 VolumeDown */
X+		0x11e,	/* Sun Type 6 VolumeUp */
X+		0x120,	/* Sun Type 6 PowerDown */
X+
X+		/* Japanese 106/109 keyboard */
X+		0x73,	/* Keyboard Intl' 1 (backslash / underscore) */
X+		0x70,	/* Keyboard Intl' 2 (Katakana / Hiragana) */
X+		0x7d,	/* Keyboard Intl' 3 (Yen sign) (Not using in jp106/109) */
X+		0x79,	/* Keyboard Intl' 4 (Henkan) */
X+		0x7b,	/* Keyboard Intl' 5 (Muhenkan) */
X+		0x5c,	/* Keyboard Intl' 6 (Keypad ,) (For PC-9821 layout) */
X 	};
X 	int scancode;
X 
X 	scancode = keycode;
X 	if ((keycode >= 89) && (keycode < 89 + sizeof(scan)/sizeof(scan[0])))
X-		scancode = scan[keycode - 89] | SCAN_PREFIX_E0;
X+		scancode = scan[keycode - 89];
X 	/* Pause/Break */
X 	if ((keycode == 104) && !(shift & (MOD_CONTROL_L | MOD_CONTROL_R)))
X 		scancode = 0x45 | SCAN_PREFIX_E1 | SCAN_PREFIX_CTL;
f8be75896e0e3b4b145846774568e271
echo x - ukbd.c.diff.current
sed 's/^X//' >ukbd.c.diff.current << '594511c3b5704ee4b236e1e96d9dbe3b'
X--- ukbd.c.orig	2009-04-18 10:31:47.000000000 +0900
X+++ ukbd.c	2009-04-25 18:39:05.000000000 +0900
X@@ -225,8 +225,8 @@
X 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 68 - 6F */
X 	NN, NN, NN, NN, 115, 108, 111, 113,	/* 70 - 77 */
X 	109, 110, 112, 118, 114, 116, 117, 119,	/* 78 - 7F */
X-	121, 120, NN, NN, NN, NN, NN, 115,	/* 80 - 87 */
X-	112, 125, 121, 123, NN, NN, NN, NN,	/* 88 - 8F */
X+	121, 120, NN, NN, NN, NN, NN, 123,	/* 80 - 87 */
X+	124, 125, 126, 127, 128, NN, NN, NN,	/* 88 - 8F */
X 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 90 - 97 */
X 	NN, NN, NN, NN, NN, NN, NN, NN,	/* 98 - 9F */
X 	NN, NN, NN, NN, NN, NN, NN, NN,	/* A0 - A7 */
X@@ -1386,20 +1386,59 @@
X ukbd_key2scan(struct ukbd_softc *sc, int code, int shift, int up)
X {
X 	static const int scan[] = {
X-		0x1c, 0x1d, 0x35,
X-		0x37 | SCAN_PREFIX_SHIFT,	/* PrintScreen */
X-		0x38, 0x47, 0x48, 0x49, 0x4b, 0x4d, 0x4f,
X-		0x50, 0x51, 0x52, 0x53,
X-		0x46,			/* XXX Pause/Break */
X-		0x5b, 0x5c, 0x5d,
X+		/* 89 */
X+		0x11c,	/* Enter */
X+		/* 90-99 */
X+		0x11d,	/* Ctrl-R */
X+		0x135,	/* Divide */
X+		0x137 | SCAN_PREFIX_SHIFT,	/* PrintScreen */
X+		0x138,	/* Alt-R */
X+		0x147,	/* Home */
X+		0x148,	/* Up */
X+		0x149,	/* PageUp */
X+		0x14b,	/* Left */
X+		0x14d,	/* Right */
X+		0x14f,	/* End */
X+		/* 100-109 */
X+		0x150,	/* Down */
X+		0x151,	/* PageDown */
X+		0x152,	/* Insert */
X+		0x153,	/* Delete */
X+		0x146,	/* XXX Pause/Break */
X+		0x15b,	/* Win_L(Super_L) */
X+		0x15c,	/* Win_R(Super_R) */
X+		0x15d,	/* Application(Menu) */
X+
X 		/* SUN TYPE 6 USB KEYBOARD */
X-		0x68, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
X-		0x64, 0x65, 0x66, 0x67, 0x25, 0x1f, 0x1e,
X-		0x20,
X+		0x168,	/* Sun Type 6 Help */
X+		0x15e,	/* Sun Type 6 Stop */
X+		/* 110 - 119 */
X+		0x15f,	/* Sun Type 6 Again */
X+		0x160,	/* Sun Type 6 Props */
X+		0x161,	/* Sun Type 6 Undo */
X+		0x162,	/* Sun Type 6 Front */
X+		0x163,	/* Sun Type 6 Copy */
X+		0x164,	/* Sun Type 6 Open */
X+		0x165,	/* Sun Type 6 Paste */
X+		0x166,	/* Sun Type 6 Find */
X+		0x167,	/* Sun Type 6 Cut */
X+		0x125,	/* Sun Type 6 Mute */
X+		/* 120 - 128 */
X+		0x11f,	/* Sun Type 6 VolumeDown */
X+		0x11e,	/* Sun Type 6 VolumeUp */
X+		0x120,	/* Sun Type 6 PowerDown */
X+
X+		/* Japanese 106/109 keyboard */
X+		0x73,	/* Keyboard Intl' 1 (backslash / underscore) */
X+		0x70,	/* Keyboard Intl' 2 (Katakana / Hiragana) */
X+		0x7d,	/* Keyboard Intl' 3 (Yen sign) (Not using in jp106/109) */
X+		0x79,	/* Keyboard Intl' 4 (Henkan) */
X+		0x7b,	/* Keyboard Intl' 5 (Muhenkan) */
X+		0x5c,	/* Keyboard Intl' 6 (Keypad ,) (For PC-9821 layout) */
X 	};
X 
X 	if ((code >= 89) && (code < (89 + (sizeof(scan) / sizeof(scan[0]))))) {
X-		code = scan[code - 89] | SCAN_PREFIX_E0;
X+		code = scan[code - 89];
X 	}
X 	/* Pause/Break */
X 	if ((code == 104) && (!(shift & (MOD_CONTROL_L | MOD_CONTROL_R)))) {
594511c3b5704ee4b236e1e96d9dbe3b
exit



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904252010.n3PKAEkh014114>