diff --git a/config/glyph/config.cpp b/config/glyph/config.cpp deleted file mode 100644 index a2cbae3b..00000000 --- a/config/glyph/config.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "button_positions.hpp" -#include "comms/backend_init.hpp" -#include "core/CommunicationBackend.hpp" -#include "core/KeyboardMode.hpp" -#include "core/Persistence.hpp" -#include "core/mode_selection.hpp" -#include "core/pinout.hpp" -#include "core/state.hpp" -#include "display/DisplayMode.hpp" -#include "display/GlyphConfigMenu.hpp" -#include "display/InputDisplay.hpp" -#include "display/MenuButtonHints.hpp" -#include "display/RgbBrightnessMenu.hpp" -#include "glyph_overrides.hpp" -#include "input/DebouncedSwitchMatrixInput.hpp" -#include "reboot.hpp" -#include "stdlib.hpp" - -#include -#include - -Config config = glyph_default_config(); - -const size_t num_rows = 4; -const size_t num_cols = 11; -const uint row_pins[num_rows] = { 26, 25, 24, 23 }; -const uint col_pins[num_cols] = { 15, 14, 13, 12, 16, 17, 21, 20, 19, 18, 22 }; -// clang-format off -const Button matrix[num_rows][num_cols] = { - {BTN_MB1, BTN_MB2, BTN_MB3, BTN_MB4, BTN_MB5, BTN_MB6, BTN_MB7, NA, NA, NA, NA }, - { BTN_LF3, BTN_LF2, BTN_LF6, BTN_LF7, BTN_RF12, BTN_RF13, BTN_RF14, BTN_RF5, BTN_RF6, BTN_RF7, BTN_RF8}, - { BTN_LF4, BTN_LF5, BTN_LF1, BTN_LF8, BTN_RF9, BTN_RF10, BTN_RF11, BTN_RF1, BTN_RF2, BTN_RF3, BTN_RF4}, - { BTN_LT5, BTN_LT4, BTN_LT1, BTN_LT3, BTN_LT2, BTN_LT6, BTN_RT2, BTN_RT3, BTN_RT1, BTN_RT4, BTN_RT5}, -}; -// clang-format on - -DebouncedSwitchMatrixInput matrix_input( - row_pins, - col_pins, - matrix, - DiodeDirection::COL2ROW -); - -const Pinout pinout = { - .joybus_data = 4, - .nes_data = 4, - .nes_clock = 5, - .nes_latch = 6, - .mux = -1, - .nunchuk_detect = -1, - .nunchuk_sda = -1, - .nunchuk_scl = -1, -}; - -CommunicationBackend **backends = nullptr; -size_t backend_count; -KeyboardMode *current_kb_mode = nullptr; - -InputState inputs; - -InputSource *input_sources[] = { &matrix_input }; -size_t input_source_count = sizeof(input_sources) / sizeof(InputSource *); - -void setup() { - // Create GPIO input source and use it to read button states for checking button holds. - matrix_input.UpdateInputs(inputs); - - // Check bootsel button hold as early as possible for safety. - if (inputs.mb1) { - reboot_bootloader(); - } - - // Attempt to load config, or write default config to flash if failed to load config. - if (!persistence.LoadConfig(config)) { - persistence.SaveConfig(config); - } - - // Create array of input sources to be used. - backend_count = initialize_backends( - backends, - inputs, - input_sources, - input_source_count, - config, - pinout, - get_backend_config_default, - get_usb_backend_config_default, - &detect_console, - &init_secondary_backends_glyph - ); - - setup_mode_activation_bindings(config.game_mode_configs, config.game_mode_configs_count); -} - -void loop() { - select_mode(backends, backend_count, config); - - for (size_t i = 0; i < backend_count; i++) { - backends[i]->SendReport(); - } - - if (current_kb_mode != nullptr) { - current_kb_mode->SendReport(backends[0]->GetInputs()); - } -} - -/* Second core handles OLED display */ -Adafruit_SSD1306 display(128, 64, &Wire1); -IntegratedDisplay *display_backend = nullptr; - -RgbBrightnessMenu rgb_brightness_menu(config); - -InputDisplay *input_viewer = nullptr; - -void setup1() { - while (!backend_count || backends == nullptr) { - delay(1); - } - - // These have to be initialized after backends. - CommunicationBackendId primary_backend_id = backends[0]->BackendId(); - static MenuButtonHints menu_button_hints(primary_backend_id); - static InputDisplay input_display( - platform_fighter_buttons, - platform_fighter_buttons_count, - primary_backend_id - ); - static GlyphConfigMenu config_menu(config, backends, backend_count); - - static DisplayMode *display_modes[] = { - &menu_button_hints, - &input_display, - &config_menu, - &rgb_brightness_menu, - }; - size_t display_modes_count = count_of(display_modes); - - input_viewer = &input_display; - - Wire1.setSDA(2); - Wire1.setSCL(3); - Wire1.setClock(1'000'000UL); - Wire1.begin(); - if (display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, false)) { - // clang-format off - display_backend = new IntegratedDisplay( - inputs, - display, - []() { display.clearDisplay(); }, - []() { display.display(); }, - DisplayControls{ .back = BTN_MB1, .down = BTN_MB6, .up = BTN_MB5, .enter = BTN_MB7 }, - display_modes, - display_modes_count - ); - // clang-format on - display_backend->SetDisplayMode( - config.default_dashboard_option == DASHBOARD_INPUT_VIEWER ? DISPLAY_MODE_VIEWER - : DISPLAY_MODE_BUTTON_HINTS - ); - } -} - -void loop1() { - if (display_backend == nullptr) { - return; - } - if (backends[0] != nullptr && backends[0]->CurrentGameMode() != nullptr && - display_backend->CurrentGameMode() != backends[0]->CurrentGameMode()) { - display_backend->SetGameMode(backends[0]->CurrentGameMode()); - } - // Update input display layout. - if (display_backend->CurrentGameMode() != nullptr) { - GameModeConfig *mode_config = display_backend->CurrentGameMode()->GetConfig(); - switch (mode_config->layout_plate) { - case LAYOUT_PLATE_UNSPECIFIED: - case LAYOUT_PLATE_EVERYTHING: - input_viewer->UpdateButtonLayout(full_layout_buttons, full_layout_buttons_count); - break; - case LAYOUT_PLATE_FGC: - input_viewer->UpdateButtonLayout(fgc_buttons, fgc_buttons_count); - break; - case LAYOUT_PLATE_SPLIT_FGC: - input_viewer->UpdateButtonLayout(split_fgc_buttons, split_fgc_buttons_count); - break; - case LAYOUT_PLATE_PLATFORM_FIGHTER: - input_viewer->UpdateButtonLayout( - platform_fighter_buttons, - platform_fighter_buttons_count - ); - break; - } - } - display_backend->SendReport(); -} diff --git a/config/glyph/env.ini b/config/glyph/env.ini deleted file mode 100644 index 2e02aecc..00000000 --- a/config/glyph/env.ini +++ /dev/null @@ -1,15 +0,0 @@ -[env:glyph] -extends = arduino_pico_base -build_flags = - ${arduino_pico_base.build_flags} - -I config/glyph/include - -D SSD1306_NO_SPLASH -build_src_filter = - ${arduino_pico_base.build_src_filter} - + -lib_ignore = - ${env.lib_ignore} - https://github.com/JonnyHaystack/HayBox-proto -lib_deps = - ${arduino_pico_base.lib_deps} - https://github.com/LimitLabs/HayBox-proto#3b7abdf \ No newline at end of file diff --git a/config/glyph/include/button_positions.hpp b/config/glyph/include/button_positions.hpp deleted file mode 100644 index 340f2883..00000000 --- a/config/glyph/include/button_positions.hpp +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef _BUTTON_POSITIONS_HPP -#define _BUTTON_POSITIONS_HPP - -#define MENU_BUTTON_RADIUS 2 -#define NORMAL_BUTTON_RADIUS 4 -#define LARGE_BUTTON_RADIUS 5 - -#include "display/InputDisplay.hpp" - -InputViewerButton full_layout_buttons[] = { - // {BTN_MB1, 2, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB2, 8, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB3, 14, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB4, 20, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB5, 26, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB6, 32, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB7, 38, 3, MENU_BUTTON_RADIUS }, - - {BTN_LF4, 6, 29, NORMAL_BUTTON_RADIUS}, - { BTN_LF3, 15, 23, NORMAL_BUTTON_RADIUS}, - { BTN_LF2, 25, 22, NORMAL_BUTTON_RADIUS}, - { BTN_LF1, 35, 27, NORMAL_BUTTON_RADIUS}, - { BTN_LF5, 24, 32, NORMAL_BUTTON_RADIUS}, - - { BTN_RF1, 93, 27, NORMAL_BUTTON_RADIUS}, - { BTN_RF2, 102, 23, NORMAL_BUTTON_RADIUS}, - { BTN_RF3, 112, 24, NORMAL_BUTTON_RADIUS}, - { BTN_RF4, 122, 29, NORMAL_BUTTON_RADIUS}, - - { BTN_RF5, 93, 17, NORMAL_BUTTON_RADIUS}, - { BTN_RF6, 102, 13, NORMAL_BUTTON_RADIUS}, - { BTN_RF7, 112, 14, NORMAL_BUTTON_RADIUS}, - { BTN_RF8, 122, 19, NORMAL_BUTTON_RADIUS}, - - { BTN_LT1, 38, 52, NORMAL_BUTTON_RADIUS}, - { BTN_LT2, 46, 58, NORMAL_BUTTON_RADIUS}, - { BTN_LT3, 46, 46, NORMAL_BUTTON_RADIUS}, - { BTN_LT4, 38, 40, NORMAL_BUTTON_RADIUS}, - { BTN_LT5, 30, 46, NORMAL_BUTTON_RADIUS}, - { BTN_LT6, 59, 50, LARGE_BUTTON_RADIUS }, - - { BTN_RT1, 90, 52, NORMAL_BUTTON_RADIUS}, - { BTN_RT2, 82, 58, NORMAL_BUTTON_RADIUS}, - { BTN_RT3, 82, 46, NORMAL_BUTTON_RADIUS}, - { BTN_RT4, 90, 40, NORMAL_BUTTON_RADIUS}, - { BTN_RT5, 98, 46, NORMAL_BUTTON_RADIUS}, - - { BTN_LF6, 35, 17, NORMAL_BUTTON_RADIUS}, - { BTN_LF7, 46, 19, NORMAL_BUTTON_RADIUS}, - { BTN_LF8, 55, 25, NORMAL_BUTTON_RADIUS}, - - { BTN_RF9, 64, 30, NORMAL_BUTTON_RADIUS}, - { BTN_RF10, 74, 25, NORMAL_BUTTON_RADIUS}, - { BTN_RF11, 84, 25, NORMAL_BUTTON_RADIUS}, - - { BTN_RF12, 64, 20, NORMAL_BUTTON_RADIUS}, - { BTN_RF13, 74, 15, NORMAL_BUTTON_RADIUS}, - { BTN_RF14, 84, 15, NORMAL_BUTTON_RADIUS}, -}; -size_t full_layout_buttons_count = count_of(full_layout_buttons); - -InputViewerButton platform_fighter_buttons[] = { - // {BTN_MB1, 2, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB2, 8, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB3, 14, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB4, 20, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB5, 26, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB6, 32, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB7, 38, 3, MENU_BUTTON_RADIUS }, - - {BTN_LF4, 6, 29, NORMAL_BUTTON_RADIUS}, - { BTN_LF3, 15, 23, NORMAL_BUTTON_RADIUS}, - { BTN_LF2, 25, 22, NORMAL_BUTTON_RADIUS}, - { BTN_LF1, 35, 27, NORMAL_BUTTON_RADIUS}, - { BTN_LF5, 24, 32, NORMAL_BUTTON_RADIUS}, - - { BTN_RF1, 93, 27, NORMAL_BUTTON_RADIUS}, - { BTN_RF2, 102, 23, NORMAL_BUTTON_RADIUS}, - { BTN_RF3, 112, 24, NORMAL_BUTTON_RADIUS}, - { BTN_RF4, 122, 29, NORMAL_BUTTON_RADIUS}, - - { BTN_RF5, 93, 17, NORMAL_BUTTON_RADIUS}, - { BTN_RF6, 102, 13, NORMAL_BUTTON_RADIUS}, - { BTN_RF7, 112, 14, NORMAL_BUTTON_RADIUS}, - { BTN_RF8, 122, 19, NORMAL_BUTTON_RADIUS}, - - { BTN_LT1, 38, 52, NORMAL_BUTTON_RADIUS}, - { BTN_LT2, 46, 58, NORMAL_BUTTON_RADIUS}, - { BTN_LT3, 46, 46, NORMAL_BUTTON_RADIUS}, - { BTN_LT4, 38, 40, NORMAL_BUTTON_RADIUS}, - { BTN_LT5, 30, 46, NORMAL_BUTTON_RADIUS}, - - { BTN_RT1, 90, 52, NORMAL_BUTTON_RADIUS}, - { BTN_RT2, 82, 58, NORMAL_BUTTON_RADIUS}, - { BTN_RT3, 82, 46, NORMAL_BUTTON_RADIUS}, - { BTN_RT4, 90, 40, NORMAL_BUTTON_RADIUS}, - { BTN_RT5, 98, 46, NORMAL_BUTTON_RADIUS}, -}; -size_t platform_fighter_buttons_count = count_of(platform_fighter_buttons); - -InputViewerButton split_fgc_buttons[] = { - // {BTN_MB1, 2, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB2, 8, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB3, 14, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB4, 20, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB5, 26, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB6, 32, 3, MENU_BUTTON_RADIUS }, - // { BTN_MB7, 38, 3, MENU_BUTTON_RADIUS }, - - {BTN_LF3, 15, 23, NORMAL_BUTTON_RADIUS}, - { BTN_LF2, 25, 22, NORMAL_BUTTON_RADIUS}, - { BTN_LF1, 35, 27, NORMAL_BUTTON_RADIUS}, - { BTN_LF5, 24, 32, NORMAL_BUTTON_RADIUS}, - - { BTN_RF1, 93, 27, NORMAL_BUTTON_RADIUS}, - { BTN_RF2, 102, 23, NORMAL_BUTTON_RADIUS}, - { BTN_RF3, 112, 24, NORMAL_BUTTON_RADIUS}, - { BTN_RF4, 122, 29, NORMAL_BUTTON_RADIUS}, - - { BTN_RF5, 93, 17, NORMAL_BUTTON_RADIUS}, - { BTN_RF6, 102, 13, NORMAL_BUTTON_RADIUS}, - { BTN_RF7, 112, 14, NORMAL_BUTTON_RADIUS}, - { BTN_RF8, 122, 19, NORMAL_BUTTON_RADIUS}, - - { BTN_LT1, 38, 52, LARGE_BUTTON_RADIUS }, - { BTN_RT1, 90, 52, LARGE_BUTTON_RADIUS }, -}; -size_t split_fgc_buttons_count = count_of(split_fgc_buttons); - -InputViewerButton fgc_buttons[] = { - {BTN_LF6, 35, 17, NORMAL_BUTTON_RADIUS}, - { BTN_LF7, 46, 19, NORMAL_BUTTON_RADIUS}, - { BTN_LF8, 55, 25, NORMAL_BUTTON_RADIUS}, - - { BTN_RF9, 64, 30, NORMAL_BUTTON_RADIUS}, - { BTN_RF10, 74, 25, NORMAL_BUTTON_RADIUS}, - { BTN_RF11, 84, 25, NORMAL_BUTTON_RADIUS}, - { BTN_RF1, 93, 27, NORMAL_BUTTON_RADIUS}, - - { BTN_RF12, 64, 20, NORMAL_BUTTON_RADIUS}, - { BTN_RF13, 74, 15, NORMAL_BUTTON_RADIUS}, - { BTN_RF14, 84, 15, NORMAL_BUTTON_RADIUS}, - { BTN_RF5, 93, 17, NORMAL_BUTTON_RADIUS}, - - { BTN_LT6, 59, 50, LARGE_BUTTON_RADIUS } -}; -size_t fgc_buttons_count = count_of(fgc_buttons); - -#endif \ No newline at end of file diff --git a/config/glyph/include/display/GlyphConfigMenu.hpp b/config/glyph/include/display/GlyphConfigMenu.hpp deleted file mode 100644 index 775db523..00000000 --- a/config/glyph/include/display/GlyphConfigMenu.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _DISPLAY_GLYPHCONFIGMENU_HPP -#define _DISPLAY_GLYPHCONFIGMENU_HPP - -#include "display/DefaultConfigMenu.hpp" - -/** - * @brief Modified version of ConfigMenu that only shows gamemodes marked as applicable for current - * CommunicationBackend. - */ -class GlyphConfigMenu : public DefaultConfigMenu { - public: - GlyphConfigMenu(Config &config, CommunicationBackend **backends, size_t backends_count); - void ReturnToDashboard(IntegratedDisplay *instance); - - private: - static void SetDashboardOption( - IntegratedDisplay *instance, - ConfigMenu *menu, - Config &config, - uint8_t mode_config_index - ); -}; - -#endif \ No newline at end of file diff --git a/config/glyph/include/display/MenuButtonHints.hpp b/config/glyph/include/display/MenuButtonHints.hpp deleted file mode 100644 index 52dc9c39..00000000 --- a/config/glyph/include/display/MenuButtonHints.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _DISPLAY_MENUBUTTONHINTS_HPP -#define _DISPLAY_MENUBUTTONHINTS_HPP - -#include "display/DisplayMode.hpp" - -class MenuButtonHints : public DisplayMode { - public: - MenuButtonHints(CommunicationBackendId backend_id); - DisplayModeId GetId(); - void HandleControls( - IntegratedDisplay *instance, - const DisplayControls &controls, - Button button - ); - void UpdateDisplay(IntegratedDisplay *instance, Adafruit_GFX &display); - - protected: - CommunicationBackendId _backend_id; -}; - -#endif \ No newline at end of file diff --git a/config/glyph/include/glyph_overrides.hpp b/config/glyph/include/glyph_overrides.hpp deleted file mode 100644 index 13511145..00000000 --- a/config/glyph/include/glyph_overrides.hpp +++ /dev/null @@ -1,404 +0,0 @@ -#ifndef _GLYPH_OVERRIDES_HPP -#define _GLYPH_OVERRIDES_HPP - -#include "comms/B0XXInputViewer.hpp" -#include "comms/IntegratedDisplay.hpp" -#include "comms/NeoPixelBackend.hpp" -#include "core/config_utils.hpp" -#include "stdlib.hpp" - -#include -#include - -#define LED_PIN 7 -#define LED_COUNT 72 - -// clang-format off - -const Config default_config = { - .game_mode_configs_count = 6, - .game_mode_configs = { - GameModeConfig { - .mode_id = MODE_MELEE, - .socd_pairs_count = 4, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_LF2, .button_dir2 = BTN_RF4, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_RT3, .button_dir2 = BTN_RT5, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_RT2, .button_dir2 = BTN_RT4, .socd_type = SOCD_2IP_NO_REAC }, - }, - .button_remapping_count = 4, - .button_remapping = { - ButtonRemap { .physical_button = BTN_MB1, .activates = BTN_UNSPECIFIED }, // Menu - ButtonRemap { .physical_button = BTN_MB2, .activates = BTN_MB1 }, // Start - ButtonRemap { .physical_button = BTN_MB3, .activates = BTN_MB3 }, // Back - ButtonRemap { .physical_button = BTN_MB4, .activates = BTN_MB2 }, // Home - }, - .rgb_config = 1, - }, - GameModeConfig { - .mode_id = MODE_PROJECT_M, - .socd_pairs_count = 4, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_LF2, .button_dir2 = BTN_RF4, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_RT3, .button_dir2 = BTN_RT5, .socd_type = SOCD_2IP_NO_REAC }, - SocdPair { .button_dir1 = BTN_RT2, .button_dir2 = BTN_RT4, .socd_type = SOCD_2IP_NO_REAC }, - }, - .button_remapping_count = 4, - .button_remapping = { - ButtonRemap { .physical_button = BTN_MB1, .activates = BTN_UNSPECIFIED }, // Menu - ButtonRemap { .physical_button = BTN_MB2, .activates = BTN_MB1 }, // Start - ButtonRemap { .physical_button = BTN_MB3, .activates = BTN_MB3 }, // Back - ButtonRemap { .physical_button = BTN_MB4, .activates = BTN_MB2 }, // Home - }, - .rgb_config = 1, - }, - GameModeConfig { - .mode_id = MODE_ULTIMATE, - .socd_pairs_count = 4, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_2IP }, - SocdPair { .button_dir1 = BTN_LF2, .button_dir2 = BTN_RF4, .socd_type = SOCD_2IP }, - SocdPair { .button_dir1 = BTN_RT3, .button_dir2 = BTN_RT5, .socd_type = SOCD_2IP }, - SocdPair { .button_dir1 = BTN_RT2, .button_dir2 = BTN_RT4, .socd_type = SOCD_2IP }, - }, - .button_remapping_count = 4, - .button_remapping = { - ButtonRemap { .physical_button = BTN_MB1, .activates = BTN_UNSPECIFIED }, // Menu - ButtonRemap { .physical_button = BTN_MB2, .activates = BTN_MB1 }, // Start - ButtonRemap { .physical_button = BTN_MB3, .activates = BTN_MB3 }, // Back - ButtonRemap { .physical_button = BTN_MB4, .activates = BTN_MB2 }, // Home - }, - .rgb_config = 1, - }, - GameModeConfig { - .mode_id = MODE_FGC, - .name = "Split FGC", - .socd_pairs_count = 2, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_NEUTRAL }, - SocdPair { .button_dir1 = BTN_LF2, .button_dir2 = BTN_LT1, .socd_type = SOCD_NEUTRAL }, - }, - .button_remapping_count = 7, - .button_remapping = { - ButtonRemap { .physical_button = BTN_RT1, .activates = BTN_LT1 }, - ButtonRemap { .physical_button = BTN_MB3, .activates = BTN_RT3 }, - ButtonRemap { .physical_button = BTN_MB4, .activates = BTN_RT2 }, - ButtonRemap { .physical_button = BTN_MB2, .activates = BTN_MB1 }, - ButtonRemap { .physical_button = BTN_RT2, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RT3, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_MB1, .activates = BTN_UNSPECIFIED }, - }, - .rgb_config = 1, - .layout_plate = LAYOUT_PLATE_SPLIT_FGC, - }, - GameModeConfig { - .mode_id = MODE_FGC, - .socd_pairs_count = 2, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_NEUTRAL }, - SocdPair { .button_dir1 = BTN_LF2, .button_dir2 = BTN_LT1, .socd_type = SOCD_NEUTRAL }, - }, - .button_remapping_count = 28, - .button_remapping = { - // Right hand bottom row - ButtonRemap { .physical_button = BTN_RF9, .activates = BTN_RF1 }, - ButtonRemap { .physical_button = BTN_RF10, .activates = BTN_RF2 }, - ButtonRemap { .physical_button = BTN_RF11, .activates = BTN_RF3 }, - ButtonRemap { .physical_button = BTN_RF1, .activates = BTN_RF4 }, - // Right hand top row - ButtonRemap { .physical_button = BTN_RF12, .activates = BTN_RF5 }, - ButtonRemap { .physical_button = BTN_RF13, .activates = BTN_RF6 }, - ButtonRemap { .physical_button = BTN_RF14, .activates = BTN_RF7 }, - ButtonRemap { .physical_button = BTN_RF5, .activates = BTN_RF8 }, - // Left hand row - ButtonRemap { .physical_button = BTN_LF8, .activates = BTN_LF1 }, - ButtonRemap { .physical_button = BTN_LF7, .activates = BTN_LF2 }, - ButtonRemap { .physical_button = BTN_LF6, .activates = BTN_LF3 }, - // Up button - ButtonRemap { .physical_button = BTN_LT6, .activates = BTN_LT1 }, - // Menu buttons - ButtonRemap { .physical_button = BTN_MB3, .activates = BTN_RT3 }, - ButtonRemap { .physical_button = BTN_MB4, .activates = BTN_RT2 }, - ButtonRemap { .physical_button = BTN_MB2, .activates = BTN_MB1 }, - - // Unmap the old buttons - ButtonRemap { .physical_button = BTN_RF2, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RF3, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RF4, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RF6, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RF7, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RF8, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_LF1, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_LF2, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_LF3, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_LT1, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RT2, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_RT3, .activates = BTN_UNSPECIFIED }, - ButtonRemap { .physical_button = BTN_MB1, .activates = BTN_UNSPECIFIED }, - }, - .rgb_config = 2, - .layout_plate = LAYOUT_PLATE_FGC, - }, - GameModeConfig { - .mode_id = MODE_KEYBOARD, - .socd_pairs_count = 2, - .socd_pairs = { - SocdPair { .button_dir1 = BTN_LF3, .button_dir2 = BTN_LF1, .socd_type = SOCD_2IP }, - SocdPair { .button_dir1 = BTN_LT1, .button_dir2 = BTN_RT4, .socd_type = SOCD_2IP }, - }, - .button_remapping_count = 0, - .keyboard_mode_config = 1, - }, - }, - .communication_backend_configs_count = 8, - .communication_backend_configs = { - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_XINPUT, - .default_mode_config = 1, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_DINPUT, - .default_mode_config = 1, - .activation_binding_count = 1, - .activation_binding = { BTN_RF3 }, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_NINTENDO_SWITCH, - .default_mode_config = 3, - .activation_binding_count = 1, - .activation_binding = { BTN_RF2 }, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_GAMECUBE, - .default_mode_config = 1, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_N64, - .default_mode_config = 1, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_NES, - .default_mode_config = 1, - .activation_binding_count = 1, - .activation_binding = { BTN_LT1 }, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_SNES, - .default_mode_config = 1, - .activation_binding_count = 1, - .activation_binding = { BTN_LT2 }, - }, - CommunicationBackendConfig { - .backend_id = COMMS_BACKEND_CONFIGURATOR, - .activation_binding_count = 1, - .activation_binding = { BTN_RT2 }, - } - }, - .keyboard_modes_count = 1, - .keyboard_modes = { - KeyboardModeConfig { - 0, - 22, - { - { BTN_LF4, HID_KEY_A }, - { BTN_LF3, HID_KEY_B }, - { BTN_LF2, HID_KEY_C }, - { BTN_LF1, HID_KEY_D }, - { BTN_LT1, HID_KEY_E }, - { BTN_LT2, HID_KEY_F }, - { BTN_MB3, HID_KEY_G }, - { BTN_MB1, HID_KEY_H }, - { BTN_MB2, HID_KEY_I }, - { BTN_RF5, HID_KEY_J }, - { BTN_RF6, HID_KEY_K }, - { BTN_RF7, HID_KEY_L }, - { BTN_RF8, HID_KEY_M }, - { BTN_RF1, HID_KEY_N }, - { BTN_RF2, HID_KEY_O }, - { BTN_RF3, HID_KEY_P }, - { BTN_RF4, HID_KEY_Q }, - { BTN_RT4, HID_KEY_R }, - { BTN_RT3, HID_KEY_S }, - { BTN_RT5, HID_KEY_T }, - { BTN_RT1, HID_KEY_U }, - { BTN_RT2, HID_KEY_V }, - }, - }, - }, - .rgb_configs_count = 2, - .rgb_configs = { - RgbConfig { - .button_colors_count = 19, - .button_colors = { - { BTN_LF1, 0x0000ff }, - { BTN_LF2, 0x0000ff }, - { BTN_LF3, 0x0000ff }, - { BTN_LF4, 0x0000ff }, - { BTN_LT1, 0x0000ff }, - { BTN_LT2, 0x0000ff }, - { BTN_RF1, 0x0000ff }, - { BTN_RF2, 0x0000ff }, - { BTN_RF3, 0x0000ff }, - { BTN_RF4, 0x0000ff }, - { BTN_RF5, 0x0000ff }, - { BTN_RF6, 0x0000ff }, - { BTN_RF7, 0x0000ff }, - { BTN_RF8, 0x0000ff }, - { BTN_RT1, 0x0000ff }, - { BTN_RT2, 0x0000ff }, - { BTN_RT3, 0x0000ff }, - { BTN_RT4, 0x0000ff }, - { BTN_RT5, 0x0000ff }, - }, - }, - RgbConfig { - .button_colors_count = 12, - .button_colors = { - { BTN_LF6, 0xff0000 }, - { BTN_LF7, 0xff0000 }, - { BTN_LF8, 0xff0000 }, - { BTN_LT6, 0xff0000 }, - { BTN_RF9, 0xff0000 }, - { BTN_RF10, 0xff0000 }, - { BTN_RF11, 0xff0000 }, - { BTN_RF1, 0xff0000 }, - { BTN_RF12, 0xff0000 }, - { BTN_RF13, 0xff0000 }, - { BTN_RF14, 0xff0000 }, - { BTN_RF5, 0xff0000 }, - }, - }, - }, - .default_backend_config = 1, - .default_usb_backend_config = 1, - .rgb_brightness = 255, -}; - -const Button pixel_to_button_mappings[LED_COUNT] = { - BTN_MB1, BTN_MB1, - BTN_LF4, BTN_LF4, - BTN_LF3, BTN_LF3, - BTN_LF5, BTN_LF5, - BTN_LF2, BTN_LF2, - BTN_LF1, BTN_LF1, - BTN_LF6, BTN_LF6, - BTN_LF7, BTN_LF7, - BTN_LF8, BTN_LF8, - BTN_RF12, BTN_RF12, - BTN_RF13, BTN_RF13, - BTN_RF14, BTN_RF14, - BTN_RF5, BTN_RF5, - BTN_RF6, BTN_RF6, - BTN_RF7, BTN_RF7, - BTN_RF8, BTN_RF8, - BTN_RF4, BTN_RF4, - BTN_RF3, BTN_RF3, - BTN_RF2, BTN_RF2, - BTN_RF1, BTN_RF1, - BTN_RF11, BTN_RF11, - BTN_RF10, BTN_RF10, - BTN_RF9, BTN_RF9, - BTN_RT3, BTN_RT3, - BTN_RT4, BTN_RT4, - BTN_RT5, BTN_RT5, - BTN_RT1, BTN_RT1, - BTN_RT1, BTN_RT1, - BTN_RT2, BTN_RT2, - BTN_LT6, BTN_LT6, - BTN_LT3, BTN_LT3, - BTN_LT4, BTN_LT4, - BTN_LT5, BTN_LT5, - BTN_LT1, BTN_LT1, - BTN_LT1, BTN_LT1, - BTN_LT2, BTN_LT2, -}; - -// clang-format on - -Config glyph_default_config() { - Config config = default_config; - - // Assign layout plates and applicable backends for default gamemode configs. - for (size_t i = 0; i < config.game_mode_configs_count; i++) { - GameModeConfig &mode_config = config.game_mode_configs[i]; - switch (mode_config.mode_id) { - case MODE_FGC: - mode_config.applicable_backends[0] = COMMS_BACKEND_XINPUT; - mode_config.applicable_backends[1] = COMMS_BACKEND_DINPUT; - mode_config.applicable_backends[2] = COMMS_BACKEND_NINTENDO_SWITCH; - mode_config.applicable_backends_count = 3; - break; - case MODE_MELEE: - case MODE_PROJECT_M: - case MODE_ULTIMATE: - case MODE_RIVALS_OF_AETHER: - mode_config.rgb_config = 1; - mode_config.layout_plate = LAYOUT_PLATE_PLATFORM_FIGHTER; - mode_config.applicable_backends[0] = COMMS_BACKEND_XINPUT; - mode_config.applicable_backends[1] = COMMS_BACKEND_DINPUT; - mode_config.applicable_backends[2] = COMMS_BACKEND_NINTENDO_SWITCH; - mode_config.applicable_backends[3] = COMMS_BACKEND_GAMECUBE; - mode_config.applicable_backends_count = 4; - break; - case MODE_KEYBOARD: - mode_config.applicable_backends[0] = COMMS_BACKEND_DINPUT; - mode_config.applicable_backends_count = 1; - mode_config.rgb_config = 1; - break; - default: - mode_config.layout_plate = LAYOUT_PLATE_EVERYTHING; - } - } - - return config; -} - -size_t init_secondary_backends_glyph( - CommunicationBackend **&backends, - CommunicationBackend *&primary_backend, - CommunicationBackendId backend_id, - InputState &inputs, - InputSource **input_sources, - size_t input_source_count, - Config &config, - const Pinout &pinout -) { - size_t backend_count = init_secondary_backends_default( - backends, - primary_backend, - backend_id, - inputs, - input_sources, - input_source_count, - config, - pinout - ); - - // Create new array containing all old backends but with length increased by 1 to make space for - // NeoPixel backend. - CommunicationBackend **new_backends = new CommunicationBackend *[backend_count + 1]; - for (size_t i = 0; i < backend_count; i++) { - new_backends[i] = backends[i]; - } - - // Add new backend to array and increase backend count to reflect this. - new_backends[backend_count++] = new NeoPixelBackend( - inputs, - input_sources, - input_source_count, - pixel_to_button_mappings, - config.rgb_configs, - config.rgb_configs_count, - config.rgb_brightness - ); - - // Delete the old backends array and reassign it. - delete[] backends; - backends = new_backends; - - return backend_count; -} - -#endif \ No newline at end of file diff --git a/config/glyph/src/display/GlyphConfigMenu.cpp b/config/glyph/src/display/GlyphConfigMenu.cpp deleted file mode 100644 index cf91f7bb..00000000 --- a/config/glyph/src/display/GlyphConfigMenu.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "display/GlyphConfigMenu.hpp" - -#include "core/Persistence.hpp" -#include "core/config_utils.hpp" -#include "core/mode_selection.hpp" -#include "reboot.hpp" - -GlyphConfigMenu::GlyphConfigMenu( - Config &config, - CommunicationBackend **backends, - size_t backends_count -) - : DefaultConfigMenu(config, backends, backends_count) { - /* Build gamemodes page */ - size_t gamemode_options_count = 0; - for (size_t i = 0; i < config.game_mode_configs_count; i++) { - GameModeConfig &mode_config = config.game_mode_configs[i]; - MenuPage::MenuItem ¤t_option = _gamemode_options_page.items[gamemode_options_count]; - - // Only show gamemodes that are applicable to the current comms backend. - if (mode_config.applicable_backends_count > 0 && _backends_count > 0 && - _backends[0] != nullptr) { - CommunicationBackendId primary_backend_id = _backends[0]->BackendId(); - bool applicable = false; - for (size_t i = 0; i < mode_config.applicable_backends_count; i++) { - if (primary_backend_id == mode_config.applicable_backends[i]) { - applicable = true; - break; - } - } - if (!applicable) { - continue; - } - } - - if (strnlen(mode_config.name, sizeof(mode_config.name)) > 0) { - strlcpy(current_option.text, mode_config.name, sizeof(current_option.text)); - } else { - strlcpy( - current_option.text, - gamemode_name(mode_config.mode_id), - sizeof(current_option.text) - ); - } - current_option.key = i; - current_option.action = &SetDefaultMode; - gamemode_options_count++; - } - _gamemode_options_page.items_count = gamemode_options_count; - - /* Add new page for dashboard option */ - // clang-format off - size_t dashboard_options_count = 2; - static MenuPage::MenuItem dashboard_options[] = { - { - .text = "Dashboard Menu", - .key = DASHBOARD_MENU_BUTTON_HINTS, - .action = &SetDashboardOption, - }, - { - .text = "Input Viewer", - .key = DASHBOARD_INPUT_VIEWER, - .action = &SetDashboardOption, - }, - }; - // clang-format on - - static MenuPage dashboard_options_page = { - .parent = _top_level_page, - .items = dashboard_options, - .items_count = sizeof(dashboard_options) / sizeof(MenuPage::MenuItem), - }; - - /* Overrides for top-level page */ - strlcpy(_top_level_page->items[2].text, "SOCD Option", sizeof(_top_level_page->items[2].text)); - _top_level_page->items[4] = { - .text = "Dashboard Option", - .page = &dashboard_options_page, - }; -} - -void GlyphConfigMenu::ReturnToDashboard(IntegratedDisplay *instance) { - instance->SetDisplayMode( - _config.default_dashboard_option == DASHBOARD_INPUT_VIEWER ? DISPLAY_MODE_VIEWER - : DISPLAY_MODE_BUTTON_HINTS - ); -} - -void GlyphConfigMenu::SetDashboardOption( - IntegratedDisplay *display_backend, - ConfigMenu *menu, - Config &config, - uint8_t dashboard_option -) { - // Restore gamemode. - GlyphConfigMenu *config_menu = (GlyphConfigMenu *)menu; - if (config_menu->_backends[0] != nullptr) { - config_menu->_backends[0]->SetGameMode(display_backend->CurrentGameMode()); - } - - config.default_dashboard_option = (DashboardOption)dashboard_option; - config_menu->ReturnToDashboard(display_backend); -} \ No newline at end of file diff --git a/config/glyph/src/display/MenuButtonHints.cpp b/config/glyph/src/display/MenuButtonHints.cpp deleted file mode 100644 index 6335f44b..00000000 --- a/config/glyph/src/display/MenuButtonHints.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "display/MenuButtonHints.hpp" - -#include "comms/IntegratedDisplay.hpp" -#include "core/config_utils.hpp" -#include "util/state_util.hpp" - -MenuButtonHints::MenuButtonHints(const CommunicationBackendId backend_id) - : _backend_id(backend_id) {} - -DisplayModeId MenuButtonHints::GetId() { - return DISPLAY_MODE_BUTTON_HINTS; -} - -void MenuButtonHints::HandleControls( - IntegratedDisplay *instance, - const DisplayControls &controls, - Button button -) { - if (button == controls.back) { - instance->SetDisplayMode(DISPLAY_MODE_CONFIG); - } -} - -void MenuButtonHints::UpdateDisplay(IntegratedDisplay *instance, Adafruit_GFX &display) { - InputState &inputs = instance->GetInputs(); - uint8_t font_width = instance->font_width; - uint8_t color = instance->default_color; - - /* Gamemode text */ - display.setCursor(0, 0); - if (instance->CurrentGameMode() != nullptr) { - const GameModeConfig &mode_config = *instance->CurrentGameMode()->GetConfig(); - if (strnlen(mode_config.name, sizeof(mode_config.name)) > 0) { - display.print(mode_config.name); - } else { - display.print(gamemode_name(mode_config.mode_id)); - } - } - - /* Backend text */ - const char *backend_text = backend_name(_backend_id); - display.setCursor(display.width() - (strlen(backend_text) * font_width), 0); - display.print(backend_name(_backend_id)); - - /* Button hints */ - uint8_t old_rotation = display.getRotation(); - display.setRotation(3); - - display.setCursor(0, 0); - - display.println("Menu\n"); - display.println("Start\n"); - display.println("Back\n"); - display.println("Home\n"); - display.println("Capt.\n"); - display.println("L3\n"); - display.println("R3\n"); - - display.setRotation(old_rotation); -} \ No newline at end of file