pickler rick
This commit is contained in:
parent
795d8d21d1
commit
5f666078ee
@ -12,10 +12,10 @@ MyVirtual = pyxinput.vController()
|
|||||||
# Connect to Server
|
# Connect to Server
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
client.connect((ip, port))
|
client.connect((ip, port))
|
||||||
|
from_server = client.makefile(mode='rb')
|
||||||
|
#Decode Sever message
|
||||||
|
unpickler = pickle.Unpickler(from_server)
|
||||||
while True:
|
while True:
|
||||||
from_server = client.makefile(mode='rb')
|
|
||||||
#Decode Sever message
|
|
||||||
unpickler = pickle.Unpickler(from_server)
|
|
||||||
decodedServerData = unpickler.load()
|
decodedServerData = unpickler.load()
|
||||||
print("Raw Data:", decodedServerData)
|
print("Raw Data:", decodedServerData)
|
||||||
# pyxinput will only accept values one at a time, so we need to apply the itme in the dictionary one by one
|
# pyxinput will only accept values one at a time, so we need to apply the itme in the dictionary one by one
|
||||||
|
11
Server.py
11
Server.py
@ -20,20 +20,19 @@ 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'}
|
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():
|
def sendData():
|
||||||
#Pickle for transmittion
|
#Pickle for transmittion
|
||||||
#print(encodedControllerData)
|
|
||||||
pickler.dump(controllerDataDict)
|
|
||||||
file.flush()
|
file.flush()
|
||||||
|
pickler.dump(controllerDataDict)
|
||||||
#Create Socket
|
#Create Socket
|
||||||
conn = socket.create_server((ip, port))
|
socket = socket.create_server((ip, port))
|
||||||
#Create pickler :D
|
#Create pickler :D
|
||||||
file = conn.makefile(mode='wb')
|
file = socket.makefile(mode='wb')
|
||||||
pickler = pickle.Pickler(file)
|
pickler = pickle.Pickler(file)
|
||||||
#Wait for connections before continuing
|
#Wait for connections before continuing
|
||||||
print("Waiting for connection...")
|
print("Waiting for connection...")
|
||||||
conn.accept()
|
socket.accept()
|
||||||
#print(colored('Connected by', 'red'), addr)
|
#print(colored('Connected by', 'red'), addr)
|
||||||
print(controllerDataDict)
|
print(controllerDataDict)
|
||||||
with conn:
|
with socket:
|
||||||
while True:
|
while True:
|
||||||
events = get_gamepad()
|
events = get_gamepad()
|
||||||
for event in events:
|
for event in events:
|
||||||
|
Loading…
Reference in New Issue
Block a user