add and update examples

This commit is contained in:
Florian Kaiser
2020-12-22 14:58:21 +01:00
parent b004d2bc7b
commit cc767d5fcd
5 changed files with 54 additions and 13 deletions

15
examples/README.md Normal file
View File

@@ -0,0 +1,15 @@
# Examples
This folder contains some examples on applications for the library and its usage
## leds.py
The leds.py shows you how you can interact and change the lights of the controller
## effects.py
The effects.py show some effects of the controller
## read_controller.py
The read_controller.py display how you can access the button state of the controller

22
examples/effects.py Normal file
View File

@@ -0,0 +1,22 @@
from pydualsense import *
# get dualsense instance
dualsense = pydualsense()
dualsense.init()
print('Trigger Effect demo started')
dualsense.setLeftMotor(255)
dualsense.setRightMotor(100)
dualsense.setLeftTriggerMode(TriggerModes.Rigid)
dualsense.setLeftTriggerForce(1, 255)
dualsense.setRightTriggerMode(TriggerModes.Pulse_A)
dualsense.setRightTriggerForce(0, 200)
dualsense.setRightTriggerForce(1, 255)
dualsense.setRightTriggerForce(2, 175)
import time; time.sleep(3)
# terminate the thread for message and close the device
dualsense.close()

View File

@@ -2,12 +2,13 @@ from pydualsense import *
# get dualsense instance
dualsense = pydualsense()
dualsense.init()
# set color around touchpad to red
dualsense.setColor(0,0,255)
# enable microphone indicator
dualsense.setMicrophoneLED(1)
# set all player indicators on
dualsense.setPlayer(PlayerID.all)
dualsense.setPlayerID(PlayerID.all)
# sleep a little to see the result on the controller
# this is not needed in normal usage
import time; time.sleep(2)

View File

@@ -0,0 +1,15 @@
from pydualsense import *
# create dualsense
dualsense = pydualsense()
# find device and initialize
dualsense.init()
# 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()

View File

@@ -1,12 +0,0 @@
from pydualsense import *
# get dualsense instance
dualsense = pydualsense()
# set left trigger mode to rigid and put some force values on it
dualsense.setLeftTriggerMode(TriggerModes.Rigid)
dualsense.setLeftTriggerForce(1, 255)
# sleep a little to see the result on the controller
# this is not needed in normal usage
import time; time.sleep(2)
# terminate the thread for message and close the device
dualsense.close()