From e108338251443a6e276303b0e0c711cfbf900e89 Mon Sep 17 00:00:00 2001 From: Ketan Date: Fri, 17 Apr 2026 21:47:42 -0400 Subject: [PATCH] initial commit --- pc.py | 25 +++++++++++++++++++++++++ terra.py | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pc.py create mode 100644 terra.py diff --git a/pc.py b/pc.py new file mode 100644 index 0000000..ac1c360 --- /dev/null +++ b/pc.py @@ -0,0 +1,25 @@ +import socket +from pynput.mouse import Controller + +mouse = Controller() + +HOST = '0.0.0.0' +PORT = 2025 + +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +sock.bind((HOST, PORT)) + +print(f"listening on {HOST}:{PORT}") + +try: + while True: + data, addr = sock.recvfrom(1024) + x_str, y_str = data.decode().split(',') + x = float(x_str) + y = float(y_str) + mouse.position = (x, y) + print(f"Moved mouse to: X={x}, Y={y}") +except KeyboardInterrupt: + print("UDP server shutting down.") +finally: + sock.close() \ No newline at end of file diff --git a/terra.py b/terra.py new file mode 100644 index 0000000..e559e73 --- /dev/null +++ b/terra.py @@ -0,0 +1,25 @@ +import socket +import time +from pynput.mouse import Controller + +mouse = Controller() +print("PC IP:") +SERVER_IP = input() +PORT = 2025 + +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +try: + last_pos = None + while True: + pos = mouse.position + if pos != last_pos: + message = f"{pos[0]},{pos[1]}" + sock.sendto(message.encode(), (SERVER_IP, PORT)) + print("Sent:", message) + last_pos = pos + time.sleep(0.05) +except KeyboardInterrupt: + print("UDP client stopped.") +finally: + sock.close() \ No newline at end of file