Example #1
0
def handle_event(wmp):
    wm = wmp[0]
    print('--- EVENT [wiimote id %i] ---' % wm.unid)

    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print(name, 'pressed')

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            print("- pressed")
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            print("+ pressed")
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            print("B pressed")
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            print("D-Pad Up pressed")
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            print("D-Pad Down Pressed")
            wiiuse.set_ir(wmp, 0)

    if wiiuse.using_acc(wm):
        print('roll  = %f' % wm.orient.roll)
        print('pitch = %f' % wm.orient.pitch)
        print('yaw   = %f' % wm.orient.yaw)

    if wiiuse.using_ir(wm):
        for i in range(4):
            if wm.ir.dot[i].visible:
                print('IR source %i: (%u, %u)' %
                      (i, wm.ir.dot[i].x, wm.ir.dot[i].y))
        print('IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y))
        print('IR z distance: %f' % wm.ir.z)

    if wm.exp.type == wiiuse.EXP_NUNCHUK:
        nc = wm.exp.u.nunchuk

        for name, b in wiiuse.nunchuk_button.items():
            if wiiuse.is_pressed(nc, b):
                print('Nunchuk: %s is pressed' % name)

        print('nunchuk roll  = %f' % nc.orient.roll)
        print('nunchuk pitch = %f' % nc.orient.pitch)
        print('nunchuk yaw   = %f' % nc.orient.yaw)
        print('nunchuk joystick angle:     %f' % nc.js.ang)
        print('nunchuk joystick magnitude: %f' % nc.js.mag)
def handle_event(wmp):
    wm = wmp[0]
    #print '--- EVENT [wiimote id %i] ---' % wm.unid
    
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)         
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)
    
    if wiiuse.using_acc(wm):
        
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw
        print 'x_acc = %f' % wm.gforce.x
        print 'y_acc = %f' % wm.gforce.y
        print 'z_acc = %f' % wm.gforce.z
def withYield():
    getConnected()
    while True:
        r = wiiuse.poll(wiimotes, nmotes)
        if r != 0:
            wmp=wiimotes[0]
            wm=wmp[0]
          
            if wm.btns:
                for name, b in wiiuse.button.items():
                    if wiiuse.is_pressed(wm, b):
                        print name,'pressed'
                if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                    wiiuse.motion_sensing(wmp, 0)
                if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                        wiiuse.motion_sensing(wmp, 1)
                if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                    wiiuse.toggle_rumble(wmp) 
            if wiiuse.using_acc(wm):
                #global rollAngle
                global completeList
                #rollAngle=[wm.orient.roll]
                completeList=[wm.orient.roll, wm.orient.pitch, wm.orient.yaw, wm.gforce.x, wm.gforce.y, wm.gforce.z ]
                #yield rollAngle
                yield completeList
Example #4
0
def handle_event(wmp):
    wm = wmp[0]
    print '--- EVENT [wiimote id %i] ---' % wm.unid
    
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)
    
    if wiiuse.using_acc(wm):
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw
		print 'x_force = %f' % wm.gforce.x
        print 'y_force = %f' % wm.gforce.y
        print 'z_force = %f' % wm.gforce.z
def withYield():
    getConnected()
    while True:
        r = wiiuse.poll(wiimotes, nmotes)
        if r != 0:
            wmp = wiimotes[0]
            wm = wmp[0]

            if wm.btns:
                for name, b in wiiuse.button.items():
                    if wiiuse.is_pressed(wm, b):
                        print name, 'pressed'
                if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                    wiiuse.motion_sensing(wmp, 0)
                if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                    wiiuse.motion_sensing(wmp, 1)
                if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                    wiiuse.toggle_rumble(wmp)
            if wiiuse.using_acc(wm):
                #global rollAngle
                global completeList
                #rollAngle=[wm.orient.roll]
                completeList = [
                    wm.orient.roll, wm.orient.pitch, wm.orient.yaw,
                    wm.gforce.x, wm.gforce.y, wm.gforce.z
                ]
                #yield rollAngle
                yield completeList
Example #6
0
    def handle_event(self, wmp):
        wm = wmp[0]
        print('--- EVENT [Wiimote ID %i] ---' % wm.unid)

        if wm.btns:
            for name, b in wiiuse.button.items():
                if wiiuse.is_pressed(wm, b):
                    print(name, 'pressed')

            if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
                wiiuse.motion_sensing(wmp, 0)
            if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
                wiiuse.motion_sensing(wmp, 1)
            if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
                wiiuse.toggle_rumble(wmp)
            if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
                wiiuse.set_ir(wmp, 1)
            if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
                wiiuse.set_ir(wmp, 0)

        if wiiuse.using_acc(wm):
            print('roll  = %f' % wm.orient.roll)
            print('pitch = %f' % wm.orient.pitch)
            print('yaw   = %f' % wm.orient.yaw)

        #if wiiuse.using_ir(wm):
        #    for i in range(4):
        #        if wm.ir.dot[i].visible:
        #            print 'IR source %i: (%u, %u)' % (i, wm.ir.dot[i].x, wm.ir.dot[i].y)
        #    print 'IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y)
        #    print 'IR z distance: %f' % wm.ir.z

        if wm.exp.type == wiiuse.EXP_NUNCHUK:
            nc = wm.exp.u.nunchuk

            if abs(nc.js.mag) < self.deadthres:
                self.end(self.ids[1])

            for name, b in wiiuse.nunchuk_button.items():
                if wiiuse.is_pressed(nc, b):
                    print('Nunchuk: %s is pressed' % name)

            print('nunchuk roll  = %f' % nc.orient.roll)
            print('nunchuk pitch = %f' % nc.orient.pitch)
            print('nunchuk yaw   = %f' % nc.orient.yaw)
            print('nunchuk joystick angle:     %f' % nc.js.ang)
            print('nunchuk joystick magnitude: %f' % nc.js.mag)
Example #7
0
def handle_event(wmp):
    wm = wmp[0]
    print '--- EVENT [wiimote id %i] ---' % wm.unid

    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                print name,'pressed'

        if wiiuse.is_just_pressed(wm, wiiuse.button['-']):
            wiiuse.motion_sensing(wmp, 0)
        if wiiuse.is_just_pressed(wm, wiiuse.button['+']):
            wiiuse.motion_sensing(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['B']):
            wiiuse.toggle_rumble(wmp)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Up']):
            wiiuse.set_ir(wmp, 1)
        if wiiuse.is_just_pressed(wm, wiiuse.button['Down']):
            wiiuse.set_ir(wmp, 0)

    if wiiuse.using_acc(wm):
        print 'roll  = %f' % wm.orient.roll
        print 'pitch = %f' % wm.orient.pitch
        print 'yaw   = %f' % wm.orient.yaw

    if wiiuse.using_ir(wm):
        for i in range(4):
            if wm.ir.dot[i].visible:
                print 'IR source %i: (%u, %u)' % (i, wm.ir.dot[i].x, wm.ir.dot[i].y)
        print 'IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y)
        print 'IR z distance: %f' % wm.ir.z

    if wm.exp.type == wiiuse.EXP_NUNCHUK:
        nc = wm.exp.u.nunchuk

        for name,b in wiiuse.nunchuk_button.items():
            if wiiuse.is_pressed(nc, b):
                print 'Nunchuk: %s is pressed' % name

        print 'nunchuk roll  = %f' % nc.orient.roll
        print 'nunchuk pitch = %f' % nc.orient.pitch
        print 'nunchuk yaw   = %f' % nc.orient.yaw
        print 'nunchuk joystick angle:     %f' % nc.js.ang
        print 'nunchuk joystick magnitude: %f' % nc.js.mag
Example #8
0
def handle_event(wmp, i, mapping_keys):
    wm = wmp[0]
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                if name == "Home":
                    return True
                elif mapping_keys.has_key(
                        str(i)) and mapping_keys[str(i)].has_key(name):
                    print "click", i, name, 'pressed'
                    pyautogui.click(mapping_keys[str(i)][name])
                else:
                    print "fail", i, name, 'pressed'
Example #9
0
		
		

    
    if wiiuse.using_ir(wm):
        for i in range(4):
            if wm.ir.dot[i].visible:
                print 'IR source %i: (%u, %u)' % (i, wm.ir.dot[i].x, wm.ir.dot[i].y)
        print 'IR cursor: (%u, %u)' % (wm.ir.x, wm.ir.y)
        print 'IR z distance: %f' % wm.ir.z

    if wm.exp.type == wiiuse.EXP_NUNCHUK:
        nc = wm.exp.u.nunchuk
        
        for name,b in wiiuse.nunchuk_button.items():
            if wiiuse.is_pressed(nc, b):
                print 'Nunchuk: %s is pressed' % name

        print 'nunchuk roll  = %f' % nc.orient.roll
        print 'nunchuk pitch = %f' % nc.orient.pitch
        print 'nunchuk yaw   = %f' % nc.orient.yaw
        print 'nunchuk joystick angle:     %f' % nc.js.ang
        print 'nunchuk joystick magnitude: %f' % nc.js.mag


def handle_ctrl_status(wmp, attachment, speaker, ir, led, battery_level):
    wm = wmp[0]
    print '--- Controller Status [wiimote id %i] ---' % wm.unid
    print 'attachment', attachment
    print 'speaker', speaker
    print 'ir', ir
Example #10
0
def handle_event(wmp):
    wm = wmp[0]
    if wm.btns:
        for name, b in wiiuse.button.items():
            if wiiuse.is_pressed(wm, b):
                return name