maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Apple Wireless keyboard hack (https://talk.maemo.org/showthread.php?t=41845)

Ulysses 2010-01-22 18:04

Apple Wireless keyboard hack
 
Hello all,

I would like to spend some time and effort to make the apple wireless keyboard work with the N900, with the help of the community.

We already know that it is possible to make some bluetooth keyboards work with the N900. At least, Jeff succeeded with a Stowaway IGo.

http://talk.maemo.org/showthread.php?t=38372

In order to make an apple bluetooth keyboard work in maemo 5, we would need to fulfill the following requirements:

1, pair the keyboard
2, make sure the keyboard has been registered as an input device (hildon-im-xkbtool --list)
3, Run the setxkbmap command to associate the keyboard layout we want (and not the default SU-W8)

So here are my observations:

The problem with the Apple wireless keyboard is that although it pairs fine, it is not being registered as an input device (hildon-im-xkbtool --list won't show it in its output).

Since maemo 5 uses the bluez stack, we have at our disposal the bluez commands to try to understand what is happening.

Nokia-N900-42-11:~# hcitool scan
Scanning ...
00:26:CC:D4:0E:80 Nokia 3720
00:1D:4F:A7:71:46 Apple Wireless Keyboard

Good, found it. Now let's create a connection:

Nokia-N900-42-11:~# hcitool cc 00:1D:4F:A7:71:46

Seems good. As mentioned in many places, the Apple wireless keyboard requires encryption and authentication. So let's do that.

Nokia-N900-42-11:~# hcitool auth 00:1D:4F:A7:71:46
Not connected.

Bummer, indeed.

Nokia-N900-42-11:~# hcitool con
Connections:

Connections remained empty!!

What could be the problem? Maybe someone experienced with bluez can chime in. Please use this thread to report all the information pertaining the apple wireless keyboard and the N900. With some community effort, we'll find a way to make it work.

Cheers,

Ulysses

axonpoet 2010-01-22 18:16

Re: Apple Wireless keyboard hack
 
I've managed to get my Apple wireless keyboard working by compiling the hid-apple kernel module. This is missing from the installed kernel modules and is required for the kernel to recognize the device.

With this loaded, the steps below (hildon-im-xkbtool --list, setxkbmap, etc.) get everything working nicely.

Cheers.

Quote:

Originally Posted by Ulysses (Post 489112)
Hello all,

I would like to spend some time and effort to make the apple wireless keyboard work with the N900, with the help of the community.

We already know that it is possible to make some bluetooth keyboards work with the N900. At least, Jeff succeeded with a Stowaway IGo.

http://talk.maemo.org/showthread.php?t=38372

In order to make an apple bluetooth keyboard work in maemo 5, we would need to fulfill the following requirements:

1, pair the keyboard
2, make sure the keyboard has been registered as an input device (hildon-im-xkbtool --list)
3, Run the setxkbmap command to associate the keyboard layout we want (and not the default SU-W8)

So here are my observations:

The problem with the Apple wireless keyboard is that although it pairs fine, it is not being registered as an input device (hildon-im-xkbtool --list won't show it in its output).

Since maemo 5 uses the bluez stack, we have at our disposal the bluez commands to try to understand what is happening.

Nokia-N900-42-11:~# hcitool scan
Scanning ...
00:26:CC:D4:0E:80 Nokia 3720
00:1D:4F:A7:71:46 Apple Wireless Keyboard

Good, found it. Now let's create a connection:

Nokia-N900-42-11:~# hcitool cc 00:1D:4F:A7:71:46

Seems good. As mentioned in many places, the Apple wireless keyboard requires encryption and authentication. So let's do that.

Nokia-N900-42-11:~# hcitool auth 00:1D:4F:A7:71:46
Not connected.

Bummer, indeed.

Nokia-N900-42-11:~# hcitool con
Connections:

Connections remained empty!!

What could be the problem? Maybe someone experienced with bluez can chime in. Please use this thread to report all the information pertaining the apple wireless keyboard and the N900. With some community effort, we'll find a way to make it work.

Cheers,

Ulysses


Ulysses 2010-01-22 19:05

Re: Apple Wireless keyboard hack
 
Fantastic.

Maybe you could attach the kernel module here as attached file for those who don't have a development environment set up. And could you please mention the commands used to load it?

That would be great.

Thanks in advance.

Ulysses

axonpoet 2010-01-22 19:50

Re: Apple Wireless keyboard hack
 
I think I'm against posting a lone little kernel module in a forum on principle alone.

My intention is to package this up exactly like kernel-module-cifs, Kernel-module-nls-utf8, or kernel-module-ntfs packages, but I'm not sure how fast I'll get to this.

Possibly someone else could get to it sooner?

Cheers.

Quote:

Originally Posted by Ulysses (Post 489218)
Fantastic.

Maybe you could attach the kernel module here as attached file for those who don't have a development environment set up. And could you please mention the commands used to load it?

That would be great.

Thanks in advance.

Ulysses


starman 2010-01-22 19:52

Re: Apple Wireless keyboard hack
 
Quote:

Originally Posted by axonpoet (Post 489125)
I've managed to get my Apple wireless keyboard working by compiling the hid-apple kernel module. This is missing from the installed kernel modules and is required for the kernel to recognize the device.

really? thats awesome.....

stuff like this makes me wonder what other interesting hacks people have dreamt up that we'll never know about, unless we stumble upon threads like this!!

.... hmmmmm i wonder?? :)

McChicken 2010-01-22 20:38

Re: Apple Wireless keyboard hack
 
I would Love to See a solution. and I am not alone see this thread http://talk.maemo.org/showthread.php?t=34872

But I need something that a Regular Joe Non-coder can utilize.

Ulysses 2010-01-22 21:08

Re: Apple Wireless keyboard hack
 
Of course a package would be the best, but failing that, a kernel module compiled against the latest kernel version would be nice too, and pretty much normal practice for linux users.

Ulysses

Ulysses 2010-01-23 15:17

Re: Apple Wireless keyboard hack
 
Hi,

I've set up a development environment in order to compile the apple module for the kernel.

A couple of observations:

In the wiki it is said that for external kernel modules, kernel headers will suffice:
Code:

[sbox-MaemoKernel: ~/maemo_kernel] > fakeroot apt-get install kernel-headers
However, this package cannot be found.

So I resorted to compiling the module against the full source. Let's get the source.

Code:

[sbox-MaemoKernel: ~/maemo_kernel ] > apt-get source kernel
Now let's configure the source tree.

Code:

sbox-MaemoKernel: ~/maemo_kernel ] > cd kernel-2.6.28
[sbox-MaemoKernel: ~/maemo_kernel/kernel-2.6.28] > make EXTRAVERSION=-omap1 rx51_defconfig

Let's grab the latest hid-apple.c and the latest hid-ids.h form the kernel gitweb, adapt the Makefile:

Code:

# Makefile for building the hello kernel module outside the kernel tree

KERNELDIR := /usr/src/maemo_kernel/kernel-2.6.28

obj-m := hid-apple.o

# default build target (uses kernel build (kbuild) system)
all:
        $(MAKE) -C $(KERNELDIR) M=`pwd` EXTRAVERSION=-omap1 modules

# target for cleaning up
clean:
        $(RM) *.o .depend .*.cmd *.ko *.mod.c Module.symvers modules.order
        $(RM) -R .tmp_versions

Compiling the module is OK. Now let's put it on the device and do a :

Code:

Nokia-N900-42-11:/home/user# insmod hid-apple.ko
insmod: error inserting 'hid-apple.ko': -1 Invalid module format

Not good. Let's go back to scratchbox and strip the version info in case the problem stems from a slight version mismatch:

Code:

[sbox-FREMANTLE_ARMEL: ~/maemo_kernel/apple-module] > objcopy --strip-debug \
-R .modinfo -R __versions apple-hid.ko

And on the device:

Code:

Nokia-N900-42-11:/home/user# insmod hid-apple.ko
insmod: error inserting 'hid-apple.ko': -1 Unknown symbol in module

Any advice?

Thanks, Ulysses

axonpoet 2010-01-23 16:17

Re: Apple Wireless keyboard hack
 
Probably getting a version from gitweb is what's borking you. Try following:

http://wiki.maemo.org/Documentation/...Kernel_Modules

The appropriate line will be
# CONFIG_HID_APPLE is not set
which should be changed to
CONFIG_HID_APPLE=m
Cheers.

axonpoet 2010-01-23 18:12

Re: Apple Wireless keyboard hack
 
It's already a part of the kernel source. You got the appropriate version when you did
[sbox-MaemoKernel: ~/maemo_kernel ] > apt-get source kernel
Cheers.

Ulysses 2010-01-23 20:56

Re: Apple Wireless keyboard hack
 
Got it. Thanks.

I followed the instructions pertaining internal modules compilation, everything went smooth, however:

Nokia-N900-42-11:/home/user# insmod hid-apple.ko
insmod: error inserting 'hid-apple.ko': -1 Invalid module format

What gives?

axonpoet 2010-01-23 21:21

Re: Apple Wireless keyboard hack
 
Maybe you compiled for an i386 target instead of ARM?

Ulysses 2010-01-23 21:58

Re: Apple Wireless keyboard hack
 
No, it was the ARM target.

So how did you do it? You compiled the module and did an insmod on the device? That's it? You didn't reflash a custom kernel on the device, or did you? Was there anything that is not documented and we should know?

Thanks in advance.

Ulysses

ashre 2010-01-29 13:01

Re: Apple Wireless keyboard hack
 
Have you got this working Ulysses?

I'm going to have a go this weekend but wondered if you had succeeded and had any hints.

ashre 2010-01-29 16:57

Re: Apple Wireless keyboard hack
 
By the way I got the same problem as you with the invalid module format, it was because I hadn't built the kernel before I built the modules. Here is the complete guide to getting it to compile:

Download and install the GUI installer from http://doiop.com/maemosdk

Open a command prompt and type:

Code:

newgrp sbox
scratchbox

# Now within the scratchbox environment
# Set up a kernel target
sb-conf setup MaemoKernel -c cs2007q3-glibc2.5-arm7 -d qemu:perl:svn:apt-https -t /scratchbox/devkits/qemu/bin/qemu-arm-sb
sb-conf select MaemoKernel
sb-conf rs MaemoKernel /home/user/maemo-sdk-rootstrap_5.0_armel.tgz
sb-conf in MaemoKernel -edFL

# Get the kernel source
mkdir ~/maemo_kernel
fakeroot apt-get update
cd ~/maemo_kernel
apt-get source kernel
cd kernel-2.6.28

# Create the config
make EXTRAVERSION=-omap1 rx51_defconfig
nano .config
# Add a line that says:
CONFIG_HID_APPLE=m

# Build the kernel and modules
make EXTRAVERSION=-omap1 oldconfig
make EXTRAVERSION=-omap1 bzImage
make EXTRAVERSION=-omap1 modules

# Exit from scratchbox
exit

# Install the new module, I use ssh and zeroconf but you can copy it manually - change the names in angle brackets to your own values and remove the angle brackets
scp /scratchbox/users/<ashre>/home/<ashre>/maemo_kernel/kernel-2.6.28/drivers/hid/hid-apple.ko root@<N900>.local:/lib/modules/2.6.28-omap1/
ssh root@<N900>.local

# Now on the N900, in an XTerminal if not using ssh
insmod /lib/modules/2.6.28-omap1/hid-apple.ko


ashre 2010-01-30 11:25

Re: Apple Wireless keyboard hack
 
I can now load hid-apple.ko (I have to load hid.ko first) with insmod but the Apple keyboard refuses to connect properly.

I've tried restarting bluetooth as well with:
Code:

stop bluetoothd
start bluetoothd

But still no joy. I think this is because I have to signal the connection is encrypted. On the N800 it seems to work out of the box:

http://cs.gmu.edu/~sean/stuff/n800/keyboard/

Will keep trying anway, any hints appreciated.

ashre 2010-01-30 12:49

Re: Apple Wireless keyboard hack
 
Looking at it now I think hid-apple.ko is a red herring. I think it's for the USB Apple keyboards.

ashre 2010-01-30 13:17

Re: Apple Wireless keyboard hack
 
Ok by editing /etc/bluetooth/main.conf and pairing repeatedly I got it to work, teh connection keeps dropping though so I need to work on that and I also need to remap the keys. Here's what I added to main.conf:

Code:

HIDD_ENABLED=1
device 00:25:BC:FB:7D:B6 {
 name "Apple Wireless Keyboard";
 auth enable;
 encrypt enable;
}


Ulysses 2010-01-30 17:00

Re: Apple Wireless keyboard hack
 
Same here. The connection keeps dropping.
I tried to debug with hcidump.
http://maemo.org/development/tools/d...bluez-hcidump/

hcidump reports a successful connection, but then a disconnect occurs almost immediately. Accordingly, the bluetooth icon on the desktop turns blue for one second, then goes white again.

What is causing the disconnect?

Ulysses

ashre 2010-01-30 19:33

Re: Apple Wireless keyboard hack
 
I think the problem of it closing the connection after a few seconds is related to this bug:

https://bugs.maemo.org/show_bug.cgi?id=8483

Talked about in this thread:

http://talk.maemo.org/showthread.php...xkbmap&page=11

Ulysses 2010-01-31 10:45

Re: Apple Wireless keyboard hack
 
I think you are right.
We should vote for that bug, by the way.

https://bugs.maemo.org/votes.cgi?act...8483#vote_8483

Alan_Peery 2010-01-31 14:51

Re: Apple Wireless keyboard hack
 
Quote:

Originally Posted by Ulysses (Post 489448)
Of course a package would be the best, but failing that, a kernel module compiled against the latest kernel version would be nice too, and pretty much normal practice for linux users.

I am willing to wait to get it right. We want the N900 to be usable by more than the part of the Linux community that is used to loading kernel modules.

After all, I am not sure that my Dad has recovered from the Apple II programming lessons yet, and I would love to recommend this phone to him to replace the Blackberry Storm he already owns. And we're getting closer to where I'd feel comfortable doing that.

burtesquire 2010-03-09 18:51

Re: Apple Wireless keyboard hack
 
I think that being able to attach a bluetooth keyboard such as the Apple Wireless Keyboard is going to make the N900 very popular!

I was not quite able to follow which of all the commands posted I need, and it looks like there is still an outstanding disconnecting bug.

It's been a month since the last post - please have we gotten any further? I've just bought my N900 and I'm dying to use my wireless apple keyboard with it! :)

bitwit 2010-04-19 10:38

Re: Apple Wireless keyboard hack
 
I bought a Apple Wireless keyboard yesterday.
It connected to my new n900 without problems.
All I had to do was to enter the blutooth pin on the keyboard and press enter.
All the letter keys work. If I press rigth alt key I get numbers and all other characters that is marked in blue on the n900 keyboard.
It connects to the n900 as an nokia_vndr/rx-51 keyboard.

What i need to solve now is to get a working keymap for swedish characters and to be able to use the numbers and other keys.

Anyone who know how to do that?

bitwit 2010-04-19 15:10

Re: Apple Wireless keyboard hack
 
Well I made it easy for me. Since the apple keyboard connected as an rx-51 with the US layout, and my n900 uses the swedish finnish layout on the internal keyboard, I went to the folder

/usr/share/X11/xkb/symbols/nokia_vndr

and edited the file rx-51 and added the following code in the section for xkb_symbols "us":

partial alphanumeric_keys
xkb_symbols "us" {
include "nokia_vndr/rx-51(english_base)"
include "nokia_vndr/rx-51(arrows_4btns)"

name[Group1] = "U.S. English";
key <AE01> { [ 1, exclam, NoSymbol, exclamdown ] };
key <AE02> { [ 2, quotedbl, at, rightdoublequotemark ] };
key <AE03> { [ 3, numbersign, sterling, guillemotright ] };
key <AE04> { [ 4, currency, dollar, guillemotleft ] };
key <AE05> { [ 5, percent, U2030, leftdoublequotemark ] };
key <AE06> { [ 6, ampersand, singlelowquotemark, doublelowquotemark ] };
key <AE07> { [ 7, slash, braceleft, NoSymbol ] };
key <AE08> { [ 8, parenleft, bracketleft, less ] };
key <AE09> { [ 9, parenright, bracketright, greater ] };
key <AE10> { [ 0, equal, braceright, degree ] };
key <AE11> { [ plus, question, backslash, questiondown ] };
key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
key <AD11> { [ aring, Aring, dead_doubleacute, dead_abovering ] };
key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_macron ] };
key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
key <LSGT> { [ less, greater, bar, NoSymbol ] };
key <AB08> { [ comma, semicolon, rightsinglequotemark, leftsinglequotemark ] };
key <AB09> { [ period, colon, dead_belowdot, dead_abovedot ] };
key <AB10> { [ minus, underscore, endash, dead_belowcomma ] };
};

So now Im up and running and kan use all the alphanumeric keys.
Some tweaks has still to be done. Right shift does not work. < > is on the wrong key and I haven't started to look into assigning the function keys yet.

Carveri 2010-05-03 15:10

Re: Apple Wireless keyboard hack
 
Quote:

Originally Posted by bitwit (Post 617467)
I bought a Apple Wireless keyboard yesterday.
It connected to my new n900 without problems.
All I had to do was to enter the blutooth pin on the keyboard and press enter.
All the letter keys work. If I press rigth alt key I get numbers and all other characters that is marked in blue on the n900 keyboard.
It connects to the n900 as an nokia_vndr/rx-51 keyboard.

What i need to solve now is to get a working keymap for swedish characters and to be able to use the numbers and other keys.

Anyone who know how to do that?

Wow, I just bought the Apple Wireless Keyboard and it didn't seem to work. It took awhile to get it listed under Bluetooth devices, but now it won't pair or connect.

Is there a way you managed to have it connect as "nokia_vndr/rx-51 keyboard"?

fixfox 2010-05-03 15:38

Re: Apple Wireless keyboard hack
 
I have an Apple wireless keyboard as well.

I got it to pair successfully and is listed under blue-tooth devices.

However, I am unable to get it to connect to the N900.

The "connect/disconnect" button under "edit" is dimmed "disconnect".

Can anyone give step -by-step instructions on how they got theirs working ?

burtesquire 2010-06-06 15:37

Re: Apple Wireless keyboard hack
 
Okay I've spent a few weekends on this and managed to follow almost every instruction to try get this to work. My Apple keyboard still refuses to show up when I call:

hildon-im-xkbtool --list

Which means I cannot run the setxkb command. So all I'm waiting for now is for axonpoet (or someone with the skills to compile kernels) to publish the kernel package that was talked about 5 months ago.

I upgraded to PR1.2 last week which encouraged me to waste another weekend going through the threads trying to get the Apple Keyboard to work. However it still doesn't. The only thing I haven't tried is compiling kernels myself but I'd rather leave it to the experts.

sfs 2010-06-20 07:24

Re: Apple Wireless keyboard hack
 
I bought an Apple Bluetooth keyboard today and I did not get it to work as well (at first).

The trick did to pair it several times (and remove it from the list in between for sure ;)

Then some time it got connected! Then I finished the steps here:

http://talk.maemo.org/showthread.php?t=38372&page=18

to get a proper layout.

Great, I am very happy that it works now!

endrik 2010-06-22 18:02

Re: Apple Wireless keyboard hack
 
Hi sfs
I just followed the steps from your link.
The keyboard ist peering fine - but I only get the "us" layout working properly, doing a setxkbmap -device 4 -I -I/usr/share/X11/xkb-chinook -rules base -model pc105 -layout de is giving this error: Error loading new keyboard description. I did a cp -i xkb-chinook/symbols/de xkb/symbols/. before.

Did you get the German version working?

regards, endrik


Quote:

Originally Posted by sfs (Post 722367)
I bought an Apple Bluetooth keyboard today and I did not get it to work as well (at first).

The trick did to pair it several times (and remove it from the list in between for sure ;)

Then some time it got connected! Then I finished the steps here:

http://talk.maemo.org/showthread.php?t=38372&page=18

to get a proper layout.

Great, I am very happy that it works now!


WhiteWolf 2010-06-23 09:05

Re: Apple Wireless keyboard hack
 
Is there in Spanish?

0x4e84 2011-10-17 15:22

Re: Apple Wireless keyboard hack
 
Hi there...

I grab this thread out of the dust because I wonder if anybody has made an attempt yet to pair an Apple Wireless keyboard to a N9? With the device having only a virtual keyboard, that would make even more sense as with the N900.

I'll have to wait a few more weeks before I get my N9, so I can't test anything myself yet, but be sure I'll be willing to report about my attempts as soon as I can.

Disclaimer: absolute n00b when it comes to kernel modules, but I'd gladly follow instructions for testing.

sconf 2011-10-17 15:56

Re: Apple Wireless keyboard hack
 
Yes, I have tried Apple Bluetooth Keyboard wih N9. Result did not surprise me after all the troubles with my kbd and n8x0 and n900.

N9 sees kbd with no troubles and looks like it pairs ok. Kbd does not notice it is paired, keeps flashing led. No luck.

Previous experience suggests that there might be variants of Apple kbd model. Mine has been always very tricky.

-n8x0: very tricky to get pairing succeed. Got to do everything in just right sequence and timing. Once paired, works ok.
-n900: semi-hard to get paired. Once paired, does not work without hid-apple.ko, which is *not* in n900 kernels by default. With hid-apple.ko sometimes works just by turning kbd on. More regularly needs one bt disconnect-connect sequence.

I'm not planning to try 50+ pairing sequences with n9 like I was once forced to do. Life is just too short and bt kbd too cheap if somebody can confirm working model....

0x4e84 2011-10-17 18:02

Re: Apple Wireless keyboard hack
 
Quote:

Originally Posted by sconf (Post 1110029)
Yes, I have tried Apple Bluetooth Keyboard wih N9. Result did not surprise me after all the troubles with my kbd and n8x0 and n900.

N9 sees kbd with no troubles and looks like it pairs ok. Kbd does not notice it is paired, keeps flashing led. No luck.

Previous experience suggests that there might be variants of Apple kbd model. Mine has been always very tricky.

-n8x0: very tricky to get pairing succeed. Got to do everything in just right sequence and timing. Once paired, works ok.
-n900: semi-hard to get paired. Once paired, does not work without hid-apple.ko, which is *not* in n900 kernels by default. With hid-apple.ko sometimes works just by turning kbd on. More regularly needs one bt disconnect-connect sequence.

I'm not planning to try 50+ pairing sequences with n9 like I was once forced to do. Life is just too short and bt kbd too cheap if somebody can confirm working model....

Thanks for the useful feedback. I'll test asap if I'm more lucky...

G_Gus 2011-11-06 17:43

Re: Apple Wireless keyboard hack
 
Just as a quick note, the only exterior difference between apple wireless keyboards, that I know of, is the number of batteries needed.

I have a 3-battery one, and it connect to the N9 but then flashes, and does not work, not even following this tut: http://forum.meego.com/showthread.php?t=4828
I get to the point of hidd --search, it lists a MAC, but then fails.

The same kbd does not work on my N900 even after fiddling a lot, and following every procedure known to man.

I know that there are 4-batteries and 2-batteries versions of the keyboard, the latter being the newer.

The few people that managed to use N900 with the apple kbd that I know of, had the 2-battery version.

If you have the opportunity to try with a 2-battery one, or generally, with a new keyboard, it may work.. keep us informed!

sconf 2011-11-06 21:40

Re: Apple Wireless keyboard hack
 
I have three battery version. It works with n900 using non-stock kernel and hidd-apple kernel module. It is PITA to pair with n900.

With instructions mentioned in link above and additional fiddling with simultaneous hidd --search plus pairing I got it paired without blinking led and N9 shows it connected. However, it is not working. Quite similar like N900 without hidd-apple. N9 don't have hidd-apple.


All times are GMT. The time now is 19:38.

vBulletin® Version 3.8.8