diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf..2ca11e7 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -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 diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..468cc3e --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,9 @@ +API +=== + +This is the front page for the API documentation of the **pydualsense** library. + + +.. toctree:: + ds_enum + ds_main \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index acfed58..e6c0ca6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -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 + diff --git a/docs/source/ds_enum.rst b/docs/source/ds_enum.rst new file mode 100644 index 0000000..087f831 --- /dev/null +++ b/docs/source/ds_enum.rst @@ -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: \ No newline at end of file diff --git a/docs/source/ds_main.rst b/docs/source/ds_main.rst new file mode 100644 index 0000000..2af7031 --- /dev/null +++ b/docs/source/ds_main.rst @@ -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 ` + + +.. automodule:: pydualsense.pydualsense + :noindex: + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/source/examples.rst b/docs/source/examples.rst new file mode 100644 index 0000000..38cbef1 --- /dev/null +++ b/docs/source/examples.rst @@ -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() \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index b0cc312..ffb1656 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -15,5 +15,11 @@ Contents .. toctree:: usage - pydualsense - modules \ No newline at end of file + api + examples + + +TODOs +----- + +.. todolist:: \ No newline at end of file diff --git a/docs/source/usage.rst b/docs/source/usage.rst index f9af512..a3c315d 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -8,4 +8,31 @@ To use **pydualsense**, first install it using pip: .. code-block:: console - (.venv) $ pip install --upgrade pydualsense \ No newline at end of file + (.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 `_. +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` \ No newline at end of file