Skip to content

Updating dependencies in setup.py #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,17 @@ nx.clear_all_macros()

## Troubleshooting

### I get an error when installing the `dbus-python` package

This error can occur due to missing dbus-related libraries on some Linux distributions. To fix this in most cases, `libdbus-glib-1-dev` and `libdbus-1-dev` need to be installed with your system's package manager. For systems using aptitude for package management (Ubuntu, Debian, etc), installation instructions follow:

```bash
sudo apt-get install libdbus-glib-1-dev libdbus-1-dev
```

### 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"

Expand All @@ -316,7 +324,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"

Expand Down
54 changes: 46 additions & 8 deletions docs/Macros.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
# 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
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:

Expand All @@ -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.

<div align="center">
<img src="img/pro-controller-stick-axis.jpg" width="300">
Expand All @@ -43,6 +53,34 @@ 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.

```
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 |
Expand Down
5 changes: 3 additions & 2 deletions nxbt/controller/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ def parse_controller_input(self, controller_input):

# 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"]:
Expand Down Expand Up @@ -307,6 +307,7 @@ def parse_macro(self, macro):

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
Expand Down
2 changes: 1 addition & 1 deletion nxbt/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion nxbt/web/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
include_package_data=True,
long_description_content_type="text/markdown",
install_requires=[
"dbus-python==1.2.16",
"Flask==1.1.2",
"Flask-SocketIO==5.0.1",
"eventlet==0.31.0",
"dbus-python==1.3.2",
"Flask==2.1.3",
"Flask-SocketIO==5.3.4",
"eventlet==0.37.0",
"blessed==1.17.10",
"pynput==1.7.1",
"psutil==5.6.6",
"cryptography==3.3.2",
"jinja2==3.0.3",
"itsdangerous==2.0.1",
"Werkzeug==2.0.3",
],
extra_require={
"dev": [
Expand Down