Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into NewPicoSDK
  • Loading branch information
Fortinbra committed Jan 13, 2025
2 parents df35879 + 7a50cfa commit 041c2ab
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 4 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,51 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
GP2040_BOARDCONFIG: [ARCController, Blank, Pico, PicoW, BentoBox, ergoSHIFTRev2, FightboardV3, FightboardV3Mirrored, FlatboxRev4, FlatboxRev5, FlatboxRev5RGB, FlatboxRev5USBPassthrough, FlatboxRev5Southpaw, Granola, KB2040, KeyboardConverter, Haute42COSMOX, Liatris, MavercadeRev1, MavercadeRev2, MiSTercadeV2, OpenCore0, OpenCore0WASD, OSUMGP-RP2040, PicoAnn, PicoFightingBoard, PXPGamepad, RanaTadpole, ReflexCtrlGenesis6, ReflexCtrlNES, ReflexCtrlSaturn, ReflexCtrlSNES, ReflexCtrlVB, ReflexEncodeV1.2, ReflexEncodeV2.0, RP2040AdvancedBreakoutBoard, RP2040AdvancedBreakoutBoardUSBPassthrough, RP2040MiniBreakoutBoard, SparkFunProMicro, WaveshareZero, Stress, SGFDevices, ZeroRhythm]
GP2040_BOARDCONFIG:
[ARCController,
Blank,
Pico,
PicoW,
BentoBox,
ergoSHIFTRev2,
FightboardV3,
FightboardV3Mirrored,
FlatboxRev4,
FlatboxRev5,
FlatboxRev5RGB,
FlatboxRev5USBPassthrough,
FlatboxRev5Southpaw,
Granola,
KB2040,
KeyboardConverter,
Haute42COSMOX,
Liatris,
MavercadeRev1,
MavercadeRev2,
MiSTercadeV2,
OpenCore0,
OpenCore0WASD,
OSUMGP-RP2040,
PicoAnn,
PicoFightingBoard,
PXPGamepad,
RanaTadpole,
ReflexCtrlGenesis6,
ReflexCtrlNES,
ReflexCtrlSaturn,
ReflexCtrlSNES,
ReflexCtrlVB,
ReflexEncodeV1.2,
ReflexEncodeV2.0,
RP2040AdvancedBreakoutBoard,
RP2040AdvancedBreakoutBoardUSBPassthrough,
RP2040MiniBreakoutBoard,
RP2040MiniBreakoutBoardUSBPassthrough,
SparkFunProMicro,
WaveshareZero,
Stress,
SGFDevices,
ZeroRhythm]

steps:
#Global Setup
Expand Down
89 changes: 89 additions & 0 deletions configs/RP2040MiniBreakoutBoardUSBPassthrough/BoardConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: Copyright (c) 2024 OpenStickCommunity (gp2040-ce.info)
*/

#ifndef PICO_BOARD_CONFIG_H_
#define PICO_BOARD_CONFIG_H_

#include "enums.pb.h"
#include "class/hid/hid.h"

#define BOARD_CONFIG_LABEL "RP2040 Mini Breakout Board USB Passthrough"

// Main pin mapping Configuration
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
#define GPIO_PIN_15 GpioAction::BUTTON_PRESS_UP // UP | UP | UP | UP | UP | UP |
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
#define GPIO_PIN_03 GpioAction::BUTTON_PRESS_B1 // B1 | A | B | Cross | 2 | K1 |
#define GPIO_PIN_02 GpioAction::BUTTON_PRESS_B2 // B2 | B | A | Circle | 3 | K2 |
#define GPIO_PIN_00 GpioAction::BUTTON_PRESS_R2 // R2 | RT | ZR | R2 | 8 | K3 |
#define GPIO_PIN_01 GpioAction::BUTTON_PRESS_L2 // L2 | LT | ZL | L2 | 7 | K4 |
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_B3 // B3 | X | Y | Square | 1 | P1 |
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_B4 // B4 | Y | X | Triangle | 4 | P2 |
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_R1 // R1 | RB | R | R1 | 6 | P3 |
#define GPIO_PIN_04 GpioAction::BUTTON_PRESS_L1 // L1 | LB | L | L1 | 5 | P4 |
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_S1 // S1 | Back | Minus | Select | 9 | Coin |
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_S2 // S2 | Start | Plus | Start | 10 | Start |
#define GPIO_PIN_28 GpioAction::BUTTON_PRESS_L3 // L3 | LS | LS | L3 | 11 | LS |
#define GPIO_PIN_29 GpioAction::BUTTON_PRESS_R3 // R3 | RS | RS | R3 | 12 | RS |
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_A1 // A1 | Guide | Home | PS | 13 | ~ |
#define GPIO_PIN_27 GpioAction::BUTTON_PRESS_A2 // A2 | ~ | Capture | ~ | 14 | ~ |

// Setting GPIO pins to assigned by add-on
//
#define GPIO_PIN_16 GpioAction::ASSIGNED_TO_ADDON
#define GPIO_PIN_18 GpioAction::ASSIGNED_TO_ADDON
#define GPIO_PIN_19 GpioAction::ASSIGNED_TO_ADDON

// Keyboard Mapping Configuration
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
#define KEY_DPAD_UP HID_KEY_ARROW_UP // UP | UP | UP | UP | UP | UP |
#define KEY_DPAD_DOWN HID_KEY_ARROW_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
#define KEY_DPAD_RIGHT HID_KEY_ARROW_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
#define KEY_DPAD_LEFT HID_KEY_ARROW_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
#define KEY_BUTTON_B1 HID_KEY_SHIFT_LEFT // B1 | A | B | Cross | 2 | K1 |
#define KEY_BUTTON_B2 HID_KEY_Z // B2 | B | A | Circle | 3 | K2 |
#define KEY_BUTTON_R2 HID_KEY_X // R2 | RT | ZR | R2 | 8 | K3 |
#define KEY_BUTTON_L2 HID_KEY_V // L2 | LT | ZL | L2 | 7 | K4 |
#define KEY_BUTTON_B3 HID_KEY_CONTROL_LEFT // B3 | X | Y | Square | 1 | P1 |
#define KEY_BUTTON_B4 HID_KEY_ALT_LEFT // B4 | Y | X | Triangle | 4 | P2 |
#define KEY_BUTTON_R1 HID_KEY_SPACE // R1 | RB | R | R1 | 6 | P3 |
#define KEY_BUTTON_L1 HID_KEY_C // L1 | LB | L | L1 | 5 | P4 |
#define KEY_BUTTON_S1 HID_KEY_5 // S1 | Back | Minus | Select | 9 | Coin |
#define KEY_BUTTON_S2 HID_KEY_1 // S2 | Start | Plus | Start | 10 | Start |
#define KEY_BUTTON_L3 HID_KEY_EQUAL // L3 | LS | LS | L3 | 11 | LS |
#define KEY_BUTTON_R3 HID_KEY_MINUS // R3 | RS | RS | R3 | 12 | RS |
#define KEY_BUTTON_A1 HID_KEY_9 // A1 | Guide | Home | PS | 13 | ~ |
#define KEY_BUTTON_A2 HID_KEY_F2 // A2 | ~ | Capture | ~ | 14 | ~ |
#define KEY_BUTTON_FN -1 // Hotkey Function |

#define BOARD_LEDS_PIN 16

#define USB_PERIPHERAL_ENABLED 1

#define USB_PERIPHERAL_PIN_DPLUS 18
#define USB_PERIPHERAL_PIN_ORDER 0

#define DEFAULT_INPUT_MODE_R1 INPUT_MODE_XBONE
#define DEFAULT_INPUT_MODE_B4 INPUT_MODE_PS5
#define DEFAULT_PS5AUTHENTICATION_TYPE INPUT_MODE_AUTH_TYPE_USB

#define LED_BRIGHTNESS_MAXIMUM 100

#define LEDS_DPAD_LEFT 0
#define LEDS_DPAD_DOWN 1
#define LEDS_DPAD_RIGHT 2
#define LEDS_DPAD_UP 3
#define LEDS_BUTTON_B3 4
#define LEDS_BUTTON_B4 5
#define LEDS_BUTTON_R1 6
#define LEDS_BUTTON_L1 7
#define LEDS_BUTTON_B1 8
#define LEDS_BUTTON_B2 9
#define LEDS_BUTTON_R2 10
#define LEDS_BUTTON_L2 11

#endif
26 changes: 26 additions & 0 deletions configs/RP2040MiniBreakoutBoardUSBPassthrough/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# GP2040 Configuration for the RP2040 Mini Breakout Board USB Passthrough

![RP2040 RP2040 Mini Breakout Board USB Passthrough](assets/RP2040MiniBreakoutBoardUSBPassthrough.jpeg)

## Main Pin Mapping Configuration

| RP2040 Pin | Action | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|------------|-------------------------------|--------|--------|--------|----------|--------|--------|
| GPIO_PIN_15| GpioAction::BUTTON_PRESS_UP | UP | UP | UP | UP | UP | UP |
| GPIO_PIN_14| GpioAction::BUTTON_PRESS_DOWN | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
| GPIO_PIN_13| GpioAction::BUTTON_PRESS_RIGHT| RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
| GPIO_PIN_12| GpioAction::BUTTON_PRESS_LEFT | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
| GPIO_PIN_03| GpioAction::BUTTON_PRESS_B1 | B1 | A | B | Cross | 2 | K1 |
| GPIO_PIN_02| GpioAction::BUTTON_PRESS_B2 | B2 | B | A | Circle | 3 | K2 |
| GPIO_PIN_00| GpioAction::BUTTON_PRESS_R2 | R2 | RT | ZR | R2 | 8 | K3 |
| GPIO_PIN_01| GpioAction::BUTTON_PRESS_L2 | L2 | LT | ZL | L2 | 7 | K4 |
| GPIO_PIN_08| GpioAction::BUTTON_PRESS_B3 | B3 | X | Y | Square | 1 | P1 |
| GPIO_PIN_06| GpioAction::BUTTON_PRESS_B4 | B4 | Y | X | Triangle| 4 | P2 |
| GPIO_PIN_05| GpioAction::BUTTON_PRESS_R1 | R1 | RB | R | R1 | 6 | P3 |
| GPIO_PIN_04| GpioAction::BUTTON_PRESS_L1 | L1 | LB | L | L1 | 5 | P4 |
| GPIO_PIN_11| GpioAction::BUTTON_PRESS_S1 | S1 | Back | Minus | Select | 9 | Coin |
| GPIO_PIN_09| GpioAction::BUTTON_PRESS_S2 | S2 | Start | Plus | Start | 10 | Start |
| GPIO_PIN_28| GpioAction::BUTTON_PRESS_L3 | L3 | LS | LS | L3 | 11 | LS |
| GPIO_PIN_29| GpioAction::BUTTON_PRESS_R3 | R3 | RS | RS | R3 | 12 | RS |
| GPIO_PIN_10| GpioAction::BUTTON_PRESS_A1 | A1 | Guide | Home | PS | 13 | ~ |
| GPIO_PIN_27| GpioAction::BUTTON_PRESS_A2 | A2 | ~ | Capture | ~ | 14 | ~ |
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------


#ifndef _BOARDS_RP2040MINIBREAKOUTBOARDUSBPASSTHROUGH_H
#define _BOARDS_RP2040MINIBREAKOUTBOARDUSBPASSTHROUGH_H

// For board detection
#define RP2040MINIBREAKOUTBOARD

//For crappy crystal
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
#endif

// --- LED ---
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 25
#endif
// no PICO_DEFAULT_WS2812_PIN

// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif

#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif

// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23

#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 1
#endif

#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions headers/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class Gamepad {
GamepadButtonMapping *mapAnalogRSXPos;
GamepadButtonMapping *mapAnalogRSYNeg;
GamepadButtonMapping *mapAnalogRSYPos;
GamepadButtonMapping *map48WayMode;

// gamepad specific proxy of debounced buttons --- 1 = active (inverse of the raw GPIO)
// see GP2040::debounceGpioGetAll for details
Expand All @@ -213,6 +214,7 @@ class Gamepad {

GamepadOptions & options;
DpadMode activeDpadMode;
bool map48WayModeToggle;
const HotkeyOptions & hotkeyOptions;

GamepadHotkey lastAction = HOTKEY_NONE;
Expand Down
2 changes: 2 additions & 0 deletions proto/enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ enum GpioAction

BUTTON_PRESS_INPUT_REVERSE = 69;
SUSTAIN_FOCUS_MODE = 70;

SUSTAIN_4_8_WAY_MODE = 71;
}

enum GpioDirection
Expand Down
11 changes: 8 additions & 3 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void Gamepad::setup()
mapAnalogRSXPos = new GamepadButtonMapping(ANALOG_DIRECTION_RS_X_POS);
mapAnalogRSYNeg = new GamepadButtonMapping(ANALOG_DIRECTION_RS_Y_NEG);
mapAnalogRSYPos = new GamepadButtonMapping(ANALOG_DIRECTION_RS_Y_POS);
map48WayMode = new GamepadButtonMapping(SUSTAIN_4_8_WAY_MODE);

const auto assignCustomMappingToMaps = [&](GpioMappingInfo mapInfo, Pin_t pin) -> void {
if (mapDpadUp->buttonMask & mapInfo.customDpadMask) mapDpadUp->pinMask |= 1 << pin;
Expand Down Expand Up @@ -161,6 +162,7 @@ void Gamepad::setup()
case GpioAction::ANALOG_DIRECTION_RS_X_POS: mapAnalogRSXPos->pinMask |= 1 << pin; break;
case GpioAction::ANALOG_DIRECTION_RS_Y_NEG: mapAnalogRSYNeg->pinMask |= 1 << pin; break;
case GpioAction::ANALOG_DIRECTION_RS_Y_POS: mapAnalogRSYPos->pinMask |= 1 << pin; break;
case GpioAction::SUSTAIN_4_8_WAY_MODE: map48WayMode->pinMask |= 1 << pin; break;
default: break;
}
}
Expand Down Expand Up @@ -220,6 +222,7 @@ void Gamepad::reinit()
delete mapAnalogRSXPos;
delete mapAnalogRSYNeg;
delete mapAnalogRSYPos;
delete map48WayMode;

// reinitialize pin mappings
this->setup();
Expand Down Expand Up @@ -257,7 +260,7 @@ void Gamepad::process()
}

// 4-way before SOCD, might have better history without losing any coherent functionality
if (options.fourWayMode) {
if (options.fourWayMode ^ map48WayModeToggle) {
state.dpad = filterToFourWayMode(state.dpad);
}

Expand All @@ -279,7 +282,7 @@ void Gamepad::process()
state.dpad &= ~dpadOnlyMask;
state.dpad = dpadOnlyMask;
break;

case DpadMode::DPAD_MODE_RIGHT_ANALOG:
if (!hasLeftAnalogStick) {
state.lx = joystickMid;
Expand All @@ -290,7 +293,7 @@ void Gamepad::process()
state.dpad &= ~dpadOnlyMask;
state.dpad = dpadOnlyMask;
break;

default:
//if (!hasLeftAnalogStick) {
// state.lx = joystickMid;
Expand Down Expand Up @@ -365,6 +368,8 @@ void Gamepad::read()
else if (values & mapButtonRS->pinMask) activeDpadMode = DpadMode::DPAD_MODE_RIGHT_ANALOG;
else activeDpadMode = options.dpadMode;

map48WayModeToggle = (values & map48WayMode->pinMask);

if (values & mapAnalogLSXNeg->pinMask) {
state.lx = GAMEPAD_JOYSTICK_MIN;
} else if (values & mapAnalogLSXPos->pinMask) {
Expand Down
1 change: 1 addition & 0 deletions www/src/Data/Pins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const BUTTON_ACTIONS = {
ANALOG_DIRECTION_MOD_HIGH: 68,
BUTTON_PRESS_INPUT_REVERSE: 69,
SUSTAIN_FOCUS_MODE: 70,
SUSTAIN_4_8_WAY_MODE: 71,
} as const;

export const PIN_DIRECTIONS = {
Expand Down
1 change: 1 addition & 0 deletions www/src/Locales/en/PinMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ export default {
ANALOG_DIRECTION_MOD_HIGH: 'Analog Stick Modifier High',
BUTTON_PRESS_INPUT_REVERSE: 'Reverse Input',
SUSTAIN_FOCUS_MODE: 'Focus Mode Enable',
SUSTAIN_4_8_WAY_MODE: 'Toggle 4-Way Mode',
},
};

0 comments on commit 041c2ab

Please sign in to comment.