def handle_command(self, d):
""" Handles commands sent from web client
:param d: command object
"""
if d["command"] == "init":
json_data = self.screen_to_json()
web_socket.send_message(json_data)
elif d["command"] == "mouse":
a = {}
a["pos"] = (d["x"], d["y"])
a["button"] = d["b"]
event = None
if d["d"] == 0:
event = pygame.event.Event(pygame.MOUSEBUTTONDOWN, **a)
elif d["d"] == 1:
event = pygame.event.Event(pygame.MOUSEBUTTONUP, **a)
elif d["d"] == 2:
event = pygame.event.Event(pygame.MOUSEMOTION, **a)
event.p = True
event.source = "browser"
thread = Thread(target=pygame.event.post, args=[event])
thread.start()
评论列表
文章目录