Skip to content
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
27 changes: 16 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.semver.outputs.pr_number }}

- name: Cache PlatformIO & Arduino CLI
- name: Cache PlatformIO and Python
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
~/.arduino15
key: ${{ runner.os }}-build-tools-${{ hashFiles('**/platformio.ini') }}

- name: Setup Python
Expand All @@ -86,9 +85,11 @@ jobs:
LUMENLAB_VERSION: ${{ steps.semver.outputs.tag }}

- name: Install Arduino CLI
if: false
uses: arduino/setup-arduino-cli@v1

- name: Setup Arduino CLI config
if: false
run: |
cat > arduino-cli.yaml <<EOF
board_manager:
Expand All @@ -97,15 +98,19 @@ jobs:
EOF

- name: Update Arduino CLI index
if: false
run: arduino-cli --config-file arduino-cli.yaml core update-index

- name: Install Bluepad32 core
if: false
run: arduino-cli --config-file arduino-cli.yaml core install esp32-bluepad32:esp32

- name: Install project dependencies
if: false
run: arduino-cli lib install FastLED@3.10.2 "Adafruit SSD1306@2.5.15"

- name: Build release for PS4
if: false
run: |
echo "" > lumenlab.ino
arduino-cli compile --fqbn esp32-bluepad32:esp32:uPesy_wroom \
Expand All @@ -116,16 +121,17 @@ jobs:

- name: Package PS3 Firmware ZIP
run: |
cp .pio/build/release/firmware.bin ./build/ps3-firmware.bin
cp .pio/build/release/bootloader.bin ./build/ps3-bootloader.bin
cp .pio/build/release/partitions.bin ./build/ps3-partitions.bin
zip -j ./build/ps3-firmware.zip \
./build/ps3-firmware.bin \
./build/ps3-bootloader.bin \
./build/ps3-partitions.bin
cp .pio/build/release/firmware.bin ./build/lumenlab-firmware.bin
cp .pio/build/release/bootloader.bin ./build/lumenlab-bootloader.bin
cp .pio/build/release/partitions.bin ./build/lumenlab-partitions.bin
zip -j ./build/lumenlab-firmware.zip \
./build/lumenlab-firmware.bin \
./build/lumenlab-bootloader.bin \
./build/lumenlab-partitions.bin


- name: Package PS4 Firmware ZIP
if: false
working-directory: build
run: |
mv ./lumenlab.ino.bin ./ps4-firmware.bin
Expand All @@ -143,7 +149,6 @@ jobs:
name: ${{ steps.semver.outputs.tag }} - ${{ steps.pr_details.outputs.title }}
body: ${{ steps.pr_details.outputs.body }}
files: |
./build/ps3-firmware.zip
./build/ps4-firmware.zip
./build/lumenlab-firmware.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{
"label": "LumenLab - Upload (PS4 Virtualization)",
"type": "shell",
"command": "echo \"\" > lumenlab.ino && export LUMENLAB_VERSION='v0.0.0' && echo $LUMENLAB_VERSION && arduino-cli compile --fqbn esp32-bluepad32:esp32:uPesy_wroom --build-property compiler.cpp.extra_flags=\"-Iinclude -Isrc -Os -DVIRTUALIZATION -std=gnu++2a -DLUMENLAB_VERSION=\\\"${LUMENLAB_VERSION}\\\"\" --output-dir build && ../lumenlab-installer/Firmware/esptool.exe --chip esp32 --baud 921600 write_flash -z 0x1000 build/lumenlab.ino.bootloader.bin 0x8000 build/lumenlab.ino.partitions.bin 0x10000 build/lumenlab.ino.bin",
"command": "echo \"\" > lumenlab.ino && export LUMENLAB_VERSION='v0.0.0' && echo $LUMENLAB_VERSION && arduino-cli compile --fqbn esp32-bluepad32:esp32:uPesy_wroom --build-property compiler.cpp.extra_flags=\"-Iinclude -Isrc -Os -DVIRTUALIZATION -std=gnu++2a -DLUMENLAB_VERSION=\\\"${LUMENLAB_VERSION}\\\"\" --output-dir build --jobs 6 && ../lumenlab-installer/Firmware/esptool.exe --chip esp32 --baud 921600 write_flash -z 0x1000 build/lumenlab.ino.bootloader.bin 0x8000 build/lumenlab.ino.partitions.bin 0x10000 build/lumenlab.ino.bin",
"problemMatcher": [
"$platformio"
],
Expand Down
3 changes: 3 additions & 0 deletions include/core/context-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

#include "engine/layer.h"
#include "engine/state-manager.h"
#ifdef USE_PS3
#include "player/ps3-controller.h"
#else
#include "player/ps4-controller.h"
#endif
#include "lights/led-strip.h"
#include "display/display.h"
#include "display/menu-navigation.h"
Expand Down
4 changes: 2 additions & 2 deletions include/player/controller-properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Player
{
struct AnalogStick
{
int8_t x = 0;
int8_t y = 0;
int16_t x = 0;
int16_t y = 0;
};

enum class ControllerButton : uint8_t
Expand Down
2 changes: 0 additions & 2 deletions include/player/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Player
{
public:
virtual ~Controller() = default;
virtual void begin(String macAddress) = 0;

virtual uint8_t cross() = 0;
virtual uint8_t circle() = 0;
Expand Down Expand Up @@ -52,7 +51,6 @@ namespace Player
bool connection = false;
uint32_t ignoreEventsUntil = 0;

virtual void handleOnConnect() = 0;
int filterDeadZone(int8_t value, int deadZone = 3);
};
}
4 changes: 2 additions & 2 deletions include/player/ps3-controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Player
public:
Ps3Controller() : controller(&Ps3) { instance = this; }

void begin(String macAddress) override;
void begin(String macAddress);
uint8_t cross() override { return instance->controller->data.analog.button.cross; }
uint8_t circle() override { return instance->controller->data.analog.button.circle; }
uint8_t triangle() override { return instance->controller->data.analog.button.triangle; }
Expand Down Expand Up @@ -45,7 +45,7 @@ namespace Player
::Ps3Controller *controller;
static Ps3Controller *instance;

void handleOnConnect() override;
void handleOnConnect();
static void onConnect()
{
if (instance)
Expand Down
89 changes: 44 additions & 45 deletions include/player/ps4-controller.h
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
#if !defined(USE_PS3)

#pragma once

#include <Bluepad32.h>

#include "player/controller.h"
#include "player/controller-properties.h"

namespace Player
{

class Ps4Controller : public Controller
{
public:
Ps4Controller() : controller(nullptr) { instance = this; }
void begin(String macAddress) {};

uint8_t cross() { return 5; } // instance->controller.data.button.cross; }
uint8_t circle() { return 5; } // instance->controller.data.button.circle; }
uint8_t triangle() { return 5; } // instance->controller.data.button.triangle; }
uint8_t square() { return 5; } // instance->controller.data.button.square; }

uint8_t l1() { return 5; } // instance->controller.data.button.l1; }
uint8_t l2() { return 5; } // instance->controller.data.button.l2; }
uint8_t r1() { return 5; } // instance->controller.data.button.r1; }
uint8_t r2() { return 5; } // instance->controller.data.button.r2; }

uint8_t up() { return 5; } // instance->controller.data.button.up; }
uint8_t down() { return 5; } // instance->controller.data.button.down; }
uint8_t left() { return 5; } // instance->controller.data.button.left; }
uint8_t right() { return 5; } // instance->controller.data.button.right; }

uint8_t start() { return 5; } // instance->controller.data.button.options; }
uint8_t select() { return 5; } // instance->controller.data.button.share; }
uint8_t ps() { return 5; } // instance->controller.data.button.ps; }

AnalogStick leftAnalog() { return {0, 0}; }
AnalogStick rightAnalog() { return {0, 0}; }

const uint8_t rawButtonState(const ControllerButton button) const override { return 0; }
const bool wasPressed(const ControllerButton button) const override { return 0; }
const bool wasPressedAndReleased(const ControllerButton button) const override { return 0; }
const bool isConnected() const { return instance->connection; }
void poll() {}
bool isDown(const ControllerButton button) const { return false; }
void reset() {}
Ps4Controller() { instance = this; };

void begin(String macAddress);
void poll() override;

uint8_t cross() override { return button(0x1); }
uint8_t circle() override { return button(0x2); }
uint8_t square() override { return button(0x4); }
uint8_t triangle() override { return button(0x8); }

uint8_t l1() { return button(0x10); }
uint8_t r1() { return button(0x20); }
uint8_t l2() override;
uint8_t r2() override;

uint8_t up() override { return dpad(0x1); }
uint8_t down() override { return dpad(0x2); }
uint8_t right() override { return dpad(0x4); }
uint8_t left() override { return dpad(0x8); }

uint8_t ps() override { return misc(0x1); }
uint8_t start() override { return misc(0x4); }

AnalogStick leftAnalog() override;
AnalogStick rightAnalog() override;

const uint8_t rawButtonState(const ControllerButton button) const override;
const bool wasPressed(const ControllerButton button) const override;
const bool wasPressedAndReleased(const ControllerButton button) const override;
const bool isConnected() const override { return connection; }
bool isDown(const ControllerButton button) const override;

private:
::Controller *controller;
ControllerPtr controllers[BP32_MAX_GAMEPADS] = {nullptr};
ControllerPtr active = nullptr;

void onConnectedInternal(ControllerPtr ctl);
void onDisconnectedInternal(ControllerPtr ctl);

static void onConnectedController(ControllerPtr ctl);
static void onDisconnectedController(ControllerPtr ctl);
uint8_t button(uint16_t mask);
uint8_t dpad(uint16_t mask);
uint8_t misc(uint16_t mask);

static Ps4Controller *instance;
bool connection = false;
uint32_t ignoreEventsUntil = 0;
void handleOnConnect() override {};
static void onConnect()
{
if (instance)
instance->handleOnConnect();
}
};
}

}
#endif
2 changes: 1 addition & 1 deletion src/display/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ namespace Display
drawHeader("LumenLab");

char controllerTypeBuffer[32] = "";
sprintf(controllerTypeBuffer, "%s controller", SystemCore::Configuration::psControllerType);
sprintf(controllerTypeBuffer, "%s controller", SystemCore::Configuration::psControllerType().c_str());

auto startingX = calculateCenterText(controllerTypeBuffer);
display.setCursor(startingX, 8);
Expand Down
8 changes: 5 additions & 3 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ namespace Engine
#endif

contextManager.controller.begin(SystemCore::Configuration::macAddress());
logf("Connecting to %s controller", SystemCore::Configuration::psControllerType);

logf("Connecting to %s controller", SystemCore::Configuration::psControllerType().c_str());

// twenty second attempt to connect to PS3/PS4 controller
int reattempt = 0;
while (!contextManager.controller.isConnected() && reattempt < 80)
{
logf(" Searching for %s controller...", SystemCore::Configuration::psControllerType);
logf(" Searching for %s controller...", SystemCore::Configuration::psControllerType().c_str());
++reattempt;
contextManager.controller.poll();
delay(250);
}

Expand Down Expand Up @@ -142,7 +144,7 @@ namespace Engine
contextManager.stateManager.setNextUserSceneChoice(SceneSelection::Canvas);
contextManager.stateManager.displayShouldUpdate = true;
contextManager.stateManager.displayIsVisible = true;
logf("%s controller connected. Transitioning to Main Menu", SystemCore::Configuration::psControllerType);
logf("%s controller connected. Transitioning to Main Menu", SystemCore::Configuration::psControllerType().c_str());
contextManager.controller.reset();
return;
}
Expand Down
Loading