From e476e6d60ac91ea615b8d2c8842d7c38e70a1877 Mon Sep 17 00:00:00 2001 From: Max Siyazov Date: Sun, 12 Dec 2021 18:50:57 +0000 Subject: [PATCH 1/3] Allow #comment lines in macros. Updated the Macros documentation. --- docs/Macros.md | 24 ++++++++++++++++++++++++ nxbt/controller/input.py | 1 + 2 files changed, 25 insertions(+) diff --git a/docs/Macros.md b/docs/Macros.md index 2484d7b..3604f5c 100644 --- a/docs/Macros.md +++ b/docs/Macros.md @@ -43,6 +43,30 @@ L_STICK@+000+000 0.75s 1.0s ``` +### Loops + +A simple for-loop can be used to repeat a macro block a specified number of times. The below example loops through an indented macro block 100 times. + +``` +LOOP 100 + B 0.1s + 0.1s +``` + +Nested loops are also supported. + +``` +LOOP 100 + B 0.1s + 0.1s + # Nested loop + LOOP 5 + A 0.1s + 0.1s +``` + +Note, a macro line starting with `#` is ignored. + ## Macro Control Values | Macro Value | Control Name | diff --git a/nxbt/controller/input.py b/nxbt/controller/input.py index 6b27749..1249f63 100644 --- a/nxbt/controller/input.py +++ b/nxbt/controller/input.py @@ -307,6 +307,7 @@ class InputParser(): parsed = macro.split("\n") parsed = list(filter(lambda s: not s.strip() == "", parsed)) + parsed = list(filter(lambda s: not s.strip().startswith("#"), parsed)) parsed = self.parse_loops(parsed) return parsed From 954273710edf167a940b5ff4285d3fd422506dd8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 2 Dec 2022 18:24:45 +0100 Subject: [PATCH 2/3] Fix typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c51e38..f3f0841 100644 --- a/README.md +++ b/README.md @@ -307,7 +307,7 @@ nx.clear_all_macros() ### My controller disconnects after exiting the "Change Grip/Order" Menu -This can occasionally occur due to timing sensitivites when transitioning off of the "Change Grip/Order" menu. To avoid disconnections when exiting this menu, please only press A (or B) a single time and wait until the menu has fully exited. If a disconnect still occurs, you should be able to reconnect your controller and use NXBT as normal. +This can occasionally occur due to timing sensitivities when transitioning off of the "Change Grip/Order" menu. To avoid disconnections when exiting this menu, please only press A (or B) a single time and wait until the menu has fully exited. If a disconnect still occurs, you should be able to reconnect your controller and use NXBT as normal. ### "No Available Adapters" @@ -316,7 +316,7 @@ This means that NXBT wasn't able to find a suitable Bluetooth adapter to use for 1. **Cause:** All available adapters are currently emulating a controller. - **Solution:** End one of the other controller sessions (either through the webapp or command line) or plug in another Bluetooth adapter. 2. **Cause:** No Bluetooth adapters are available to NXBT. - - **Solution:** Ensure that you've installed the relevant Bluetooth stack for your operating system (BlueZ on Linux) and check that your Bluetooh adapter is visible within to your OS. + - **Solution:** Ensure that you've installed the relevant Bluetooth stack for your operating system (BlueZ on Linux) and check that your Bluetooth adapter is visible within to your OS. ### "Address already in use" From 467c7b0456b3b402f4b63aa1b4a578476b7e9177 Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Wed, 14 Dec 2022 01:58:06 +0800 Subject: [PATCH 3/3] Correct plus and minus input index --- nxbt/controller/input.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nxbt/controller/input.py b/nxbt/controller/input.py index 6b27749..0c28b2d 100644 --- a/nxbt/controller/input.py +++ b/nxbt/controller/input.py @@ -250,9 +250,9 @@ class InputParser(): # Shared byte if controller_input["MINUS"]: - shared[7] = '1' - if controller_input["PLUS"]: shared[6] = '1' + if controller_input["PLUS"]: + shared[7] = '1' if controller_input["R_STICK"]["PRESSED"]: shared[5] = '1' if controller_input["L_STICK"]["PRESSED"]: