mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-08-13 13:15:41 -05:00
Formatting and cleanup
This commit is contained in:
@@ -4,16 +4,13 @@
|
||||
#include "../config/WUPSConfig.h"
|
||||
#include "../globals.h"
|
||||
#include "DrawUtils.h"
|
||||
#include "StringTools.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <coreinit/screen.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <memory/mappedmemory.h>
|
||||
#include <vpad/input.h>
|
||||
#include <padscore/kpad.h>
|
||||
#include <padscore/wpad.h>
|
||||
#include <gx2/display.h>
|
||||
|
||||
#define COLOR_BACKGROUND Color(238, 238, 238, 255)
|
||||
@@ -26,96 +23,94 @@
|
||||
#define COLOR_BLACK Color(0, 0, 0, 255)
|
||||
|
||||
struct ConfigDisplayItem {
|
||||
WUPSConfig* config;
|
||||
WUPSConfig *config{};
|
||||
std::string name;
|
||||
std::string author;
|
||||
std::string version;
|
||||
bool enabled;
|
||||
bool enabled{};
|
||||
};
|
||||
|
||||
#define MAX_BUTTONS_ON_SCREEN 8
|
||||
|
||||
static uint32_t remapWiiMoteButtons(uint32_t buttons)
|
||||
{
|
||||
static uint32_t remapWiiMoteButtons(uint32_t buttons) {
|
||||
uint32_t conv_buttons = 0;
|
||||
|
||||
if(buttons & WPAD_BUTTON_LEFT)
|
||||
if (buttons & WPAD_BUTTON_LEFT)
|
||||
conv_buttons |= VPAD_BUTTON_LEFT;
|
||||
|
||||
if(buttons & WPAD_BUTTON_RIGHT)
|
||||
if (buttons & WPAD_BUTTON_RIGHT)
|
||||
conv_buttons |= VPAD_BUTTON_RIGHT;
|
||||
|
||||
if(buttons & WPAD_BUTTON_DOWN)
|
||||
if (buttons & WPAD_BUTTON_DOWN)
|
||||
conv_buttons |= VPAD_BUTTON_DOWN;
|
||||
|
||||
if(buttons & WPAD_BUTTON_UP)
|
||||
if (buttons & WPAD_BUTTON_UP)
|
||||
conv_buttons |= VPAD_BUTTON_UP;
|
||||
|
||||
if(buttons & WPAD_BUTTON_PLUS)
|
||||
if (buttons & WPAD_BUTTON_PLUS)
|
||||
conv_buttons |= VPAD_BUTTON_PLUS;
|
||||
|
||||
if(buttons & WPAD_BUTTON_B)
|
||||
if (buttons & WPAD_BUTTON_B)
|
||||
conv_buttons |= VPAD_BUTTON_B;
|
||||
|
||||
if(buttons & WPAD_BUTTON_A)
|
||||
if (buttons & WPAD_BUTTON_A)
|
||||
conv_buttons |= VPAD_BUTTON_A;
|
||||
|
||||
if(buttons & WPAD_BUTTON_MINUS)
|
||||
if (buttons & WPAD_BUTTON_MINUS)
|
||||
conv_buttons |= VPAD_BUTTON_MINUS;
|
||||
|
||||
if(buttons & WPAD_BUTTON_HOME)
|
||||
if (buttons & WPAD_BUTTON_HOME)
|
||||
conv_buttons |= VPAD_BUTTON_HOME;
|
||||
|
||||
return conv_buttons;
|
||||
}
|
||||
|
||||
static uint32_t remapClassicButtons(uint32_t buttons)
|
||||
{
|
||||
static uint32_t remapClassicButtons(uint32_t buttons) {
|
||||
uint32_t conv_buttons = 0;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_LEFT)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_LEFT)
|
||||
conv_buttons |= VPAD_BUTTON_LEFT;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_RIGHT)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_RIGHT)
|
||||
conv_buttons |= VPAD_BUTTON_RIGHT;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_DOWN)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_DOWN)
|
||||
conv_buttons |= VPAD_BUTTON_DOWN;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_UP)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_UP)
|
||||
conv_buttons |= VPAD_BUTTON_UP;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_PLUS)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_PLUS)
|
||||
conv_buttons |= VPAD_BUTTON_PLUS;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_X)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_X)
|
||||
conv_buttons |= VPAD_BUTTON_X;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_Y)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_Y)
|
||||
conv_buttons |= VPAD_BUTTON_Y;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_B)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_B)
|
||||
conv_buttons |= VPAD_BUTTON_B;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_A)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_A)
|
||||
conv_buttons |= VPAD_BUTTON_A;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_MINUS)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_MINUS)
|
||||
conv_buttons |= VPAD_BUTTON_MINUS;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_HOME)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_HOME)
|
||||
conv_buttons |= VPAD_BUTTON_HOME;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_ZR)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZR)
|
||||
conv_buttons |= VPAD_BUTTON_ZR;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_ZL)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_ZL)
|
||||
conv_buttons |= VPAD_BUTTON_ZL;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_R)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_R)
|
||||
conv_buttons |= VPAD_BUTTON_R;
|
||||
|
||||
if(buttons & WPAD_CLASSIC_BUTTON_L)
|
||||
if (buttons & WPAD_CLASSIC_BUTTON_L)
|
||||
conv_buttons |= VPAD_BUTTON_L;
|
||||
|
||||
return conv_buttons;
|
||||
@@ -140,25 +135,19 @@ void ConfigUtils::displayMenu() {
|
||||
if (hook_data->func_pointer == nullptr) {
|
||||
break;
|
||||
}
|
||||
WUPSConfig *cur_config = reinterpret_cast<WUPSConfig *>(((WUPSConfigHandle (*)()) ((uint32_t *) hook_data->func_pointer))());
|
||||
if(cur_config == nullptr){
|
||||
auto *cur_config = reinterpret_cast<WUPSConfig *>(((WUPSConfigHandle (*)()) ((uint32_t *) hook_data->func_pointer))());
|
||||
if (cur_config == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
//if(cur_config > 0x8000000);
|
||||
//DCFlushRange(&cur_config, sizeof(WUPSConfig*));
|
||||
//DCFlushRange(cur_config, sizeof(WUPSConfig));
|
||||
cfg.config = cur_config;
|
||||
|
||||
DEBUG_FUNCTION_LINE("name %s author %s version %s enabled %d config %08X",cfg.name.c_str(),cfg.author.c_str(),cfg.version.c_str(),cfg.enabled, cfg.config)
|
||||
configs.push_back(cfg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigDisplayItem* currentConfig = nullptr;
|
||||
WUPSConfigCategory* currentCategory = nullptr;
|
||||
ConfigDisplayItem *currentConfig = nullptr;
|
||||
WUPSConfigCategory *currentCategory = nullptr;
|
||||
|
||||
uint32_t selectedBtn = 0;
|
||||
uint32_t start = 0;
|
||||
@@ -187,7 +176,7 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (KPADReadEx((KPADChan)i, &kpad_data, 1, &kpad_error) > 0) {
|
||||
if (KPADReadEx((KPADChan) i, &kpad_data, 1, &kpad_error) > 0) {
|
||||
if (kpad_error == KPAD_ERROR_OK) {
|
||||
if (kpad_data.extensionType == WPAD_EXT_CORE || kpad_data.extensionType == WPAD_EXT_NUNCHUK) {
|
||||
buttonsTriggered |= remapWiiMoteButtons(kpad_data.trigger);
|
||||
@@ -211,8 +200,7 @@ void ConfigUtils::displayMenu() {
|
||||
selectedBtn++;
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
if (selectedBtn > 0) {
|
||||
selectedBtn--;
|
||||
redraw = true;
|
||||
@@ -221,11 +209,9 @@ void ConfigUtils::displayMenu() {
|
||||
if (buttonsTriggered & VPAD_BUTTON_X) {
|
||||
configs[selectedBtn].enabled = !configs[selectedBtn].enabled;
|
||||
redraw = true;
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_A) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_A) {
|
||||
currentConfig = &configs[selectedBtn];
|
||||
if(currentConfig == nullptr){
|
||||
DEBUG_FUNCTION_LINE("BYEBYE");
|
||||
if (currentConfig == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -245,8 +231,7 @@ void ConfigUtils::displayMenu() {
|
||||
if (selectedBtn >= end) {
|
||||
end = selectedBtn + 1;
|
||||
start = end - MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
else if (selectedBtn < start) {
|
||||
} else if (selectedBtn < start) {
|
||||
start = selectedBtn;
|
||||
end = start + MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
@@ -265,17 +250,17 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
|
||||
if (i == selectedBtn) {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
} else {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 2, configs[i].enabled ? COLOR_BORDER : COLOR_DISABLED);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 2, configs[i].enabled ? COLOR_BORDER : COLOR_DISABLED);
|
||||
}
|
||||
|
||||
DrawUtils::setFontSize(24);
|
||||
DrawUtils::print(16*2, index + 8 + 24, configs[i].name.c_str());
|
||||
DrawUtils::print(16 * 2, index + 8 + 24, configs[i].name.c_str());
|
||||
uint32_t sz = DrawUtils::getTextWidth(configs[i].name.c_str());
|
||||
DrawUtils::setFontSize(12);
|
||||
DrawUtils::print(16*2 + sz + 4, index + 8 + 24, configs[i].author.c_str());
|
||||
DrawUtils::print(SCREEN_WIDTH - 16*2, index + 8 + 24, configs[i].version.c_str(), true);
|
||||
DrawUtils::print(16 * 2 + sz + 4, index + 8 + 24, configs[i].author.c_str());
|
||||
DrawUtils::print(SCREEN_WIDTH - 16 * 2, index + 8 + 24, configs[i].version.c_str(), true);
|
||||
index += 42 + 8;
|
||||
}
|
||||
|
||||
@@ -289,7 +274,7 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::drawRectFilled(8, 8 + 24 + 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
|
||||
|
||||
// draw bottom bar
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8*2, 3, COLOR_BLACK);
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
|
||||
DrawUtils::setFontSize(18);
|
||||
DrawUtils::print(16, SCREEN_HEIGHT - 8, "\ue07d Navigate ");
|
||||
if (configs[selectedBtn].enabled) {
|
||||
@@ -309,7 +294,7 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
// draw home button
|
||||
DrawUtils::setFontSize(18);
|
||||
const char* exitHint = "\ue044 Exit";
|
||||
const char *exitHint = "\ue044 Exit";
|
||||
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHint) / 2, SCREEN_HEIGHT - 8, exitHint, true);
|
||||
|
||||
DrawUtils::endDraw();
|
||||
@@ -319,24 +304,22 @@ void ConfigUtils::displayMenu() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!currentCategory){
|
||||
auto cats = currentConfig->config->getCategories();
|
||||
|
||||
if (!currentCategory) {
|
||||
auto cats = currentConfig->config->getCategories();
|
||||
if (buttonsTriggered & VPAD_BUTTON_DOWN) {
|
||||
if (selectedBtn < cats.size() - 1) {
|
||||
selectedBtn++;
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
if (selectedBtn > 0) {
|
||||
selectedBtn--;
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_A) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_A) {
|
||||
currentCategory = cats[selectedBtn];
|
||||
if(currentCategory == nullptr){
|
||||
if (currentCategory == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("BYEBYE");
|
||||
break;
|
||||
}
|
||||
@@ -368,8 +351,7 @@ void ConfigUtils::displayMenu() {
|
||||
if (selectedBtn >= end) {
|
||||
end = selectedBtn + 1;
|
||||
start = end - MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
else if (selectedBtn < start) {
|
||||
} else if (selectedBtn < start) {
|
||||
start = selectedBtn;
|
||||
end = start + MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
@@ -384,13 +366,13 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::setFontColor(COLOR_TEXT);
|
||||
|
||||
if (i == selectedBtn) {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
} else {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 2, COLOR_BORDER);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 2, COLOR_BORDER);
|
||||
}
|
||||
|
||||
DrawUtils::setFontSize(24);
|
||||
DrawUtils::print(16*2, index + 8 + 24, cats[i]->getName().c_str());
|
||||
DrawUtils::print(16 * 2, index + 8 + 24, cats[i]->getName().c_str());
|
||||
index += 42 + 8;
|
||||
}
|
||||
|
||||
@@ -404,7 +386,7 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::drawRectFilled(8, 8 + 24 + 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
|
||||
|
||||
// draw bottom bar
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8*2, 3, COLOR_BLACK);
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
|
||||
DrawUtils::setFontSize(18);
|
||||
DrawUtils::print(16, SCREEN_HEIGHT - 8, "\ue07d Navigate ");
|
||||
if (configs[selectedBtn].enabled) {
|
||||
@@ -424,7 +406,7 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
// draw home button
|
||||
DrawUtils::setFontSize(18);
|
||||
const char* exitHint = "\ue044 Exit";
|
||||
const char *exitHint = "\ue044 Exit";
|
||||
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHint) / 2, SCREEN_HEIGHT - 8, exitHint, true);
|
||||
|
||||
DrawUtils::endDraw();
|
||||
@@ -441,14 +423,12 @@ void ConfigUtils::displayMenu() {
|
||||
selectedBtn++;
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_UP) {
|
||||
if (selectedBtn > 0) {
|
||||
selectedBtn--;
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
else if (buttonsTriggered & VPAD_BUTTON_B) {
|
||||
} else if (buttonsTriggered & VPAD_BUTTON_B) {
|
||||
currentCategory = nullptr;
|
||||
selectedBtn = 0;
|
||||
start = 0;
|
||||
@@ -490,8 +470,7 @@ void ConfigUtils::displayMenu() {
|
||||
if (selectedBtn >= end) {
|
||||
end = selectedBtn + 1;
|
||||
start = end - MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
else if (selectedBtn < start) {
|
||||
} else if (selectedBtn < start) {
|
||||
start = selectedBtn;
|
||||
end = start + MAX_BUTTONS_ON_SCREEN;
|
||||
}
|
||||
@@ -506,21 +485,20 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::setFontColor(COLOR_TEXT);
|
||||
|
||||
if (i == selectedBtn) {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||
} else {
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16*2, 44, 2, COLOR_BORDER);
|
||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 2, COLOR_BORDER);
|
||||
}
|
||||
|
||||
DrawUtils::setFontSize(24);
|
||||
DrawUtils::print(16*2, index + 8 + 24, config_items[i]->getDisplayName().c_str());
|
||||
DrawUtils::print(16 * 2, index + 8 + 24, config_items[i]->getDisplayName().c_str());
|
||||
if (i == selectedBtn) {
|
||||
if (pressedButtons != WUPS_CONFIG_BUTTON_NONE) {
|
||||
config_items[i]->onButtonPressed(pressedButtons);
|
||||
}
|
||||
DrawUtils::print(SCREEN_WIDTH - 16*2, index + 8 + 24, config_items[i]->getCurrentValueSelectedDisplay().c_str(), true);
|
||||
}
|
||||
else {
|
||||
DrawUtils::print(SCREEN_WIDTH - 16*2, index + 8 + 24, config_items[i]->getCurrentValueDisplay().c_str(), true);
|
||||
DrawUtils::print(SCREEN_WIDTH - 16 * 2, index + 8 + 24, config_items[i]->getCurrentValueSelectedDisplay().c_str(), true);
|
||||
} else {
|
||||
DrawUtils::print(SCREEN_WIDTH - 16 * 2, index + 8 + 24, config_items[i]->getCurrentValueDisplay().c_str(), true);
|
||||
}
|
||||
index += 42 + 8;
|
||||
}
|
||||
@@ -528,7 +506,7 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::setFontColor(COLOR_TEXT);
|
||||
|
||||
std::string headline;
|
||||
StringTools::strprintf(headline, "%s - %s",currentConfig->config->getName().c_str(), currentCategory->getName().c_str());
|
||||
StringTools::strprintf(headline, "%s - %s", currentConfig->config->getName().c_str(), currentCategory->getName().c_str());
|
||||
// draw top bar
|
||||
DrawUtils::setFontSize(24);
|
||||
DrawUtils::print(16, 6 + 24, headline.c_str());
|
||||
@@ -537,7 +515,7 @@ void ConfigUtils::displayMenu() {
|
||||
DrawUtils::print(SCREEN_WIDTH - 16, 8 + 24, currentConfig->version.c_str(), true);
|
||||
|
||||
// draw bottom bar
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8*2, 3, COLOR_BLACK);
|
||||
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK);
|
||||
DrawUtils::setFontSize(18);
|
||||
DrawUtils::print(16, SCREEN_HEIGHT - 8, "\ue07d Navigate ");
|
||||
DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 8, "\ue001 Back", true);
|
||||
@@ -553,7 +531,7 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
// draw home button
|
||||
DrawUtils::setFontSize(18);
|
||||
const char* exitHint = "\ue044 Exit";
|
||||
const char *exitHint = "\ue044 Exit";
|
||||
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHint) / 2, SCREEN_HEIGHT - 8, exitHint, true);
|
||||
|
||||
DrawUtils::endDraw();
|
||||
@@ -561,10 +539,10 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& element : configs) {
|
||||
for (const auto& cat : element.config->getCategories()) {
|
||||
for (const auto& item : cat->getItems()) {
|
||||
if(item->isDirty()){
|
||||
for (const auto &element: configs) {
|
||||
for (const auto &cat: element.config->getCategories()) {
|
||||
for (const auto &item: cat->getItems()) {
|
||||
if (item->isDirty()) {
|
||||
item->callCallback();
|
||||
}
|
||||
}
|
||||
@@ -589,36 +567,35 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& element : configs) {
|
||||
for (const auto &element: configs) {
|
||||
DEBUG_FUNCTION_LINE("Delete %08X", element.config);
|
||||
delete element.config;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigUtils::openConfigMenu()
|
||||
{
|
||||
void ConfigUtils::openConfigMenu() {
|
||||
bool wasHomeButtonMenuEnabled = OSIsHomeButtonMenuEnabled();
|
||||
|
||||
OSScreenInit();
|
||||
|
||||
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||
void* screenbuffer0 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size, 0x100);
|
||||
void* screenbuffer1 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf1_size, 0x100);
|
||||
void *screenbuffer0 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size, 0x100);
|
||||
void *screenbuffer1 = MEMAllocFromMappedMemoryForGX2Ex(screen_buf1_size, 0x100);
|
||||
|
||||
bool skipScreen0Free = false;
|
||||
bool skipScreen1Free = false;
|
||||
|
||||
if (!screenbuffer0 || !screenbuffer1) {
|
||||
if(screenbuffer0 == nullptr){
|
||||
if(storedTVBuffer.buffer_size >= screen_buf0_size){
|
||||
if (screenbuffer0 == nullptr) {
|
||||
if (storedTVBuffer.buffer_size >= screen_buf0_size) {
|
||||
screenbuffer0 = storedTVBuffer.buffer;
|
||||
skipScreen0Free = true;
|
||||
DEBUG_FUNCTION_LINE("Use storedTVBuffer");
|
||||
}
|
||||
}
|
||||
if(screenbuffer1 == nullptr){
|
||||
if(storedDRCBuffer.buffer_size >= screen_buf1_size){
|
||||
if (screenbuffer1 == nullptr) {
|
||||
if (storedDRCBuffer.buffer_size >= screen_buf1_size) {
|
||||
screenbuffer1 = storedDRCBuffer.buffer;
|
||||
skipScreen1Free = true;
|
||||
DEBUG_FUNCTION_LINE("Use storedDRCBuffer");
|
||||
@@ -658,22 +635,20 @@ void ConfigUtils::openConfigMenu()
|
||||
|
||||
error_exit:
|
||||
|
||||
if(storedTVBuffer.buffer != nullptr) {
|
||||
if (storedTVBuffer.buffer != nullptr) {
|
||||
GX2SetTVBuffer(storedTVBuffer.buffer, storedTVBuffer.buffer_size, static_cast<GX2TVRenderMode>(storedTVBuffer.mode),
|
||||
storedTVBuffer.surface_format, storedTVBuffer.buffering_mode);
|
||||
}
|
||||
|
||||
if(storedDRCBuffer.buffer != nullptr) {
|
||||
if (storedDRCBuffer.buffer != nullptr) {
|
||||
GX2SetDRCBuffer(storedDRCBuffer.buffer, storedDRCBuffer.buffer_size, static_cast<GX2DrcRenderMode>(storedDRCBuffer.mode),
|
||||
storedDRCBuffer.surface_format, storedDRCBuffer.buffering_mode);
|
||||
}
|
||||
if (!skipScreen0Free && screenbuffer0) {
|
||||
MEMFreeToMappedMemory(screenbuffer0);
|
||||
screenbuffer0 = nullptr;
|
||||
}
|
||||
|
||||
if (!skipScreen1Free && screenbuffer1) {
|
||||
MEMFreeToMappedMemory(screenbuffer1);
|
||||
screenbuffer1 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <gx2/enum.h>
|
||||
|
||||
struct StoredBuffer {
|
||||
void* buffer;
|
||||
void *buffer;
|
||||
uint32_t buffer_size;
|
||||
uint32_t mode;
|
||||
GX2SurfaceFormat surface_format;
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
|
||||
union Color {
|
||||
explicit Color(uint32_t color) {
|
||||
this->color = color;
|
||||
this->color = color;
|
||||
}
|
||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
this->r = r; this->g = g; this->b = b; this->a = a;
|
||||
|
||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
this->r = r;
|
||||
this->g = g;
|
||||
this->b = b;
|
||||
this->a = a;
|
||||
}
|
||||
|
||||
uint32_t color{};
|
||||
@@ -25,33 +29,47 @@ union Color {
|
||||
|
||||
class DrawUtils {
|
||||
public:
|
||||
static void initBuffers(void* tvBuffer, uint32_t tvSize, void* drcBuffer, uint32_t drcSize);
|
||||
static void initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize);
|
||||
|
||||
static void beginDraw();
|
||||
|
||||
static void endDraw();
|
||||
|
||||
static void clear(Color col);
|
||||
|
||||
static void drawPixel(uint32_t x, uint32_t y, Color col) { drawPixel(x, y, col.r, col.g, col.b, col.a); }
|
||||
|
||||
static void drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
|
||||
static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col);
|
||||
|
||||
static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col);
|
||||
|
||||
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t* data);
|
||||
static void drawPNG(uint32_t x, uint32_t y, const uint8_t* data);
|
||||
static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data);
|
||||
|
||||
static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data);
|
||||
|
||||
static void initFont();
|
||||
|
||||
static void deinitFont();
|
||||
|
||||
static void setFontSize(uint32_t size);
|
||||
|
||||
static void setFontColor(Color col);
|
||||
static void print(uint32_t x, uint32_t y, const char* string, bool alignRight = false);
|
||||
static void print(uint32_t x, uint32_t y, const wchar_t* string, bool alignRight = false);
|
||||
static uint32_t getTextWidth(const char* string);
|
||||
static uint32_t getTextWidth(const wchar_t* string);
|
||||
|
||||
static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false);
|
||||
|
||||
static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false);
|
||||
|
||||
static uint32_t getTextWidth(const char *string);
|
||||
|
||||
static uint32_t getTextWidth(const wchar_t *string);
|
||||
|
||||
private:
|
||||
static bool isBackBuffer;
|
||||
|
||||
static uint8_t* tvBuffer;
|
||||
static uint8_t *tvBuffer;
|
||||
static uint32_t tvSize;
|
||||
static uint8_t* drcBuffer;
|
||||
static uint8_t *drcBuffer;
|
||||
static uint32_t drcSize;
|
||||
};
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include <coreinit/cache.h>
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include "elfio/elfio.hpp"
|
||||
#include "ElfUtils.h"
|
||||
|
||||
// See https://github.com/decaf-emu/decaf-emu/blob/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader/cafe_loader_reloc.cpp#L144
|
||||
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, RelocationType reloc_type, uint8_t trampolinId) {
|
||||
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||
RelocationType reloc_type, uint8_t trampolinId) {
|
||||
if (type == R_PPC_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,5 +46,6 @@ uint32_t load_loader_elf(unsigned char *baseAddress, char *elf_data, uint32_t fi
|
||||
class ElfUtils {
|
||||
|
||||
public:
|
||||
static bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, RelocationType reloc_type, uint8_t trampolinId);
|
||||
static bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||
RelocationType reloc_type, uint8_t trampolinId);
|
||||
};
|
||||
|
||||
@@ -6,23 +6,23 @@
|
||||
#include "fs/CFile.hpp"
|
||||
#include "fs/FSUtils.h"
|
||||
|
||||
static void processJson(wups_storage_item_t* items, nlohmann::json json) {
|
||||
static void processJson(wups_storage_item_t *items, nlohmann::json json) {
|
||||
if (items == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
items->data = (wups_storage_item_t*) malloc(json.size() * sizeof(wups_storage_item_t));
|
||||
items->data = (wups_storage_item_t *) malloc(json.size() * sizeof(wups_storage_item_t));
|
||||
items->data_size = json.size();
|
||||
|
||||
uint32_t index = 0;
|
||||
for (auto it = json.begin(); it != json.end(); ++it) {
|
||||
wups_storage_item_t* item = &((wups_storage_item_t*) items->data)[index];
|
||||
wups_storage_item_t *item = &((wups_storage_item_t *) items->data)[index];
|
||||
item->type = WUPS_STORAGE_TYPE_INVALID;
|
||||
item->pending_delete = false;
|
||||
item->data = nullptr;
|
||||
item->key = nullptr;
|
||||
|
||||
item->key = (char*) malloc(it.key().size() + 1);
|
||||
item->key = (char *) malloc(it.key().size() + 1);
|
||||
strcpy(item->key, it.key().c_str());
|
||||
|
||||
if (it.value().is_string()) {
|
||||
@@ -30,12 +30,12 @@ static void processJson(wups_storage_item_t* items, nlohmann::json json) {
|
||||
uint32_t size = it.value().get<std::string>().size() + 1;
|
||||
item->data = malloc(size);
|
||||
item->data_size = size;
|
||||
strcpy((char*) item->data, it.value().get<std::string>().c_str());
|
||||
strcpy((char *) item->data, it.value().get<std::string>().c_str());
|
||||
} else if (it.value().is_number_integer()) {
|
||||
item->type = WUPS_STORAGE_TYPE_INT;
|
||||
item->data = malloc(sizeof(int32_t));
|
||||
item->data_size = sizeof(int32_t);
|
||||
*(int32_t*) item->data = it.value().get<int32_t>();
|
||||
*(int32_t *) item->data = it.value().get<int32_t>();
|
||||
} else if (it.value().is_object()) {
|
||||
if (it.value().size() > 0) {
|
||||
item->type = WUPS_STORAGE_TYPE_ITEM;
|
||||
@@ -48,7 +48,7 @@ static void processJson(wups_storage_item_t* items, nlohmann::json json) {
|
||||
}
|
||||
}
|
||||
|
||||
int StorageUtils::OpenStorage(const char* plugin_id, wups_storage_item_t* items) {
|
||||
int StorageUtils::OpenStorage(const char *plugin_id, wups_storage_item_t *items) {
|
||||
if (!plugin_id || !items) {
|
||||
return WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ int StorageUtils::OpenStorage(const char* plugin_id, wups_storage_item_t* items)
|
||||
nlohmann::json j;
|
||||
CFile file(filePath, CFile::ReadOnly);
|
||||
if (file.isOpen() && file.size() > 0) {
|
||||
uint8_t* json_data = new uint8_t[file.size() + 1];
|
||||
uint8_t *json_data = new uint8_t[file.size() + 1];
|
||||
json_data[file.size()] = '\0';
|
||||
|
||||
file.read(json_data, file.size());
|
||||
@@ -80,7 +80,7 @@ int StorageUtils::OpenStorage(const char* plugin_id, wups_storage_item_t* items)
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static nlohmann::json processItems(wups_storage_item_t* items) {
|
||||
static nlohmann::json processItems(wups_storage_item_t *items) {
|
||||
nlohmann::json json;
|
||||
|
||||
if (!items) {
|
||||
@@ -88,16 +88,16 @@ static nlohmann::json processItems(wups_storage_item_t* items) {
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < items->data_size; i++) {
|
||||
wups_storage_item_t* item = &((wups_storage_item_t*) items->data)[i];
|
||||
wups_storage_item_t *item = &((wups_storage_item_t *) items->data)[i];
|
||||
|
||||
if (item->pending_delete || item->type == WUPS_STORAGE_TYPE_INVALID || !item->data || !item->key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item->type == WUPS_STORAGE_TYPE_STRING) {
|
||||
json[item->key] = (const char*) item->data;
|
||||
json[item->key] = (const char *) item->data;
|
||||
} else if (item->type == WUPS_STORAGE_TYPE_INT) {
|
||||
json[item->key] = *(int32_t*) item->data;
|
||||
json[item->key] = *(int32_t *) item->data;
|
||||
} else if (item->type == WUPS_STORAGE_TYPE_ITEM) {
|
||||
json[item->key] = processItems(item);
|
||||
} else {
|
||||
@@ -107,7 +107,7 @@ static nlohmann::json processItems(wups_storage_item_t* items) {
|
||||
return json;
|
||||
}
|
||||
|
||||
int StorageUtils::CloseStorage(const char* plugin_id, wups_storage_item_t* items) {
|
||||
int StorageUtils::CloseStorage(const char *plugin_id, wups_storage_item_t *items) {
|
||||
if (!plugin_id || !items) {
|
||||
return WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int StorageUtils::CloseStorage(const char* plugin_id, wups_storage_item_t* items
|
||||
j["storageitems"] = processItems(items);
|
||||
|
||||
std::string jsonString = j.dump(4);
|
||||
file.write((const uint8_t*) jsonString.c_str(), jsonString.size());
|
||||
file.write((const uint8_t *) jsonString.c_str(), jsonString.size());
|
||||
file.close();
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
class StorageUtils {
|
||||
public:
|
||||
static int OpenStorage(const char* plugin_id, wups_storage_item_t* items);
|
||||
static int CloseStorage(const char* plugin_id, wups_storage_item_t* items);
|
||||
static int OpenStorage(const char *plugin_id, wups_storage_item_t *items);
|
||||
|
||||
static int CloseStorage(const char *plugin_id, wups_storage_item_t *items);
|
||||
};
|
||||
|
||||
@@ -25,14 +25,11 @@
|
||||
***************************************************************************/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <cstdlib>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <strings.h>
|
||||
#include <wut_types.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <utils/StringTools.h>
|
||||
|
||||
|
||||
@@ -78,7 +75,7 @@ const char *StringTools::fmt(const char *format, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
@@ -107,7 +104,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
|
||||
@@ -165,11 +162,11 @@ int32_t StringTools::strtokcmp(const char *string, const char *compare, const ch
|
||||
|
||||
char *strTok = strtok(TokCopy, separator);
|
||||
|
||||
while (strTok != NULL) {
|
||||
while (strTok != nullptr) {
|
||||
if (strcasecmp(string, strTok) == 0) {
|
||||
return 0;
|
||||
}
|
||||
strTok = strtok(NULL, separator);
|
||||
strTok = strtok(nullptr, separator);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <wums.h>
|
||||
|
||||
void fillPluginInformation(plugin_information *out, PluginMetaInformation *metaInformation) {
|
||||
strncpy(out->author, metaInformation->getAuthor().c_str(), 255);
|
||||
strncpy(out->buildTimestamp, metaInformation->getBuildTimestamp().c_str(), 255);
|
||||
strncpy(out->description, metaInformation->getDescription().c_str(), 255);
|
||||
strncpy(out->name, metaInformation->getName().c_str(), 255);
|
||||
strncpy(out->license, metaInformation->getLicense().c_str(), 255);
|
||||
strncpy(out->version, metaInformation->getVersion().c_str(), 255);
|
||||
strncpy(out->id, metaInformation->getId().c_str(), 255);
|
||||
strncpy(out->author, metaInformation->getAuthor().c_str(), sizeof(out->author) - 1);
|
||||
strncpy(out->buildTimestamp, metaInformation->getBuildTimestamp().c_str(), sizeof(out->buildTimestamp) - 1);
|
||||
strncpy(out->description, metaInformation->getDescription().c_str(), sizeof(out->description) - 1);
|
||||
strncpy(out->name, metaInformation->getName().c_str(), sizeof(out->name) - 1);
|
||||
strncpy(out->license, metaInformation->getLicense().c_str(), sizeof(out->license) - 1);
|
||||
strncpy(out->version, metaInformation->getVersion().c_str(), sizeof(out->version) - 1);
|
||||
strncpy(out->id, metaInformation->getId().c_str(), sizeof(out->id) - 1);
|
||||
out->size = metaInformation->getSize();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ extern "C" PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const plugin_da
|
||||
for (uint32_t i = 0; i < plugin_data_handle_list_size; i++) {
|
||||
plugin_data_handle handle = plugin_data_handle_list[i];
|
||||
auto *pluginData = (PluginData *) handle;
|
||||
DEBUG_FUNCTION_LINE("Saving plugin data %08X", pluginData);
|
||||
PluginDataPersistence::save(&gLinkOnReload.plugin_data[gLinkOnReload.number_used_plugins], *pluginData);
|
||||
|
||||
gLinkOnReload.number_used_plugins++;
|
||||
@@ -36,6 +35,7 @@ extern "C" PluginBackendApiErrorType WUPSLoadAndLinkByDataHandle(const plugin_da
|
||||
}
|
||||
DCFlushRange(&gLinkOnReload, sizeof(gLinkOnReload));
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return PLUGIN_BACKEND_API_ERROR_NONE;
|
||||
@@ -46,7 +46,6 @@ extern "C" PluginBackendApiErrorType WUPSDeletePluginContainer(const plugin_cont
|
||||
for (uint32_t i = 0; i < handle_list_size; i++) {
|
||||
auto handle = handle_list[i];
|
||||
auto *pluginContainer = (PluginContainer *) handle;
|
||||
DEBUG_FUNCTION_LINE("Delete plugin container: %08X", pluginContainer);
|
||||
delete pluginContainer;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +57,6 @@ extern "C" PluginBackendApiErrorType WUPSDeletePluginData(const plugin_data_hand
|
||||
for (uint32_t i = 0; i < plugin_data_handle_list_size; i++) {
|
||||
auto handle = plugin_data_handle_list[i];
|
||||
auto *pluginData = (PluginData *) handle;
|
||||
DEBUG_FUNCTION_LINE("Delete plugin data: %08X", pluginData);
|
||||
delete pluginData;
|
||||
}
|
||||
}
|
||||
@@ -78,16 +76,15 @@ extern "C" PluginBackendApiErrorType WUPSLoadPluginAsData(GetPluginInformationIn
|
||||
}
|
||||
|
||||
if (!pluginData) {
|
||||
DEBUG_FUNCTION_LINE("Failed to alloc plugin data");
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC");
|
||||
return PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC;
|
||||
}
|
||||
|
||||
if (out == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("out was NULL");
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
} else {
|
||||
auto *pluginDataHandle = new PluginData(pluginData.value());
|
||||
DEBUG_FUNCTION_LINE("Saving plugin data handle: %08X", pluginDataHandle);
|
||||
*out = (uint32_t) pluginDataHandle;
|
||||
}
|
||||
|
||||
@@ -102,27 +99,25 @@ extern "C" PluginBackendApiErrorType WUPSLoadPluginAsDataByBuffer(plugin_data_ha
|
||||
return WUPSLoadPluginAsData(PLUGIN_INFORMATION_INPUT_TYPE_BUFFER, nullptr, buffer, size, output);
|
||||
}
|
||||
|
||||
extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, const char* path, char *buffer, size_t size, plugin_information *output) {
|
||||
extern "C" PluginBackendApiErrorType WUPSGetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output) {
|
||||
std::optional<PluginMetaInformation> pluginInfo;
|
||||
if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_PATH && path != nullptr) {
|
||||
std::string pathStr(path);
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_INFORMATION_INPUT_TYPE_PATH %s", path);
|
||||
pluginInfo = PluginMetaInformationFactory::loadPlugin(pathStr);
|
||||
} else if (inputType == PLUGIN_INFORMATION_INPUT_TYPE_BUFFER && buffer != nullptr && size > 0) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_INFORMATION_INPUT_TYPE_BUFFER %08X %d", buffer, size);
|
||||
pluginInfo = PluginMetaInformationFactory::loadPlugin(buffer, size);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!pluginInfo) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load plugin meta information");
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND");
|
||||
return PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Loaded plugin meta information");
|
||||
|
||||
if (output == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
return PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
} else {
|
||||
fillPluginInformation(output, &pluginInfo.value());
|
||||
@@ -145,10 +140,10 @@ extern "C" PluginBackendApiErrorType WUPSGetPluginDataForContainerHandles(const
|
||||
auto handle = plugin_container_handle_list[i];
|
||||
auto *container = (PluginContainer *) handle;
|
||||
auto *pluginData = new PluginData(container->getPluginData());
|
||||
DEBUG_FUNCTION_LINE("Created pluginData [%08X]", pluginData);
|
||||
plugin_data_list[i] = (uint32_t) pluginData;
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return res;
|
||||
@@ -171,6 +166,7 @@ extern "C" PluginBackendApiErrorType WUPSGetMetaInformation(const plugin_contain
|
||||
plugin_information_list[i].size = container->metaInformation.getSize();
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("PLUGIN_BACKEND_API_ERROR_INVALID_ARG");
|
||||
res = PLUGIN_BACKEND_API_ERROR_INVALID_ARG;
|
||||
}
|
||||
return res;
|
||||
@@ -182,7 +178,6 @@ extern "C" PluginBackendApiErrorType WUPSGetLoadedPlugins(plugin_container_handl
|
||||
for (auto &plugin: plugins) {
|
||||
if (counter < buffer_size) {
|
||||
auto *container = new PluginContainer(plugin);
|
||||
DEBUG_FUNCTION_LINE("Created container [%08X]", container);
|
||||
io_handles[counter] = (uint32_t) container;
|
||||
counter++;
|
||||
} else {
|
||||
|
||||
@@ -16,11 +16,11 @@ extern "C" {
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user