added more documentation
This commit is contained in:
@@ -18,3 +18,6 @@ help:
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
generate_doc:
|
||||
sphinx-apidoc ../pydualsense -f -o ./source --ext-autodoc --ext-coverage --ext-todo
|
||||
|
9
docs/source/api.rst
Normal file
9
docs/source/api.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
API
|
||||
===
|
||||
|
||||
This is the front page for the API documentation of the **pydualsense** library.
|
||||
|
||||
|
||||
.. toctree::
|
||||
ds_enum
|
||||
ds_main
|
@@ -9,8 +9,8 @@ import os
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
project = 'pydualsense'
|
||||
copyright = '2022, flok'
|
||||
author = 'flok'
|
||||
copyright = '2022, Florian (flok) K'
|
||||
author = 'Florian (flok) K'
|
||||
release = '0.6.1'
|
||||
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
@@ -19,7 +19,7 @@ sys.path.insert(0, os.path.abspath('../../'))
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.coverage']
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.coverage', 'sphinx.ext.todo']
|
||||
|
||||
templates_path = ['templates']
|
||||
exclude_patterns = []
|
||||
@@ -29,3 +29,15 @@ exclude_patterns = []
|
||||
|
||||
html_theme = 'furo'
|
||||
html_static_path = ['static']
|
||||
|
||||
autodoc_default_options = {
|
||||
'members': True,
|
||||
'member-order': 'bysource',
|
||||
'special-members': '__init__',
|
||||
'undoc-members': True,
|
||||
'exclude-members': '__weakref__'
|
||||
}
|
||||
|
||||
autoclass_content = 'both'
|
||||
todo_include_todos = True
|
||||
|
||||
|
11
docs/source/ds_enum.rst
Normal file
11
docs/source/ds_enum.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
pydualsense enums classes
|
||||
=========================
|
||||
|
||||
The enum module provides the used `enums` by **pydualsense**. These `enums` are used to update the state of the controller as a parameter to call the used functions.
|
||||
|
||||
|
||||
.. automodule:: pydualsense.enums
|
||||
:noindex:
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
11
docs/source/ds_main.rst
Normal file
11
docs/source/ds_main.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
pydualsense main class
|
||||
======================
|
||||
|
||||
`pydualsense` is the main class of the library with the same name. It provides access to the states of the controller through manual reading of the :class:`DSState <pydualsense.pydualsense.DSState>`
|
||||
|
||||
|
||||
.. automodule:: pydualsense.pydualsense
|
||||
:noindex:
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
82
docs/source/examples.rst
Normal file
82
docs/source/examples.rst
Normal file
@@ -0,0 +1,82 @@
|
||||
Examples
|
||||
========
|
||||
|
||||
This pages displays some examples that on how the library can be used. All the examples can also be found inside the `examples` folder on the github repository.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
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 down {state}')
|
||||
|
||||
|
||||
def joystick(stateX, stateY):
|
||||
print(f'joystick {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:
|
||||
...
|
||||
|
||||
# close device
|
||||
dualsense.close()
|
||||
|
||||
|
||||
The above example demonstrates the newly added c# like event system that makes it possible to trigger an event for the inputs of the controller.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pydualsense import *
|
||||
|
||||
# get dualsense instance
|
||||
dualsense = pydualsense()
|
||||
# initialize controller and connect
|
||||
dualsense.init()
|
||||
|
||||
print('Trigger Effect demo started')
|
||||
|
||||
# set left and right rumble motors
|
||||
dualsense.setLeftMotor(255)
|
||||
dualsense.setRightMotor(100)
|
||||
|
||||
# set left l2 trigger to Rigid and set index 1 to force 255
|
||||
dualsense.triggerL.setMode(TriggerModes.Rigid)
|
||||
dualsense.triggerL.setForce(1, 255)
|
||||
|
||||
# set left r2 trigger to Rigid
|
||||
dualsense.triggerR.setMode(TriggerModes.Pulse_A)
|
||||
dualsense.triggerR.setForce(0, 200)
|
||||
dualsense.triggerR.setForce(1, 255)
|
||||
dualsense.triggerR.setForce(2, 175)
|
||||
|
||||
# loop until r1 is pressed to feel effect
|
||||
while not dualsense.state.R1:
|
||||
...
|
||||
|
||||
# terminate the thread for message and close the device
|
||||
dualsense.close()
|
@@ -15,5 +15,11 @@ Contents
|
||||
|
||||
.. toctree::
|
||||
usage
|
||||
pydualsense
|
||||
modules
|
||||
api
|
||||
examples
|
||||
|
||||
|
||||
TODOs
|
||||
-----
|
||||
|
||||
.. todolist::
|
@@ -8,4 +8,31 @@ To use **pydualsense**, first install it using pip:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
(.venv) $ pip install --upgrade pydualsense
|
||||
(.venv) $ pip install --upgrade pydualsense
|
||||
|
||||
This install the needed dependencies and the **pydualsense** library itself.
|
||||
|
||||
|
||||
Windows
|
||||
-------
|
||||
|
||||
If you are on Windows the hidapi need to downloaded from `here <https://github.com/libusb/hidapi/releases>`_.
|
||||
The downloaded `.dll` file need to be placed in a path that is in your environments variable `path`.
|
||||
|
||||
|
||||
Linux based
|
||||
-----------
|
||||
|
||||
If you are on a linux based system (e.g debian) you need to first need to install the hidapi through your package manager.
|
||||
|
||||
On Ubuntu systems the package `libhidapi-dev` is required.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
sudo apt install libhidapi-dev
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
For code examles on using the library see :doc:`examples`
|
Reference in New Issue
Block a user