Decreased latency and improved reconnections
This commit is contained in:
parent
924bfbe989
commit
639227ea1d
2 changed files with 4 additions and 4 deletions
|
|
@ -242,7 +242,7 @@ class ControllerProtocol():
|
||||||
|
|
||||||
# Get how many ticks have passed in hex with overflow at 255
|
# Get how many ticks have passed in hex with overflow at 255
|
||||||
# Joy-Con uses 4.96ms as the timer tick rate
|
# Joy-Con uses 4.96ms as the timer tick rate
|
||||||
elapsed_ticks = int(delta_t // 4.96)
|
elapsed_ticks = int(delta_t * 4)
|
||||||
self.timer = (self.timer + elapsed_ticks) & 0xFF
|
self.timer = (self.timer + elapsed_ticks) & 0xFF
|
||||||
|
|
||||||
self.report[2] = self.timer
|
self.report[2] = self.timer
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class ControllerServer():
|
||||||
self.cached_msg = msg[3:]
|
self.cached_msg = msg[3:]
|
||||||
# Send a blank packet every so often to keep the Switch
|
# Send a blank packet every so often to keep the Switch
|
||||||
# from disconnecting from the controller.
|
# from disconnecting from the controller.
|
||||||
elif self.tick == 660:
|
elif self.tick == 2400:
|
||||||
itr.sendall(msg)
|
itr.sendall(msg)
|
||||||
self.tick = 0
|
self.tick = 0
|
||||||
# print(msg, "tick")
|
# print(msg, "tick")
|
||||||
|
|
@ -179,7 +179,7 @@ class ControllerServer():
|
||||||
timer_end = time.perf_counter()
|
timer_end = time.perf_counter()
|
||||||
elapsed_time = timer_end - timer_start
|
elapsed_time = timer_end - timer_start
|
||||||
|
|
||||||
sleep_time = 1/66 - elapsed_time
|
sleep_time = 1/240 - elapsed_time
|
||||||
if sleep_time >= 0:
|
if sleep_time >= 0:
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
self.tick += 1
|
self.tick += 1
|
||||||
|
|
@ -289,7 +289,7 @@ class ControllerServer():
|
||||||
self.bt.remove_device(key)
|
self.bt.remove_device(key)
|
||||||
connected_devices_count[key] = 0
|
connected_devices_count[key] = 0
|
||||||
|
|
||||||
time.sleep(0.25)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Configures as a specified controller, pairs with a Nintendo Switch,
|
"""Configures as a specified controller, pairs with a Nintendo Switch,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue