Пример #1
0
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()

    ##    osc.createListener() # this defaults to port 9001 as well
    osc.listen('127.0.0.1', 40001)

    # bind addresses to functions -> printStuff() function will be triggered everytime a
    # "/test" labeled message arrives
    osc.bind(update, "/tuio/Get")

    import time  # in this example we will have a small delay in the while loop

    print ' ready to receive and send osc messages ... FROM SERVER', 40001

    while 1:
        #osc.sendMsg("/test", [], "127.0.0.1", 4001) # send normal msg to a specific ip and port

        time.sleep(
            0.5
        )  # you don't need this, but otherwise we're sending as fast as possible.

    osc.dontListen()  # finally close the connection bfore exiting or program
Пример #2
0
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()
    
##    osc.createListener() # this defaults to port 9001 as well
    osc.listen('127.0.0.1', 9001)

    # bind addresses to functions -> printStuff() function will be triggered everytime a
    # "/test" labeled message arrives
    osc.bind(printStuff, "/test")

    import time # in this example we will have a small delay in the while loop

    print 'ready to receive and send osc messages ...'
    
    while 1:
##        osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port
        osc.sendMsg("/test", [444]) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 
        # create and send a bundle
        bundle = osc.createBundle()
        osc.appendToBundle(bundle, "/test/bndlprt1", [1, 2, 3]) # 1st message appent to bundle
        osc.appendToBundle(bundle, "/test/bndlprt2", [4, 5, 6]) # 2nd message appent to bundle
##        osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port

        osc.sendBundle(bundle) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 
        #osc.getOSC(inSocket) # listen to incomming OSC in this socket
        time.sleep(0.5) # you don't need this, but otherwise we're sending as fast as possible.
        

    osc.dontListen() # finally close the connection bfore exiting or program
Пример #3
0
Файл: tuio.py Проект: azoon/pymt
 def start(self):
     '''Start the tuio provider'''
     osc.init()
     self.oscid = osc.listen(self.ip, self.port)
     for oscpath in TuioTouchProvider.__handlers__:
         self.touches[oscpath] = {}
         osc.bind(self._osc_tuio_cb, oscpath)
Пример #4
0
def myTest():
    osc.init()
    osc.listen('192.168.11.15', 8000)  #local IP; listen on port 8000
    osc.bind(recvMsg, "/echo")
    # enable reporting of all adc channels
    osc.sendMsg("/echo", [0], '192.168.11.200', 8888)  # Arduino's IP and Port
    while 1:
        time.sleep(0.1)
Пример #5
0
def myTest():
	osc.init()
	osc.listen('192.168.11.15', 8000) #local IP; listen on port 8000
	osc.bind(recvMsg,"/echo")
	# enable reporting of all adc channels
	osc.sendMsg("/echo",[0],'192.168.11.200',8888) # Arduino's IP and Port
	while 1:
		time.sleep(0.1)
Пример #6
0
 def __init__(self, path, host=LOCALHOST, port=44001):
     """ Creates a listener for data broadcast from Pd.
         PDCallback.__call__() is called from PD.get().
     """
     osc.bind(self, path)
     self._path   = path
     self._data   = []
     self._socket = socket(host, port)
     self._socket.connections += 1
Пример #7
0
 def __init__(self, path, host=LOCALHOST, port=44001):
     """ Creates a listener for data broadcast from Pd.
         PDCallback.__call__() is called from PD.get().
     """
     osc.bind(self, path)
     self._path = path
     self._data = []
     self._socket = socket(host, port)
     self._socket.connections += 1
Пример #8
0
def main():
	osc.init()
	osc.listen("127.0.0.1",9001)
	osc.bind(heartBeat, "/beat")
	while(1):
		global last_beat
		time_diff = (time.clock() - last_beat)
		print time_diff;
		time.sleep(0.1);
    def init_osc(self):
        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=self.receive_port)

        osc.bind(self.oscid, self.receive_osc_message, b'/stdout')
        osc.bind(self.oscid, self.receive_osc_message, b'/stderr')
        osc.bind(self.oscid, self.receive_osc_message, b'/interpreter')
        osc.bind(self.oscid, self.receive_osc_message, b'/pong')
        osc.bind(self.oscid, self.receive_osc_message, b'/requestinput')
Пример #10
0
	def listen(self, prefix = "/global", port = 9900):
		if not PStaticGlobal.listening:
			import osc

			osc.init()
			osc.listen(port = port)
			PStaticGlobal.listening = True

		self.prefix = prefix
		osc.bind(self.recv, prefix)
Пример #11
0
 def start(self):
     '''Start the tuio provider'''
     self.oscid = osc.listen(self.ip, self.port)
     
     osc.bind(self.oscid, self._osc_tuio_cb, '')
     self.touches[''] = {}
     
     for oscpath in TuioListener.__handlers__:
         self.touches[oscpath] = {}
         osc.bind(self.oscid, self._osc_tuio_cb, oscpath)
Пример #12
0
    def __init__(self, default=0, address="/value", port=9900):
        if not PStaticViaOSC.initialised:
            import osc

            osc.init()
            osc.listen(port=port)

        self.value = default
        self.address = address
        osc.bind(self.recv, address)
Пример #13
0
	def __init__(self, default = 0, address = "/value", port = 9900):
		if not PStaticViaOSC.initialised:
			import osc

			osc.init()
			osc.listen(port = port)

		self.value = default
		self.address = address
		osc.bind(self.recv, address)
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()
    osc.bind(printStuff, "/gainSlider")
    inSocket = osc.createListener("127.0.0.1", 9001)

    import time

    while 1:
        osc.getOSC(inSocket)

    osc.dontListen()
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()
    osc.bind(printStuff, "/gainSlider")
    inSocket = osc.createListener("127.0.0.1", 9001)

    import time

    while 1:
        osc.getOSC(inSocket)

    osc.dontListen()
Пример #16
0
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()

    inSocket = osc.createListener('127.0.0.1',
                                  9001)  # in this case just using one socket
    ##    inSocket = osc.createListener() # this defaults to port 9001 as well

    # bind addresses to functions -> printStuff() function will be triggered everytime a
    # "/test" labeled message arrives
    osc.bind(printStuff, "/test")

    import time  # in this example we will have a small delay in the while loop

    print 'ready to receive and send osc messages ...'

    while 1:
        ##        osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port
        osc.sendMsg("/test", [
            444
        ])  # !! it sends by default to localhost ip "127.0.0.1" and port 9000

        # create and send a bundle
        bundle = osc.createBundle()
        osc.appendToBundle(bundle, "/test/bndlprt1",
                           [1, 2, 3])  # 1st message appent to bundle
        osc.appendToBundle(bundle, "/test/bndlprt2",
                           [4, 5, 6])  # 2nd message appent to bundle
        ##        osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port

        osc.sendBundle(
            bundle
        )  # !! it sends by default to localhost ip "127.0.0.1" and port 9000

        osc.getOSC(inSocket)  # listen to incomming OSC in this socket

        time.sleep(
            0.5
        )  # you don't need this, but otherwise we're sending as fast as possible.
Пример #17
0
 def __init__(self, address='127.0.0.1', port=9000, prefix='/wii/1'):
     if osc.outSocket == 0:  # Only init once.
         osc.init()
     self.address = address
     self.port = port
     self.listener = osc.createListener(address, port)
     osc.bind(self._wii_pry, "/wii/1/accel/pry")
     osc.bind(self._wii_xyz, "/wii/1/accel/xyz")
     osc.bind(self._wii_a, "/wii/1/button/A")
     osc.bind(self._wii_b, "/wii/1/button/B")
     self.prefix = prefix
     self.pitch = 0.0
     self.roll = 0.0
     self.yaw = 0.0
     self.accel = 0.0
     self.x = 0.0
     self.y = 0.0
     self.z = 0.0
     self.a = False
     self.b = False
Пример #18
0
 def __init__(self, address='127.0.0.1', port=9000, prefix='/wii/1'):
     if osc.outSocket == 0: # Only init once.
         osc.init()
     self.address = address
     self.port = port
     self.listener = osc.createListener(address, port)
     osc.bind(self._wii_pry, "/wii/1/accel/pry")
     osc.bind(self._wii_xyz, "/wii/1/accel/xyz")
     osc.bind(self._wii_a, "/wii/1/button/A")
     osc.bind(self._wii_b, "/wii/1/button/B")
     self.prefix = prefix
     self.pitch = 0.0
     self.roll = 0.0
     self.yaw = 0.0
     self.accel = 0.0
     self.x = 0.0
     self.y = 0.0
     self.z = 0.0
     self.a = False
     self.b = False
Пример #19
0
    def __init__(self, host, port):
        self.client = {}
        self.host = host
        self.port = port
        osc.init()

        ##    osc.createListener() # this defaults to port 9001 as well

        osc.listen(self.host, self.port)

        # bind addresses to functions -> printStuff() function will be triggered everytime a
        # "/test" labeled message arrives
        osc.bind(self.update, "/tuio/Set")
        osc.bind(self.sendClients, "/tuio/Get")
        osc.bind(self.send, "/tuio/msg")
Пример #20
0
def main():


    global mainObj
    
    global sendIP
    global sendPort
    
    configFile = open('OSCadr.cfg', 'r')
    for line in configFile:
        line = line.split()
        if line[0] == "sendPort":
            sendPort = int(line[1])
        if line[0] == "sendIP":
            sendIP = line[1]
        if line[0] == "listenIP":
            listenIP = line[1]
        if line[0] == "listenPort":
            listenPort = int(line[1])

    pygame.init()

    osc.init()
    osc.listen(listenIP, listenPort)

    mainObj = Globject()
    
    clock = pygame.time.Clock()
    
    osc.bind(mainObj.curve.editCurve, '/curve/gui_curve/edit') 
    osc.bind(mainObj.curve.editMidi, '/curve/midi_params')
    osc.bind(mainObj.curve.editLengths, '/curve/curve_lengths')
    osc.bind(mainObj.curve.editPlayStates, '/curve/play_states')

    osc.bind(mainObj.grid16.editGrid, '/grid16/pattern_grid/edit')
    osc.bind(mainObj.grid16.editMidi, '/grid16/midi_params')
    osc.bind(mainObj.grid16.editPatternSeqLength, '/grid16/pattern_seq/length')
    osc.bind(mainObj.grid16.editPatternSeq, '/grid16/pattern_seq')

    osc.bind(mainObj.grid32.editGrid, '/grid32/pattern_grid/edit')
    osc.bind(mainObj.grid32.editMidi, '/grid32/midi_params')
    osc.bind(mainObj.grid32.editPatternSeqLength, '/grid32/pattern_seq/length')
    osc.bind(mainObj.grid32.editPatternSeq, '/grid32/pattern_seq')
   
    osc.bind(mainObj.menu.trackInfo, '/main/track_info')

    osc.bind(mainObj.menu.seqStepNumber, '/main/stepnumber')

    loop = True
    while loop:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == QUIT:
                loop = False
            if event.type == pygame.MOUSEBUTTONUP :
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('up',mousePosition)
                
            if event.type == pygame.MOUSEBUTTONDOWN :
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('down',mousePosition)
                
            if event.type == pygame.MOUSEMOTION :
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('drag',mousePosition)
        
        mainObj.drawStuff()


    osc.dontListen()
    pygame.quit()
    sys.exit()
Пример #21
0
def main(host='0.0.0.0', port=8000, address='/update'):
    oscid = listen(host, port)
    bind(oscid, dump_data, address)
    while True:
        readQueue(oscid)
Пример #22
0
 def __init__(self,  ip='127.0.0.1', port=3333):
         osc.init()
         osc.listen(ip, port)
         osc.bind(self.osc_2dcur_Callback, "/tuio/2Dcur")
         osc.bind(self.osc_2dobj_Callback, "/tuio/2Dobj")
Пример #23
0
 def bind_osc(self, osc):
     print "Binding Mario functions"
     osc.bind(self.on_coin, "/mario/coin")
     osc.bind(self.on_flag, "/mario/flag")
     osc.bind(self.on_speed, "/mario/speed")
     osc.bind(self.on_sky, "/mario/sky")
     osc.bind(self.on_die, "/mario/die")
     osc.bind(self.on_enemy, "/mario/enemy")
Пример #24
0
def python_fu_receiveosc( inImage, inDrawable, netAddr="127.0.0.1",
                       port=57130):
    global receiving,newSpecs,pic
    inImage.disable_undo()
    gimp.progress_init("receiving...")
    receiving = 1
    startingTime = time.time()
    # get right port for sc
    if shelf.has_key('oscnetaddr'):
        sendAddr = shelf['oscnetaddr'][0]
    else:
        sendAddr = "127.0.0.1"
    if shelf.has_key('oscport'):
        sendPort = shelf['oscport'][0]
    else:
        sendPort = 57120
    ## init osc listeners
    osc.init()
    osc.listen(netAddr, port)
    osc.bind(python_fu_receiveosc_storeSpecs, "/gimp/spec")
    osc.bind(python_fu_receiveosc_receiveImage, "/gimp/pic")
    osc.bind(python_fu_receiveosc_displayImage, "/gimp/end")
    ## ping sc to send image
    osc.sendMsg("/gimp/ping", [-1], sendAddr, sendPort)
    ## loop until done
    while receiving:
        #print("ping", len(pic))
        if receiving == 3:
            time.sleep(1)
            gimp.progress_update(96)
            newPic = []
            newLayer = gimp.Layer(inImage,
                                  "fromOSC",
                                  newSpecs[0],
                                  newSpecs[1],
                                  RGB_IMAGE, 100, NORMAL_MODE)
            inImage.add_layer(newLayer, 0)
            pdb.gimp_edit_fill(newLayer, BACKGROUND_FILL)
            newPic = newLayer.get_pixel_rgn(0,0,
                                            newSpecs[0],newSpecs[1], True)
            #newPic = pic
            print(len(pic))
            ## remove all brightness values
            ## convert from int to chr-values
            ## if newSpecs[2] == 4:
            ##     for index in range(len(pic)):
            ##         if index%4 == 3:
            ##             pic[index] = 255
            ##         elif index == 0:
            ##             picAsStr = chr(pic[index])
            ##         else:
            ##             picAsStr = picAsStr + chr(pic[index])
            ## set the pixel region to pic
            #print(pic)
            newPic[0:newSpecs[0],0:newSpecs[1]] = pic
            newLayer.flush()
            newLayer.update(0,0,newSpecs[0],newSpecs[1])
            print("flushed & updated")
            receiving = 0
        elif time.time() - startingTime > 20:
            print("time's up")
            receiving = 0
        else:
            gimp.progress_update(int(18 * (time.time() - startingTime)))
            #time.sleep(0.2)
    osc.dontListen()
    inImage.enable_undo()
    gimp.displays_flush()
    gimp.extension_ack()
Пример #25
0
def main():
	osc.init()
	osc.listen("127.0.0.1",9001)
	osc.bind(heartBeat, "/beat")
Пример #26
0
def shoot_end_handler(*msg):
    # ipAddress, x, y
    try:
        ipAddress = msg[0][2]
        x = msg[0][3]
        y = msg[0][4]
        global current_state
        current_state.shoot_end_handler(ipAddress, x, y)
    except Exception, e:
        print e

def add_player(ipAddress):
    players[ipAddress] = Player(ipAddress, random.randint(0, 639), random.randint(0, 479), 0, 0)

def player_exists(ipAddress):
    return players.has_key(ipAddress)

if __name__ == "__main__":
    setup()
    osc.init()
    osc.listen('127.0.0.1', 9002)
    osc.bind(move_start_handler, '/movestart')
    osc.bind(move_end_handler, '/moveend')
    osc.bind(shoot_start_handler, '/shootstart')
    osc.bind(shoot_end_handler, '/shootend')
    pyglet.clock.schedule(update)
    current_state.enter()
    pyglet.app.run()


Пример #27
0
    def __init__(self):
        osc.init()
        oscid = osc.listen(ipAddr="0.0.0.0", port=3000)
        # Receive start/stop message
        osc.bind(oscid, self.startquit, "/start")
        self.can_start = False
        # Cycle info?
        osc.bind(oscid, self.send_hello, "/hello")
        # Send status of simulation
        osc.bind(oscid, self.simulation_status_send, "/simu-status_ask")
        # Receive simulation speed
        osc.bind(oscid, self.simuspeed, "/simu-speed")

        # Init actual model
        self.sim = Simulation()
        self.sim_speed = 1
        self.cycle = 0
        self.max_cycles = self.sim.model.parameters.get("max_cycles")
        print("Max cycles: {}".format(self.max_cycles))

        # Make statistics instance
        # Only for testing writing to CSV
        self.statistics = Statistics()

        # Send server is running
        self.simulation_status_send()

        # Code always running / waiting for instructions
        while True:
            # Try so that a server stopped message can be send
            try:
                if self.cycle % 1000 == 0 or self.cycle == 0:
                    print("Current cycle: {}".format(self.cycle))
                osc.readQueue(oscid)
                # Only run simulation when started and max cycles not reached
                # print("Start: {}, Max Cycles: {}".format(self.can_start, self.max_cycles))
                if self.can_start == True and self.cycle < self.max_cycles:
                    # Reset model
                    if self.cycle == 0:
                        print("\nNew simulation detected!!!\n")
                        print("\nReset model")
                        self.sim.model.reset()
                        self.statistics.driver_update(self.sim.model.drivers)
                        # print("\nCSV filename function")
                        self.statistics.create_csv(self.sim.model.parameters.param)

                    # Make statistics instance
                    # print "LIST PRINTED in LOOP\n"

                    # Agent stuff
                    self.sim.run()

                    # Send agent positions
                    self.positions()

                    # Statistics stuff
                    self.do_statistics()

                    # Hello world test
                    self.cycle += 1
                    self.send_hello()

                sleep(self.sim_speed)

            # Send message server stopped
            except:
                traceback.print_exc()  # Please tell me what is wrong then...
                self.send_server_stop()
                exit()
Пример #28
0
 def start(self):
     '''Start the tuio provider'''
     self.oscid = osc.listen(self.ip, self.port)
     for oscpath in TuioMotionEventProvider.__handlers__:
         self.touches[oscpath] = {}
         osc.bind(self.oscid, self._osc_tuio_cb, oscpath)
Пример #29
0
to = os.environ.get('PYTHON_SERVICE_ARGUMENT', '')
for entry in to.split(':'):
    if entry.startswith('throttle_output='):
        throttle_output = False if entry[16:] == '0' else True
    if entry.startswith('use_thread='):
        use_thread = False if entry[11:] == '0' else True
    if entry.startswith('send_port='):
        send_port = int(entry.split('=')[-1])
    if entry.startswith('receive_port='):
        receive_port = int(entry.split('=')[-1])


osc.init()
oscid = osc.listen(ipAddr='127.0.0.1', port=receive_port)
osc.bind(oscid, receive_message, b'/interpret')
osc.bind(oscid, receive_message, b'/ping')
osc.bind(oscid, receive_message, b'/sigint')
osc.bind(oscid, receive_message, b'/throttling')
osc.bind(oscid, receive_message, b'/userinput')
osc.bind(oscid, receive_message, b'/execfile')

sys.stdout = OscOut(b'/stdout', send_port)
sys.stderr = OscOut(b'/stderr', send_port)

real_print('got this far4')

while True:
    osc.readQueue(oscid)
    time.sleep(.1)
Пример #30
0

def ping(*args):
    osc.sendMsg(
        '/message',
        [''.join(sample(ascii_letters, randint(10, 20))), ],
        port=3002)


def printy(mesg, *args):
    print(mesg)
    osc.sendMsg(
        '/message',
        [mesg[2], ],
        port=3002)


def send_date():
    osc.sendMsg('/date', [asctime(localtime()), ], port=3002)


if __name__ == '__main__':
    osc.init()
    oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
    osc.bind(oscid, ping, '/ping')
    osc.bind(oscid, printy, '/printy')
    while True:
        osc.readQueue(oscid)
        send_date()
        sleep(.1)
Пример #31
0
print('got this far')

to = os.environ.get('PYTHON_SERVICE_ARGUMENT', '')
for entry in to.split(':'):
    if entry.startswith('throttle_output='):
        throttle_output = False if entry[16:] == '0' else True
    if entry.startswith('use_thread='):
        use_thread = False if entry[11:] == '0' else True
    if entry.startswith('send_port='):
        send_port = int(entry.split('=')[-1])
    if entry.startswith('receive_port='):
        receive_port = int(entry.split('=')[-1])

osc.init()
oscid = osc.listen(ipAddr='127.0.0.1', port=receive_port)
osc.bind(oscid, receive_message, b'/interpret')
osc.bind(oscid, receive_message, b'/ping')
osc.bind(oscid, receive_message, b'/sigint')
osc.bind(oscid, receive_message, b'/throttling')
osc.bind(oscid, receive_message, b'/userinput')
osc.bind(oscid, receive_message, b'/execfile')

sys.stdout = OscOut(b'/stdout', send_port)
sys.stderr = OscOut(b'/stderr', send_port)

real_print('got this far4')

while True:
    osc.readQueue(oscid)
    time.sleep(.1)
        if not finger in fingers:
            fingers[finger] = [0,0]
# msg[0][4] should be X, but seems to be Y.  why?
        fingers[finger][X] = msg[0][4]
# msg[0]5] should be Y, but seems to be X. why ? and flipped!?!?!?
        fingers[finger][Y] = msg[0][5]
#        print 'set', finger, fingers[finger]
    elif msg[0][2] == 'alive':
        # go through fingerState and mark the living fingers
        livingFingers = msg[0][3:]
#        print 'alive', livingFingers

osc.init()
#osc.listen('192.168.1.7',9001)
osc.listen('127.0.0.1', 3333)
osc.bind ( tuioCursorHandler, "/tuio/2Dcur" )

###########################################
# game objects
#

class Bullet:
    def __init__(self, pos=(0,0), vel=(0,0)):
        x,y = pos
        self.position = numpy.array([float(x),float(y)])
        x,y = vel
        self.velocity = numpy.array([float(x),float(y)])

    def update(self):
        global targets
        global hitTarget
Пример #33
0
def main():

    global mainObj

    global sendIP
    global sendPort

    configFile = open('OSCadr.cfg', 'r')
    for line in configFile:
        line = line.split()
        if line[0] == "sendPort":
            sendPort = int(line[1])
        if line[0] == "sendIP":
            sendIP = line[1]
        if line[0] == "listenIP":
            listenIP = line[1]
        if line[0] == "listenPort":
            listenPort = int(line[1])

    pygame.init()

    osc.init()
    osc.listen(listenIP, listenPort)

    mainObj = Globject()

    clock = pygame.time.Clock()

    osc.bind(mainObj.curve.editCurve, '/curve/gui_curve/edit')
    osc.bind(mainObj.curve.editMidi, '/curve/midi_params')
    osc.bind(mainObj.curve.editLengths, '/curve/curve_lengths')
    osc.bind(mainObj.curve.editPlayStates, '/curve/play_states')

    osc.bind(mainObj.grid16.editGrid, '/grid16/pattern_grid/edit')
    osc.bind(mainObj.grid16.editMidi, '/grid16/midi_params')
    osc.bind(mainObj.grid16.editPatternSeqLength, '/grid16/pattern_seq/length')
    osc.bind(mainObj.grid16.editPatternSeq, '/grid16/pattern_seq')

    osc.bind(mainObj.grid32.editGrid, '/grid32/pattern_grid/edit')
    osc.bind(mainObj.grid32.editMidi, '/grid32/midi_params')
    osc.bind(mainObj.grid32.editPatternSeqLength, '/grid32/pattern_seq/length')
    osc.bind(mainObj.grid32.editPatternSeq, '/grid32/pattern_seq')

    osc.bind(mainObj.menu.trackInfo, '/main/track_info')

    osc.bind(mainObj.menu.seqStepNumber, '/main/stepnumber')

    loop = True
    while loop:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == QUIT:
                loop = False
            if event.type == pygame.MOUSEBUTTONUP:
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('up', mousePosition)

            if event.type == pygame.MOUSEBUTTONDOWN:
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('down', mousePosition)

            if event.type == pygame.MOUSEMOTION:
                mousePosition = pygame.mouse.get_pos()
                mainObj.modeObject.mouseInput('drag', mousePosition)

        mainObj.drawStuff()

    osc.dontListen()
    pygame.quit()
    sys.exit()
Пример #34
0
    try:
        ipAddress = msg[0][2]
        x = msg[0][3]
        y = msg[0][4]
        global current_state
        current_state.shoot_end_handler(ipAddress, x, y)
    except Exception, e:
        print e


def add_player(ipAddress):
    players[ipAddress] = Player(ipAddress, random.randint(0, 639),
                                random.randint(0, 479), 0, 0)


def player_exists(ipAddress):
    return players.has_key(ipAddress)


if __name__ == "__main__":
    setup()
    osc.init()
    osc.listen('127.0.0.1', 9002)
    osc.bind(move_start_handler, '/movestart')
    osc.bind(move_end_handler, '/moveend')
    osc.bind(shoot_start_handler, '/shootstart')
    osc.bind(shoot_end_handler, '/shootend')
    pyglet.clock.schedule(update)
    current_state.enter()
    pyglet.app.run()
Пример #35
0
 def bind_osc(self, osc):
     print "Binding Tetris Functions"
     osc.bind(self.on_line, "/tetris/line")
     osc.bind(self.on_level, "/tetris/level")
     osc.bind(self.on_piece_down, "/tetris/piece_down")