Having configured my mac68k to boot with NetBSD, I wasn't very surprised to see that it doesn't have an Spanish keymap. So... first task, write one. Yeah, I could get used to the us mapping, but hey, I want to hack the sources ;-)

Keymaps are specific to each platform (just think that keyboards are different). Furthermore (and if I'm not too confused), some platforms use kernel keymaps while others use userland ones; if you ask me, the way to go is userland. Anyway I've only modified i386 and mac68k maps, which are both in-kernel, so this is what I'm going to explain.

To get started, take a look to the sys/dev/pckbport/wskbdmap_mfii.c file, which is used in the i386 platform, among others. It's quite complete (as i386 is the most extended platform); I've used it as a reference to create the Spanish keymap for mac68k. As you can see, the only complete map is us; all others just override the bits that differ from it. This saves space and keeps common keycodes centralized in just one table.

Ok, so let's go to the file that defines keymaps for mac68k, sys/arch/mac68k/dev/akbdmap.h. Notice that its structure is very similar to the one described in the previous paragraph. I just had to add a new array overriding the keys that don't match the us keyboard. While at it, I also modified the later as it lacked some extra keys (insert, delete, etc.).

How did I guess which keycodes correspond to those undefined keys? Well, it was "easy": I created a small program that reads from /dev/wskbd0 and prints each key press/release event together with its keycode (very easy; if you have doubts, check out wsmoused's sources, which does the same but for the mouse device).

Now you know the basics. If your keymap is not supported, it can be a good reason to start hacking! ;-)