I always thought it would be cool to have a wiimote connected to my phone, specifically for use with emulators, so I'm going to try to compile CWiid for android!
In order to compile the CWiid code for android, you're obviously going to need a native compiler for android. Thus, you will need to complete the native tutorial prior to embarking on this exciting adventure. For the entirety of this howto, I will assume that the location of your android sdk directory from that tutorial be in ${ANDROIDSDK} and that your copy of the agcc script be located at ${AGCC}.
Also, as per usual, set up a place to compile:
mkdir ${CWIID} cd ${CWIID}
The first step is obviously to get the CWiid source:
cd ${CWIID} wget http://abstrakraft.org/cwiid/downloads/cwiid-0.6.00.tgz tar -zxvf cwiid-0.6.00.tgz cd cwiid-0.6.00
This step has essentially been the bane of my existance, as there is a LOT of problems with trying to get the code to compile, mostly in the sense that libraries that are required aren't present.
To circumvent this, I have essentially solved the problems and made a beautiful little patch for everyone to download to auto-fix everything. However I will document what I can remember below
Every time I see a ./configure script when porting, it makes my blood boil. They are a nuisance to code around as they try to run code for tests, which is difficult when cross-compiling. (I know there is a more adequate way to do this (like actually cross-compiling), but I haven't learned it yet).
So anyway, I ran ./configure as using the host toolchain, and then manually modified the makefiles (yep).
I must put in a special thanks to whoever posted the patch that I reference at the bottom of the page. It was a fantastic starting point and helped out with a lot of problems.
hci_remote_name was deprecated in bluez, so I simply changed those references to the new hci_read_remote_name
There were some ugly path issues that had to be solved as well. I'm going to try to forget about them now >.>
Anyone who has spoken to me while working on this knows that bionic + plugins = bad. There were SO many undefined reference errors I don't even know where to begin. So essentially I had to rip all of wminput apart and put it in it's own library, libwminput.so. This required quite a bit of Makefile editing as well as some substantial source code changes, but in the end it was worth it :D
So after many hours of toiling, here are the patches:
And now we patch our source, as well as make some last-minute modifications:
cd ${CWIID}/cwiid-0.6.00 lzma -cd ${loc_to_download}/cwiid-android-001.patch.lzma | patch -Np1 lzma -cd ${loc_to_download}/cwiid-android-002.patch.lzma | patch -Np1 lzma -cd ${loc_to_download}/cwiid-android-003.patch.lzma | patch -Np1 SED="s/^COMMON =.*$/COMMON = $(pwd | sed -r 's/\//\\\//g')\/common/"; sed -i -r "$SED" defs.mak ln -s ${ANDROIDSDK} android-sdk chmod 755 agcc
Finally, we can compile our cwiid libraries:
cd ${CWIID}/cwiid-0.6.00 export PATH=$(pwd)/android-sdk/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:${PATH} make
And if all goes well, things should compile smoothly! :D
To make this easier, I am going to first log into the device, and create the necessary directories, as well as mount the system rw.
adb shell # mount read/write $ sysrw # set umask (so that directories are created with proper permissions $ umask 0022 # make the directories $ busybox mkdir -p /system/etc/cwiid/wminput $ busybox mkdir -p /system/lib/cwiid/plugins # now exit $ exit
Next we push the files to the system in the proper places:
cd ${CWIID}/cwiid-0.6.00 # push the libraries first adb push libcwiid/libcwiid.so.1.0 /system/lib/libcwiid.so adb push libwminput/libwminput.so.1.0 /system/lib/libwminput.so # then the executables adb push wminput/wminput /system/xbin/ adb push lswm/lswm /system/xbin/ # then the plugins for i in wminput/plugins/*/*.so; do adb push ${i} /system/lib/cwiid/plugins/; done # push default configs for i in wminput/configs/*; do adb push ${i} /system/etc/cwiid/wminput/; done
And finally, we return to our device to modify permissions and ownership, as well as remount our system ro:
adb shell # permissions! $ chmod 755 \ /system/xbin/lswm \ /system/xbin/wminput $ chmod 644 \ /system/lib/libcwiid.so \ /system/lib/libwminput.so \ /system/lib/cwiid/plugins/* \ /system/etc/cwiid/wminput/* # ownership! $ busybox sh $ chown 0.0 \ /system/xbin/lswm \ /system/xbin/wminput \ /system/lib/libcwiid.so \ /system/lib/libwminput.so \ /system/lib/cwiid/plugins/* \ /system/etc/cwiid/wminput/* \ /system/lib/cwiid \ /system/lib/cwiid/plugins \ /system/etc/cwiid \ /system/etc/cwiid/wminput $ exit # and now mount the system read-only $ sysro $ sync $ exit
And there you have it! A working copy of CWiid for Android!
Well, since I haven't taken the time to write an APP to control it yet, you have to start the input daemon from adb. Essentially these are the steps:
adb shell $ wminput -w -c ${CONFIGFILE_NAME}
This will start up the daemon and put it into a perpetual waiting state (-w), for more options check wminput –help
And that's basically all there is to it!
Below are any releases of this software that I have made.
Well here it is! The MAJOR RELEASE of CWIID! So far as I can tell ALL functionality currently supported in CWiid 0.6.00 is now supported in CWiid-Android!
Download: [removed]
Install:
Changes from v0.9.1:
TODO:
I have finally gotten a ROM.tgz build of this working for easier installation. It removes any existing CWiid libraries/binaries/default configs/plugins and installs the new ones for this release automagically.
Download: TAKEN DOWN (there was an error in this O.O)
Changes from v0.9.0:
TODO:
I have built a release of this just to make it easier on people who don't wish to build the SDK and compile everything from scratch. It basically is just a tarball of all of the files that would be pushed to your system, in the proper directory structure.
Download: [removed]
Features:
TODO: