usb/144414: Apple "Fn" key doesn't work properly

Hans Petter Selasky hselasky at c2i.net
Sun Mar 14 13:50:11 UTC 2010


On Sunday 14 March 2010 14:22:33 Steven Noonan wrote:
> On Sun, Mar 14, 2010 at 3:01 AM, Hans Petter Selasky <hselasky at c2i.net> 
wrote:
> > On Sunday 14 March 2010 11:30:04 Steven Noonan wrote:
> >> The following reply was made to PR usb/144414; it has been noted by
> >> GNATS.
> >>
> >> From: Steven Noonan <steven at uplinklabs.net>
> >> To: perryh at pluto.rain.com
> >> Cc: freebsd-usb at freebsd.org, freebsd-gnats-submit at freebsd.org
> >> Subject: Re: usb/144414: Apple "Fn" key doesn't work properly
> >> Date: Sun, 14 Mar 2010 03:26:19 -0700
> >>
> >>  On Thu, Mar 4, 2010 at 12:01 AM, Steven Noonan <steven at uplinklabs.net>
> >>  wrot=
> >>
> >>  e:
> >>  > On Wed, Mar 3, 2010 at 11:00 PM, Steven Noonan
> >> <steven at uplinklabs.net> > wr=
> >>
> >>  ote:
> >>  >> On Wed, Mar 3, 2010 at 10:36 PM, =C2=A0<perryh at pluto.rain.com>
> >> wrote: >>> Steven Noonan <steven at uplinklabs.net> wrote:
> >>  >>>> Interestingly, my tilde key doesn't work either (though the key
> >>  >>>> press is detected, no character shows when the key is pressed).
> >>  >>>
> >>  >>> Any chance it is configured as a "dead" key? =C2=A0If you press
> >>  >>> tilde followed by n do you get an n with a tilde over it?
> >>  >>
> >>  >> Nope. It simply does nothing in the console.
> >>  >>
> >>  >> But in X11, it does something very odd. Shift+Tilde Key gives me
> >> '>', >> and Tilde Key gives me '<'. And Alt+Tilde gives me... What? I
> >> don't >> even know what action. It's grabbing some arbitrary command in
> >> my >> .bash_history. It gave me the first item in my .bash_history the
> >> first >> time I tried it. Then I tried an arbitrary command ("echo"),
> >> and then >> Alt+Tilde gave me the second command in my .bash_history.
> >> Whaa?
> >>
> >>  Any more ideas/news on this from anyone?
> >>
> >>  The tilde key thing is especially irritating.
> >
> > static uint8_t
> > ukbd_apple_swap(uint8_t keycode) {
> >        switch (keycode) {
> >        case 0x35: return 0x64;
> >        case 0x64: return 0x35;
> >        default: return keycode;
> >        }
> > }
> >
> > Can you try to change the function above in ukbd.c to only return
> > keycode? Any difference?
> 
> Yep, commenting the two case lines brought my tilde key back. Any idea
> what the ukbd_apple_swap() function was _supposed_ to be doing?
> 
> Also, there's only one thing left (input-wise) that I can't get to
> work, and that's the 'delete' key (Fn+Backspace). I'm pretty certain
> that it's not a problem with Fn+Backspace failing to map to Delete,
> because my non-Mac i386 box has the same problem.
> 
> Everything I read online keeps saying to muck with an .inputrc file
> (for bash, anyway), but I haven't been able to get it to work. Places
> I've looked have said to add this to .inputrc:
> 
> "\e[3~": delete-char
> 
> But this seems to have no effect (and I tried bind -f .inputrc in case
> my INPUTRC environment variable wasn't working). Is there something
> FreeBSD-specific I'm not seeing, or what?
> 
> - Steven
> 

Hi Steven,

Can you talk this over with Christoph and send me a patch when you agreed? 
He's the one that made the Apple-SWAP key patch. Meanwhile I suggest the 
following patch:

==== //depot/projects/usb/src/sys/dev/usb/input/ukbd.c#47 - 
src/sys/dev/usb/input/ukbd.c ====
@@ -896,8 +896,7 @@
                    hid_input, 0, &sc->sc_loc_apple_fn, &flags,
                    &temp_id)) {
                        if (flags & HIO_VARIABLE)
-                               sc->sc_flags |= UKBD_FLAG_APPLE_FN |
-                                   UKBD_FLAG_APPLE_SWAP;
+                               sc->sc_flags |= UKBD_FLAG_APPLE_FN;
                        DPRINTFN(1, "Found Apple FN-key\n");
                        apple_keys = 1;
                        sc->sc_kbd_id = temp_id;


The hardware that Christoph was using had an Eject-key, while yours didn't. I 
think the patch above will make both cases work.

Christoph, do you have any comments?

http://p4db.freebsd.org/fileViewer.cgi?FSPC=//depot/projects/usb/src/sys/dev/usb/input/ukbd.c&REV=47

--HPS


More information about the freebsd-usb mailing list