Acer Aspire 9412ZWSMi

Acer Aspire 9412ZWSMi
Windows Vista™ Home Premium
Mandriva Linux Free 2007 Spring

Klik hier voor de oorspronkelijke, nederlandstalige versie van deze pagina.

If you're having trouble printing this page, click here to download it as a PDF.

Previous page


The keyboard

A story of scancodes, Linux keycodes, X11 keycodes and a program named lineakd.

This laptop has quite some extra keys on and around the keyboard.
These should all work, of course.

These are them (with the functions they have under Windows):

Some keys just work, because they are hardwired (Fn+F4, Fn+F6, Fn+F7, Fn+Arrow left, Fn+Arrow right); you can leave those alone. The other keys can be devided into 2 categories: the keys that are recognized by the kernel, and those that are not.
To be able to program the keys, they must be recognized by the kernel, so we'll take care of that first.

To see which keys are recognized by the kernel, you run

xev
('X Events').
When you start xev from a Konsole (or any other terminal program) a small window opens, and your console fills up with output. You need this output.

When you press and release a button, you see output like:

KeyPress event, serial 27, synthetic NO, window 0x6000001,
    root 0x5d, subw 0x0, time 38675548, (1037,-202), root:(1040,328),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x6000001,
    root 0x5d, subw 0x0, time 38675661, (1037,-202), root:(1040,328),
    state 0x10, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False
(This is the letter 'a'.)
What you need of this information is the keycode (3rd line; in this case it's 38).
This is the X11 keycode, not to be confused with the Linux keycode we'll be talking about later.

These are the X11 keycodes of the extra keys on the keyboard of the Acer Aspire 9412ZWSMi:

key keycode
'e' -
envelope 236
globe 178
'P' -
antenna -
Bluetooth logo -
Fn+F1 -
Fn+F2 -
Fn+F3 -
Fn+F5 -
Fn+F8 160
Fn+F12 78
Fn+Arrow up 176
Fn+Arrow down 174
Fn+Page up 164
Fn+Page down 144
Fn+Home 162
Fn+End 153
-
$ -

Now there are 10 keys (or key combinations) left that are not hardwired, and are also not supported by the kernel. You must now tell the kernel how these keys can be recognized.
Luckily the kernel reports these keys in /var/log/messages.
Type in a console

tail -n 0 -f /var/log/messages
and press the missing keys. You will see lines like
kernel: atkbd.c: Unknown key pressed (translated set 2, code 0xf4 on isa0060/serio0).
kernel: atkbd.c: Use 'setkeycodes e074 <keycode>' to make it known.
kernel: atkbd.c: Unknown key released (translated set 2, code 0xf4 on isa0060/serio0).
kernel: atkbd.c: Use 'setkeycodes e074 <keycode>' to make it known.
(This is the key with the 'e'.)
The keycode we talk about now, is the Linux keycode (I know, it doesn't make things clearer, but I didn't make it up).
The program you use to tell the kernel which Linux keycode belongs to which key is setkeycodes; 'e074' is the scancode (in this example), and the keycode to attach to it can be found in /usr/include/linux/input.h.
Not for all functions have keycodes been defined, so you will have to choose sometimes. In that case you will, of course, pick one that's not in use at the moment. Some keycodes have not been defined yet (84, 120, 195-199, 237-239); maybe it's a good idea to take those.

These are the scancodes, and the Linux keycodes I chose to go with them:

key scancode keycode
'e' e074 148 (KEY_PROG1)
'P' e073 149 (KEY_PROG2)
antenna e055 218 (KEY_CONNECT)
Bluetooth logo e058 237
Fn+F1 e025 138 (KEY_HELP)
Fn+F2 e026 202 (KEY_PROG3)
Fn+F3 e027 203 (KEY_PROG4)
Fn+F5 e029 238
e033 219 (KEY_FINANCE)
$ e034 239

For all these keys you can now attach a LInux keycode to the scancode:

setkeycodes e025 138	# Fn + F1
setkeycodes e026 202	# Fn + F2
setkeycodes e027 203	# Fn + F3
setkeycodes e029 238	# Fn + F5
setkeycodes e033 219	# euro sign
setkeycodes e034 239	# dollar sign
setkeycodes e055 218	# wireless
setkeycodes e058 237	# bluetooth
setkeycodes e073 149	# 'P'
setkeycodes e074 148	# 'e'

Every key on your keyboard now has a Linux keycode.
The above commands must be run at every boot, so add those lines to /etc/rc.d/rc.local.

Then you run

xev
again to find the X11 keycodes for these keys.

When you're done, the list of X11 keycodes is (finally) complete. These are the keys, the keycodes, and the actions I want to assign to the keys:

key keycode action
Fn+F12 78 Scroll Lock
Fn+Page down 144 backward mediaplayer
'P' 151 klineakconfig
Fn+End 153 forward mediaplayer
'e' 159 ? (Acer program for backups, etc.)
Fn+F8 160 mute sound
Fn+Home 162 start/pause mediaplayer
Fn+Page up 164 stop mediaplayer
Fn+F2 171 ? (Acer eSettings)
Fn+F3 172 ? (Acer ePower Management)
Fn+Arrow down 174 turn sound down
Fn+Arrow up 176 turn sound up
globe 178 open browser
antenna 194 start/stop wireless connection
195 euro sign
envelope 236 start email client
Bluetooth logo 242 start/stop Bluetooth
Fn+F5 243 switch between laptop display and external monitor
$ 244 dollar sign
Fn+F1 245 start Help

Now all you have to do, is attach an action to each keycode.
For this we need the packages lineakd, lineakd-plugins-default, lineakd-plugins-kde, lineakd-plugins-xosd and klineakconfig (menu -> System -> Configuration -> Packages -> Install software).

First see what klineakconfig can do for you. For me that wasn't much, because it kept crashing, but you might have more luck.
If you get klineakconfig to work, you probably won't need the rest of this text.

Okay, on for the people who can't (or won't) work with klineakconfig.

First we add the keyboard definition to /etc/lineakkb.def:

[ACER-ASP9410]
    # Contributed by Rob la Lau <rob[at]nerdstock.org>
    # Documented at http://nerdstock.org/acer_vista_mandriva
    # Tested on an Acer Aspire 9412ZWSMi

    brandname = "Acer"
    modelname = "Aspire 9410 series"

    [KEYS]
        ScrollLock      = 78
        AudioPrev       = 144
        PButton         = 151   # scancode e073 - Linux keycode 149
        AudioNext       = 153
        EButton         = 159   # scancode e074 - Linux keycode 148
        Mute            = 160
        Play|Pause      = 162
        Stop            = 164
        Setup           = 171   # scancode e026 - Linux keycode 202
        PowerMan        = 172   # scancode e027 - Linux keycode 203
        VolumeDown      = 174
        VolumeUp        = 176
        WWW             = 178
        Wireless        = 194   # scancode e055 - Linux keycode 218
        EuroSign        = 195   # scancode e033 - Linux keycode 219
        Mail            = 236
        Bluetooth       = 242   # scancode e058 - Linux keycode 237
        Display         = 243   # scancode e029 - Linux keycode 238
        DollarSign      = 244   # scancode e034 - Linux keycode 239
        Help            = 245   # scancode e025 - Linux keycode 138
    [END KEYS]
[END ACER-ASP9410]
I named this configuration ACER-ASP9410, because the Acer Aspire 9412ZWSMi is a 9410 series, and I'm guessing the keyboard is the same for the whole series.
Of course you can leave out the comments if you like; I added them because I asked the lineakd developers to add this keyboard definition to lineakd.def.

Then, as user you, you create an empty configuration file:

lineakd -c ACER-ASP9410

This generates a file (~/.lineak/lineakd.conf) with all the key names in it we just defined in /etc/lineakkb.def.
In this file you can add the actions you wish to use for the keys.

Apart from regular commands, you can also use generic commands.
More information on these commands can be found at this page and in the man pages lineak_defaultplugin, lineak_kdeplugins and lineak_xosdplugin (the links to the man pages won't work in every browser).

This is my ~/.lineak/lineakd.conf (for now):

CdromDevice = /dev/dvd
Display_align = center
Display_color = 0aff00
Display_font = -adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*
Display_hoffset = 0
Display_plugin = xosd
Display_pos = bottom
Display_soffset = 1
Display_timeout = 3
Display_voffset = 50
KeyboardType = ACER-ASP9410
MixerDevice = /dev/mixer
RAWCommands =
Screensaver =
conffilename = /home/rob/.lineak/lineakd.conf
keystate_capslock =
keystate_numlock =
keystate_scrolllock =

AudioNext = EAK_MEDIADETECT(NEXT)
AudioPrev = EAK_MEDIADETECT(PREVIOUS)
Bluetooth =
DollarSign = EAK_SENDKEYS(shift+4)
EuroSign = EAK_SENDKEYS(mod5+5)
Help = /usr/bin/khelpcenter
ScrollLock =
Mail = KMAIL_COMPOSE
Mute = EAK_MUTE
Play|Pause = EAK_MEDIADETECT(PLAYPAUSE)
PowerMan =
Setup =
Stop = EAK_MEDIADETECT(STOP)
EButton =
PButton = /usr/bin/klineakconfig
Display =
VolumeDown = EAK_VOLDOWN
VolumeUp = EAK_VOLUP
WWW = KONQUEROR
Wireless =
(I should reboot this machine into Windows first, to see what the other keys exactly do there.)

And when the configuration is done, we need to make sure lineakd is running, or the configuration will be useless.
You can start lineakd now by typing this into a console:

lineakd &

And then this would be a good moment to test whether it works...
And for me it does. :)

But having to type this command each time you login is no fun, so I created a symlink in the Autostart directory to start lineakd when I login

ln -s /usr/bin/lineakd ~/.kde/Autostart/lineakd
and a little script to stop lineakd on logout
# ~/.kde/shutdown/lineakd.sh

# exit lineakd
lineakd -x
If you don't use KDE as your desktop environment, you'll have to find some other place to start lineakd at login, and stop it at logout.

Now reboot to make sure you haven't forgotten anything, and if it all works you're done.
It took some time and effort, but it was worth it...


Previous page

Responses are welcomed:
rob[at]nerdstock.org
Creative Commons License
http://creativecommons.org/licenses/by-nc-sa/3.0/nl/deed.en
Linux On Laptops TuxMobil - Linux on Laptops, Notebooks, PDAs and Mobile Phones
Permission is hereby granted to Acer Inc. (the manufacturer of my laptop) to copy, distribute and display this documentation, as well as to make derivative works, provided that name ('Rob la Lau'), email ('rob@nerdstock.org') and website ('http://nerdstock.org/acer_vista_mandriva') of the author are mentioned in those works as being the original source.