From 80d31972edc98943fe7a38b721f334713d8a6374 Mon Sep 17 00:00:00 2001 From: Brikwerk Date: Tue, 7 Sep 2021 16:45:04 -0700 Subject: [PATCH] Added better active input detection --- nxbt/controller/input.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nxbt/controller/input.py b/nxbt/controller/input.py index b726161..c6272d7 100644 --- a/nxbt/controller/input.py +++ b/nxbt/controller/input.py @@ -150,6 +150,29 @@ class InputParser(): def set_controller_input(self, controller_input): self.controller_input = controller_input + + def commands_queued(self): + check = dumps(self.controller_input) != dumps(DIRECT_INPUT_IDLE_PACKET) + check = check or self.macro_buffer + check = check or self.current_macro + check = check or self.current_macro_commands + return check + + def active_input_queued(self): + """Checks if an active command input is queued. An active command + is a depressed button or tilted stick. + + :return: True (on an active button) or False (no active buttons) + :rtype: bool + """ + if (self.current_macro_commands is not None or + dumps(self.controller_input) != dumps(DIRECT_INPUT_IDLE_PACKET)): + if len(self.current_macro_commands) < 2: + return False + else: + return True + else: + return False def set_protocol_input(self, state=None):