Almost done, although there's a data send collision now
parent
13139912aa
commit
fa6e5d8213
@ -1,44 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
import socket
|
||||
import threading
|
||||
#import pyxinput
|
||||
import pyxinput
|
||||
from time import sleep
|
||||
import pickle
|
||||
# Define server ip and port
|
||||
ip = '192.168.122.1'
|
||||
port = 2222
|
||||
#Define globals
|
||||
decodedServerData = ""
|
||||
def recvData(ip, port):
|
||||
global decodedServerData
|
||||
# Connect to Server
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
#client.setblocking(False)
|
||||
client.connect((ip, port))
|
||||
while True:
|
||||
from_server = client.recv(4096)
|
||||
# Create virtual controller
|
||||
MyVirtual = pyxinput.vController()
|
||||
# Connect to Server
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect((ip, port))
|
||||
while True:
|
||||
from_server = client.recv(8144)
|
||||
#Decode Sever message
|
||||
decodedServerData = pickle.loads(from_server)
|
||||
print("Raw Data:", decodedServerData)
|
||||
MyVirtual.set_value(decodedServerData)
|
||||
def virtualController():
|
||||
MyVirtual = pyxinput.vController()
|
||||
#Set percent to false so values match the raw data from the server
|
||||
# MyVirtual.percent = False
|
||||
MyRead = pyxinput.rController(1)
|
||||
print(MyRead.gamepad)
|
||||
'''
|
||||
while True:
|
||||
#global decodedServerData
|
||||
# Init virtual XInput Controller
|
||||
|
||||
MyVirtual.set_value('AxisLy', 0)
|
||||
|
||||
'''
|
||||
# Execute all functions as threads
|
||||
if __name__ == "__main__":
|
||||
#Create Threads
|
||||
t1 = threading.Thread(target=recvData, args=(ip, port))
|
||||
#t2 = threading.Thread(target=virtualController, args=())
|
||||
t1.start()
|
||||
#t2.start()
|
||||
print("Raw Data:", str(decodedServerData))
|
||||
# pyxinput will only accept values one at a time, so we need to apply the itme in the dictionary one by one
|
||||
for event, state in decodedServerData.items():
|
||||
MyVirtual.set_value(event, state)
|
||||
print('\''+event+'\''+',', state)
|
||||
|
@ -1,4 +1,8 @@
|
||||
# pyInputStreaming
|
||||
Python Scripts to stream controller input from a Linux Host to a Windows 10 virtual machine
|
||||
|
||||
lol
|
||||
# Dependancies
|
||||
On the server, the following libraries are required:
|
||||
colored
|
||||
inputs
|
||||
On the Client:
|
||||
PYXInput
|
||||
|
Loading…
Reference in New Issue