2020-06-02 18:10:07 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
import socket
|
|
|
|
import threading
|
2020-06-03 01:07:28 -05:00
|
|
|
#import pyxinput
|
2020-06-02 22:11:32 -05:00
|
|
|
from time import sleep
|
2020-06-03 01:07:28 -05:00
|
|
|
import pickle
|
2020-06-02 18:10:07 -05:00
|
|
|
# Define server ip and port
|
2020-06-02 22:11:32 -05:00
|
|
|
ip = '192.168.122.1'
|
2020-06-02 18:10:07 -05:00
|
|
|
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)
|
|
|
|
#Decode Sever message
|
2020-06-03 01:07:28 -05:00
|
|
|
decodedServerData = pickle.loads(from_server)
|
2020-06-02 22:11:32 -05:00
|
|
|
print("Raw Data:", decodedServerData)
|
2020-06-03 01:07:28 -05:00
|
|
|
MyVirtual.set_value(decodedServerData)
|
2020-06-02 22:11:32 -05:00
|
|
|
def virtualController():
|
|
|
|
MyVirtual = pyxinput.vController()
|
2020-06-03 01:07:28 -05:00
|
|
|
#Set percent to false so values match the raw data from the server
|
|
|
|
# MyVirtual.percent = False
|
2020-06-02 22:11:32 -05:00
|
|
|
MyRead = pyxinput.rController(1)
|
|
|
|
print(MyRead.gamepad)
|
2020-06-03 01:07:28 -05:00
|
|
|
'''
|
2020-06-02 18:10:07 -05:00
|
|
|
while True:
|
2020-06-02 22:11:32 -05:00
|
|
|
#global decodedServerData
|
|
|
|
# Init virtual XInput Controller
|
2020-06-03 01:07:28 -05:00
|
|
|
|
|
|
|
MyVirtual.set_value('AxisLy', 0)
|
|
|
|
|
|
|
|
'''
|
2020-06-02 18:10:07 -05:00
|
|
|
# Execute all functions as threads
|
|
|
|
if __name__ == "__main__":
|
|
|
|
#Create Threads
|
|
|
|
t1 = threading.Thread(target=recvData, args=(ip, port))
|
2020-06-03 01:07:28 -05:00
|
|
|
#t2 = threading.Thread(target=virtualController, args=())
|
|
|
|
t1.start()
|
|
|
|
#t2.start()
|