Subject: port-arm/17972: The Jornada 720 has a software Fn key
To: None <gnats-bugs@gnats.netbsd.org>
From: Brad Spencer <brad@anduin.eldar.org>
List: netbsd-bugs
Date: 08/17/2002 13:52:40
>Number:         17972
>Category:       port-arm
>Synopsis:       The Jornada 720 has a software Fn key
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 17 10:53:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Brad Spencer
>Release:        NetBSD 1.6E
>Organization:
	Home
>Environment:
System: NetBSD meriadoc 1.6E NetBSD 1.6E (MERIADOC) #7: Fri Aug 16 21:59:23 EDT 2002 brad@meriadoc:/usr/src/sys/arch/hpcarm/compile/MERIADOC hpcarm
Architecture: arm
Machine: hpcarm

>Description:
Unlike some small computers, the U.S. version of the Jornada 720 has a
software Fn key.  This key, as expected, is used to get at characters
on the keyboard that are not given a discrete key as they normally
would on a full sized keyboard.  This key typically isn't the Meta or
Alt keys nor the Shift or Control.

In particular, on the U.S. Jornada you need to use the Fn key to get
access to the ~, `, English sterling, International currency, {, }, [,
], and capslock keys.

>How-To-Repeat:
Try to generate a tilde character from the U.S. Jornada keyboard.  Try
to figure out how to make the key maps deal with this..  fail at
both...

>Fix:
The following two patches create a software Fn key by messing with the
keycodes coming from the keyboard.  This is probably done all wrong,
and I have no idea how this will interact with X or if it will cause
problems on non-US Jornada.  The later probably is a problem as
keycode 102 is used for other things on those keyboards.  I couldn't
tell if wscons did this sort of thing in a better way.  I tried using
KC_MultiKey and others without any joy.

Apply this to sys/arch/hpcarm/dev/j720ssp.c:

--- j720ssp.c.DIST	Tue Jul 23 03:20:38 2002
+++ j720ssp.c	Fri Aug 16 21:16:58 2002
@@ -393,6 +393,7 @@
 	struct j720ssp_softc *sc = arg;
 	int s, type, value;
 	char buf[9], *p;
+	static int softFnkey = 0;
 
 	j720kbd_read(sc, buf);
 
@@ -400,15 +401,21 @@
 		type = *p & 0x80 ? WSCONS_EVENT_KEY_UP :
 		    WSCONS_EVENT_KEY_DOWN;
 		value = *p & 0x7f;
+
+		if (value == 102)
+		  softFnkey = (type == WSCONS_EVENT_KEY_DOWN) ? 0x100 : 0;
+
+		value = value | softFnkey;
+
 		s = spltty();
 		wskbd_input(sc->sc_wskbddev, type, value);
 		splx(s);
 		if (type == WSCONS_EVENT_KEY_DOWN &&
 		    value == 0x7f) {
-			j720ssp_powerstate = ! j720ssp_powerstate;
-			config_hook_call(CONFIG_HOOK_POWERCONTROL,
-					 CONFIG_HOOK_POWERCONTROL_LCDLIGHT,
-					 (void *)j720ssp_powerstate);
+		  j720ssp_powerstate = ! j720ssp_powerstate;
+		  config_hook_call(CONFIG_HOOK_POWERCONTROL,
+				   CONFIG_HOOK_POWERCONTROL_LCDLIGHT,
+				   (void *)j720ssp_powerstate);
 		}
 	}
 

Apply this to sys/arch/hpcarm/dev/j720kbdmap.c:

--- j720kbdmap.c.DIST	Fri Aug 16 21:12:55 2002
+++ j720kbdmap.c	Fri Aug 16 21:14:54 2002
@@ -117,6 +117,27 @@
     KC(105),			KS_Left,
     KC(107),			KS_Right,
     KC(106),			KS_Down,
+
+    /* Fake key codes created by the Fn key */
+
+    /* 17 | 0x100 */
+    KC(273),  			KS_asciitilde,
+    /* 18 | 0x100 */
+    KC(274),  			KS_grave,
+    /* 19 | 0x100 */
+    KC(275),  			KS_sterling,
+    /* 20 | 0x100 */
+    KC(276),  			KS_currency,
+    /* 42 | 0x100 */
+    KC(298),  			KS_braceleft,
+    /* 43 | 0x100 */
+    KC(299),  			KS_braceright,
+    /* 58 | 0x100 */
+    KC(314),  			KS_bracketleft,
+    /* 75 | 0x100 */
+    KC(331),  			KS_bracketright,
+    /* 83 | 0x100 */
+    KC(339),  			KS_Caps_Lock,
 };
 
 static const keysym_t j720kbd_keydesc_fr[] = {
>Release-Note:
>Audit-Trail:
>Unformatted: