Skip to content

Commit

Permalink
update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aarron-lee committed Nov 29, 2023
1 parent 889092d commit c76f67c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 93 deletions.
143 changes: 52 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,87 @@
# React-Frontend Plugin Template [![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://deckbrew.xyz/discord)
# Legion Go Remapper - Decky Plugin

Reference example for using [decky-frontend-lib](https://github.com/SteamDeckHomebrew/decky-frontend-lib) in a [decky-loader](https://github.com/SteamDeckHomebrew/decky-loader) plugin.
Decky Plugin that replicates some of the Legion Space remapping functionality.

### **Please also refer to the [wiki](https://wiki.deckbrew.xyz/en/user-guide/home#plugin-development) for important information on plugin development and submissions/updates. currently documentation is split between this README and the wiki which is something we are hoping to rectify in the future.**
![remap buttons image](./images/remap-buttons.png | height=100)
![color-picker image](./images/color-picker.png | height=100)

## Developers
## Functionality

### Dependencies
### This plugin uses the Lenovo-built remapping functionality that's used for Legion Space, which means that this plugin can only do what Legion Space is capable of

This template relies on the user having Node.js v16.14+ and `pnpm` (v8.5.1) installed on their system.
Please make sure to install pnpm v8.5.1 to prevent issues with CI during plugin submission.
`pnpm` can be downloaded from `npm` itself which is recommended.
This remapping plugin also only covers remapping for the X-input mode of the controller, it does NOT support FPS mode or D-input modes.

#### Linux
Included Functionality in this plugin:

```bash
sudo npm i -g [email protected]
```

If you would like to build plugins that have their own custom backends, Docker is required as it is used by the Decky CLI tool.

### Making your own plugin

If you use VSCode or it's derivatives (we suggest [VSCodium](https://vscodium.com/)!) just run the `setup` and `build` tasks. It's really that simple.
- Manage RBG lights, including modes, brightness, cycle speed for certain modes, and RGB light color
- Back Button Remapping for Y1, Y2, Y3, M2, M3 (M1 is not supported)
- Enabling/Disabling the touchpad
- Gyro remapping to Left or Right Control Stick
- allow any of these settings on a per-game basis

1. You can fork this repo or utilize the "Use this template" button on Github.
2. In your local fork/own plugin-repository run these commands:
1. `pnpm i`
2. `pnpm run build`
- These setup pnpm and build the frontend code for testing.
3. Consult the [decky-frontend-lib](https://github.com/SteamDeckHomebrew/decky-frontend-lib) repository for ways to accomplish your tasks.
- Documentation and examples are still rough,
- While decky-loader primarily targets Steam Deck hardware so keep this in mind when developing your plugin.
4. Run the `setup` and `build` and `deploy` vscode tasks, or you can derive your own makefile or just manually utilize the scripts for these commands as you see fit.
## Install Instructions

If you use VSCode or it's derivatives (we suggest [VSCodium](https://vscodium.com/)!) just run the `setup` and `build` tasks. It's really that simple.
Add Udev rules to your device.

#### Other important information
Create a file at `/etc/udev/rules.d/99-usb-tweak.rules`, and add the following to the file:

Everytime you change the frontend code (`index.tsx` etc) you will need to rebuild using the commands from step 2 above or the build task if you're using vscode or a derivative.

Note: If you are receiving build errors due to an out of date library, you should run this command inside of your repository:

```bash
pnpm update decky-frontend-lib --latest
```
# allow r/w access by all local/physical sessions (seats)
# https://github.com/systemd/systemd/issues/4288
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", TAG+="uaccess"
### Backend support

If you are developing with a backend for a plugin and would like to submit it to the [decky-plugin-database](https://github.com/SteamDeckHomebrew/decky-plugin-database) you will need to have all backend code located in `backend/src`, with backend being located in the root of your git repository.
When building your plugin, the source code will be built and any finished binary or binaries will be output to `backend/out` (which is created during CI.)
If your buildscript, makefile or any other build method does not place the binary files in the `backend/out` directory they will not be properly picked up during CI and your plugin will not have the required binaries included for distribution.

Example:
In our makefile used to demonstrate the CI process of building and distributing a plugin backend, note that the makefile explicitly creates the `out` folder (`backend/out`) and then compiles the binary into that folder. Here's the relevant snippet.
# allow r/w access by users of the plugdev group
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", GROUP="plugdev", MODE="0660"
```make
hello:
mkdir -p ./out
gcc -o ./out/hello ./src/main.c
# allow r/w access by all users
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
```

The CI does create the `out` folder itself but we recommend creating it yourself if possible during your build process to ensure the build process goes smoothly.

Note: When locally building your plugin it will be placed into a folder called 'out' this is different from the concept described above.
After saving the file, then run `sudo udevadm control --reload` in terminal.

The out folder is not sent to the final plugin, but is then put into a `bin` folder which is found at the root of the plugin's directory.
More information on the bin folder can be found below in the distribution section below.
Download the latest release from the [releases page](https://github.com/aarron-lee/LegionGoRemapper/releases)

### Distribution
Unzip the `tar.gz` file, and move the `LegionGoRemapper` folder to your `$HOME/homebrew/plugins` directory

We recommend following the instructions found in the [decky-plugin-database](https://github.com/SteamDeckHomebrew/decky-plugin-database) on how to get your plugin up on the plugin store. This is the best way to get your plugin in front of users.
You can also choose to do distribution via a zip file containing the needed files, if that zip file is uploaded to a URL it can then be downloaded and installed via decky-loader.

**NOTE: We do not currently have a method to install from a downloaded zip file in "game-mode" due to lack of a usable file-picking dialog.**

Layout of a plugin zip ready for distribution:
then run:

```
pluginname-v1.0.0.zip (version number is optional but recommended for users sake)
|
pluginname/ <directory>
| | |
| | bin/ <directory> (optional)
| | |
| | binary (optional)
| |
| dist/ <directory> [required]
| |
| index.js [required]
|
package.json [required]
plugin.json [required]
main.py {required if you are using the python backend of decky-loader: serverAPI}
README.md (optional but recommended)
LICENSE(.md) [required, filename should be roughly similar, suffix not needed]
sudo systemctl restart plugin_loader.service
```

Note regarding licenses: Including a license is required for the plugin store if your chosen license requires the license to be included alongside usage of source-code/binaries!
then reboot your machine.

Standard procedure for licenses is to have your chosen license at the top of the file, and to leave the original license for the plugin-template at the bottom. If this is not the case on submission to the plugin database, you will be asked to fix this discrepancy.
## Manual Build

We cannot and will not distribute your plugin on the Plugin Store if it's license requires it's inclusion but you have not included a license to be re-distributed with your plugin in the root of your git repository.
- Node.js v16.14+ and pnpm installed

# Attribution
```bash
git clone https://github.com/aarron-lee/LegionGoRemapper.git

> PromptFont by Yukari "Shinmera" Hafner, available at https://shinmera.com/promptfont
cd LegionGoRemapper

# Udev rule:
# if pnpm not already installed
npm install -g pnpm

pnpm install
pnpm update decky-frontend-lib --latest
pnpm run build
```
# allow r/w access by all local/physical sessions (seats)
# https://github.com/systemd/systemd/issues/4288
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", TAG+="uaccess"

# allow r/w access by users of the plugdev group
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", GROUP="plugdev", MODE="0660"
Afterwards, you can place the entire `LegionGoRemapper` folder in the `~/homebrew/plugins` directly, then restart your plugin service

# allow r/w access by all users
SUBSYSTEMS=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
```bash
sudo systemctl restart plugin_loader.service

sudo systemctl reboot
```

save to `/etc/udev/rules.d/99-usb-tweak.rules`
## Attribution

then `sudo udevadm control --reload`
Special thanks to [antheas](https://github.com/antheas) for [reverse engineering and documenting the HID protocols](https://github.com/antheas/hwinfo/tree/master/devices/legion_go/peripherals) for the Legion Go Controllers.

Also special thanks to [cornando98](https://github.com/corando98) for writing + testing the backend functions for talking to the HID devices, as well as contributing to the RGB light management code on the frontend.

Icon and controller button SVG files generated from PromptFont using FontForge.

> PromptFont by Yukari "Shinmera" Hafner, available at https://shinmera.com/promptfont
Binary file added images/color-picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/remap-buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "LegionGoRemapper",
"author": "Aarron Lee",
"flags": ["root", "debug"],
"flags": ["root"],
"publish": {
"tags": ["root"],
"description": "plugin for Legion Go Buttons, RGB, etc",
Expand Down
2 changes: 1 addition & 1 deletion src/components/rgb/ControllerLightingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ControllerLightingPanel: VFC = () => {

let title =
displayName === 'Default'
? 'Controller Lighting - Default'
? 'Controller Lighting'
: `Controller Lighting - ${displayName.substring(0, 10)}...`;

return (
Expand Down

0 comments on commit c76f67c

Please sign in to comment.