Monday, October 20, 2008

Dvorak keyboard layout for Advent 4211

Ukelele is a keyboard layout program. Download and run it from Desktop, seems to be able to do everything to do with keyboard layouts. This is the Apple kb document for the .keylayout files.

Could use Keyboard & Mouse/Keyboard preference pane to set Ctrl key to act as Cmd, which means that shortcut keys act when I press Ctrl, just like Windows. In Ukelele now when I press Ctrl it detects it as Cmd. So I need to set Cmd-Left and Cmd-Right to act as Word Left and Word Right. If possible.

Looking around, I think that it might not be possible by changing the layout file. The layout file doesn't really specify which command is done when Cmd is pressed - this seems to be in a key bindings file. But if that's the case then there is another way to do it, which works only for programs built on standard Cocoa text controls. That page also references a page for firefox key bindings which operate similarly.

I made the following key binding file for my system, which operates how I would like (with Cmd/Ctrl swapped so shortcuts are done with the physical Ctrl key):

{
/* Note that this file is also designed to work when Ctrl and Cmd are
swapped in keyboard preferences, so that pressing Ctrl key will
be seen as Cmd (@) here. */

/* home */
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"@\UF729" = "moveToBeginningOfDocument:";
"@$\UF729" = "moveToBeginningOfDocumentAndModifySelection:";

/* end */
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
"@\UF72B" = "moveToEndOfDocument:";
"@$\UF72B" = "moveToEndOfDocumentAndModifySelection:";

/* page up/down */
"\UF72C" = "pageUp:";
"\UF72D" = "pageDown:";

/* up and down */
"$\UF700" = "moveUpAndModifySelection:";
"$\UF701" = "moveDownAndModifySelection:";
"@\UF700" = "pageUp:";
"@\UF701" = "pageDown:";
/* the ideal behaviour here would to move selection to bottom of
the paragraph, but that isn't supported. Instead, move selection
down a line, which is better than the native behaviour of
selecting to the end of the document.*/
"@$\UF700" = "moveUpAndModifySelection:";
"@$\UF701" = "moveDownAndModifySelection:";

/* left and right */
"@\UF702" = "moveWordLeft:";
"@\UF703" = "moveWordRight:";
"@$\UF702" = "moveWordLeftAndModifySelection:";
"@$\UF703" = "moveWordRightAndModifySelection:";
}

When I just created this myself and put it in ~/Library/KeyBindings/DefaultKeyBinding.dict, it didn't work. I had to use the KeyFixer script/app and then edit that file, to get it to work. Don't understand why. There were two files with apparently the same name there after running their script.

You can use 'pl -input filename' to check the property list file, it sort of compiles it.

This Windows kb article explains how to remap keys in Windows, looks like it would be possible to swap Ctrl and Alt there. But that's tricky and requires rebooting, so instead AutoHotkey is an option.

Download the AutoHotkey installer and use this script, with Cmd/Ctrl swapped in keyboard and mouse, and Ctrl, Alt and Windows keys work as they should do under Windows:

Ctrl::Alt
LWin::Ctrl
Alt::LWin

UK keyboard layout for Advent 4211

Paul @ Modaco made a keyboard layout that has the correct position of the @ and other keys, i.e. that matches what is actually printed on the keys. It's available here, and installed by following these instructions:

47. FIXING KEYBOARD MAP (UK keyboard layouts only): Change to the 'kaylayout' directory on my Wind driver and utility pack, and copy 'Advent 4211.keylayout' to '\Library\Keyboard Layouts'. Run 'System Preferences' -> 'International', and click 'Input Menu'. SCroll down the list until you see 'Advent 4211'. Click the checkbox, and you will see a flag appear in your menu bar. Click this to select the Advent layout.

Sunday, October 19, 2008

Hibernate/sleep in OS X on Advent

Found I could change the HDD sleep time to 3 minutes using this command:

sudo pmset -b disksleep 3

Don't know if it works though.

10.5.5 update woes

Now the Advent 4211 won't boot after accepting Apple's update patch from 10.5.4 to 10.5.5. It goes to a blue screen with a mouse cursor, but flashes back to a terminal window every 10s with sometimes an error message, mostly blank.

There is some info in this forum topic that suggests various kernel extensions (kexts) need to be reinstalled:

http://forums.msiwind.net/viewtopic.php?f=32&t=3722&view=next

However, that is mainly for video display issues - seems that special MSI display kexts get nuked by the update. This one is for exactly my problem:

http://forums.msiwind.net/mac/blue-screen-after-update-t4018.html

I deleted AppleIntelCPUPowerManagement.kext folder from /System/Library/Extensions because I found that it in this post, from Biohead (at the bottom of page):

http://forums.msiwind.net/mac/released-t3551.html

You have to make the disk writeable first:

/sbin/fsck -fy
/sbin/mount -uw /

The first one does a filesystem check, the second actually makes the disk writeable. I tried this several times but it didn't seem to work (using rm -r to remove the .kext directory) - turns out you need to 'exit' rather than just turn off the computer by holding down the power button for a long time. It must flush a cache then.

However, this didn't change anything.

Second post above seems to suggest downloading a pile of kernel extensions and installing over the ones that are there, after someone had the exact same problem as me. Also on this page, grantonstar also says to reinstall all kexts. Will track down what that means exactly!

The download is for a whole lot of kexts and other things required for a fresh install, and requires running kexthelper.app, which is clearly impossible. Looking for other ways, I figure I could just copy the kexts.

Need to mount the USB stick:

http://www.macosxhints.com/article.php?story=20030714194313542

I am moving all the relevant kexts that are going to be replaced to /Users/michaelfielding/. Natit.kext and ACPIBattery.kext don't exist on the Advent yet.

Now I exit, and instead of going back to another terminal-like thing, it actually boots OS X! Hooray! And the right screen resolution too!

Wednesday, October 1, 2008

Sorting out Dvorak keyboard layouts on OS X and parallels

I'm getting annoyed that the shortcut keys I'm used to on Windows, for navigating text and for Ctrl-key combinations, are different on the Mac. And different again on the Parallels VM.

I would like it to be like Windows:

Ctrl-arrows = word left or right
Alt-arrows = navigate forward and backward in browser
Shift = select text
Home/End = beginning/end of line
Ctrl-key = shortcut, where key is what it would be labelled if it was a Dvorak keyboard

Interestingly, os x applies the face letter of the key as a shortcut. On Windows you press Ctrl-B I think to get Ctrl-X; on OS-X it's actually Cmd-X.

In OS X, with Control and Command keys swapped in System Preferences - > Keyboard & Mouse -> Keyboard ->Modifier keys, I get this behaviour:

Ctrl-arrows = nothing
Alt-arrows = nothing
Command-arrows (Windows key) = word left/right
Ctrl-key = shortcut
Command-key = alternative character

Also, the Fn arrow keys should, according to the keyboard's labels, function as Home and End, but they don't. I can't get that functionality that I can see.

Alt = command key (funny cross thing)
Ctrl = ctrl key
Windows = option key

This page has a very good article from Apple's KB:

http://docs.info.apple.com/article.html?artnum=304270


It links to the MS keyboard layout creator tool:

http://www.microsoft.com/globaldev/tools/msklc.mspx

But now some people seem to have worked on the Home/End key problem:

http://www.starryhope.com/tech/2006/mac-os-x-home-and-end-keys/

The crux of the problem is that I want to press the Ctrl key and get left and right, but also get shortcuts. But while I can switch the Ctrl key to be the Option key (which on the Mac does the word-skipping), then I can't use it to be the command key (which on the mac does the commands). Worse, when I go to Windows, it interprets the Ctrl key as the Alt key (of course), and opens the menu bar. So Ctrl arrows doesn't work there.

Some help might be available here:

http://lists.apple.com/archives/projectbuilder-users/2002/May/msg00474.html

This gives information on the key bindings file and some actions and keys that you can use in it.