Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display test #12

Merged
merged 5 commits into from
Mar 31, 2024
Merged
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
1 change: 0 additions & 1 deletion headers/addons/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class DisplayAddon : public GPAddon
uint32_t prevMillis;
std::string statusBar;
Gamepad* gamepad;
Gamepad* pGamepad;
bool configMode;

GPGFX* gpDisplay;
Expand Down
30 changes: 12 additions & 18 deletions headers/addons/input_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,18 @@ class InputMacro : public GPAddon {
void checkMacroAction();
void runCurrentMacro();
void reset();

bool isMacroRunning = false;
bool isMacroTriggerHeld = false;
int macroPosition = -1;

uint32_t macroButtonMask = 0;
uint32_t macroPinMasks[6] = {};

uint64_t macroStartTime = 0;

int pressedMacro = -1;
int macroInputPosition = 0;
bool macroInputPressed = false;
uint32_t macroInputHoldTime = INPUT_HOLD_US;
bool prevMacroInputPressed = false;
bool boardLedEnabled = false;

MacroOptions inputMacroOptions;
bool isMacroRunning;
bool isMacroTriggerHeld;
int macroPosition;
uint32_t macroButtonMask;
uint32_t macroPinMasks[6];
uint64_t macroStartTime;
int pressedMacro;
int macroInputPosition;
uint32_t macroInputHoldTime;
bool prevMacroInputPressed;
bool boardLedEnabled;
MacroOptions * inputMacroOptions;
};

#endif // _InputMacro_H_
3 changes: 1 addition & 2 deletions headers/display/ui/elements/GPButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
class GPButton : public GPWidget {
public:
void draw();
GPButton* setSizeX(uint16_t sizeX) { this->_sizeX = sizeX; return this; }
GPButton* setSizeY(uint16_t sizeY) { this->_sizeY = sizeY; return this; }
GPButton* setSize(uint16_t sizeX, uint16_t sizeY) { this->_sizeX = sizeX; this->_sizeY = sizeY; return this; }
GPButton* setInputMask(int16_t inputMask) { this->_inputMask = inputMask; return this; }
GPButton* setInputDirection(bool inputDirection) { this->_inputDirection = inputDirection; return this; }
GPButton* setInputType(GPElement inputType) { this->_inputType = inputType; return this; }
Expand Down
8 changes: 3 additions & 5 deletions headers/display/ui/elements/GPScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
class GPScreen : public GPWidget {
public:
void draw();
std::string header = "";
std::string footer = "";
virtual int8_t update();
GPWidget* addElement(GPWidget* element);
virtual int8_t update() = 0;
virtual void init() = 0;
protected:
virtual void drawScreen() = 0;

GPWidget* addElement(GPWidget* element);
private:
std::vector<GPWidget*> displayList;
};
Expand Down
3 changes: 1 addition & 2 deletions headers/display/ui/elements/GPShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
class GPShape : public GPWidget {
public:
void draw();
GPShape* setSizeX(uint16_t sizeX) { this->_sizeX = sizeX; return this; }
GPShape* setSizeY(uint16_t sizeY) { this->_sizeY = sizeY; return this; }
GPShape* setSize(uint16_t sizeX, uint16_t sizeY) { this->_sizeX = sizeX; this->_sizeY = sizeY; return this; }
GPShape* setAngle(double angle) { this->_angle = angle; return this; }
GPShape* setAngleEnd(double angleEnd) { this->_angleEnd = angleEnd; return this; }
GPShape* setClosed(bool closed) { this->_closed = closed; return this; }
Expand Down
3 changes: 1 addition & 2 deletions headers/display/ui/elements/GPSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
class GPSprite : public GPWidget {
public:
void draw();
GPSprite* setSizeX(uint16_t sizeX) { this->_sizeX = sizeX; return this; }
GPSprite* setSizeY(uint16_t sizeY) { this->_sizeY = sizeY; return this; }
GPSprite* setSize(uint16_t sizeX, uint16_t sizeY) { this->_sizeX = sizeX; this->_sizeY = sizeY; return this; }
private:
uint16_t _sizeX = 0;
uint16_t _sizeY = 0;
Expand Down
30 changes: 16 additions & 14 deletions headers/display/ui/screens/ButtonLayoutScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ class ButtonLayoutScreen : public GPScreen {
public:
ButtonLayoutScreen() {}
ButtonLayoutScreen(GPGFX* renderer) { setRenderer(renderer); }
int8_t update();
virtual int8_t update();
virtual void init();
protected:
void drawScreen();
virtual void drawScreen();
private:
// new layout methods
GPLever* drawLever(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor, uint16_t inputType);
GPButton* drawButton(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor, int16_t inputMask = -1);
GPSprite* drawSprite(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY);
GPShape* drawShape(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor);
GPWidget* drawElement(GPButtonLayout element);
GPLever* addLever(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor, uint16_t inputType);
GPButton* addButton(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor, int16_t inputMask = -1);
GPSprite* addSprite(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY);
GPShape* addShape(uint16_t startX, uint16_t startY, uint16_t sizeX, uint16_t sizeY, uint16_t strokeColor, uint16_t fillColor);
GPWidget* pushElement(GPButtonLayout element);
void generateHeader();

const std::map<uint16_t, uint16_t> displayModeLookup = {
{INPUT_MODE_HID, 0},
Expand All @@ -72,6 +74,11 @@ class ButtonLayoutScreen : public GPScreen {
{INPUT_MODE_XBOXORIGINAL, 10},
};

Gamepad* gamepad;
InputMode inputMode;
std::string statusBar;
std::string footer;

bool isInputHistoryEnabled = false;
uint16_t inputHistoryX = 0;
uint16_t inputHistoryY = 0;
Expand All @@ -80,16 +87,11 @@ class ButtonLayoutScreen : public GPScreen {
std::deque<std::string> inputHistory;
std::array<bool, INPUT_HISTORY_MAX_INPUTS> lastInput;

bool profileModeDisplay;
uint8_t profileDelay = 2;
int profileDelayStart = 0;
bool displayProfileBanner = true;

bool hasInitialized = false;

uint16_t prevButtonState = 0;

void showProfileBanner();

uint16_t map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
void processInputHistory();
bool pressedUp();
Expand All @@ -101,7 +103,7 @@ class ButtonLayoutScreen : public GPScreen {
bool pressedDownLeft();
bool pressedDownRight();

const std::string displayNames[INPUT_HISTORY_MAX_MODES][INPUT_HISTORY_MAX_INPUTS] = {
const char * displayNames[INPUT_HISTORY_MAX_MODES][INPUT_HISTORY_MAX_INPUTS] = {
{ // HID / DINPUT
CHAR_UP, CHAR_DOWN, CHAR_LEFT, CHAR_RIGHT,
CHAR_UL, CHAR_UR, CHAR_DL, CHAR_DR,
Expand Down
7 changes: 5 additions & 2 deletions headers/display/ui/screens/ConfigScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ class ConfigScreen : public GPScreen {
ConfigScreen() {}
ConfigScreen(GPGFX* renderer) { setRenderer(renderer); }

int8_t update();
virtual int8_t update();
virtual void init();
uint8_t getDisplayMode() { return prevDisplayMode; }
protected:
void drawScreen();
virtual void drawScreen();

uint16_t prevButtonState = 0;
int8_t prevDisplayMode = 0;
int8_t currDisplayMode = 0;

std::string version;
};

#endif
6 changes: 3 additions & 3 deletions headers/display/ui/screens/MainMenuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class MainMenuScreen : public GPScreen {
MainMenuScreen() {}
MainMenuScreen(GPGFX* renderer) { setRenderer(renderer); }
void setMenu(std::vector<MenuEntry>* menu);
int8_t update();
virtual int8_t update();
virtual void init();
protected:
void drawScreen();
virtual void drawScreen();
private:
uint8_t menuIndex = 0;
bool isPressed = false;
uint32_t checkDebounce;

std::vector<MenuEntry>* currentMenu;
uint16_t prevButtonState = 0;
};
Expand Down
6 changes: 3 additions & 3 deletions headers/display/ui/screens/SplashScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class SplashScreen : public GPScreen {
public:
SplashScreen() {}
SplashScreen(GPGFX* renderer) { setRenderer(renderer); }
int8_t update();
virtual int8_t update();
virtual void init();
protected:
void drawScreen();

virtual void drawScreen();
uint16_t prevButtonState = 0;
};

Expand Down
16 changes: 9 additions & 7 deletions headers/drivermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ class GPDriver;

class DriverManager {
public:
DriverManager(DriverManager const&) = delete;
void operator=(DriverManager const&) = delete;
DriverManager(DriverManager const&) = delete;
void operator=(DriverManager const&) = delete;
static DriverManager& getInstance() {// Thread-safe storage ensures cross-thread talk
static DriverManager instance; // Guaranteed to be destroyed. // Instantiated on first use.
return instance;
}
GPDriver * getDriver() { return driver; }
void setup(InputMode);
static DriverManager instance; // Guaranteed to be destroyed. // Instantiated on first use.
return instance;
}
GPDriver * getDriver() { return driver; }
void setup(InputMode);
InputMode getInputMode(){ return inputMode; }
private:
DriverManager() {}
GPDriver * driver;
InputMode inputMode;
};

#endif
9 changes: 2 additions & 7 deletions headers/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,10 @@ class Gamepad {
uint8_t getMultimedia(uint8_t code);
void processHotkeyAction(GamepadHotkey action);

GamepadOptions& options;
const HotkeyOptions& hotkeyOptions;
GamepadOptions & options;
const HotkeyOptions & hotkeyOptions;

GamepadHotkey lastAction = HOTKEY_NONE;

uint32_t keep_alive_timer;
uint8_t keep_alive_sequence;
uint8_t virtual_keycode_sequence;
bool xb1_guide_pressed;
};

#endif
4 changes: 2 additions & 2 deletions headers/gp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

class GP2040 {
public:
GP2040();
~GP2040();
GP2040() {}
~GP2040() {}
void setup(); // setup core0
void run(); // loop core0
private:
Expand Down
79 changes: 4 additions & 75 deletions headers/layoutmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "config.pb.h"
#include "enums.pb.h"

#include "buttonlayouts.h"

typedef struct {
uint16_t x1;
uint16_t y1;
Expand Down Expand Up @@ -121,81 +123,8 @@ class LayoutManager {

std::string getLayoutNameByID();

std::map<uint16_t,LayoutFunction> GPButtonLayouts_LeftLayouts = {
// levers
// parameters: x, y, radiusX/width, radiusY/height, stroke, fill, DpadMode
{BUTTON_LAYOUT_STICK, [this]() { return this->drawArcadeStick(); }},
{BUTTON_LAYOUT_TWINSTICKA, [this]() { return this->drawTwinStickA(); }},
{BUTTON_LAYOUT_VLXA, [this]() { return this->drawVLXA(); }},
{BUTTON_LAYOUT_FIGHTBOARD_STICK, [this]() { return this->drawFightboardStick(); }},

// buttons
// parameters: x, y, radiusX/width, radiusY/height, stroke, fill, Gamepad button mask, shape
{BUTTON_LAYOUT_STICKLESS, [this]() { return this->drawStickless(); }},
{BUTTON_LAYOUT_BUTTONS_ANGLED, [this]() { return this->drawUDLR(); }},
{BUTTON_LAYOUT_BUTTONS_BASIC, [this]() { return this->drawMAMEA(); }},
{BUTTON_LAYOUT_KEYBOARD_ANGLED, [this]() { return this->drawKeyboardAngled(); }},
{BUTTON_LAYOUT_KEYBOARDA, [this]() { return this->drawWasdBox(); }},
{BUTTON_LAYOUT_DANCEPADA, [this]() { return this->drawDancepadA(); }},
{BUTTON_LAYOUT_BLANKA, [this]() { return this->drawBlankA(); }},
{BUTTON_LAYOUT_FIGHTBOARD_MIRRORED, [this]() { return this->drawFightboardMirrored(); }},
{BUTTON_LAYOUT_CUSTOMA, [this]() { return this->drawButtonLayoutLeft(); }},
{BUTTON_LAYOUT_OPENCORE0WASDA, [this]() { return this->drawOpenCore0WASDA(); }},
{BUTTON_LAYOUT_STICKLESS_13, [this]() { return this->drawStickless13A(); }},
{BUTTON_LAYOUT_STICKLESS_16, [this]() { return this->drawStickless16A(); }},
{BUTTON_LAYOUT_STICKLESS_14, [this]() { return this->drawStickless14A(); }},
{BUTTON_LAYOUT_DANCEPADA, [this]() { return this->drawDancepadA(); }},

{BUTTON_LAYOUT_DANCEPAD_DDR_LEFT, [this]() { return this->drawDancepadDDRLeft(); }},
{BUTTON_LAYOUT_DANCEPAD_DDR_SOLO, [this]() { return this->drawDancepadDDRSolo(); }},
{BUTTON_LAYOUT_DANCEPAD_PIU_LEFT, [this]() { return this->drawDancepadPIULeft(); }},
{BUTTON_LAYOUT_POPN_A, [this]() { return this->drawPopnA(); }},
{BUTTON_LAYOUT_TAIKO_A, [this]() { return this->drawTaikoA(); }},
{BUTTON_LAYOUT_BM_TURNTABLE_A, [this]() { return this->drawBMTurntableA(); }},
{BUTTON_LAYOUT_BM_5KEY_A, [this]() { return this->drawBM5KeyA(); }},
{BUTTON_LAYOUT_BM_7KEY_A, [this]() { return this->drawBM7KeyA(); }},
{BUTTON_LAYOUT_GITADORA_FRET_A, [this]() { return this->drawGitadoraFretA(); }},
{BUTTON_LAYOUT_GITADORA_STRUM_A, [this]() { return this->drawGitadoraStrumA(); }},

{BUTTON_LAYOUT_BOARD_DEFINED_A, [this]() { return this->drawBoardDefinedA(); }},
};

std::map<uint16_t,LayoutFunction> GPButtonLayouts_RightLayouts = {
{BUTTON_LAYOUT_ARCADE, [this]() { return this->drawArcadeButtons(); }},
{BUTTON_LAYOUT_STICKLESSB, [this]() { return this->drawSticklessButtons(); }},
{BUTTON_LAYOUT_BUTTONS_ANGLEDB, [this]() { return this->drawMAMEB(); }},
{BUTTON_LAYOUT_VEWLIX, [this]() { return this->drawVewlix(); }},
{BUTTON_LAYOUT_VEWLIX7, [this]() { return this->drawVewlix7(); }},
{BUTTON_LAYOUT_CAPCOM, [this]() { return this->drawCapcom(); }},
{BUTTON_LAYOUT_CAPCOM6, [this]() { return this->drawCapcom6(); }},
{BUTTON_LAYOUT_SEGA2P, [this]() { return this->drawSega2p(); }},
{BUTTON_LAYOUT_NOIR8, [this]() { return this->drawNoir8(); }},
{BUTTON_LAYOUT_KEYBOARDB, [this]() { return this->drawMAMEB(); }},
{BUTTON_LAYOUT_TWINSTICKB, [this]() { return this->drawTwinStickB(); }},
{BUTTON_LAYOUT_BLANKB, [this]() { return this->drawBlankB(); }},
{BUTTON_LAYOUT_VLXB, [this]() { return this->drawVLXB(); }},
{BUTTON_LAYOUT_FIGHTBOARD, [this]() { return this->drawFightboard(); }},
{BUTTON_LAYOUT_FIGHTBOARD_STICK_MIRRORED, [this]() { return this->drawFightboardStickMirrored(); }},
{BUTTON_LAYOUT_CUSTOMB, [this]() { return this->drawButtonLayoutRight(); }},
{BUTTON_LAYOUT_KEYBOARD8B, [this]() { return this->drawMAME8B(); }},
{BUTTON_LAYOUT_OPENCORE0WASDB, [this]() { return this->drawOpenCore0WASDB(); }},
{BUTTON_LAYOUT_STICKLESS_13B, [this]() { return this->drawSticklessButtons13B(); }},
{BUTTON_LAYOUT_STICKLESS_16B, [this]() { return this->drawSticklessButtons16B(); }},
{BUTTON_LAYOUT_STICKLESS_14B, [this]() { return this->drawSticklessButtons14B(); }},
{BUTTON_LAYOUT_DANCEPADB, [this]() { return this->drawDancepadB(); }},

{BUTTON_LAYOUT_DANCEPAD_DDR_RIGHT, [this]() { return this->drawDancepadDDRRight(); }},
{BUTTON_LAYOUT_DANCEPAD_PIU_RIGHT, [this]() { return this->drawDancepadPIURight(); }},
{BUTTON_LAYOUT_POPN_B, [this]() { return this->drawPopnB(); }},
{BUTTON_LAYOUT_TAIKO_B, [this]() { return this->drawTaikoB(); }},
{BUTTON_LAYOUT_BM_TURNTABLE_B, [this]() { return this->drawBMTurntableB(); }},
{BUTTON_LAYOUT_BM_5KEY_B, [this]() { return this->drawBM5KeyB(); }},
{BUTTON_LAYOUT_BM_7KEY_B, [this]() { return this->drawBM7KeyB(); }},
{BUTTON_LAYOUT_GITADORA_FRET_B, [this]() { return this->drawGitadoraFretB(); }},
{BUTTON_LAYOUT_GITADORA_STRUM_B, [this]() { return this->drawGitadoraStrumB(); }},

{BUTTON_LAYOUT_BOARD_DEFINED_B, [this]() { return this->drawBoardDefinedB(); }},
};
LayoutManager::LayoutList getLeftLayout(uint16_t index);
LayoutManager::LayoutList getRightLayout(uint16_t index);
};

#endif
3 changes: 2 additions & 1 deletion headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Storage {
GpioAction* getProfilePinMappings() { return functionalPinMappings; }
PeripheralOptions& getPeripheralOptions() { return config.peripheralOptions; }

void init();
bool save();

// Perform saves that were enqueued from core1
Expand All @@ -73,7 +74,7 @@ class Storage {
void ResetSettings(); // EEPROM Reset Feature

private:
Storage();
Storage() {}
bool CONFIG_MODE = false; // Config mode (boot)
Gamepad * gamepad = nullptr; // Gamepad data
Gamepad * processedGamepad = nullptr; // Gamepad with ONLY processed data
Expand Down
Loading