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 the version of Environment Loader in menu #22

Merged
merged 3 commits into from
Jul 20, 2023
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ jobs:
needs: clang-format
steps:
- uses: actions/checkout@v3
- name: create version.h
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
cat <<EOF > ./source/version.h
#pragma once
#define ENVIRONMENT_LOADER_VERSION_EXTRA " (nightly-$git_hash)"
EOF
- name: build binary
run: |
docker build . -t builder
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ jobs:
needs: clang-format
steps:
- uses: actions/checkout@v3
- name: create version.h
run: |
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
cat <<EOF > ./source/version.h
#pragma once
#define ENVIRONMENT_LOADER_VERSION_EXTRA " (nightly-$git_hash)"
EOF
- name: build binary
run: |
docker build . -t builder
Expand Down
5 changes: 5 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "utils/DrawUtils.h"
#include "utils/InputUtils.h"
#include "utils/PairUtils.h"
#include "version.h"

#define ENVIRONMENT_LOADER_VERSION "v0.2.0"

// clang-format off
#define MEMORY_REGION_START 0x00A00000
Expand Down Expand Up @@ -350,6 +353,8 @@ std::string EnvironmentSelectionScreen(const std::map<std::string, std::string>
DrawUtils::setFontSize(24);
DrawUtils::print(16, 6 + 24, "Environment Loader");
DrawUtils::drawRectFilled(8, 8 + 24 + 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
DrawUtils::setFontSize(16);
DrawUtils::print(SCREEN_WIDTH - 16, 6 + 24, ENVIRONMENT_LOADER_VERSION ENVIRONMENT_LOADER_VERSION_EXTRA, true);

// draw bottom bar
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
Expand Down
16 changes: 11 additions & 5 deletions source/utils/InputUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "InputUtils.h"
#include "logger.h"
#include <coreinit/thread.h>
#include <padscore/kpad.h>
#include <padscore/wpad.h>
#include <vpad/input.h>
Expand Down Expand Up @@ -97,11 +99,15 @@ InputUtils::InputData InputUtils::getControllerInput() {
InputData inputData{};
VPADStatus vpadStatus{};
VPADReadError vpadError = VPAD_READ_UNINITIALIZED;
if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) {
inputData.trigger = vpadStatus.trigger;
inputData.hold = vpadStatus.hold;
inputData.release = vpadStatus.release;
}
do {
if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) {
inputData.trigger = vpadStatus.trigger;
inputData.hold = vpadStatus.hold;
inputData.release = vpadStatus.release;
} else {
OSSleepTicks(OSMillisecondsToTicks(1));
}
} while (vpadError == VPAD_READ_NO_SAMPLES);

KPADStatus kpadStatus{};
KPADError kpadError = KPAD_ERROR_UNINITIALIZED;
Expand Down
2 changes: 2 additions & 0 deletions source/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#define ENVIRONMENT_LOADER_VERSION_EXTRA ""