Pismo Keyboard

Luckily, Apple provided a hackish but still not too hard way to remap keys on the ADB Keyboard:

/System/Library/Extensions/AppleADBKeyboard.kext/Contents/Info.plist
In this file, there is a section ADBVirtualKeys that looks like this:

0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
0x30,0x31,0x32,0x33,0x34,0x35,0x3B,0x37,0x38,0x39,0x3A,0x7B,0x7C,0x7D,0x7E,0x3F,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x3C,0x3D,0x3E,0x36,0x7F
and here, you can actually remap keys permanently (or until an apple update shoots it back again...) by just using the text editor of your choice...

find the 0x34 which is the code for the enter key and replace it with

0x37 for command
0x38 for shift
0x3a for alt / option
0x3b for control (see correction below)
0x75 for forward delete
correction on May 27th 2005: I had previously written 0x36 for control while in fact 0x3b is correct - that was just my poor hadwriting: scribble a small b on a piece of paper - read a 6 later when i type it here... sorry.

Don't add any linefeeds or formatting. leave those hex codes just as they are or the System might not be able to read them properly. Also: be warned: this is a modifiaction of a core system file that may render your machine unusable! While the keyboard driver code tries to have sane fallback rules in case the Info.plist file does not make sense, you might still turn it into that kind of gibberish that is barely acceptable but leaves you with a non-working keyboard. Best keep a spare USB keyboard around in case you mess up (those use another driver that is not affected by these modifications).

Once (after you made a backup of the original of course) you changed this as root and rebooted, your enter key should have turned into another modifier key... Instead of rebooting, you can simply unload and reload your keyboard driver - but be sure to do this in just one command line because once you unloaded it, you won't be able to type the command for loading it again...

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /System/Library/Extensions/AppleADBKeyboard.kext.org/Contents/Info.plist
sudo kextunload /System/Library/Extensions/AppleADBKeyboard.kext && sudo kextload /System/Library/Extensions/AppleADBKeyboard.kext
This simple hack does not work for remapping from or to the fn key and there is no way to deal differently with left or right modifier keys (ie. remap just the right command key instead) in this setup because both features are handled deep within the keyboard controller. It works the same way in OSX Panther (10.3) by the way.
Addition on June 3rd 2005: I have had a few reports of problems:

using kextload: It seems, some other kernel driver keeps a pointer to the unloaded original kext and the machine can crash some time later - but it does not have to... I have experienced this once on wakeup from sleep but could not reproduce it later.
getting OSX to reckognize the permanent changes in /System/Library/Extensions/: Mac OSX tries to be clever and keeps a cache of preloaded, prelinked and initialized extensions around to speed up the next boot as long as nothing has changed. Detecting something has changed seems to be the problem here. In order to convince the system, not to use caches - delete them!
sudo rm /System/Library/Extensions.mkext
sudo rm /System/Library/Extensions.kextcache
sudo touch /System/Library/Extensions
sudo touch /System/Library/Extensions/AppleADBKeyboard.kext
I have also had one very weird scenario, where i had changed the enter mpping like described above, rebooted, happily saw that the modification worked, closed the lid of the powerbook so it slept and then - after wakeup - found that the enter mapping had reverted to the previous setting. No traces of this older mapping should have been left on the system so i can not really explain what has happened here (and again: i have not been able to reproduce this ever since). I would be glad, if someone could shed some light on this...

Addition on June 8th 2005: Thanks to a Hint by William Mortensen: If for some reason, your Modifications don't stick, you may also try deleting yet another kernel cache:

sudo rm /System/Library/Caches/com.apple.kernelcaches/*
and/or rebuild it with:
sudo kextcache -c

タグ:

+ タグ編集
  • タグ:
最終更新:2010年10月01日 10:26
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。