Tuesday 5 June 2007

Wiimote under FreeBSD using bsdmoted

I have recently acquired a Wii and the Wiimote is an interesting creation indeed. Some attempts to reverse engineer it has been made and I found that FreeBSD has a driver. Sadly though, it lacks good documentation so I thought that I would walk through what I made in order to make it work.

First of all, we need to enable Bluetooth device support by loading the ng_ubt Bluetooth module into the kernel.

If you want it to load upon boot add the following line to /etc/loader.conf

/etc/loader.conf
ng_ubt_load="YES"

And load the module immediately in order to detect any Bluetooth devices. Afterwards check dmesg in order to check if any device was detected. In my case I had to remove the BT USB stick and then insert it again for it to work properly. Somehow it seems that the O/S won't detect it properly if ng_ubg wasn't loaded when the device was first detected.

# kldload ng_ubt

Then we need to make config for the Bluetooth daemon, the default conf will do just fine.

# cp /usr/share/examples/netgraph/bluetooth/rc.bluetooth /etc/rc.bluetooth
# chmod +x /etc/rc.bluetooth
# /etc/rc.bluetooth start ubt0

Now we are on to starting the bthid daemon. First let's use the default conf. If you are unable to start bthid due to some load command (yes, I admit that I have forgot which command it was AND lost the link to the solution). Then you need to upgrade to the latest STABLE RELENG_6, where the problem has been solved.

# cp /usr/src/usr.sbin/bluetooth/bthidd/bthidd.conf.sample /etc/bluetooth/bthidd.conf
# /etc/rc.d/bthid start

Now on to getting your Wiimote's BD_ADDR. You will probably have a bundle of BT devices nearby if you live in an apartment. I detected "Willy's mobile" for example. Press 1 and 2 simultaneously on the Wiimote and it will enter a detectable mode. Then execute a following command and note down all BD_ADDR of the devices that responds.

# hccontrol -n ubt0hci inquiry
[a list of devices]

When you request the name of the device (the Wiimote should still be blinking on happily in 1 + 2 detectable mode) it should respond accordingly. It will of course use another BD_ADDR.

# hccontrol -n ubt0hci remote_name_request 12:34:56:78:9A:BC
BD_ADDR: 12:34:56:78:9A:BC
Name: Nintendo RVL-CNT-01

Now you need to fetch the bsdmoted source. Get the latest version from. http://sourceforge.net/projects/bsdmoted/
Extract it somewhere and cd into the directory. Then clean, compile, install clean.

# make clean
# make
# make install
# make clean

You now need to configure bsdmoted with some info from the Wiimote. Execute the following command to do this.

# bthidcontrol -a 12:34:56:78:9A:BC query >> /usr/local/etc/bsdmoted.conf


Now you only need to start the bsdmoted daemon.

# bsdmoted

The binds are the following:
A is the left mouse button.
B is the right mouse button.
+ and - are used to calibrate the sensitivity .
Use 1 and 2 to switch between IR-mode and tilting mode.

I did not get the IR-mode working, but perhaps you do. Enjoy!

Recommended reading:
The FreeBSD handbook on Bluetooth.

bsdmoted links:
The bsdmoted Sourceforge page.
Chuan-Heng Hsiao's bsdmoted page (videos showing that it actually works).

10 comments:

Buganini said...

I am using bsdmoted 0.4.0 on FreeBSD 7.
bsdmoted 0.4.0 is conflicts with bthidd, so i need to stop it. Simple steps to get it work:
1) Get the BD_ADDR
hccontrol -n ubt0hci inquiry
2) compile and install bsdmoted
3) bthidcontrol -a BD_ADDR query >> /usr/local/etc/bsdmoted.conf
4) Press the red sync button besides the batteries && bsdmoted -d

Anonymous said...

hi all
http://www.tor.com/community/users/childrimrabu1982
http://www.tor.com/community/users/quinutlira1980
http://www.tor.com/community/users/vorszilheter1979
http://www.tor.com/community/users/rhubusunlas1987
http://www.tor.com/community/users/unatchaipres1973

Anonymous said...

Great article, totally what I needed.

Feel free to visit my web site - Full Posting

Anonymous said...

What a funny blog! I truly loved watching this humorous video with my family
unit as well as together with my mates.

Also visit my webpage: click the following internet page

Anonymous said...

Of course, one of the reasons why this area of Ohio has remained so persistently branded as a pocket of joblessness is its failure to recover
from the death of the steel industry and also because of automotive production lines outsourced to foreign
lands. He was instrumental in MTV showing African American artists.

Indian business news tells about the facts that Indian market is most preferred by
the foreign investors and also about various other factors like quick population growth, high economic growth, English knowledge etc.


Here is my webpage ... rideanything.com

Anonymous said...

To maintain your house harmless and prevent filing high priced property insurance claims, make sure to clear your chimney frequently. If the chimney gets blocked you can end up having key smoke or fireplace damage within your home. The price of experiencing it cleaned out is significantly below it will be to mend your home! [url=http://www.ss12w12ws.info]Dividfr5y4en[/url]

Anonymous said...

The fitness tips for motivation we've been discussing can be very powerful if you use them. My grandma can really feel vindicated at such a claim,she's been saying this all my life.
This can be achieved by adding more weight, increasing the number of repetitions, or
by adding on additional sets.

my web page ... http://www.alexanderburstein.com/

Anonymous said...

Most of you hunger to know more about the glitzy
life styles of glamorous celebrities and sensual models.

But unlike their blank counterparts, custom lanyards
also can proclaim a marketing or motivational message to customers and
employees. He covers gossip on celebrities, actors and musicians.


Also visit my site :: dirtyepicltd.com

Anonymous said...

Internet is the biggest server of fun with a lot of variety.
It's almost always easy to make a joke about the way a cat ends up lying down or sitting. The world will suddenly look a much better place to live in.

Feel free to surf to my blog - 10birr.com

Anonymous said...

bookmarked!!, I like your website!

my website ... latest world news