Format the code via clang-format (#3)

This commit is contained in:
Maschell 2022-02-02 19:57:14 +01:00 committed by GitHub
parent ad693c94ff
commit beedc7513c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 168 additions and 90 deletions

66
.clang-format Normal file
View File

@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,18 +6,18 @@ on:
- main
jobs:
build-binary:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
- name: clang-format
run: |
git config --file .gitmodules --get-regexp url | while read url; do
git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//")
done
git submodule sync
git submodule update --init --recursive
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -t builder

View File

@ -3,17 +3,18 @@ name: CI-PR
on: [pull_request]
jobs:
build-binary:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
- name: clang-format
run: |
git config --file .gitmodules --get-regexp url | while read url; do
git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//")
done
git submodule sync
git submodule update --init --recursive
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -t builder

View File

@ -1,3 +1,4 @@
[![CI-Release](https://github.com/wiiu-env/AutobootModule/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/AutobootModule/actions/workflows/ci.yml)
# AutobootModule
This is a bootmenu targetted to be loaded with the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader). It allows you to boot into the Wii U Menu, Homebrew Channel, vWii System Menu or vWii Homebrew Channel.
@ -33,6 +34,10 @@ docker run -it --rm -v ${PWD}:/project autobootmodule-builder make
docker run -it --rm -v ${PWD}:/project autobootmodule-builder make clean
```
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
## Credits
- GaryOderNichts
- Maschell

View File

@ -1,4 +1,7 @@
#pragma once
#include <nn/act.h>
#include <stdint.h>
#include <string>
class AccountInfo {
public:

View File

@ -1,26 +1,26 @@
#include <malloc.h>
#include <string>
#include <map>
#include <locale>
#include <vector>
#include <codecvt>
#include <locale>
#include <malloc.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "ACTAccountInfo.h"
#include "BootUtils.h"
#include "logger.h"
#include "DrawUtils.h"
#include "MenuUtils.h"
#include "ACTAccountInfo.h"
#include "logger.h"
#include <coreinit/debug.h>
#include <coreinit/screen.h>
#include <nn/cmpt/cmpt.h>
#include <gx2/state.h>
#include <nn/act.h>
#include <nn/cmpt/cmpt.h>
#include <padscore/kpad.h>
#include <sysapp/launch.h>
#include <sysapp/title.h>
#include <padscore/kpad.h>
#include <vpad/input.h>
#include <gx2/state.h>
#include <iosuhax.h>
@ -32,9 +32,9 @@ void bootWiiUMenu() {
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
nn::act::Finalize();
if (defaultSlot) { //normal menu boot
if (defaultSlot) {//normal menu boot
SYSLaunchMenu();
} else { //show mii select
} else {//show mii select
_SYSLaunchMenuWithCheckingAccount(slot);
}
}
@ -50,7 +50,7 @@ void handleAccountSelection() {
nn::act::Initialize();
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
if (!defaultSlot) { // No default account is set.
if (!defaultSlot) {// No default account is set.
std::vector<std::shared_ptr<AccountInfo>> accountInfoList;
for (int32_t i = 0; i < 13; i++) {
if (!nn::act::IsSlotOccupied(i)) {
@ -134,9 +134,9 @@ void bootHomebrewChannel() {
// test if the OHBC or HBC is installed
if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) {
titleId = 0x000100014F484243L; // 'OHBC'
titleId = 0x000100014F484243L;// 'OHBC'
} else if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) {
titleId = 0x000100014C554C5AL; // 'LULZ'
titleId = 0x000100014C554C5AL;// 'LULZ'
} else {
DEBUG_FUNCTION_LINE("Cannot find HBC, booting vWii System Menu");
}

View File

@ -2,11 +2,11 @@
#include <malloc.h>
#include <cmath>
#include <coreinit/cache.h>
#include <coreinit/memory.h>
#include <coreinit/screen.h>
#include <coreinit/cache.h>
#include <png.h>
#include <ft2build.h>
#include <png.h>
#include FT_FREETYPE_H
#include "MenuUtils.h"
@ -266,7 +266,8 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh
buffer[num] = 0;
} else {
wchar_t *tmp = buffer;
while ((*tmp++ = *string++));
while ((*tmp++ = *string++))
;
}
print(x, y, buffer, alignRight);
@ -306,7 +307,8 @@ uint32_t DrawUtils::getTextWidth(const char *string) {
buffer[num] = 0;
} else {
wchar_t *tmp = buffer;
while ((*tmp++ = *string++));
while ((*tmp++ = *string++))
;
}
uint32_t width = getTextWidth(buffer);

View File

@ -1,20 +1,20 @@
#include <malloc.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
#include "MenuUtils.h"
#include "DrawUtils.h"
#include <cstdint>
#include <cstring>
#include <malloc.h>
#include <string>
#include <vector>
#include <coreinit/screen.h>
#include <coreinit/debug.h>
#include <vpad/input.h>
#include <coreinit/screen.h>
#include <gx2/state.h>
#include <nn/act/client_cpp.h>
#include <memory>
#include <nn/act/client_cpp.h>
#include <vpad/input.h>
#include "icon_png.h"
#include "ACTAccountInfo.h"
#include "icon_png.h"
#include "logger.h"
const char *menu_options[] = {
@ -31,13 +31,13 @@ const char *autoboot_config_strings[] = {
"vwii_homebrew_channel",
};
template<typename ... Args>
std::string string_format(const std::string &format, Args ... args) {
int size_s = std::snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0'
auto size = static_cast<size_t>( size_s );
template<typename... Args>
std::string string_format(const std::string &format, Args... args) {
int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1;// Extra space for '\0'
auto size = static_cast<size_t>(size_s);
auto buf = std::make_unique<char[]>(size);
std::snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
std::snprintf(buf.get(), size, format.c_str(), args...);
return std::string(buf.get(), buf.get() + size - 1);// We don't want the '\0' inside
}
int32_t readAutobootOption(std::string &configPath) {
@ -220,9 +220,9 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
auto yOffset = index;
for (uint32_t y = 0; y < target_height; y++) {
for (uint32_t x = 0; x < target_width; x++) {
uint32_t col = (((x) * width / target_width) + ((target_height - y - 1) * height / target_height) * width) * 4;
uint32_t col = (((x) *width / target_width) + ((target_height - y - 1) * height / target_height) * width) * 4;
uint32_t colVal = ((uint32_t *) &val->miiImageBuffer[col + 1])[0];
if (colVal == 0x00808080) { // Remove the green background.
if (colVal == 0x00808080) {// Remove the green background.
DrawUtils::drawPixel(x + xOffset, y + yOffset, COLOR_BACKGROUND.r, COLOR_BACKGROUND.g, COLOR_BACKGROUND.b, COLOR_BACKGROUND.a);
} else {
DrawUtils::drawPixel(x + xOffset, y + yOffset, val->miiImageBuffer[col + 1], val->miiImageBuffer[col + 2], val->miiImageBuffer[col + 3], val->miiImageBuffer[col]);
@ -289,7 +289,7 @@ nn::act::SlotNo handleAccountSelectScreen(const std::vector<std::shared_ptr<Acco
auto i = 0;
nn::act::SlotNo resultSlot = 0;
for (auto const &val: data) {
for (auto const &val : data) {
if (i == selected) {
resultSlot = val->slot;
}

View File

@ -1,20 +1,22 @@
#pragma once
#include "ACTAccountInfo.h"
#include <cstdint>
#include <string>
#include <memory>
#include <nn/act.h>
#include <string>
#include <vector>
#include "ACTAccountInfo.h"
#define COLOR_WHITE Color(0xffffffff)
#define COLOR_BLACK Color(0, 0, 0, 255)
#define COLOR_BACKGROUND COLOR_BLACK
#define COLOR_TEXT COLOR_WHITE
#define COLOR_TEXT2 Color(0xB3ffffff)
#define COLOR_AUTOBOOT Color(0xaeea00ff)
#define COLOR_BORDER Color(204, 204, 204, 255)
#define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff)
// clang-format off
#define COLOR_WHITE Color(0xffffffff)
#define COLOR_BLACK Color(0, 0, 0, 255)
#define COLOR_BACKGROUND COLOR_BLACK
#define COLOR_TEXT COLOR_WHITE
#define COLOR_TEXT2 Color(0xB3ffffff)
#define COLOR_AUTOBOOT Color(0xaeea00ff)
#define COLOR_BORDER Color(204, 204, 204, 255)
#define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff)
// clang-format on
enum {
BOOT_OPTION_WII_U_MENU,

View File

@ -1,20 +1,20 @@
#include <malloc.h>
#include "BootUtils.h"
#include "QuickStartUtils.h"
#include "logger.h"
#include "BootUtils.h"
#include <coreinit/exit.h>
#include <coreinit/thread.h>
#include <coreinit/memdefaultheap.h>
#include <coreinit/foreground.h>
#include <coreinit/memdefaultheap.h>
#include <coreinit/thread.h>
#include <nn/acp/title.h>
#include <nn/act/client_cpp.h>
#include <nn/ccr/sys_caffeine.h>
#include <nn/sl.h>
#include <sysapp/title.h>
#include <sysapp/launch.h>
#include <proc_ui/procui.h>
#include <sysapp/launch.h>
#include <sysapp/title.h>
extern "C" void __fini_wut();
@ -87,7 +87,7 @@ bool getQuickBoot() {
if (bootCheck == 0) {
nn::sl::Initialize(MEMAllocFromDefaultHeapEx, MEMFreeToDefaultHeap);
char path[0x80];
nn::sl::GetDefaultDatabasePath(path, 0x80, 0x0005001010066000); // ECO process
nn::sl::GetDefaultDatabasePath(path, 0x80, 0x0005001010066000);// ECO process
FSCmdBlock cmdBlock;
FSInitCmdBlock(&cmdBlock);
@ -101,7 +101,7 @@ bool getQuickBoot() {
auto database = new nn::sl::LaunchInfoDatabase;
database->Load(fileStream, nn::sl::REGION_EUR);
CCRAppLaunchParam data; // load sys caffeine data
CCRAppLaunchParam data;// load sys caffeine data
// load app launch param
CCRSysCaffeineGetAppLaunchParam(&data);
@ -197,7 +197,7 @@ bool getQuickBoot() {
return true;
}
if (info.titleId == 0x0005001010004000L) { // OSv0
if (info.titleId == 0x0005001010004000L) {// OSv0
DEBUG_FUNCTION_LINE("Launching vWii System Menu");
bootvWiiMenu();

View File

@ -6,8 +6,8 @@
#include <coreinit/thread.h>
#include <coreinit/title.h>
#include <nn/spm.h>
#include <nn/acp/save.h>
#include <nn/spm.h>
#include <nsysuhs/uhs.h>
#include <sysapp/title.h>
@ -56,8 +56,7 @@ static int numberUSBStorageDevicesConnected() {
UhsInterfaceProfile profiles[10];
UhsInterfaceFilter filter = {
.match_params = MATCH_ANY
};
.match_params = MATCH_ANY};
UHSStatus result;
if ((result = UhsQueryInterfaces(handle, &filter, profiles, 10)) <= UHS_STATUS_OK) {
@ -106,7 +105,7 @@ void initExternalStorage() {
int tries = 0;
bool found = false;
while (tries < 1200) { // Wait up to 20 seconds, like the Wii U Menu
while (tries < 1200) {// Wait up to 20 seconds, like the Wii U Menu
int32_t numItems = nn::spm::GetStorageList(items, 0x20);
DEBUG_FUNCTION_LINE("Number of items: %d", numItems);
@ -141,4 +140,3 @@ void initExternalStorage() {
nn::spm::Finalize();
}

View File

@ -3,8 +3,8 @@
#ifdef DEBUG
#include <stdint.h>
#include <whb/log_cafe.h>
#include <whb/log_udp.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false;
@ -17,7 +17,7 @@ void initLogging() {
cafeLogInit = WHBLogCafeInit();
udpLogInit = WHBLogUdpInit();
}
#endif // DEBUG
#endif// DEBUG
}
void deinitLogging() {
@ -34,5 +34,5 @@ void deinitLogging() {
WHBLogUdpDeinit();
udpLogInit = false;
}
#endif // DEBUG
#endif// DEBUG
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#include <whb/log.h>
#ifdef __cplusplus
extern "C" {
@ -12,12 +12,14 @@ extern "C" {
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#else
@ -35,4 +37,3 @@ void deinitLogging();
#ifdef __cplusplus
}
#endif

View File

@ -1,12 +1,12 @@
#include "DrawUtils.h"
#include "QuickStartUtils.h"
#include "StorageUtils.h"
#include "logger.h"
#include <coreinit/debug.h>
#include <gx2/state.h>
#include <malloc.h>
#include <string>
#include <vpad/input.h>
#include <coreinit/debug.h>
#include <gx2/state.h>
#include "StorageUtils.h"
#include "QuickStartUtils.h"
#include "DrawUtils.h"
#include "logger.h"
#include "BootUtils.h"
#include "MenuUtils.h"