flok / pydualsense

control your dualsense controller with python
MIT License
112 stars 33 forks source link

Failure on macOS, M1 #40

Open UEFI-code opened 1 year ago

UEFI-code commented 1 year ago

I'm trying on my M1 Mac, and got error out of index. I guess some hid data were missing

Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydualsense
>>> obj = pydualsense.pydualsense()
>>> obj.init()
>>> Exception in thread Thread-1 (sendReport):
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 216, in sendReport
    self.readInput(inReport)
  File "/opt/homebrew/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 262, in readInput
    misc2 = states[10]
IndexError: list index out of range

>>> obj.device.get_product_string()
'DualSense Wireless Controller'
>>> data = obj.device.read(64)
>>> data
b'\x01\x80~\x7f~\x08\x00\x08\x00\x00'
flok commented 1 year ago

I dont have an arm device to test. but it seems like the hidapi works diffrent in the m1.

how did you install the hidapi?

UEFI-code commented 1 year ago

I use the “brew install hidapi” directly

------------------ Original ------------------ From: Flo @.> Date: Tue,Jan 10,2023 10:55 PM To: flok/pydualsense @.> Cc: SuperHacker UEFI @.>, Author @.> Subject: Re: [flok/pydualsense] Failure on macOS, M1 (Issue #40)

I dont have an arm device to test. but it seems like the hidapi works diffrent in the m1.

how did you install the hidapi?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

flok commented 1 year ago

This is weird. Could you change the source and output the states list with a print ?

UEFI-code commented 1 year ago

I think I set the verbose to True it will print something.

>>> import pydualsense
>>> obj = pydualsense.pydualsense(True)
>>> obj.init()
>>> 2023-01-19 11:00:42,754 b'\x01\x7f~\x80\x80\x08\x00\x00\x00\x00'
Exception in thread Thread-1 (sendReport):
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 216, in sendReport
    self.readInput(inReport)
  File "/opt/homebrew/lib/python3.10/site-packages/pydualsense/pydualsense.py", line 268, in readInput
    self.state.trackPadTouch0.ID = inReport[33] & 0x7F
IndexError: index out of range

Hidapi on m1 output data less then other platform