Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Firmware/RP2040/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/DInput/DInput.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/N64/N64.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/PS3/PS3.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/PS5/PS5.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstring>
#include <array>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"
#include "class/hid/hid_host.h"
Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/XInput/Xbox360.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"

Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOG.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"

Expand Down
1 change: 1 addition & 0 deletions Firmware/RP2040/src/USBHost/HostDriver/XInput/XboxOne.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cstring>
#include <tuple>

#include "host/usbh.h"

Expand Down
48 changes: 48 additions & 0 deletions Firmware/RP2040/src/UserSettings/UserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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<uint32_t>(Gamepad::BUTTON_START) << 16)) ||
last_button_combo != current_button_combo)
{
Expand Down
2 changes: 2 additions & 0 deletions Firmware/RP2040/src/UserSettings/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
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.