mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-11-22 10:39:16 +01:00
Add basic config menu to disable the wiiload server
This commit is contained in:
parent
a8a3287ebf
commit
937e259f4c
@ -1,3 +1,4 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false;
|
bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false;
|
||||||
|
bool gWiiloadServerEnabled __attribute__((section(".data"))) = true;
|
@ -1,3 +1,4 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern bool gLibRPXLoaderInitDone;
|
extern bool gLibRPXLoaderInitDone;
|
||||||
|
extern bool gWiiloadServerEnabled;
|
63
src/main.cpp
63
src/main.cpp
@ -4,6 +4,7 @@
|
|||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <rpxloader/rpxloader.h>
|
#include <rpxloader/rpxloader.h>
|
||||||
#include <wups.h>
|
#include <wups.h>
|
||||||
|
#include <wups/config/WUPSConfigItemBoolean.h>
|
||||||
|
|
||||||
WUPS_PLUGIN_NAME("Wiiload");
|
WUPS_PLUGIN_NAME("Wiiload");
|
||||||
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
||||||
@ -13,6 +14,9 @@ WUPS_PLUGIN_LICENSE("GPL");
|
|||||||
|
|
||||||
WUPS_USE_WUT_DEVOPTAB();
|
WUPS_USE_WUT_DEVOPTAB();
|
||||||
|
|
||||||
|
WUPS_USE_STORAGE("wiiload"); // Unqiue id for the storage api
|
||||||
|
#define WIILOAD_ENABLED_STRING "enabled"
|
||||||
|
|
||||||
TcpReceiver *thread = nullptr;
|
TcpReceiver *thread = nullptr;
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
INITIALIZE_PLUGIN() {
|
||||||
@ -25,13 +29,64 @@ INITIALIZE_PLUGIN() {
|
|||||||
thread = nullptr;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gServerEnabledChanged(ConfigItemBoolean *item, bool newValue) {
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("New value in gWiiloadServerEnabled: %d", newValue);
|
||||||
|
gWiiloadServerEnabled = newValue;
|
||||||
|
if (thread) {
|
||||||
|
delete thread;
|
||||||
|
thread = nullptr;
|
||||||
|
}
|
||||||
|
if (gWiiloadServerEnabled) {
|
||||||
|
DEBUG_FUNCTION_LINE("Starting server!");
|
||||||
|
thread = new (std::nothrow) TcpReceiver(4299);
|
||||||
|
if (thread == nullptr) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to create wiiload thread");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Wiiload server has been stopped!");
|
||||||
|
}
|
||||||
|
// If the value has changed, we store it in the storage.
|
||||||
|
auto res = WUPS_StoreInt(nullptr, item->configId, gWiiloadServerEnabled);
|
||||||
|
if (res != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to store gWiiloadServerEnabled: %s (%d)", WUPS_GetStorageStatusStr(res), res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WUPS_GET_CONFIG() {
|
||||||
|
// We open the storage, so we can persist the configuration the user did.
|
||||||
|
if (WUPS_OpenStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to open storage");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WUPSConfigHandle config;
|
||||||
|
WUPSConfig_CreateHandled(&config, "Wiiload");
|
||||||
|
|
||||||
|
WUPSConfigCategoryHandle setting;
|
||||||
|
WUPSConfig_AddCategoryByNameHandled(config, "Settings", &setting);
|
||||||
|
WUPSConfigItemBoolean_AddToCategoryHandled(config, setting, WIILOAD_ENABLED_STRING, "Enable Wiiload", gWiiloadServerEnabled, &gServerEnabledChanged);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
WUPS_CONFIG_CLOSED() {
|
||||||
|
// Save all changes
|
||||||
|
if (WUPS_CloseStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Entry point */
|
/* Entry point */
|
||||||
ON_APPLICATION_START() {
|
ON_APPLICATION_START() {
|
||||||
initLogging();
|
initLogging();
|
||||||
DEBUG_FUNCTION_LINE("Start wiiload thread");
|
if (gWiiloadServerEnabled) {
|
||||||
thread = new (std::nothrow) TcpReceiver(4299);
|
DEBUG_FUNCTION_LINE("Start wiiload thread");
|
||||||
if (thread == nullptr) {
|
thread = new (std::nothrow) TcpReceiver(4299);
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to create wiiload thread");
|
if (thread == nullptr) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to create wiiload thread");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Wiiload server is disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user