WHY DO DUALSHOCKS REPRESENT ANALOG VALUES DIFFERENTLY >:(

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2024-10-28 02:17:31 -05:00
parent 7daadd2eaf
commit e4294bbadc

16
Server.py Normal file → Executable file
View File

@ -20,7 +20,7 @@ controllerData = ""
#Dictionary of of all possible values #Dictionary of of all possible values
controllerDataDict = {'AxisLx': 0, 'AxisLy': 0, 'AxisRx': 0, 'AxisRy': 0, 'BtnBack': 0, 'BtnStart': 0, 'BtnA': 0, 'BtnB': 0, 'BtnX': 0, 'BtnY': 0, 'BtnThumbL': 0, 'BtnThumbR': 0, 'BtnShoulderL': 0, 'BtnShoulderR': 0, 'Dpad': 0, 'TriggerL': 0, 'TriggerR': 0} controllerDataDict = {'AxisLx': 0, 'AxisLy': 0, 'AxisRx': 0, 'AxisRy': 0, 'BtnBack': 0, 'BtnStart': 0, 'BtnA': 0, 'BtnB': 0, 'BtnX': 0, 'BtnY': 0, 'BtnThumbL': 0, 'BtnThumbR': 0, 'BtnShoulderL': 0, 'BtnShoulderR': 0, 'Dpad': 0, 'TriggerL': 0, 'TriggerR': 0}
#Lookup table to convert values from the "inputs" library #Lookup table to convert values from the "inputs" library
lookup_table = {'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'} lookup_table = {'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', 'BTN_TL2': 'TriggerL', 'BTN_TR2': 'TriggerR'}
def sendData(): def sendData():
#Pickle for transmittion #Pickle for transmittion
pickle.dump(controllerDataDict, file) pickle.dump(controllerDataDict, file)
@ -41,6 +41,8 @@ iwantThatRaddr = re.findall(r"'(?<=raddr=\(')\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
print(iwantThatRaddr) print(iwantThatRaddr)
print(colored('Connected by', 'red'), iwantThatRaddr[0]) print(colored('Connected by', 'red'), iwantThatRaddr[0])
print(controllerDataDict) print(controllerDataDict)
min = 0
max = 255
while True: while True:
events = get_gamepad() events = get_gamepad()
for event in events: for event in events:
@ -78,25 +80,25 @@ while True:
#'ABS_X': 'AxisLx', 'ABS_Y': 'AxisLy', 'ABS_RX': 'AxisRx', 'ABS_RY': 'AxisRy' #'ABS_X': 'AxisLx', 'ABS_Y': 'AxisLy', 'ABS_RX': 'AxisRx', 'ABS_RY': 'AxisRy'
#Left Joystick #Left Joystick
elif event.code == 'ABS_X': # Left Joystick, left+right elif event.code == 'ABS_X': # Left Joystick, left+right
controllerDataDict['AxisLx'] = 2/(32767 - -32768)*(event.state-32767)+1 controllerDataDict['AxisLx'] = (event.state - 127.5) / 127.5
sendData() sendData()
elif event.code == 'ABS_Y': # Left Joystick, up+down elif event.code == 'ABS_Y': # Left Joystick, up+down
controllerDataDict['AxisLy'] = - 2/(32767 - -32768)*(event.state-32767)+1-2 controllerDataDict['AxisLy'] = - (event.state - 127.5) / 127.5
sendData() sendData()
#Right Joystick #Right Joystick
elif event.code == 'ABS_RX': # Left Joystick, left+right elif event.code == 'ABS_RX': # Left Joystick, left+right
controllerDataDict['AxisRx'] = 2/(32767 - -32768)*(event.state-32767)+1 controllerDataDict['AxisRx'] = (event.state - 127.5) / 127.5
sendData() sendData()
elif event.code == 'ABS_RY': # Left Joystick, up+down elif event.code == 'ABS_RY': # Left Joystick, up+down
controllerDataDict['AxisRy'] = - 2/(32767 - -32768)*(event.state-32767)+1-2 controllerDataDict['AxisRy'] = - (event.state - 127.5) / 127.5
sendData() sendData()
#Now, for the triggers #Now, for the triggers
#'ABS_Z': 'TriggerL', 'ABS_RZ': 'TriggerR' #'ABS_Z': 'TriggerL', 'ABS_RZ': 'TriggerR'
elif event.code == 'ABS_Z': elif event.code == 'ABS_Z':
controllerDataDict['TriggerL'] = float(event.state) / 1023 controllerDataDict['TriggerL'] = (event.state - 127.5) / 127.5
sendData() sendData()
elif event.code == 'ABS_RZ': elif event.code == 'ABS_RZ':
controllerDataDict['TriggerR'] = float(event.state) / 1023 controllerDataDict['TriggerR'] = (event.state - 127.5) / 127.5
sendData() sendData()
else: else:
# Add button values to controllerDataDict # Add button values to controllerDataDict