Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keepishop@velma:~/wii$ cat wiibin.py
- import cwiid
- import time
- import array
- print 'Press 1+2 on your Wiimote now...'
- wm = cwiid.Wiimote()
- time.sleep(1)
- wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC
- print 'Now press A or B'
- binarray=array.array('c',['0','0','0','0','0','0','0','0'])
- binkey=0
- while True:
- if wm.state['buttons'] & cwiid.BTN_A:
- wm.led = (wm.state['led'] + 1) % 8
- binarray[binkey]='1'
- binkey=(binkey+1) % 8
- if binkey == 0:
- print (chr(int(binarray.tostring(),2)))
- print (binarray.tostring())
- wm.rumble=1
- time.sleep(.2)
- wm.rumble=0
- while wm.state['buttons'] & cwiid.BTN_A:
- time.sleep(.01)
- if wm.state['buttons'] & cwiid.BTN_B:
- wm.led = (wm.state['led'] + 1) % 8
- binarray[binkey]='0'
- binkey=(binkey+1) % 8
- if binkey == 0:
- print (chr(int(binarray.tostring(),2)))
- print (binarray.tostring())
- wm.rumble=1
- time.sleep(.2)
- wm.rumble=0
- while wm.state['buttons'] & cwiid.BTN_B:
- time.sleep(.01)
Advertisement
Add Comment
Please, Sign In to add comment