Skip to content

Commit

Permalink
implementing poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
flok committed Mar 2, 2024
1 parent fc60c0f commit 519e667
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine poetry
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
poetry build
twine upload dist/*
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
from pathlib import Path
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
Expand All @@ -11,10 +11,10 @@
project = 'pydualsense'
copyright = '2022, Florian (flok) K'
author = 'Florian (flok) K'
release = '0.6.1'
release = '0.7.1'

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../../'))

sys.path.append(str(Path(__file__).parents[2]))

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/ds_eventsystem.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydualsense event system classes
=========================
================================

The `Event System` implements the event system used for the button callbacks

Expand Down
8 changes: 5 additions & 3 deletions examples/leds.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from pydualsense import *
from pydualsense import pydualsense
from pydualsense.enums import PlayerID
import time

# get dualsense instance
dualsense = pydualsense()
dualsense.init()
# set color around touchpad to red
dualsense.light.setColorI(255,0,0)
dualsense.light.setColorI(255, 0, 0)
# mute microphone
dualsense.audio.setMicrophoneState(True)
# set all player 1 indicator on
dualsense.light.setPlayerID(PlayerID.PLAYER_1)
# sleep a little to see the result on the controller
# this is not needed in normal usage
import time; time.sleep(2)
time.sleep(2)
# terminate the thread for message and close the device
dualsense.close()
185 changes: 185 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions pydualsense/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from .enums import LedOptions, Brightness, PlayerID, PulseOptions, TriggerModes
from .event_system import Event
from .pydualsense import pydualsense, DSLight, DSState, DSTouchpad, DSTrigger, DSAudio
import os
import sys
sys.path.append(os.path.dirname(__file__))

from .enums import LedOptions, Brightness, PlayerID, PulseOptions, TriggerModes # noqa : F401
from .event_system import Event # noqa : F401
from .pydualsense import pydualsense, DSLight, DSState, DSTouchpad, DSTrigger, DSAudio # noqa : F401

print(sys.path)

__version__ = "0.7.1"
9 changes: 5 additions & 4 deletions pydualsense/checksum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import array

# from South-River

# fmt: off
hashTable = array.array('I', [
0xd202ef8d, 0xa505df1b, 0x3c0c8ea1, 0x4b0bbe37, 0xd56f2b94, 0xa2681b02, 0x3b614ab8, 0x4c667a2e,
0xdcd967bf, 0xabde5729, 0x32d70693, 0x45d03605, 0xdbb4a3a6, 0xacb39330, 0x35bac28a, 0x42bdf21c,
Expand Down Expand Up @@ -36,12 +36,13 @@
0x6fbf1d91, 0x18b82d07, 0x81b17cbd, 0xf6b64c2b, 0x68d2d988, 0x1fd5e91e, 0x86dcb8a4, 0xf1db8832,
0x616495a3, 0x1663a535, 0x8f6af48f, 0xf86dc419, 0x660951ba, 0x110e612c, 0x88073096, 0xff000000
])
# fmt:on


def compute(buffer):
result = 0xeada2d49
result = 0xEADA2D49

for i in range(0, 74):
result = hashTable[(result&0xFF)^(buffer[i]&0xFF)]^(result>>8)
result = hashTable[(result & 0xFF) ^ (buffer[i] & 0xFF)] ^ (result >> 8)

return result
return result
6 changes: 3 additions & 3 deletions pydualsense/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class BatteryState(IntFlag):
POWER_SUPPLY_STATUS_DISCHARGING = 0x0
POWER_SUPPLY_STATUS_CHARGING = 0x1
POWER_SUPPLY_STATUS_FULL = 0x2
POWER_SUPPLY_STATUS_NOT_CHARGING = 0xb
POWER_SUPPLY_STATUS_ERROR = 0xf
POWER_SUPPLY_TEMP_OR_VOLTAGE_OUT_OF_RANGE = 0xa
POWER_SUPPLY_STATUS_NOT_CHARGING = 0xB
POWER_SUPPLY_STATUS_ERROR = 0xF
POWER_SUPPLY_TEMP_OR_VOLTAGE_OUT_OF_RANGE = 0xA
POWER_SUPPLY_STATUS_UNKNOWN = 0x0
3 changes: 0 additions & 3 deletions pydualsense/event_system.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from collections import defaultdict


class Event(object):
"""
Base class for the event driven system
Expand Down
Binary file added pydualsense/hidapi.dll
Binary file not shown.
Loading

0 comments on commit 519e667

Please sign in to comment.