diff --git a/docs/Macros.md b/docs/Macros.md index 3604f5c..3c99ce0 100644 --- a/docs/Macros.md +++ b/docs/Macros.md @@ -1,17 +1,27 @@ -# NXBT Macros +# Writing an NXBT Macro -## Writing an NXBT Macro +### Basic Macro script -Each NXBT macro line is composed of the buttons/sticks being set and the amount of time they are set for. A simple macro follows: +Every macro script is composed of Button/Stick input followed by a set duration. Here is a sample of this. ``` B 0.1s -0.1s ``` -The above macro is the B button being pressed for 0.1s and no controls being set for 0.1s. This is effectively a single B button press. +The above macro is setting the B button to be pressed for 0.1s (0.1 seconds). -A slightly more complicated example follows: +Oftentimes you'll need gaps between your inputs when no buttons should be pressed. This is easily scripted by making a new line and inserting a new time. + +``` +B 0.1s +1s +``` + +This is effectively a single B button press. NXBT will then wait 1 second before moving to the next action. + +### Advanced Macros + +To set multiple inputs simultaneously, we write our inputs on the same line, separated by a space, followed by the duration. This is how our script looks now. ``` A B 0.5s @@ -19,7 +29,7 @@ B 0.1s 0.1s ``` -This new macro, first, has both the A and the B button being pressed for 0.5s. Next, the A button is released and the B button continues to be held for an additional 0.1s. Finally, no controls are set for 0.1s. +First, This new macro has both the A and B buttons pressed for 0.5s. Next, the A button is released and the B button continues to be held for an additional 0.1s. Finally, no buttons are pressed for 0.1s. The above macros deal with only button-based input. A stick input example follows: @@ -28,7 +38,7 @@ L_STICK@-100+000 0.75s 1.0s ``` -Above, we're setting the left analog stick to 100% in the left horizontal direction. To explain, analog stick positions are composed of two values: and X position and Y position. You can think of both as positions on a traditional X/Y plane, with X being the horizontal component and Y being the vertical component. An X/Y of 0/0 means that the analog stick is in a neutral position (no input), while an X/Y position of 0/100 means our stick is tilted 100% up. +Above, we're setting the left analog stick to 100% in the left horizontal direction. To explain, analog stick positions are composed of two values: an X position and a Y position. You can think of both as positions on a traditional X/Y plane, with X being the horizontal component and Y being the vertical component. An X/Y of 0/0 means that the analog stick is in a neutral position (no input), while an X/Y position of 0/100 means our stick is tilted 100% up.
@@ -43,6 +53,10 @@ L_STICK@+000+000 0.75s
1.0s
```
+
+Remember, each X and Y value must be 3 digits. If you want to tilt the Right Thumbstick 75% to the left, you must write it as `R_STICK@-075+000`. Another thing to keep in mind, the sum of your X and Y can be more than 100. For example, `L_STICK@+100+100` is a 45° angle.
+
+
### 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.
diff --git a/nxbt/web/app.py b/nxbt/web/app.py
index da434d9..481fdcf 100644
--- a/nxbt/web/app.py
+++ b/nxbt/web/app.py
@@ -73,7 +73,7 @@ def on_shutdown(index):
nxbt.remove_controller(index)
-@sio.on('create_pro_controller')
+@sio.on('web_create_pro_controller')
def on_create_controller():
print("Create Controller")
diff --git a/nxbt/web/static/js/main.js b/nxbt/web/static/js/main.js
index 1e0c977..82e79c8 100644
--- a/nxbt/web/static/js/main.js
+++ b/nxbt/web/static/js/main.js
@@ -381,7 +381,7 @@ function createProController() {
HTML_CONTROLLER_SELECTION.classList.add('hidden');
HTML_LOADER.classList.remove('hidden');
- socket.emit('create_pro_controller');
+ socket.emit('web_create_pro_controller');
}
function shutdownController() {
diff --git a/setup.py b/setup.py
index d82c3ce..b6984d0 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ setup(
install_requires=[
"dbus-python==1.2.16",
"Flask==2.1.3",
- "Flask-SocketIO==4.3.1",
+ "Flask-SocketIO==5.3.4",
"eventlet==0.33.3",
"blessed==1.17.10",
"pynput==1.7.1",