Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #~ WiimotePyConnect v1.5
- import cwiid
- c = input('Cuantos controles va a conectar? ')
- wm = []
- for i in range(c):
- print 'Presione 1+2 en el Wiimote ' + str(i+1) + '...'
- wm.append(cwiid.Wiimote())
- wm[i].rpt_mode = cwiid.RPT_BTN | cwiid.RPT_IR | cwiid.RPT_ACC | cwiid.RPT_EXT
- wm[i].led = i+1
- bWiimote = {8:'A', 4:'B', 2:'1', 1:'2', 16:'-', 4096:'+', 128:'Home', 2048:'Up', 1024:'Down', 256:'Left', 512:'Right'}
- bClassic = {16:'a', 64:'b', 8:'x', 32:'y', 4096:'-', 1024:'+', 8192:'L', 512:'R', 128:'zL', 4:'zR', 2048:'Home', 1:'Up', 16384:'Down', 2:'Left', 32768:'Right'}
- bNunchuk = {2:'c', 1:'Z'}
- def checkPressed(w, mapp):
- buttons = w['buttons']
- bn = sorted(mapp.keys())
- bn.reverse()
- p = []
- for i in bn:
- if i <= buttons:
- p.append(mapp[i])
- buttons -= i
- return p
- def checkConnected(wm, c):
- keys = wm.state.keys()
- return c in keys
- while True:
- #~ #Buttons pressed
- classic = []
- wiimote = []
- nunchuk = []
- pressed = []
- for i in range(c):
- if checkConnected(wm[i],'nunchuk'):
- nunchuk = checkPressed(wm[i].state['nunchuk'],bNunchuk)
- elif checkConnected(wm[i], 'classic'):
- classic = checkPressed(wm[i].state['classic'],bClassic)
- wiimote = checkPressed(wm[i].state,bWiimote)
- pressed.append({'classic':classic, 'wiimote':wiimote, 'nunchuk':nunchuk})
- print pressed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement