Almost done, although there's a data send collision now
parent
13139912aa
commit
fa6e5d8213
@ -1,44 +1,23 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
#import pyxinput
|
import pyxinput
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import pickle
|
import pickle
|
||||||
# Define server ip and port
|
# Define server ip and port
|
||||||
ip = '192.168.122.1'
|
ip = '192.168.122.1'
|
||||||
port = 2222
|
port = 2222
|
||||||
#Define globals
|
# Create virtual controller
|
||||||
decodedServerData = ""
|
MyVirtual = pyxinput.vController()
|
||||||
def recvData(ip, port):
|
# Connect to Server
|
||||||
global decodedServerData
|
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
# Connect to Server
|
client.connect((ip, port))
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
while True:
|
||||||
#client.setblocking(False)
|
from_server = client.recv(8144)
|
||||||
client.connect((ip, port))
|
#Decode Sever message
|
||||||
while True:
|
decodedServerData = pickle.loads(from_server)
|
||||||
from_server = client.recv(4096)
|
print("Raw Data:", str(decodedServerData))
|
||||||
#Decode Sever message
|
# pyxinput will only accept values one at a time, so we need to apply the itme in the dictionary one by one
|
||||||
decodedServerData = pickle.loads(from_server)
|
for event, state in decodedServerData.items():
|
||||||
print("Raw Data:", decodedServerData)
|
MyVirtual.set_value(event, state)
|
||||||
MyVirtual.set_value(decodedServerData)
|
print('\''+event+'\''+',', state)
|
||||||
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()
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
# pyInputStreaming
|
# pyInputStreaming
|
||||||
Python Scripts to stream controller input from a Linux Host to a Windows 10 virtual machine
|
Python Scripts to stream controller input from a Linux Host to a Windows 10 virtual machine
|
||||||
|
# Dependancies
|
||||||
lol
|
On the server, the following libraries are required:
|
||||||
|
colored
|
||||||
|
inputs
|
||||||
|
On the Client:
|
||||||
|
PYXInput
|
||||||
|
Loading…
Reference in New Issue