geekhack

geekhack Projects => Making Stuff Together! => Topic started by: metalliqaz on Mon, 23 February 2015, 12:19:45

Title: How is the "Keyboard Power" scancode used on Mac?
Post by: metalliqaz on Mon, 23 February 2015, 12:19:45
Hey guys, being a windows user I'm confused by this key and how I should support it.

The USB HID usage page 7 for keyboards defines scancode 0x66 as "Keyboard Power" and only lists it as supported on the Mac platform.  It also implies through a footnote that it never mapped to a key.

If I remember correctly, the KMAC keymapper included this scancode but it didn't do anything on Windows.  (I haven't used it in a long time)

So is this scancode useful when mapped to a key on the Mac?  What does it do?  Should I add it as an option?

To all you poor Apple users, thanks for any insights!
Title: Re: How is the "Keyboard Power" scancode used on Mac?
Post by: metalliqaz on Mon, 23 February 2015, 12:52:08
So there's a wiki page on the topic: https://en.wikipedia.org/wiki/Apple_Keyboard

However I'm still not sure if the modern USB boards actually send that scancode.  It appears the older boards had dedicated lines for the power switch.
Title: Re: How is the "Keyboard Power" scancode used on Mac?
Post by: MJ45 on Mon, 23 February 2015, 13:27:59
I think that was from the ABD days before Apple went to USB.
Title: Re: How is the "Keyboard Power" scancode used on Mac?
Post by: tufty on Mon, 23 February 2015, 15:03:43
However I'm still not sure if the modern USB boards actually send that scancode.  It appears the older boards had dedicated lines for the power switch.
The older boards for ADB based macs do both.  They send a scancode, which the OS interprets as a command to power down, *and* do soft power on through the extra wire in the ADB connector.

The USB keyboards, with the exception of the original USB keyboard, don't have a power button.  You'd want to look at what's sent when you do cmd-option-eject, which is the "power off" keystroke these days
Title: Re: How is the "Keyboard Power" scancode used on Mac?
Post by: hasu on Tue, 24 February 2015, 08:36:24
I've not owned Mac for long time since my first-gen Macbook pro was broken miserably but I can remember 0x66 works on OSX.
Mac mode of HHKB sends the code as Power key(Fn + Esc).

Linux also recognize that code without problem but poor Windows doesn't so we have to use Usage page 0x01 instead.


EDIT: IIRC, volume control keys(0x7F, 0x80, 0x83) also can be used on Linux and Mac but not Windows :(
Title: Re: How is the "Keyboard Power" scancode used on Mac?
Post by: metalliqaz on Tue, 24 February 2015, 12:03:15
Thanks Hasu :)

I added the scancodes to the selector.  What the heck, doesn't hurt anything.

Aqua's key test on Windows saw a scancode but obviously didn't match it to anything.

Also apparently Mac-only is the KEYPAD_EQUALS, which I think is 0x67.