|
|
Customizing the keyboard (swap any key!)
I recently bought a cheap USB keyboard to replace my OEM dinky keyboard. It's nice having a forward delete key again, but the Command and Option keys are reversed ('cause the keyboard is made for Windows PCs). So I've worked out how to swap the keys in OS10.1. The hack affects the entire system, including Classic. You'll need to install the Developer Tools and sign up with ADC at www.apple.com/developer. So here goes...
Download the IOUSBFamily source files:
href="http://www.opensource.apple.com/projects/darwin/1.4/source/apsl/IOUSBFamily-1.8.4GMc3.tar.gz">http://www.opensource.apple.com/projects/darwin/1.4/source/apsl/IOUSBFamily-1.8.4GMc3.tar.gz
Save the archive in a folder of your choice. Launch Terminal, navigate to the folder you saved the .tar.gz file in and execute the following command:
gnutar -xvfz IOUSBFamily-1.8.4GMc3.tar.gz
This will create a folder called "IOUSBFamily-1.8.4GMc3.tar.gz". If you get a message about the SCM status operation failing, just click the Disable button (at least, that's what I did; feel free to correct me). Inside the folder is a project file and a bunch of folders filled with libraries. Source code!! Double click on the file called "IOUSBFamily.pbproj" and it will open in Project Builder. Click on the drop down arrow for "AppleUSBKeyboard" and then "Classes". Highlight the item called "cosmo_USB2ADB.cpp". On the right will appear the code for this resource. Scroll down past the header comments and you'll see a list of codes. Each one represents a key. Fortunately for us the ones we're looking for were commented by a considerate programmer. To switch the Command and Option keys, simply swap their position in the list. Thus:
0x3a, // e2 Left option/alt key
0x37, // e3 Left command key
Becomes:
0x37, // e3 Left command key
0x3a, // e2 Left option/alt key
Do the same for the right hand keys, and then select File -> Save. Now just select Build -> Build from the menu bar.
When it's finished there will be a new directory in the "IOUSBFamily-1.8.4GMc3.tar.gz" folder called "build". Inside it are the compiled binaries that you just created from your modified source code. Go back to the Terminal, navigate to the build directory, and then enter the following commands, along with your root password when asked for it:
sudo -s
cp -R AppleUSBKeyboard.kext /System/Library/Extensions
That's it! Just restart your computer and the keys are switched. If your system goes haywire boot to single user mode or perform sudo, then navigate to the /System/Library/Extensions folder and rm -R AppleUSBKeyboard.kext to get yourself back to normal.
I'm considering posting the binary on my mac.com account, if someone can reassure me that doing so won't violate the Apple Public Source License.
-Morgan
morganize_it@mac.com
System: G4/350 AGP
OSX 10.1 Build: 5L14
Keyboard: Yahoo! USB Hub Internet Keyboard (Sakar Int'l Inc. model# 9001AH)
Customizing the keyboard (swap any key!)
Hey, I haven't successfully been able to swap command with option/alt, but to swap Caps Lock and Ctrl on USB mice, you no longer need to rebuild AppleUSBKeyboard.kext, and instead can do the following, taken from From http://ella.slis.indiana.edu/~jfieber/osx/ , look below. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|