You are not logged in.

#1 2012-02-24 06:41:12

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

[ALMOST SOLVED] Pretending an Apple keyboard isn't

I just got an Apple aluminium USB keyboard.  I like the keyboard itself, but I'd like the layout to match the rest of my normal (US) keyboards.  This means:

- Make the function keys default over the multimedia keys (solved)
- Map F13-15 to SysRQ, Scroll Lock, and Pause, respectively (solved)
- Swap the Command (Meta) and Alt keys (solved, see next post)
- Disable Num Lock, and make the numeric keypad always enter digits
- This should all happen automatically when the keyboard is attached, not on boot (solved, see next post)

This has to work both on a VT and in X.  And it shouldn't affect any other keyboards in the system, just the Apple keyboard.  So far, I've done this:

- Add "options hid_apple fnmode=2" to /etc/modprobe.d/modprobe.conf.  This makes the F keys the default
- Used keyfuzz to remap the F13-15 keys:

# cat apple_fuzz

# map F13 to SYSRQ
458856 99
# map F14 to Scroll Lock
458857 70
# map F15 to Pause
458858 119

# keyfuzz -s -d /dev/input/by-id/usb-Apple_Inc._Apple_Keyboard-event-kbd < apple_fuzz

I suspect I need to write a udev rule to run the keyfuzz script when the keyboard is plugged in.

How do I do the rest of these things?  In particular, how do I figure out the scancodes for keyfuzz?  showkey -s gives 0xe0 0x5b for the command key, but "0xe05b 56" doesn't work as input to keyfuzz (EVIOCGKEYCODE: Invalid argument).  And how do I disable num lock?

Last edited by tavianator (2012-02-24 19:54:39)

Offline

#2 2012-02-24 19:53:55

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Okay, so I've made progress.  Using a program called getscancodes, I identified the scancodes of the Alt and Command (Meta) keys.  I've also written a udev rule to do all this when the keyboard is plugged in.

I've uploaded a package to the AUR that does all these things automatically.

I still don't know how to get the number pad to always enter digits.  There's an option for it in KDE, but I'd like it to behave the same way on the console too.

Offline

#3 2012-02-24 20:03:44

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

I still don't know how to get the number pad to always enter digits. ...on the console too.

numlockx?

Last edited by Earnestly (2012-02-24 20:04:27)

Offline

#4 2012-02-24 20:13:29

masteryod
Member
Registered: 2010-05-19
Posts: 433

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Did you consider making a wiki page about this? It could be very handy for many people in the future wink

Offline

#5 2012-02-24 20:35:00

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Kaustic wrote:

I still don't know how to get the number pad to always enter digits. ...on the console too.

numlockx?

Only works in X11.  And while that will turn on numlock, it doesn't prevent me from turning it off again.  I guess I could do that and then remap the Clear key to something other than numlock.

masteryod wrote:

Did you consider making a wiki page about this? It could be very handy for many people in the future wink

I will add it to the Apple Keyboard wiki page when I figure the rest of it out, or give up smile

Offline

#6 2012-02-24 20:43:15

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Oh, forgive me, I didn't realise the keyboard lacked a physical Numlock key. What does "Clear" actually do (out of curiosity), something similar to "^u" on the terminal?

Edit: What about remapping the F13-F16 keys or do they serve another purpose?

Last edited by Earnestly (2012-02-24 20:45:05)

Offline

#7 2012-02-24 22:48:05

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Kaustic wrote:

Oh, forgive me, I didn't realise the keyboard lacked a physical Numlock key. What does "Clear" actually do (out of curiosity), something similar to "^u" on the terminal?

Edit: What about remapping the F13-F16 keys or do they serve another purpose?

I have no idea what it does in OS X.  Under linux, it gets mapped to numlock.  But of course there's no numlock LED, so it's confusing.

The lack of a numlock key is the one design deviation that I like about this keyboard.  In OS X, no matter what, the number pad keys produce numbers.  There is no concept of num lock, it's just always on.  I've never in my life used the number pad for arrow keys (I don't game), so the whole key is useless to me.

I guess I could remap all the number pad keys to their non-number-pad equivalents, but then there would be no way to differentiate between the numpad and the other keys for keyboard shortcuts.

Offline

#8 2012-02-24 23:07:59

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Every single one of my LEDs have died over the years, first the capslock (odd as I never used it), then the numlock and recently scroll lock. It's not too confusing once you get used to it.
Gamers tend to use WSAD or at least the actual arrow keys. The numpad is just somewhat odd, out of place, on keyboards these days. However, the extra keys are always welcome.

It's strange though, that there's no way to simply send a keycode (keysym) to your keyboard driver instructing it to use the numlock key (mapped or not), or atleast, that there's no Console alternative to numlockx.

At any rate, good luck with your project, and yeah, updating the various wiki entries is always awesome.

Offline

#9 2012-02-25 00:34:32

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

The console alternative to numlockx is setleds.  I can of course use that, but I find it to be a hack.  I don't really want, "turn numlock on programmatically," I want, "understand that this keyboard doesn't have a concept of numlock, and the numpad-8 key is always an 8."

I guess what I really want is for numlockx and setleds to outright fail on this keyboard, because there's no num lock to set in the first place.  I think I'd have to patch the kernel for that though.

Actually, Linux (and possibly others) seems to treat the locks in a weird way.  I'd expect them to be per-keyboard, but if I hit caps lock on my laptop keyboard, the letters on my USB keyboard come out capitalised too.

EDIT: Added some documentation to the wiki: https://wiki.archlinux.org/index.php/Ap … _Keyboards

Last edited by tavianator (2012-02-25 00:59:56)

Offline

#10 2012-12-15 17:03:53

netmanny
Member
Registered: 2008-05-13
Posts: 41

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Command clear or shift clear or just clear turn numlock on and off it's been a while just try...

Offline

#11 2012-12-16 22:28:17

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

netmanny wrote:

Command clear or shift clear or just clear turn numlock on and off it's been a while just try...

Yeah I know how to do it, I'd just prefer if I didn't have to.  There's no numlock key on this keyboard, Linux should just handle it like OS X and force numlock on all the time.

Offline

#12 2013-01-25 21:50:25

tammer
Member
From: Philadelphia
Registered: 2010-06-18
Posts: 11

Re: [ALMOST SOLVED] Pretending an Apple keyboard isn't

Hello, sorry to necropost but I came across this thread in my search for the same issue, and I've got a semi-solution that isn't mentioned here yet:

It only works in X, but is a slightly cleaner solution than numlockx. The xkb option numpad:mac changes the keymap so that the numlock state has no effect, and the numpad keys only send numbers.

You can either set it via "setxkbmap -option numpad:mac", or permanently through an X config file like this one:

10-keyboard.conf

Section "InputClass"
    Identifier        "evdev keyboard catchall"
    MatchIsKeyboard   "on"
    MatchDevicePath   "/dev/input/event*"
    Driver            "evdev"
    Option            "XkbOptions" "numpad:mac"
EndSection

You can throw as many comma-separated xkb options as you like into that one, I've got a few more to remap some keys. A full list of options can be found @ /usr/share/X11/xkb/rules/base.lst

Last edited by tammer (2013-01-25 21:52:44)

Offline

Board footer

Powered by FluxBB