forked from OpenStickCommunity/GP2040-CE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert core GPIO pin mappings from button-to-pin to pin-to-action (O…
…penStickCommunity#504) * convert core GPIO pin mappings from button2pin to pin2action this changes the core board config and gamepad behavior to be that the settings/user configures what each pin does, rather than the old behavior which configures what pin each button is assigned to. this allows for the new configuration to have one canonical location for what each of the pins does, and removes the limitation that a button can only normally be activated by one pin --- now it is trivial to assign many pins to take the same action "actions" are all button presses right now, but they may be other things in the future as this branch expands. this is just the core functionality and migration code for now, further changes (removing extra input addon, refactoring DDI, maybe refactoring the sliders, working the profiles into this scheme, etc.) to come * remove the extra button addon, it is unnecessary now * unset deprecated pin mappings after migration * unset the extra button addon pin after migration * fix the processing of the aux state/Fn button * renumber the non-managed pin enum entries motivation for this is the migration sets everything to NONE anyway, so the 0 value isn't super important to us, and protobuf by convention seems to use the lowest value as a default (e.g. in the python GUI editor), so setting that to NONE is idiomatic in both cases * fix the unsetting of the extra input addon after migrating * convert DDI pins to gpioMappings the rest of the DDI settings remain untouched, and the whole addon is basically where it always was, this just allows for centralization in the new GPIO mappings * add TODO for fixing the pin UI * fix the checking of the DDI masks * convert get/setPinMappings API to match refactor * "hardcode" the writing of 30 pins to JSON ArduinoJson retains the reference to the string until write time, so it was only actually publishing the value for pin29 * convert the JS slider pins to the centralized config there's not much left of the addon other than the config for what to do when nothing is held, so, this is a great candidate for getting folded into core * rename default JS mode option for consistency w/SOCD slider * preliminary SOCD slider port to gpioMappings * correct JS slider migration to refer to proper config/defines * correct SOCD slider migration by referring to proper settings * Global pin state action example using zustand * Export baseUrl * Pin to action ui playground, using global state with zustand * Hide som actions from dropdown. make the select disabled if action is set from board * Add a form for semantics * Add translation for labels, dynamic columns. * Remove pin -> action PoC from playground * Make savePins return promise * Replace pin mapping with pin -> action * Remove unused handler in usePinStore * remove DDI pins from addon page, point at Pin Mapping page * add more add-on pin usages to the UI * flag miscellaneous addon pins as ASSIGNED in migration * when saving addons/display pins in web config, mark them ASSIGNED * don't allow profiles to touch RESERVED/ASSIGNED_TO_ADDON this is partially a problem now (we shouldn't let a profile assign a pin that is normally reserved or on a addon), and partially a problem in the future (we shouldn't let a profile SET a pin to reserved/for an addon), when the profiles are refactored to use gpio mappings * Add better typing for usePinStore * - Create a new Capture button component that is reusable for any input. - Make new pin mapping handle labels for all input modes including swapTpShareLabels * don't include ASSIGNED_TO_ADDON in getUsedPins temporary measure as the addons' validation needs reworking to support a response that includes their own pins * don't allow setPinMappings to set/change addon/reserved pins * addons API shouldn't refer to DDI pins anymore now that they're "core" * remove unused API stuff from the dev server JSON * DRY on the simple protobuf-or-boardconfig pin migrations this also removes the protobuf isValidPin(foo) check and replaces it with a has_ + a nested check that it's between 0 and 29, so that if a user set a button to -1, we don't fallback to the BoardConfig.h, which would clobber their intentional unmapping * set ASSIGNED_TO_ADDON -> NONE if the new addon pin is invalid * un-ASSIGNED_TO_ADDON the Dminus pins when unsetting the Dplus pins * Remove double call on context * Remove useState for selectedBoard as it's only set once * Remove unused imports * Remove setLoading on getPinMappings as this creates race conditions, remove log * Map new pin actions to button mappings for profile settings * Remove unused lodash import * Remove export * remove unused EXTRA_BUTTON_ENABLED define * track when migrations have occurred I believe that it would be possible, without this history, for someone to unmap certain gpioMappings (or hotkeys) for intentional reasons and then accidentally trigger a re-conversion of the old BoardConfig.h values, meaning they could never unmap certain hotkeys or gpioMappings. this bool avoids that by only running the migration code once ever maybe it makes startup faster too, idk * remove unnecessary save()s in slider addons * define types for a pin and a gamepad mask --------- Co-authored-by: ian <[email protected]>
- Loading branch information
Showing
40 changed files
with
1,721 additions
and
1,297 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
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 was deleted.
Oops, something went wrong.
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
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,13 @@ | ||
/* | ||
* SPDX-License-Identifier: MIT | ||
* SPDX-FileCopyrightText: Copyright (c) 2023 Brian S. Stephan <[email protected]> | ||
*/ | ||
|
||
#ifndef TYPES_H_ | ||
#define TYPES_H_ | ||
|
||
// common types | ||
#define Pin_t int32_t // signed to accommodate for -1 | ||
#define Mask_t uint32_t | ||
|
||
#endif |
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.