pickler rick

master
Chloe Fontenot 🏳️‍⚧️ 2020-06-03 16:28:03 +07:00
parent 795d8d21d1
commit 5f666078ee
2 changed files with 8 additions and 9 deletions

@ -12,10 +12,10 @@ 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')
#Decode Sever message
unpickler = pickle.Unpickler(from_server)
while True:
from_server = client.makefile(mode='rb')
#Decode Sever message
unpickler = pickle.Unpickler(from_server)
decodedServerData = unpickler.load()
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

@ -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'}
def sendData():
#Pickle for transmittion
#print(encodedControllerData)
pickler.dump(controllerDataDict)
file.flush()
pickler.dump(controllerDataDict)
#Create Socket
conn = socket.create_server((ip, port))
socket = socket.create_server((ip, port))
#Create pickler :D
file = conn.makefile(mode='wb')
file = socket.makefile(mode='wb')
pickler = pickle.Pickler(file)
#Wait for connections before continuing
print("Waiting for connection...")
conn.accept()
socket.accept()
#print(colored('Connected by', 'red'), addr)
print(controllerDataDict)
with conn:
with socket:
while True:
events = get_gamepad()
for event in events: