2018-06-30 13:42:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2017,2018 Maschell
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
2023-02-16 10:52:22 +01:00
|
|
|
#include "main.h"
|
|
|
|
#include "retain_vars.hpp"
|
|
|
|
#include "utils/WUPSConfigItemButtonCombo.h"
|
|
|
|
#include "utils/config.h"
|
|
|
|
#include "utils/logger.h"
|
|
|
|
#include <notifications/notifications.h>
|
|
|
|
#include <wups.h>
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
// Mandatory plugin information.
|
2018-06-30 13:42:02 +02:00
|
|
|
WUPS_PLUGIN_NAME("SwipSwapMe");
|
2023-02-16 10:52:22 +01:00
|
|
|
WUPS_PLUGIN_DESCRIPTION("Swaps the GamePad and TV screen when pressing a certain button combination");
|
|
|
|
WUPS_PLUGIN_VERSION(PLUGIN_VERSION_FULL);
|
2018-06-30 13:42:02 +02:00
|
|
|
WUPS_PLUGIN_AUTHOR("Maschell");
|
|
|
|
WUPS_PLUGIN_LICENSE("GPL");
|
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
// FS Access
|
|
|
|
WUPS_USE_WUT_DEVOPTAB();
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
WUPS_USE_STORAGE("SwipSwapMeAroma");
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
// Gets called once the loader exists.
|
2018-06-30 13:42:02 +02:00
|
|
|
INITIALIZE_PLUGIN() {
|
2023-02-16 10:52:22 +01:00
|
|
|
initLogging();
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
if (NotificationModule_InitLibrary() == NOTIFICATION_MODULE_RESULT_SUCCESS) {
|
|
|
|
gNotificationModuleInitDone = true;
|
|
|
|
} else {
|
|
|
|
gNotificationModuleInitDone = false;
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to init notification lib");
|
2018-06-30 13:42:02 +02:00
|
|
|
}
|
|
|
|
|
2023-12-28 13:45:31 +01:00
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(ENABLED_CONFIG_STRING, gEnabled, DEFAULT_ENABLED_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ENABLED_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(SWAP_SCREENS_CONFIG_STRING, gDoScreenSwap, DEFAULT_SWAP_SCREENS_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", SWAP_SCREENS_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(ENABLED_SWAP_SCREENS_COMBO_CONFIG_STRING, gSwapScreenButtonComboEnabled, DEFAULT_ENABLED_SWAP_SCREENS_COMBO_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ENABLED_SWAP_SCREENS_COMBO_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(ENABLED_CHANGE_AUDIO_COMBO_CONFIG_STRING, gChangeAudioModeButtonComboEnabled, DEFAULT_ENABLED_CHANGE_AUDIO_COMBO_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ENABLED_CHANGE_AUDIO_COMBO_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(ENABLE_NOTIFICATIONS_CONFIG_STRING, gShowNotifications, DEFAULT_ENABLE_NOTIFICATIONS_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ENABLE_NOTIFICATIONS_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(SWAP_SCREEN_BUTTON_COMBO_CONFIG_STRING, gSwapScreenButtonCombo, (uint32_t) DEFAULT_SWAP_SCREEN_BUTTON_COMBO_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", SWAP_SCREEN_BUTTON_COMBO_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(CHANGE_AUDIO_BUTTON_COMBO_CONFIG_STRING, gSwapAudioButtonCombo, (uint32_t) DEFAULT_CHANGE_AUDIO_BUTTON_COMBO_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", CHANGE_AUDIO_BUTTON_COMBO_CONFIG_STRING);
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::GetOrStoreDefault(AUDIO_MODE_CONFIG_STRING, gCurAudioMode, DEFAULT_AUDIO_MODE_CONFIG_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", AUDIO_MODE_CONFIG_STRING);
|
|
|
|
}
|
2023-02-16 10:52:22 +01:00
|
|
|
|
2023-12-28 13:45:31 +01:00
|
|
|
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage");
|
2018-06-30 13:42:02 +02:00
|
|
|
}
|
2023-12-28 13:45:31 +01:00
|
|
|
|
|
|
|
WUPSConfigAPIOptionsV1 configOptions = {.name = "Swip Swap Me"};
|
|
|
|
if (WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to init config api");
|
|
|
|
}
|
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
deinitLogging();
|
|
|
|
}
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 11:51:23 +01:00
|
|
|
DEINITIALIZE_PLUGIN() {
|
|
|
|
if (gNotificationModuleInitDone) {
|
|
|
|
NotificationModule_DeInitLibrary();
|
|
|
|
gNotificationModuleInitDone = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
// Called whenever an application was started.
|
|
|
|
ON_APPLICATION_START() {
|
|
|
|
initLogging();
|
|
|
|
}
|
2018-06-30 13:42:02 +02:00
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
ON_APPLICATION_REQUESTS_EXIT() {
|
2023-12-28 13:45:31 +01:00
|
|
|
if (WUPSStorageAPI::Store(AUDIO_MODE_CONFIG_STRING, gCurAudioMode) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to store screen mode to storage");
|
|
|
|
}
|
|
|
|
if (WUPSStorageAPI::Store(SWAP_SCREENS_CONFIG_STRING, gDoScreenSwap) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to store screen mode to storage");
|
2018-06-30 13:42:02 +02:00
|
|
|
}
|
2023-12-28 13:45:31 +01:00
|
|
|
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage");
|
|
|
|
}
|
|
|
|
|
2023-02-16 10:52:22 +01:00
|
|
|
deinitLogging();
|
|
|
|
}
|