-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add macro implementation * WIP * Favor dedicated pin model * Add interruptible, exclusive & wait options * Add debounce for macro trigger * Refactor and cleanup * Move macro to proper addon order * Cleanup * Add more strings for frontend localization * Fix frontend Macro schema and defaults * Cleanup * Cleanup * Fix boolean serialization * Fix some assignment and validation * Fix label * Fix another mistake in serialization * Add missing fields in macro page defaultValues * Fix direction pad macro combination issue * Add tooltip on delete button * Filter macro inputs that are empty * Fix improper cleanup of empty macro inputs * Revamp macro type with any button interruptibility * Switch to microseconds & add show frame interface * Update duration & exclusive toggle behavior * Fix interruptibility for ON_PRESS macro type * Fix default macro duration * Add Macro Documentation * Fix an issue failing to clear macro inputs * Fix incorrectly referenced next macro time --------- Co-authored-by: Kevin Nguyen <[email protected]>
- Loading branch information
1 parent
a8ebe0e
commit 170e97d
Showing
24 changed files
with
988 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Macro Settings | ||
|
||
Purpose: Macros are a series or combination of gamepad inputs triggered with a single button or a combination of buttons. | ||
|
||
![GP2040-CE Configurator - Macros](../assets/images/gpc-macros.png) | ||
|
||
## Macro Options | ||
|
||
`Macro Button Pin` - The GPIO Pin used to activate macros in combination with other inputs when `Uses Button` is enabled and set. | ||
|
||
### Label | ||
|
||
This is the name of the macro and is optional. | ||
|
||
### Activate | ||
|
||
- `Off` - The macro is not available for use. | ||
- `On` - The macro is available for use when triggered by either the GPIO pin or the combination set in [`Uses Button`](#uses-button). | ||
|
||
### Interruptible | ||
|
||
- `Off` - The macro cannot be stopped and will execute all lines until the macro is completed. | ||
- `On` - Any input will stop the current ongoing macro or, if the input is another macro, the interrupting macro trigger will start executing instead. | ||
|
||
### Exclusive | ||
|
||
- `Off` - Additional inputs from user will be sent as the macro continues to execute, resulting in a blend of macro and user inputs. | ||
- `On` - Filters only the macro inputs through and excludes any additional user gamepad inputs | ||
|
||
?> This option is **only** available when `Interruptible` is enabled. | ||
|
||
### Show Frames | ||
|
||
- `Off` - The duration in the macro input line editor will appear in milliseconds (ms). | ||
- `On` - The duration in the macro input line editor will appear as a number of frames, assuming 60 frames per second. | ||
|
||
### Uses Button | ||
|
||
- `Off` - This macro is assigned to a GPIO pin on the board and when pressed, the macro will be triggered. | ||
- `On` - This macro is assigned to a button combination of `Macro Button Pin + Input` where the input can be any of the standard gamepad inputs. | ||
|
||
### Trigger Mode | ||
|
||
This describes is how the GPIO pin or the combination set in [`Uses Button`](#uses-button) triggers and repeats the macro. | ||
|
||
- Press - Full press of button triggers the macro once | ||
- Hold Repeat - Holding button to repeatedly triggers macro | ||
- Toggle - Full press of button causes the macro to repeatedly trigger, another full press of the button will stop the macro from repeatedly triggering. | ||
|
||
## Macro Input Line Editor | ||
|
||
Each individual macro has a maximum of 50 lines where each input line has a maximum of 18 gamepad inputs (using all available gamepad inputs). | ||
|
||
![GP2040-CE Configurator - Macro Input Line](../assets/images/gpc-macros-input-line.png) | ||
|
||
Each input line is composed of the following elements from left to right. | ||
|
||
`Input Line Duration` ms `Inputs` | `Post Input Wait Duration` ms | ||
|
||
- Input Line Duration - The duration that the inputs are held for. (Maximum 4,294,967ms or 268,435 frames) | ||
- Inputs - The inputs to be held during the execution of the input line. | ||
- Post Input Wait Duration - The duration in-between when that input line finishes executing and when the next line will start executing. (Maximum 4,294,967ms or 268,435 frames) | ||
|
||
?> To delete an input line, double-click the "x" button. | ||
|
||
## Note | ||
|
||
- When a macro stops for any reason and are triggered. again, the macro starts again from the beginning. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef _InputMacro_H | ||
#define _InputMacro_H | ||
|
||
#include "gpaddon.h" | ||
|
||
#include "GamepadEnums.h" | ||
|
||
#ifndef INPUT_MACRO_ENABLED | ||
#define INPUT_MACRO_ENABLED 0 | ||
#endif | ||
|
||
#ifndef INPUT_MACRO_PIN | ||
#define INPUT_MACRO_PIN -1 | ||
#endif | ||
|
||
#define MAX_MACRO_INPUT_LIMIT 50 | ||
#define MAX_MACRO_LIMIT 6 | ||
#define INPUT_HOLD_US 16666 | ||
|
||
// Input Macro Module Name | ||
#define InputMacroName "Input Macro" | ||
|
||
class InputMacro : public GPAddon { | ||
public: | ||
virtual bool available(); // GPAddon available | ||
virtual void setup(); // Analog Setup | ||
virtual void process() {}; // Analog Process | ||
virtual void preprocess(); | ||
virtual std::string name() { return InputMacroName; } | ||
private: | ||
int macroPosition = -1; | ||
bool isMacroRunning = false; | ||
bool isMacroTriggerHeld = false; | ||
|
||
uint64_t macroStartTime = 0; | ||
uint64_t macroTriggerDebounceStartTime = 0; | ||
|
||
int macroInputPosition = 0; | ||
bool macroInputPressed = false; | ||
uint32_t macroInputHoldTime = INPUT_HOLD_US; | ||
bool prevMacroInputPressed = false; | ||
|
||
MacroOptions inputMacroOptions; | ||
void reset(); | ||
}; | ||
|
||
#endif // _InputMacro_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.