Пример #1
0
def main():
    wi = Wiimote()

    def cb_A():
        print("RELEASED A !")

    wi.on(BTN_A, RELEASED, cb_A)

    import time
    while True:
        # connect the wiimote
        if not wi.connected():
            try:
                print("connecting...")
                wi.connect()
                time.sleep(0.4)
                print("connected")
            except WiimoteError:
                print("connection fail")
                time.sleep(0.2)
        else:
            time.sleep(0.4)

    exit = False
    while not exit:
        c = sys.stdin.read(1)
        if c == "s":
            print wi._wm.state
        elif c == "a":
            print wi.is_pressed(BTN_A)
        exit = c == "x"
    wi.close()
Пример #2
0
def main():
    wi = Wiimote()

    def cb_A():
        print("RELEASED A !")
    wi.on(BTN_A, RELEASED, cb_A)

    import time
    while True:
        # connect the wiimote
        if not wi.connected():
            try:
                print("connecting...")
                wi.connect()
                time.sleep(0.4)
                print("connected")
            except WiimoteError:
                print("connection fail")
                time.sleep(0.2)
        else:
            time.sleep(0.4)

    exit = False
    while not exit:
        c = sys.stdin.read(1)
        if c == "s":
            print wi._wm.state
        elif c == "a":
            print wi.is_pressed(BTN_A)
        exit = c == "x"
    wi.close()