added xInput library to client
This commit is contained in:
parent
23c00b6758
commit
9afdf5a4d9
30
Client.py
30
Client.py
@ -2,8 +2,10 @@
|
|||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import re
|
import re
|
||||||
|
import pyxinput
|
||||||
|
from time import sleep
|
||||||
# Define server ip and port
|
# Define server ip and port
|
||||||
ip = '127.0.0.1'
|
ip = '192.168.122.1'
|
||||||
port = 2222
|
port = 2222
|
||||||
#Define globals
|
#Define globals
|
||||||
decodedServerData = ""
|
decodedServerData = ""
|
||||||
@ -17,17 +19,27 @@ def recvData(ip, port):
|
|||||||
from_server = client.recv(4096)
|
from_server = client.recv(4096)
|
||||||
#Decode Sever message
|
#Decode Sever message
|
||||||
decodedServerData = from_server.decode()
|
decodedServerData = from_server.decode()
|
||||||
|
print("Raw Data:", decodedServerData)
|
||||||
def printData():
|
def virtualController():
|
||||||
|
MyVirtual = pyxinput.vController()
|
||||||
|
MyRead = pyxinput.rController(1)
|
||||||
|
print(MyRead.gamepad)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
global decodedServerData
|
#global decodedServerData
|
||||||
#print("Raw Data:", decodedServerData)
|
# Init virtual XInput Controller
|
||||||
#print('\n'+":O", end="\r", flush=True)
|
#print(MyRead.gamepad)
|
||||||
|
MyVirtual.set_value('BtnA', 1)
|
||||||
|
print(MyRead.buttons)
|
||||||
|
sleep(3)
|
||||||
|
#print(MyRead.gamepad)
|
||||||
|
MyVirtual.set_value('BtnA', 0)
|
||||||
|
print(MyRead.buttons)
|
||||||
|
sleep(3)
|
||||||
# Execute all functions as threads
|
# Execute all functions as threads
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#Create Threads
|
#Create Threads
|
||||||
t1 = threading.Thread(target=recvData, args=(ip, port))
|
t1 = threading.Thread(target=recvData, args=(ip, port))
|
||||||
t2 = threading.Thread(target=printData, args=())
|
t2 = threading.Thread(target=virtualController, args=())
|
||||||
t1.start()
|
#t1.start()
|
||||||
t2.start()
|
t2.start()
|
||||||
|
@ -6,7 +6,7 @@ import threading
|
|||||||
import socket
|
import socket
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
# Define ip/port to use
|
# Define ip/port to use
|
||||||
ip = "127.0.0.1"
|
ip = "192.168.122.1"
|
||||||
port = 2222
|
port = 2222
|
||||||
# Show available gamepads
|
# Show available gamepads
|
||||||
print("Gamepads available:")
|
print("Gamepads available:")
|
||||||
|
Loading…
Reference in New Issue
Block a user