![]() |
HowTo.ConnectWiimoteDebianPython HistoryHide minor edits - Show changes to markup August 26, 2008, at 06:04 AM
by --
Changed lines 30-31 from:
http://www.lukulu.com/files/wii.pys to:
http://www.bluekulu.com/files/wii.pys February 14, 2008, at 01:54 PM
by --
Changed lines 23-24 from:
Use the code from www.wiili.org/index.php/Wiiewer and respect the license DWTFYWT public licence. to:
Use the code from http://www.wiili.org/index.php/Wiiewer and respect the license DWTFYWT public licence. Changed lines 30-31 from:
www.lukulu.com/files/wii.pys to:
http://www.lukulu.com/files/wii.pys February 14, 2008, at 01:53 PM
by -- wiimote on debian with python and pybluez
Changed line 16 from:
to:
Changed lines 23-26 from:
Use this code and respect the license. Change the address as required. Don't worry about pairing and all the rubbish. It's not needed. The critical thing is to make sure bluetooth is going to:
Use the code from www.wiili.org/index.php/Wiiewer and respect the license DWTFYWT public licence. Change the address as required. Don't worry about pairing and all the rubbish. It's not needed. The critical thing is to make sure bluetooth is going using hcitool dev and hcitool scan. Changed lines 28-102 from:
from bluetooth import BluetoothSocket?, BluetoothError?, L2CAP? import thread, time WIDTH = 512 HEIGHT = 256 # Don't change this one ADDRESS = '00:1E:35:06:E5:CE' # Change this one, of course
def listener(): global connected, sensor
fdin.settimeout(0.1)
while connected == 1:
try:
msg = fdin.recv(23)
except BluetoothError?:
continue
if len(msg) >= 7:
for c in range(3):
sensor[c] = ord(msg[4 + c])
fdin.close()
fdout.close()
connected = -1
print 'connecting to Wiimote ' + ADDRESS + ', please press buttons 1 and 2' fdin = BluetoothSocket?(L2CAP?) fdin.connect((ADDRESS, 0x13)) fdout = BluetoothSocket?(L2CAP?) fdout.connect((ADDRESS, 0x11)) if not fdin or not fdout: raise 'could not connect to Wiimote, check the address'
old = [127] * 3 sensor = [127] * 3 connected = 1 thread.start_new_thread(listener, ()) fdout.send("\x52\x12\x00\x31") x = 0 y = 0 z = 0
while connected == 1: for c in range(3):
if c == 0:
x = sensor[c]
if c == 1:
y = sensor[c]
if c == 2:
z = sensor[c]
print "s,(x,y,z)
time.sleep(0.5)
while connected == 0: time.sleep(0.5) \\ to:
ps. Use my code as it does not require pygame and has a simpler output. www.lukulu.com/files/wii.pys Now that you have that done, scratch your head and wonder the age old question of geekery ... "why?" February 14, 2008, at 01:44 PM
by --
Added lines 1-102:
Copied from http://www.nslu2-linux.org/wiki/HowTo/ConnectWiimoteDebian In this page I will describe how to connect a Nintendo wiimote on your slug. This document follows on from the debian link ConnectWiimoteDebian. In that page just go as far as the following bit that gets the address of the mote.
Please note the address of the wiimote is returned. This number is the address of the wiimote. I log in as root. use sudo otherwise Install Python, bluez and python-bluez
Use this code and respect the license. Change the address as required. Don't worry about pairing and all the rubbish. It's not needed. The critical thing is to make sure bluetooth is going Easy Peezy Lemon Squeezy!!
from bluetooth import BluetoothSocket?, BluetoothError?, L2CAP? import thread, time WIDTH = 512 HEIGHT = 256 # Don't change this one ADDRESS = '00:1E:35:06:E5:CE' # Change this one, of course
def listener(): global connected, sensor
fdin.settimeout(0.1)
while connected == 1:
try:
msg = fdin.recv(23)
except BluetoothError?:
continue
if len(msg) >= 7:
for c in range(3):
sensor[c] = ord(msg[4 + c])
fdin.close()
fdout.close()
connected = -1
print 'connecting to Wiimote ' + ADDRESS + ', please press buttons 1 and 2' fdin = BluetoothSocket?(L2CAP?) fdin.connect((ADDRESS, 0x13)) fdout = BluetoothSocket?(L2CAP?) fdout.connect((ADDRESS, 0x11)) if not fdin or not fdout: raise 'could not connect to Wiimote, check the address'
old = [127] * 3 sensor = [127] * 3 connected = 1 thread.start_new_thread(listener, ()) fdout.send("\x52\x12\x00\x31") x = 0 y = 0 z = 0
while connected == 1: for c in range(3):
if c == 0:
x = sensor[c]
if c == 1:
y = sensor[c]
if c == 2:
z = sensor[c]
print "s,(x,y,z)
time.sleep(0.5)
while connected == 0: time.sleep(0.5) \\ |