diff --git a/Firmware/RP2040/.vscode/settings.json b/Firmware/RP2040/.vscode/settings.json index da9731d5..f0506b3a 100644 --- a/Firmware/RP2040/.vscode/settings.json +++ b/Firmware/RP2040/.vscode/settings.json @@ -2,7 +2,7 @@ "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", "cmake.configureArgs": [ - "-DOGXM_BOARD=ESP32_BLUERETRO_I2C", + "-DOGXM_BOARD=RP2040_ZERO", // "-DOGXM_RETAIL=TRUE", "-DMAX_GAMEPADS=1" ], diff --git a/Firmware/RP2040/src/USBHost/HostDriver/DInput/DInput.cpp b/Firmware/RP2040/src/USBHost/HostDriver/DInput/DInput.cpp index e1e97eb6..930effc9 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/DInput/DInput.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/DInput/DInput.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/N64/N64.cpp b/Firmware/RP2040/src/USBHost/HostDriver/N64/N64.cpp index a5939aab..79697081 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/N64/N64.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/N64/N64.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/PS3/PS3.cpp b/Firmware/RP2040/src/USBHost/HostDriver/PS3/PS3.cpp index 075acfbb..6271c834 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/PS3/PS3.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/PS3/PS3.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/PS5/PS5.cpp b/Firmware/RP2040/src/USBHost/HostDriver/PS5/PS5.cpp index 0389b787..0030f711 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/PS5/PS5.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/PS5/PS5.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/SwitchPro/SwitchPro.cpp b/Firmware/RP2040/src/USBHost/HostDriver/SwitchPro/SwitchPro.cpp index 105f3081..e82f15c4 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/SwitchPro/SwitchPro.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/SwitchPro/SwitchPro.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/SwitchWired/SwitchWired.cpp b/Firmware/RP2040/src/USBHost/HostDriver/SwitchWired/SwitchWired.cpp index b5c6210a..5704a0db 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/SwitchWired/SwitchWired.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/SwitchWired/SwitchWired.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" #include "class/hid/hid_host.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/XInput/Xbox360.cpp b/Firmware/RP2040/src/USBHost/HostDriver/XInput/Xbox360.cpp index 58e75051..2635cfc2 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/XInput/Xbox360.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/XInput/Xbox360.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOG.cpp b/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOG.cpp index 78122c3f..968b954a 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOG.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOG.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" diff --git a/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOne.cpp b/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOne.cpp index 6dab8113..df3f21f1 100644 --- a/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOne.cpp +++ b/Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOne.cpp @@ -1,4 +1,5 @@ #include +#include #include "host/usbh.h" diff --git a/Firmware/RP2040/src/UserSettings/UserSettings.cpp b/Firmware/RP2040/src/UserSettings/UserSettings.cpp index b0cd1805..dc075bc6 100644 --- a/Firmware/RP2040/src/UserSettings/UserSettings.cpp +++ b/Firmware/RP2040/src/UserSettings/UserSettings.cpp @@ -23,6 +23,9 @@ namespace ButtonCombo { static constexpr uint32_t XBOXOG_XR = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_LB, Gamepad::DPAD_RIGHT); static constexpr uint32_t PSCLASSIC = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_A); static constexpr uint32_t WEBAPP = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_LB | Gamepad::BUTTON_RB); + static constexpr uint32_t NEXTPREF = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_RB, Gamepad::DPAD_DOWN); + static constexpr uint32_t PREVPREF = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_RB, Gamepad::DPAD_UP); + static constexpr uint32_t RESPREF = BUTTON_COMBO(Gamepad::BUTTON_START | Gamepad::BUTTON_LB, Gamepad::DPAD_DOWN); }; static constexpr DeviceDriverType VALID_DRIVER_TYPES[] = { @@ -114,6 +117,51 @@ bool UserSettings::check_for_driver_change(Gamepad& gamepad) uint32_t current_button_combo = BUTTON_COMBO(gp_in.buttons, gp_in.dpad); + if (current_button_combo == ButtonCombo::NEXTPREF) + { + if (ACTIVE_PROFILE == MAX_PROFILES) + { + ACTIVE_PROFILE = 1U; + board_api::usb::disconnect_all(); + nvs_tool_.write(ACTIVE_PROFILE_KEY(0U), &ACTIVE_PROFILE, sizeof(uint8_t)); + board_api::reboot(); + } + else + { + ACTIVE_PROFILE = ACTIVE_PROFILE + 1U; + board_api::usb::disconnect_all(); + nvs_tool_.write(ACTIVE_PROFILE_KEY(0U), &ACTIVE_PROFILE, sizeof(uint8_t)); + board_api::reboot(); + } + return true; + } + if (current_button_combo == ButtonCombo::PREVPREF) + { + if (ACTIVE_PROFILE == 1U) + { + ACTIVE_PROFILE = MAX_PROFILES; + board_api::usb::disconnect_all(); + nvs_tool_.write(ACTIVE_PROFILE_KEY(0U), &ACTIVE_PROFILE, sizeof(uint8_t)); + board_api::reboot(); + } + else + { + ACTIVE_PROFILE = ACTIVE_PROFILE - 1U; + board_api::usb::disconnect_all(); + nvs_tool_.write(ACTIVE_PROFILE_KEY(0U), &ACTIVE_PROFILE, sizeof(uint8_t)); + board_api::reboot(); + } + return true; + } + if (current_button_combo == ButtonCombo::RESPREF) + { + ACTIVE_PROFILE = 1U; + board_api::usb::disconnect_all(); + nvs_tool_.write(ACTIVE_PROFILE_KEY(0U), &ACTIVE_PROFILE, sizeof(uint8_t)); + board_api::reboot(); + return true; + } + if (!(current_button_combo & (static_cast(Gamepad::BUTTON_START) << 16)) || last_button_combo != current_button_combo) { diff --git a/Firmware/RP2040/src/UserSettings/UserSettings.h b/Firmware/RP2040/src/UserSettings/UserSettings.h index ae406942..2f5a123c 100644 --- a/Firmware/RP2040/src/UserSettings/UserSettings.h +++ b/Firmware/RP2040/src/UserSettings/UserSettings.h @@ -46,6 +46,8 @@ class UserSettings UserSettings(const UserSettings&) = delete; UserSettings& operator=(const UserSettings&) = delete; + uint8_t ACTIVE_PROFILE = 1U; + static constexpr uint8_t GP_CHECK_COUNT = 3000 / GP_CHECK_DELAY_MS; static constexpr uint8_t FLASH_INIT_FLAG = 0xF8; const std::string DATETIME_TAG = BUILD_DATETIME; diff --git a/README.md b/README.md index 0e9257e0..0d3716ef 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,16 @@ Start = Plus (Switch) = Options (Dualsense/DS4) After a new mode is stored, the RP2040 will reset itself so you don't need to unplug it. +## Changing profiles +You can quickly switch between predefined profiles by holding a button combo for 3 seconds. This won't change the selected platform. + +- Next Profile + - Start + Right Bumper + Dpad Down +- Previous Profile + - Start + Right Bumper + Dpad Up +- Jump to First Profile + - Start + Left Bumper + Dpad Down + ## Supported devices ### Wired controllers - Original Xbox Duke and S @@ -139,4 +149,4 @@ Please see the Hardware directory for a diagram showing how to hookup the ESP32 You will need ESP-IDF v5.1, esptool, python3, and git installed. If you use VSCode, you can install the ESP-IDF extension and configure the project for ESP-IDF v5.1, it'll download everything for you and then you just click the build button at the bottom of the window. -When you build with ESP-IDF, Cmake will run a python script that copies the necessary BTStack files into the components directory, this is needed since BTStack isn't configured as an ESP-IDF component when you download it with git. \ No newline at end of file +When you build with ESP-IDF, Cmake will run a python script that copies the necessary BTStack files into the components directory, this is needed since BTStack isn't configured as an ESP-IDF component when you download it with git.