Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

TwinStick display #117

Merged
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
2 changes: 2 additions & 0 deletions include/addons/i2cdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class I2CDisplayAddon : public GPAddon
void drawSplashScreen(int splashMode, int splashSpeed);
void drawDancepadA(int startX, int startY, int buttonSize, int buttonPadding);
void drawDancepadB(int startX, int startY, int buttonSize, int buttonPadding);
void drawTwinStickA(int startX, int startY, int buttonSize, int buttonPadding);
void drawTwinStickB(int startX, int startY, int buttonSize, int buttonPadding);
uint8_t ucBackBuffer[1024];
OBDISP obd;
std::string statusBar;
Expand Down
2 changes: 2 additions & 0 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef enum
BUTTON_LAYOUT_KEYBOARD_ANGLED,
BUTTON_LAYOUT_KEYBOARDA,
BUTTON_LAYOUT_DANCEPADA,
BUTTON_LAYOUT_TWINSTICKA,
} ButtonLayout;

typedef enum
Expand All @@ -25,6 +26,7 @@ typedef enum
BUTTON_LAYOUT_NOIR8,
BUTTON_LAYOUT_KEYBOARDB,
BUTTON_LAYOUT_DANCEPADB,
BUTTON_LAYOUT_TWINSTICKB,
} ButtonLayoutRight;

typedef enum
Expand Down
70 changes: 70 additions & 0 deletions src/addons/i2cdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ void I2CDisplayAddon::process() {
case BUTTON_LAYOUT_DANCEPADA:
drawDancepadA(39, 12, 15, 2);
break;
case BUTTON_LAYOUT_TWINSTICKA:
drawTwinStickA(8, 28, 8, 2);
break;
}

switch (BUTTON_LAYOUT_RIGHT)
Expand Down Expand Up @@ -112,6 +115,9 @@ void I2CDisplayAddon::process() {
case BUTTON_LAYOUT_DANCEPADB:
drawDancepadB(39, 12, 15, 2);
break;
case BUTTON_LAYOUT_TWINSTICKB:
drawTwinStickB(100, 28, 8, 2);
break;
}
}

Expand Down Expand Up @@ -203,6 +209,70 @@ void I2CDisplayAddon::drawArcadeStick(int startX, int startY, int buttonRadius,
}
}

void I2CDisplayAddon::drawTwinStickA(int startX, int startY, int buttonRadius, int buttonPadding)
{
const int buttonMargin = buttonPadding + (buttonRadius * 2);

// Stick
obdPreciseEllipse(&obd, startX + (buttonMargin / 2), startY + (buttonMargin / 2), buttonRadius * 1.25, buttonRadius * 1.25, 1, 0);

if (pGamepad->pressedUp()) {
if (pGamepad->pressedLeft()) {
obdPreciseEllipse(&obd, startX + (buttonMargin / 5), startY + (buttonMargin / 5), buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedRight()) {
obdPreciseEllipse(&obd, startX + (buttonMargin * 0.875), startY + (buttonMargin / 5), buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + (buttonMargin / 2), startY, buttonRadius, buttonRadius, 1, 1);
}
} else if (pGamepad->pressedDown()) {
if (pGamepad->pressedLeft()) {
obdPreciseEllipse(&obd, startX + (buttonMargin / 5), startY + (buttonMargin * 0.875), buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedRight()) {
obdPreciseEllipse(&obd, startX + (buttonMargin * 0.875), startY + (buttonMargin * 0.875), buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + buttonMargin / 2, startY + buttonMargin, buttonRadius, buttonRadius, 1, 1);
}
} else if (pGamepad->pressedLeft()) {
obdPreciseEllipse(&obd, startX, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedRight()) {
obdPreciseEllipse(&obd, startX + buttonMargin, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + buttonMargin / 2, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
}
}

void I2CDisplayAddon::drawTwinStickB(int startX, int startY, int buttonRadius, int buttonPadding)
{
const int buttonMargin = buttonPadding + (buttonRadius * 2);

// Stick
obdPreciseEllipse(&obd, startX + (buttonMargin / 2), startY + (buttonMargin / 2), buttonRadius * 1.25, buttonRadius * 1.25, 1, 0);

if (pGamepad->pressedB4()) {
if (pGamepad->pressedB3()) {
obdPreciseEllipse(&obd, startX + (buttonMargin / 5), startY + (buttonMargin / 5), buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedB2()) {
obdPreciseEllipse(&obd, startX + (buttonMargin * 0.875), startY + (buttonMargin / 5), buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + (buttonMargin / 2), startY, buttonRadius, buttonRadius, 1, 1);
}
} else if (pGamepad->pressedB1()) {
if (pGamepad->pressedB3()) {
obdPreciseEllipse(&obd, startX + (buttonMargin / 5), startY + (buttonMargin * 0.875), buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedB2()) {
obdPreciseEllipse(&obd, startX + (buttonMargin * 0.875), startY + (buttonMargin * 0.875), buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + buttonMargin / 2, startY + buttonMargin, buttonRadius, buttonRadius, 1, 1);
}
} else if (pGamepad->pressedB3()) {
obdPreciseEllipse(&obd, startX, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
} else if (pGamepad->pressedB2()) {
obdPreciseEllipse(&obd, startX + buttonMargin, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
} else {
obdPreciseEllipse(&obd, startX + buttonMargin / 2, startY + buttonMargin / 2, buttonRadius, buttonRadius, 1, 1);
}
}

void I2CDisplayAddon::drawMAMEA(int startX, int startY, int buttonSize, int buttonPadding)
{
const int buttonMargin = buttonPadding + buttonSize;
Expand Down