Add event system for states, added gyro and accelerometer

This commit is contained in:
Florian Kaiser
2022-08-14 15:48:58 +02:00
parent 82d407bfe2
commit b091660130
4 changed files with 260 additions and 19 deletions

View File

@@ -1,15 +1,41 @@
from pydualsense import *
def cross_down(state):
print(f'cross {state}')
def circle_down(state):
print(f'circle {state}')
def dpad_down(state):
print(f'dpad {state}')
def joystick(stateX, stateY):
print(f'lj {stateX} {stateY}')
def gyro_changed(pitch, yaw, roll):
print(f'{pitch}, {yaw}, {roll}')
# create dualsense
dualsense = pydualsense()
# find device and initialize
dualsense.init()
# add events handler functions
dualsense.cross_pressed += cross_down
dualsense.circle_pressed += circle_down
dualsense.dpad_down += dpad_down
dualsense.left_joystick_changed += joystick
dualsense.gyro_changed += gyro_changed
# read controller state until R1 is pressed
while not dualsense.state.R1:
print(f"Circle : {dualsense.state.circle} Cross : {dualsense.state.cross} L Stick X : {dualsense.state.LX} L Stick Y : {dualsense.state.LY}")
...
# close device
dualsense.close()