From 135f69bec501cbeea08fb586f52cded0297d773d Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 30 Apr 2022 10:45:26 +0700 Subject: [PATCH] Reverse back to thread --- pycon/joycon.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pycon/joycon.py b/pycon/joycon.py index e051ae7..81040d6 100644 --- a/pycon/joycon.py +++ b/pycon/joycon.py @@ -1,4 +1,4 @@ -import asyncio +import threading import time from typing import Optional, Tuple @@ -47,7 +47,9 @@ class JoyCon: self._setup_sensors() # start talking with the joycon in a daemon thread - asyncio.run(self._update_input_report()) + self._update_input_report_thread = threading.Thread(target=self._update_input_report) + self._update_input_report_thread.setDaemon(True) + self._update_input_report_thread.start() def _open(self, vendor_id, product_id, serial): try: @@ -113,7 +115,7 @@ class JoyCon: return report[7:size + 7] - async def _update_input_report(self): # daemon thread + def _update_input_report(self): # daemon thread try: while self._joycon_device: report = [0]