Author Topic: Fn and Media keys on Apple Aluminium on Macintosh  (Read 1695 times)

0 Members and 1 Guest are viewing this topic.

Offline Findecanor

  • Thread Starter
  • Posts: 5081
  • Location: Koriko
Fn and Media keys on Apple Aluminium on Macintosh
« on: Thu, 21 November 2013, 15:20:30 »
Has anyone delved into how Media Keys (F1..F12) work on Macintosh with the Apple Aluminium keyboard?

From what I understand, PC keyboards' media keys should work on Mac, but the opposite doesn't: An Apple Aluminium Keyboard plugged into a PC produces F1..F19, plus F20 on the Eject key.
I remember from an old post that the Fn key when used on a Mac produces a scancode, apart from working as a Fn key, but I haven't been able to find that thread again.

I'm just trying get a grip on how it works, to update a Wiki page and to make my own keyboard firmware as compatible as possible with Mac. Thanks in advance.
🍉

Offline Daniel Beardsmore

  • Posts: 1874
  • Location: Hertfordshire, England
  • RIP
    • Boring twaddle
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #1 on: Fri, 22 November 2013, 16:53:43 »
Might be related to why the Matias keyboards pretend to be from Apple? Apple keyboards on Windows are weird — they sort-of map to the keys on a PC keyboard, sort of .....
Bore Awards
Most Boring Person on the Planet – 2011 Winner

Offline tuxsavvy

  • Posts: 441
  • 白HHKBの魔法使い
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #2 on: Fri, 22 November 2013, 17:22:45 »
Has anyone delved into how Media Keys (F1..F12) work on Macintosh with the Apple Aluminium keyboard?

From what I understand, PC keyboards' media keys should work on Mac, but the opposite doesn't: An Apple Aluminium Keyboard plugged into a PC produces F1..F19, plus F20 on the Eject key.
I remember from an old post that the Fn key when used on a Mac produces a scancode, apart from working as a Fn key, but I haven't been able to find that thread again.

I'm just trying get a grip on how it works, to update a Wiki page and to make my own keyboard firmware as compatible as possible with Mac. Thanks in advance.

I don't have any sort of Apple aluminium keyboard but as far as I know Fn key does not produce any key codes when pressed alone. It must be pressed on a key that has alternative key code. All the Fn stuff is handled on the keyboard controller, not the host machine. In other words pressing Fn key alone will not give you any sort of code because of the controller onboard. I suppose on the same controller level is where one might be able to intercept the codes for the Fn key alone.

There are programs like keyremap4mac just as well as autohotkey for windows. I am unsure if either of them will give you the keycodes but I know under linux with xev for instance or even showkey, one can easily enumerate the keycode sent by the controller. Again this only works for keys apart from Fn, pressing Fn alone shouldn't emit any sort of key codes as it basically tells the controller to switch the "map". Pressing Fn plus a key that has alternative functions gives out a completely different key code. E.g. on HHKB Pro for instance the key "A" has a function of both printing letters "a" and "A" respectively. There's another function which when one for instance presses Fn+A and that will tell the controller to give the keycode for the "Eject" to the host computer.
HHKB Pro JP Type-S | Northgate Omnikey 101 | APC/"Clicker" F-21 (GOG3YL) | Cherry G80-5000 HAMDE

僕の日本語が下手です。我的中文也一樣爛。

Offline rowdy

  • HHKB Hapster
  • * Erudite Elder
  • Posts: 21175
  • Location: melbourne.vic.au
  • Missed another sale.
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #3 on: Fri, 22 November 2013, 17:25:06 »
I used an Apple alunimium keyboard under Windows 7 for a while.  It worked fine, although I didn't try any media keys or anything like that.
"Because keyboards are accessories to PC makers, they focus on minimizing the manufacturing costs. But that’s incorrect. It’s in HHKB’s slogan, but when America’s cowboys were in the middle of a trip and their horse died, they would leave the horse there. But even if they were in the middle of a desert, they would take their saddle with them. The horse was a consumable good, but the saddle was an interface that their bodies had gotten used to. In the same vein, PCs are consumable goods, while keyboards are important interfaces." - Eiiti Wada

NEC APC-H4100E | Ducky DK9008 Shine MX blue LED red | Ducky DK9008 Shine MX blue LED green | Link 900243-08 | CM QFR MX black | KeyCool 87 white MX reds | HHKB 2 Pro | Model M 02-Mar-1993 | Model M 29-Nov-1995 | CM Trigger (broken) | CM QFS MX green | Ducky DK9087 Shine 3 TKL Yellow Edition MX black | Lexmark SSK 21-Apr-1994 | IBM SSK 13-Oct-1987 | CODE TKL MX clear | Model M 122 01-Jun-1988

Ị̸͚̯̲́ͤ̃͑̇̑ͯ̊̂͟ͅs̞͚̩͉̝̪̲͗͊ͪ̽̚̚ ̭̦͖͕̑́͌ͬͩ͟t̷̻͔̙̑͟h̹̠̼͋ͤ͋i̤̜̣̦̱̫͈͔̞ͭ͑ͥ̌̔s̬͔͎̍̈ͥͫ̐̾ͣ̔̇͘ͅ ̩̘̼͆̐̕e̞̰͓̲̺̎͐̏ͬ̓̅̾͠͝ͅv̶̰͕̱̞̥̍ͣ̄̕e͕͙͖̬̜͓͎̤̊ͭ͐͝ṇ̰͎̱̤̟̭ͫ͌̌͢͠ͅ ̳̥̦ͮ̐ͤ̎̊ͣ͡͡n̤̜̙̺̪̒͜e̶̻̦̿ͮ̂̀c̝̘̝͖̠̖͐ͨͪ̈̐͌ͩ̀e̷̥͇̋ͦs̢̡̤ͤͤͯ͜s͈̠̉̑͘a̱͕̗͖̳̥̺ͬͦͧ͆̌̑͡r̶̟̖̈͘ỷ̮̦̩͙͔ͫ̾ͬ̔ͬͮ̌?̵̘͇͔͙ͥͪ͞ͅ

Offline Findecanor

  • Thread Starter
  • Posts: 5081
  • Location: Koriko
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #4 on: Fri, 22 November 2013, 18:42:13 »
All the Fn stuff is handled on the keyboard controller, not the host machine.
That is how a Fn key usually functions on most keyboards that has one, but I think that Apple's keyboard is different.

The default on MacOS with the Apple keyboard is that the function keys are Media keys, but that numbered functions are available together with the Fn key.
This behaviour can be flipped in the Keyboard settings panel.
(image)

In KeyRemap4MacBook you can also swap the positions of left Ctrl and Fn. (That program works on more Macintoshes than the MacBook btw..)

For using Windows on Macintosh, Apple supplies a special Windows driver for the Apple keyboards.
🍉

Offline aggiejy

  • ** Moderator Emeritus
  • Posts: 1126
  • Location: ~Austin, Texas
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #5 on: Fri, 22 November 2013, 18:47:57 »
I'm not sure if it's helpful, but you may want to try enabling debug mode of KeyRemap4Macbook and you can see what (if any) events are sent when the Fn key is pressed, or Fn+F1/etc.

https://pqrs.org/macosx/keyremap4macbook/document.html.en#debugmode

I haven't tried it myself.

Offline Hellmark

  • Posts: 349
  • Location: Maryland Heights, Mo, USA
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #6 on: Wed, 27 November 2013, 07:00:49 »
From what I remember, Mac OS X can have multiple key mappings for different keyboards. It supports up to 128 separate input devices. Out of the box it only really recognizes Apple keyboards, and assumes everything else is a normal standard.

The only thing is that you have to probably get down and dirty with config files if you want to have things different on a per keyboard basis, as I am not sure of any GUI tools that do it out of the box. They more or less assume you to have one keyboard (or just be using one), despite these days of laptops and wireless keyboards.

It is kinda frustrating that pretty much all of the OS's don't really provide an easy solution for. I use Linux and a Windows at work, and when docked use only a external keyboard, and there really isn't even options to support differences for that.

On my mac and hackintosh, I use Keyremap4Macbook. It works well, but applies things across the board at least by default (I haven't dug into the XML settings to see if it can do things per keyboard.

Offline Jixr

  • Posts: 864
  • Location: Ireland
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #7 on: Wed, 27 November 2013, 09:14:35 »
as far as a mac keyboard on a pc

google
uawks
( unofficial apple wireless keyboard support )

basically an autohot key script that allows the use of the apple keyboards media keys to work on a pc.
worked flawlessly for me before I got into mechanical keyboards.

( as far as pc to mac, i'm still hunting for that )

Offline Findecanor

  • Thread Starter
  • Posts: 5081
  • Location: Koriko
Re: Fn and Media keys on Apple Aluminium on Macintosh
« Reply #8 on: Wed, 27 November 2013, 18:58:02 »
Thanks. I checked the code, and found that it was made a bit quick&dirty.
I could find that Apple's Fn key is in the Consumer usage page, where the other media keys are, but not which code it has.
I will have to get hold of an Apple keyboard to be able to get its Report Descriptor.

Edit 2016-07-07:
I am posting this in this old thread just in case someone else comes across it.

I got an Apple aluminium keyboard and looked at its report descriptor and output.
The protocol is almost the same as the regular 6KRO protocol, except that it has only 5 places for non-modifier keys.
The 6th place is declared to be vendor-dependent and is either 0 (Fn key up) or ErrorUndefined (Fn key down).
A buggy BIOS that expects the 6KRO protocol would just ignore the 6th place.
« Last Edit: Thu, 07 July 2016, 08:01:57 by Findecanor »
🍉