[haiku-development] Looking for feedback on enhancements for dealing with Mac keyboards with Haiku

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 6 Sep 2011 00:53:54 -0400

Haiku developers,

I have created 3 new enhancement tickets each dealing in some way with using
a Mac keyboards on Haiku.

The tickets URLs are listed below.

http://dev.haiku-os.org/ticket/7964   (update/add keyboard layout files for
Apple Aluminum keyboard)
http://dev.haiku-os.org/ticket/7965   (add support Mac modifier keys to
keymap)
http://dev.haiku-os.org/ticket/7967   (update the modifier images in menus)



TL;DR Details below for the interested:



The first enhancement is the "safest" in that it does not touch the code.
The enhancement updates and adds some new keyboard layouts for the Apple
Aluminum keyboard. The ticket linked above contains images of the new
layouts. There are 4 layout files, two for the mini keyboard (US and
international) that have become popular recently and 2 for the traditional
extended version with numeric keypad (US and International). To install
these KeyLayouts drop the files into the data/system/data/KeyLayouts/
directory of the Haiku source repository. As noted in the ticket, you want
to remote the existing "Apple Aluminium" layout file as it has been renamed
and updated.

The feedback I'd like is, firstly, do these layouts look okay? What do you
think about the missing eject and fn keys. I left holes in the layout on
purpose to show that these keys don't function. I used a program written by
PulkoMandy to check the key codes and these keys produce no output so I
removed them. I could put blank buttons in but if I did that I'd have to
give them a keycode and I don't know what key codes to give. I could put
0x00 but some keymaps assign 0x00 to a modifier key to disable it so they
show up on the key which is not good. I could make up a non-sense keycode
like 0xff.

In VMware the F13 key is mapped to print screen (0x00) but not on actual
hardware. You can map print screen to 0x70068 and the key to do a print
screen which opens the screenshot app. So I set the F13 through F19 keys to
0x70068-0x7006e. I guess the (Mac) keymap files should be updated use these
codes.


The second enhancement updates the keymap preference application to replace
the "Switch Shortcuts to Windows/Linux Mode" button with a "Set modifier
keys" drop-down menu. The drop-down contains a "Haiku modifiers",
"Windows/Linux modifiers" and now a third option "Mac modifiers" which
switches the control and option modifier keys compared to default. Details
and screenshots are in the ticket. Note that I provided this enhancement as
a convenience to the user. You can achieve the same effect right now by just
swapping the command and option keys on the on-screen keyboard.

The "Mac modifiers" option is not really on the same level of a change as
the "Linux/Windows modifier" because it doesn't change the modifiers as much
as correct them. Due to historical mismatches B_COMMAND_KEY corresponds to
the Option key and B_OPTION_KEY corresponds to the Command key. "Mac
modifiers" simply makes B_COMMAND_KEY point to the Command key and
B_OPTION_KEY point to the Option key. This should be fixed in the keymap
files, the ones labelled xxxxxx (Mac). If that were to be done though this
patch would still be useful because it would mark the "Mac modifiers" item
in the menu and you could still select "Haiku Modifiers" if you wanted to.


The third enhancement aims to make the bitmap images that appear in menus
("SHFT", "CTL", "ALT", and "OPT") closer to the image that appears on the
keyboard. This is mostly just a small enhancement changing CTL -> CTRL and
SHFT to SHIFT. The big change is to change option to either a Windows key
flag or a Command clover depending on if you have a Windows or Mac keyboard.
Should I go with the curvy Windows key or the square one? Should I just go
for the word "WIN". Same with "CMD" vs. the clover? Should I just leave the
key as "OPT"?

As a side note this enhancement will also fix:

http://dev.haiku-os.org/ticket/3176

Right now the menu just flips between Alt and Ctrl depending on the keymap.
So if you go outside of that box things get screwed up. The patch that I
have made already fixes that ticket but I am looking to do more.

I haven't included patches for the third ticket because I haven't quite
nailed-down how to detect if the keyboard attached is a Mac or PC keyboard.
Right now I detect it by seeing if you have an Menu key defined in your
keymap since PC keyboards generally do and Mac keyboards do not. Of course
this means you would get see command key in the menu for a 101-key keyboard
(no Windows or Menu keys). Any better suggestion here?

My first attempt to detect a Mac or Windows keyboard was to use the
get_keyboard_id() function. Unfortunately it is unimplemented. It always
returns 0. I checked in src/servers/InputServer.cpp and it doesn't actually
call any methods to get the id. I have filed the following ticket for that
with some details and code. I would really like that function implemented so
I could at least get some idea as to what kind of keyboard is plugged in but
unfortunately I never got it to work. If you want to take a stab at
implementing that function you can use the code in the ticket as a starting
point.

http://dev.haiku-os.org/ticket/7963

John Scipione

Other related posts: