Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- wm[i].led = i+1
- buttons = {8:'A', 4:'B', 2:'1', 1:'2', 16:'-', 4096:'+', 128:'Home', 2048:'Up', 1024:'Down', 256:'Left', 512:'Right'}
- bn = sorted(buttons.keys())
- bn.reverse()
- def checkPressed(wm):
- bp = wm.state['buttons']
- p = []
- for i in bn:
- if i <= bp:
- p.append(i)
- bp -= i
- pressed = []
- for i in p:
- pressed.append(buttons[i])
- return pressed
- while True:
- #Buttons pressed
- pressed = []
- for i in range(c):
- pressed.append(checkPressed(wm[i]))
- print pressed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement