Data is transfered, but client no longer updates...
This commit is contained in:
parent
5f666078ee
commit
613799f536
@ -12,9 +12,9 @@ MyVirtual = pyxinput.vController()
|
||||
# Connect to Server
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect((ip, port))
|
||||
from_server = client.makefile(mode='rb')
|
||||
file = client.makefile(mode='rb')
|
||||
#Decode Sever message
|
||||
unpickler = pickle.Unpickler(from_server)
|
||||
unpickler = pickle.Unpickler(file)
|
||||
while True:
|
||||
decodedServerData = unpickler.load()
|
||||
print("Raw Data:", decodedServerData)
|
||||
|
22
Server.py
22
Server.py
@ -6,6 +6,7 @@ import threading
|
||||
import socket
|
||||
from termcolor import colored
|
||||
import pickle
|
||||
import re
|
||||
# Define ip/port to use
|
||||
ip = "192.168.122.1"
|
||||
port = 2222
|
||||
@ -20,20 +21,25 @@ controllerDataDict = {'AxisLx': 0, 'AxisLy': 0, 'AxisRx': 0, 'AxisRy': 0, 'BtnBa
|
||||
lookup_table = {'ABS_X': 'AxisLx', 'ABS_Y': 'AxisLy', 'ABS_RX': 'AxisRx', 'ABS_RY': 'AxisRy', 'BTN_SELECT': 'BtnBack', 'BTN_START': 'BtnStart', 'BTN_SOUTH': 'BtnA', 'BTN_EAST': 'BtnB', 'BTN_NORTH': 'BtnX', 'BTN_WEST': 'BtnY', 'BTN_THUMBL': 'BtnThumbL', 'BTN_THUMBR': 'BtnThumbR', 'BTN_TL': 'BtnShoulderL', 'BTN_TR': 'BtnShoulderR', 'ABS_Z': 'TriggerL', 'ABS_RZ': 'TriggerR'}
|
||||
def sendData():
|
||||
#Pickle for transmittion
|
||||
file.flush()
|
||||
pickler.dump(controllerDataDict)
|
||||
file.flush()
|
||||
#Create Socket
|
||||
socket = socket.create_server((ip, port))
|
||||
#Create pickler :D
|
||||
file = socket.makefile(mode='wb')
|
||||
pickler = pickle.Pickler(file)
|
||||
#Wait for connections before continuing
|
||||
print("Waiting for connection...")
|
||||
socket.accept()
|
||||
#print(colored('Connected by', 'red'), addr)
|
||||
connection, _ = socket.accept()
|
||||
#Create pickler :D
|
||||
file = connection.makefile(mode='wb')
|
||||
pickler = pickle.Pickler(file)
|
||||
file.flush()
|
||||
print(connection)
|
||||
print(type(connection))
|
||||
#Immutiple socket? I don't think so...
|
||||
iwantThatRaddr = re.findall(r"'(?<=raddr=\(')\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'", str(connection))
|
||||
print(iwantThatRaddr)
|
||||
print(colored('Connected by', 'red'), iwantThatRaddr[0])
|
||||
print(controllerDataDict)
|
||||
with socket:
|
||||
while True:
|
||||
while True:
|
||||
events = get_gamepad()
|
||||
for event in events:
|
||||
#controllerDataTuple = event.ev_type, event.code, event.state
|
||||
|
Loading…
Reference in New Issue
Block a user