Ejemplo n.º 1
0
def sendCommandFromCommandName(name, val=1):
    command = Command()
    command.controller = Command.COMMAND_LINE
    raw = command.raw_command.add()
    raw.name = name
    raw.value = val
    sendCommand(command)
Ejemplo n.º 2
0
def sendCommandFromCommandName(name, val=1):
    command = Command()
    command.controller = Command.COMMAND_LINE
    raw = command.raw_command.add()
    raw.name = name
    raw.value = val
    sendCommand(command)
Ejemplo n.º 3
0
 def serve(self):
     while self.continue_serving:
         try:
             self.conn, addr = self.sock.accept()
             print "Got connection from " + str(addr)
             self.conn.settimeout(SOCKET_TIMEOUT)
             if self.authorizeConnection():
                 while self.continue_serving:  # redundant check here to quit on Ctrl+C
                     try:
                         proto_bin = self.conn.recv(4096)
                     except timeout:
                         continue  # do nothing, the timeout is only set so we can poll for Ctrl+C
                     if not proto_bin:  # successfully recving no data implies conn closed
                         break  # so break out of the conn specific loop to await another conn
                     command = Command()
                     command.ParseFromString(proto_bin)
                     self.last_command = CommandWrapper(command)
                     if (command.HasField('intended_command')
                             and command.intended_command
                             == Command.DISCONNECT):
                         self.conn.close()
             else:
                 self.conn.close()
                 logger.warning("Invalid login attempt from " + str(addr))
         except timeout:
             pass  # this just means an accept has timed out, which is expected
         except Exception, e:
             logger.error("Controls Server error!", error=e)
Ejemplo n.º 4
0
 def sendRawData(self, data):
     command = Command()
     command.controller = Command.PS3_CONTROLLER
     for datum, i in zip(data, range(len(data))):
         rc = command.raw_command.add()
         rc.index = i
         rc.value = datum
     self.sock.send(command.SerializeToString())
Ejemplo n.º 5
0
 def sendRawData(self, data):
     command = Command()
     command.controller = Command.PS3_CONTROLLER
     for datum, i in zip(data, range(len(data))):
         rc = command.raw_command.add()
         rc.index = i
         rc.value = datum
     self.sock.send(command.SerializeToString())
Ejemplo n.º 6
0
def sendCommandFromEventKey(event_key):
    command = Command()
    command.controller = Command.PYGAME
    raw = command.raw_command.add()
    raw.index = event_key
    raw.value = 1
    try:
        raw.name = chr(event_key)
        sendCommand(command)
    except ValueError:
        pass
Ejemplo n.º 7
0
def sendCommandFromEventKey(event_key):
    command = Command()
    command.controller = Command.PYGAME
    raw = command.raw_command.add()
    raw.index = event_key
    raw.value = 1
    try:
        raw.name = chr(event_key)
        sendCommand(command)
    except ValueError:
        pass