mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2026-08-28 04:36:39 -05:00
- Plugins now will be provided in RPX format and have the extension ".wps"
- Remove the fs function wrapper
This commit is contained in:
34
include/wups.h
Normal file
34
include/wups.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* based on blsug.h
|
||||
* by Alex Chadwick
|
||||
*
|
||||
* Copyright (C) 2014, Alex Chadwick
|
||||
* Modified by Maschell, 2018
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_H_
|
||||
#define WUPS_H_
|
||||
|
||||
#include "wups/common.h"
|
||||
#include "wups/function_patching.h"
|
||||
#include "wups/hooks.h"
|
||||
#include "wups/utils.h"
|
||||
|
||||
#endif /* WUPS_WUPS_H_ */
|
||||
58
include/wups/common.h
Normal file
58
include/wups/common.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* based on blsug.h
|
||||
* by Alex Chadwick
|
||||
*
|
||||
* Copyright (C) 2014, Alex Chadwick
|
||||
* Modified by Maschell, 2018
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_COMMON_DEF_H_
|
||||
#define WUPS_COMMON_DEF_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_SECTION(x) __attribute__((__section__ (".wups." x)))
|
||||
|
||||
#define WUPS_META(id, value) \
|
||||
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
|
||||
const char wups_meta_ ## id [] = #id "=" value
|
||||
|
||||
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.2"); WUPS_META(buildtimestamp, __DATE__ " " __TIME__)
|
||||
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
|
||||
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
|
||||
#define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x)
|
||||
#define WUPS_PLUGIN_DESCRIPTION(x) WUPS_META(description, x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_COMMON_DEF_H_ */
|
||||
30
include/wups/config.h
Normal file
30
include/wups/config.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef WUPS_CONFIG_HOOKS_DEF_H_
|
||||
#define WUPS_CONFIG_HOOKS_DEF_H_
|
||||
|
||||
#include "hooks.h"
|
||||
#include "config/WUPSConfig.h"
|
||||
|
||||
#define WUPS_GET_CONFIG() \
|
||||
WUPSConfig* get_config();\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_GET_CONFIG,get_config); \
|
||||
WUPSConfig* get_config()
|
||||
|
||||
|
||||
#endif /* WUPS_CONFIG_HOOKS_DEF_H_ */
|
||||
87
include/wups/config/WUPSConfig.h
Normal file
87
include/wups/config/WUPSConfig.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _WUPS_CONFIG_H_
|
||||
#define _WUPS_CONFIG_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config/WUPSConfigCategory.h>
|
||||
|
||||
class WUPSConfig {
|
||||
public:
|
||||
WUPSConfig(std::string name) {
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
~WUPSConfig() {
|
||||
for (auto & element : categories) {
|
||||
delete element;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns the name of this WUPSConfig
|
||||
**/
|
||||
std::string getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Creates a new WUPSCategory add its to this WUPSConfig.
|
||||
The category will be added to the end of the list.
|
||||
This class holds responsibility for deleting the created instance.
|
||||
|
||||
\param categoryName: The name of the category that will be created.
|
||||
|
||||
\return On success, the created and inserted category will be returned.
|
||||
**/
|
||||
WUPSConfigCategory * addCategory(std::string categoryName){
|
||||
WUPSConfigCategory * curCat = new WUPSConfigCategory(categoryName);
|
||||
categories.push_back(curCat);
|
||||
return curCat;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Adds a given WUPSConfigCategory to this WUPSConfig.
|
||||
The category will be added to the end of the list.
|
||||
This class holds responsibility for deleting the created instance.
|
||||
|
||||
\param category: The category that will be added to this config.
|
||||
|
||||
\return On success, the inserted category will be returned.
|
||||
On error NULL will be returned. In this case the caller still has the responsibility
|
||||
for deleting the WUPSConfigCategory instance.
|
||||
**/
|
||||
WUPSConfigCategory * addCategory(WUPSConfigCategory * category){
|
||||
categories.push_back(category);
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns a vector with all categories.
|
||||
**/
|
||||
std::vector<WUPSConfigCategory *> getCategories(){
|
||||
return this->categories;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::vector<WUPSConfigCategory *> categories;
|
||||
};
|
||||
|
||||
#endif
|
||||
72
include/wups/config/WUPSConfigCategory.h
Normal file
72
include/wups/config/WUPSConfigCategory.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _WUPS_CONFIG_CATEGORY_H_
|
||||
#define _WUPS_CONFIG_CATEGORY_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config/WUPSConfigItem.h>
|
||||
|
||||
class WUPSConfigCategory {
|
||||
public:
|
||||
WUPSConfigCategory(std::string name) {
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
~WUPSConfigCategory() {
|
||||
for (auto & element : items) {
|
||||
delete element;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns the name of this WUPSConfigCategory
|
||||
**/
|
||||
std::string getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Adds a given WUPSConfigItem to this WUPSConfigCategory.
|
||||
The item will be added to the end of the list.
|
||||
This class holds responsibility for deleting the created instance.
|
||||
|
||||
\param item: The item that will be added to this config.
|
||||
|
||||
\return On success, the inserted item will be returned.
|
||||
On error NULL will be returned. In this case the caller still has the responsibility
|
||||
for deleting the WUPSConfigItem instance.
|
||||
**/
|
||||
WUPSConfigItem * addItem(WUPSConfigItem * item){
|
||||
items.push_back(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns a vector with all items.
|
||||
**/
|
||||
std::vector<WUPSConfigItem *> getItems(){
|
||||
return this->items;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::vector<WUPSConfigItem *> items;
|
||||
};
|
||||
|
||||
#endif
|
||||
165
include/wups/config/WUPSConfigItem.h
Normal file
165
include/wups/config/WUPSConfigItem.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _WUPS_CONFIG_ITEM_H_
|
||||
#define _WUPS_CONFIG_ITEM_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../utils.h"
|
||||
|
||||
#define WUPS_CONFIG_BUTTON_NONE 0
|
||||
#define WUPS_CONFIG_BUTTON_LEFT (1<<0)
|
||||
#define WUPS_CONFIG_BUTTON_RIGHT (1<<1)
|
||||
#define WUPS_CONFIG_BUTTON_UP (1<<2)
|
||||
#define WUPS_CONFIG_BUTTON_DOWN (1<<3)
|
||||
#define WUPS_CONFIG_BUTTON_A (1<<4)
|
||||
#define WUPS_CONFIG_BUTTON_B (1<<5)
|
||||
#define WUPS_CONFIG_BUTTON_ZL (1<<6)
|
||||
#define WUPS_CONFIG_BUTTON_ZR (1<<7)
|
||||
#define WUPS_CONFIG_BUTTON_L (1<<8)
|
||||
#define WUPS_CONFIG_BUTTON_R (1<<9)
|
||||
typedef int32_t WUPSConfigButtons;
|
||||
|
||||
class WUPSConfigItem {
|
||||
public:
|
||||
/**
|
||||
Sets the display name of this WUPSConfigItem
|
||||
This is the value which will be shown in the configuration menu.
|
||||
**/
|
||||
virtual void setDisplayName(std::string displayName) {
|
||||
this->displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns the display name of this WUPSConfigItem
|
||||
**/
|
||||
virtual std::string getDisplayName() {
|
||||
return this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the config ID name of this WUPSConfigItem.
|
||||
This config ID is used to persist the configuration values and needs
|
||||
to be unique in the context of this WUPSConfig.
|
||||
Items in different categories are NOT allowed to have the config ID.
|
||||
**/
|
||||
virtual void setConfigID(std::string configID) {
|
||||
this->configID = configID;
|
||||
}
|
||||
|
||||
/**
|
||||
\return Returns the configID of this WUPSConfigItem.
|
||||
**/
|
||||
virtual std::string getConfigID() {
|
||||
return this->configID;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a string that displays the current value.
|
||||
This string is shown next to the display name when the cursor is NOT on this item
|
||||
**/
|
||||
virtual std::string getCurrentValueDisplay() = 0;
|
||||
|
||||
/**
|
||||
Returns a string that displays the current value when selected.
|
||||
This string is shown next to the display name when the cursor IS on this item
|
||||
**/
|
||||
virtual std::string getCurrentValueSelectedDisplay() = 0;
|
||||
|
||||
/**
|
||||
Is called when the cursor enters or leaves the item.
|
||||
When the cursor enters the item, "isSelected" will be true.
|
||||
When the cursor leaves the item, "isSelected" will be false.
|
||||
**/
|
||||
virtual void onSelected(bool isSelected) = 0;
|
||||
|
||||
/**
|
||||
Is called when a button is pressed while the cursor on this item.
|
||||
See the WUPSConfigButtons enum for possible values.
|
||||
**/
|
||||
virtual void onButtonPressed(WUPSConfigButtons buttons) = 0;
|
||||
|
||||
/**
|
||||
When the cursor is on this item, the configuration menu asks this item
|
||||
if it's allowed to leave it.
|
||||
If it returns true, the item can be leaved.
|
||||
It it returns false, leaves is not allowed.
|
||||
**/
|
||||
virtual bool isMovementAllowed() = 0;
|
||||
|
||||
/**
|
||||
Returns a string that represents the value of this item.
|
||||
**/
|
||||
virtual std::string persistValue() = 0;
|
||||
|
||||
/**
|
||||
Loads a value for a given string that contains the persisted value.
|
||||
\param persistedValue A valued that the result of the persistValue function
|
||||
**/
|
||||
virtual void loadValue(std::string persistedValue) = 0;
|
||||
|
||||
/**
|
||||
Restores the default value
|
||||
**/
|
||||
virtual void restoreDefault() = 0;
|
||||
|
||||
/**
|
||||
Call callback with with current value.
|
||||
This function will be called whenever this item should call it's (optional) given
|
||||
callback with the current value.
|
||||
Returns true if a valid callback could be called
|
||||
Returns false if no callback was called (e.g. callback was NULL)
|
||||
**/
|
||||
virtual bool callCallback() = 0;
|
||||
|
||||
/**
|
||||
Will be called by the "config menu manager" if this configitem is currently displayed on the screen.
|
||||
If this config item decides to draw onto the screen, it can use "lastVisibleOnScreen()" function to
|
||||
get information about which screen(s) are available.
|
||||
Check the Overlay API for more information on drawing on the screen.
|
||||
**/
|
||||
virtual void visibleOnScreen(wups_overlay_options_type_t screen){
|
||||
this->displayScreen = screen;
|
||||
}
|
||||
|
||||
WUPSConfigItem(std::string configID, std::string displayName){
|
||||
this->configID = configID;
|
||||
this->displayName = displayName;
|
||||
}
|
||||
|
||||
virtual ~WUPSConfigItem(){
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
If this config item decides to draw onto the screen, this function can be used
|
||||
get information about which screen(s) are available for OS drawing.
|
||||
Check the Overlay API for more information on drawing on the screen.
|
||||
**/
|
||||
wups_overlay_options_type_t lastVisibleOnScreen(){
|
||||
return displayScreen;
|
||||
}
|
||||
private:
|
||||
std::string displayName;
|
||||
|
||||
std::string configID;
|
||||
|
||||
wups_overlay_options_type_t displayScreen = WUPS_OVERLAY_NONE;
|
||||
};
|
||||
|
||||
#endif
|
||||
79
include/wups/config/WUPSConfigItemBoolean.h
Normal file
79
include/wups/config/WUPSConfigItemBoolean.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _WUPS_CONFIG_ITEM_BOOLEAN_H_
|
||||
#define _WUPS_CONFIG_ITEM_BOOLEAN_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config/WUPSConfigItem.h>
|
||||
|
||||
class WUPSConfigItemBoolean;
|
||||
|
||||
typedef void (*BooleanValueChangedCallback)(WUPSConfigItemBoolean *, bool);
|
||||
|
||||
class WUPSConfigItemBoolean : public WUPSConfigItem {
|
||||
public:
|
||||
WUPSConfigItemBoolean(std::string configID, std::string displayName, bool defaultValue, BooleanValueChangedCallback callback);
|
||||
|
||||
virtual ~WUPSConfigItemBoolean();
|
||||
|
||||
/**
|
||||
Sets the name with will be displayed as "true" value
|
||||
\param name of the "true" value
|
||||
**/
|
||||
void setTrueValueName(std::string trueValName);
|
||||
|
||||
/**
|
||||
Sets the name with will be displayed as "false" value
|
||||
\param name of the "false" value
|
||||
**/
|
||||
void setFalseValueName(std::string falseValName);
|
||||
|
||||
/**
|
||||
Toggles the value. When it was true, it now false, when it was false, it's now true.
|
||||
Call the callback with the new value.
|
||||
**/
|
||||
virtual void toggleValue();
|
||||
|
||||
virtual std::string getCurrentValueDisplay();
|
||||
|
||||
virtual std::string getCurrentValueSelectedDisplay();
|
||||
|
||||
virtual void onSelected(bool isSelected);
|
||||
|
||||
virtual void onButtonPressed(WUPSConfigButtons buttons);
|
||||
|
||||
virtual bool isMovementAllowed();
|
||||
|
||||
virtual std::string persistValue();
|
||||
|
||||
virtual void loadValue(std::string persistedValue);
|
||||
|
||||
virtual void restoreDefault();
|
||||
|
||||
virtual bool callCallback();
|
||||
|
||||
private:
|
||||
BooleanValueChangedCallback callback = NULL;
|
||||
bool value;
|
||||
bool defaultValue;
|
||||
std::string trueValName = "on";
|
||||
std::string falseValName = "off";
|
||||
};
|
||||
|
||||
#endif
|
||||
61
include/wups/config/WUPSConfigItemIntegerRange.h
Normal file
61
include/wups/config/WUPSConfigItemIntegerRange.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018-2019 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _WUPS_CONFIG_ITEM_INTEGER_RANGE_H_
|
||||
#define _WUPS_CONFIG_ITEM_INTEGER_RANGE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wups/config/WUPSConfigItem.h>
|
||||
|
||||
class WUPSConfigItemIntegerRange;
|
||||
|
||||
typedef void (*IntegerRangeValueChangedCallback)(WUPSConfigItemIntegerRange *, int32_t);
|
||||
|
||||
class WUPSConfigItemIntegerRange : public WUPSConfigItem {
|
||||
public:
|
||||
WUPSConfigItemIntegerRange(std::string configID, std::string displayName, int32_t defaultValue, int32_t minValue, int32_t maxValue, IntegerRangeValueChangedCallback callback);
|
||||
|
||||
virtual ~WUPSConfigItemIntegerRange();
|
||||
|
||||
virtual std::string getCurrentValueDisplay();
|
||||
|
||||
virtual std::string getCurrentValueSelectedDisplay();
|
||||
|
||||
virtual void onSelected(bool isSelected);
|
||||
|
||||
virtual void onButtonPressed(WUPSConfigButtons buttons);
|
||||
|
||||
virtual bool isMovementAllowed();
|
||||
|
||||
virtual std::string persistValue();
|
||||
|
||||
virtual void loadValue(std::string persistedValue);
|
||||
|
||||
virtual void restoreDefault();
|
||||
|
||||
virtual bool callCallback();
|
||||
|
||||
private:
|
||||
IntegerRangeValueChangedCallback callback = NULL;
|
||||
int32_t value;
|
||||
int32_t defaultValue;
|
||||
int32_t minValue;
|
||||
int32_t maxValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
60
include/wups/config/WUPSConfigItemMultipleValues.h
Normal file
60
include/wups/config/WUPSConfigItemMultipleValues.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _WUPS_CONFIG_ITEM_MULTIPLE_VALUES_H_
|
||||
#define _WUPS_CONFIG_ITEM_MULTIPLE_VALUES_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <wups/config/WUPSConfigItem.h>
|
||||
|
||||
class WUPSConfigItemMultipleValues;
|
||||
|
||||
typedef void (*MultipleValuesChangedCallback)(WUPSConfigItemMultipleValues *, int32_t);
|
||||
|
||||
class WUPSConfigItemMultipleValues : public WUPSConfigItem {
|
||||
public:
|
||||
WUPSConfigItemMultipleValues(std::string configID, std::string displayName, int32_t defaultValue, std::map<int32_t,std::string> values_, MultipleValuesChangedCallback callback);
|
||||
|
||||
virtual ~WUPSConfigItemMultipleValues();
|
||||
|
||||
virtual std::string getCurrentValueDisplay();
|
||||
|
||||
virtual std::string getCurrentValueSelectedDisplay();
|
||||
|
||||
virtual void onSelected(bool isSelected);
|
||||
|
||||
virtual void onButtonPressed(WUPSConfigButtons buttons) ;
|
||||
|
||||
virtual bool isMovementAllowed();
|
||||
|
||||
virtual std::string persistValue();
|
||||
|
||||
virtual void loadValue(std::string persistedValue);
|
||||
|
||||
virtual void restoreDefault();
|
||||
|
||||
virtual bool callCallback();
|
||||
|
||||
private:
|
||||
MultipleValuesChangedCallback callback = NULL;
|
||||
int32_t defaultValue;
|
||||
uint32_t valueIndex = 0;
|
||||
std::map<int32_t,std::string> values;
|
||||
};
|
||||
|
||||
#endif
|
||||
154
include/wups/function_patching.h
Normal file
154
include/wups/function_patching.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/* based on blsug.h
|
||||
* by Alex Chadwick
|
||||
*
|
||||
* Copyright (C) 2014, Alex Chadwick
|
||||
* Modified by Maschell, 2018
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_FUNCTION_PATCHING_DEF_H_
|
||||
#define WUPS_FUNCTION_PATCHING_DEF_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum wups_loader_library_type_t {
|
||||
WUPS_LOADER_LIBRARY_AVM,
|
||||
WUPS_LOADER_LIBRARY_CAMERA,
|
||||
WUPS_LOADER_LIBRARY_COREINIT,
|
||||
WUPS_LOADER_LIBRARY_DC,
|
||||
WUPS_LOADER_LIBRARY_DMAE,
|
||||
WUPS_LOADER_LIBRARY_DRMAPP,
|
||||
WUPS_LOADER_LIBRARY_ERREULA,
|
||||
WUPS_LOADER_LIBRARY_GX2,
|
||||
WUPS_LOADER_LIBRARY_H264,
|
||||
WUPS_LOADER_LIBRARY_LZMA920,
|
||||
WUPS_LOADER_LIBRARY_MIC,
|
||||
WUPS_LOADER_LIBRARY_NFC,
|
||||
WUPS_LOADER_LIBRARY_NIO_PROF,
|
||||
WUPS_LOADER_LIBRARY_NLIBCURL,
|
||||
WUPS_LOADER_LIBRARY_NLIBNSS,
|
||||
WUPS_LOADER_LIBRARY_NLIBNSS2,
|
||||
WUPS_LOADER_LIBRARY_NN_AC,
|
||||
WUPS_LOADER_LIBRARY_NN_ACP,
|
||||
WUPS_LOADER_LIBRARY_NN_ACT,
|
||||
WUPS_LOADER_LIBRARY_NN_AOC,
|
||||
WUPS_LOADER_LIBRARY_NN_BOSS,
|
||||
WUPS_LOADER_LIBRARY_NN_CCR,
|
||||
WUPS_LOADER_LIBRARY_NN_CMPT,
|
||||
WUPS_LOADER_LIBRARY_NN_DLP,
|
||||
WUPS_LOADER_LIBRARY_NN_EC,
|
||||
WUPS_LOADER_LIBRARY_NN_FP,
|
||||
WUPS_LOADER_LIBRARY_NN_HAI,
|
||||
WUPS_LOADER_LIBRARY_NN_HPAD,
|
||||
WUPS_LOADER_LIBRARY_NN_IDBE,
|
||||
WUPS_LOADER_LIBRARY_NN_NDM,
|
||||
WUPS_LOADER_LIBRARY_NN_NETS2,
|
||||
WUPS_LOADER_LIBRARY_NN_NFP,
|
||||
WUPS_LOADER_LIBRARY_NN_NIM,
|
||||
WUPS_LOADER_LIBRARY_NN_OLV,
|
||||
WUPS_LOADER_LIBRARY_NN_PDM,
|
||||
WUPS_LOADER_LIBRARY_NN_SAVE,
|
||||
WUPS_LOADER_LIBRARY_NN_SL,
|
||||
WUPS_LOADER_LIBRARY_NN_SPM,
|
||||
WUPS_LOADER_LIBRARY_NN_TEMP,
|
||||
WUPS_LOADER_LIBRARY_NN_UDS,
|
||||
WUPS_LOADER_LIBRARY_NN_VCTL,
|
||||
WUPS_LOADER_LIBRARY_NSYSCCR,
|
||||
WUPS_LOADER_LIBRARY_NSYSHID,
|
||||
WUPS_LOADER_LIBRARY_NSYSKBD,
|
||||
WUPS_LOADER_LIBRARY_NSYSNET,
|
||||
WUPS_LOADER_LIBRARY_NSYSUHS,
|
||||
WUPS_LOADER_LIBRARY_NSYSUVD,
|
||||
WUPS_LOADER_LIBRARY_NTAG,
|
||||
WUPS_LOADER_LIBRARY_PADSCORE,
|
||||
WUPS_LOADER_LIBRARY_PROC_UI,
|
||||
WUPS_LOADER_LIBRARY_SND_CORE,
|
||||
WUPS_LOADER_LIBRARY_SND_USER,
|
||||
WUPS_LOADER_LIBRARY_SNDCORE2,
|
||||
WUPS_LOADER_LIBRARY_SNDUSER2,
|
||||
WUPS_LOADER_LIBRARY_SWKBD,
|
||||
WUPS_LOADER_LIBRARY_SYSAPP,
|
||||
WUPS_LOADER_LIBRARY_TCL,
|
||||
WUPS_LOADER_LIBRARY_TVE,
|
||||
WUPS_LOADER_LIBRARY_UAC,
|
||||
WUPS_LOADER_LIBRARY_UAC_RPL,
|
||||
WUPS_LOADER_LIBRARY_USB_MIC,
|
||||
WUPS_LOADER_LIBRARY_UVC,
|
||||
WUPS_LOADER_LIBRARY_UVD,
|
||||
WUPS_LOADER_LIBRARY_VPAD,
|
||||
WUPS_LOADER_LIBRARY_VPADBASE,
|
||||
WUPS_LOADER_LIBRARY_ZLIB125,
|
||||
WUPS_LOADER_LIBRARY_OTHER,
|
||||
}
|
||||
wups_loader_library_type_t;
|
||||
|
||||
typedef enum wups_loader_entry_type_t {
|
||||
WUPS_LOADER_ENTRY_FUNCTION,
|
||||
WUPS_LOADER_ENTRY_FUNCTION_MANDATORY,
|
||||
WUPS_LOADER_ENTRY_EXPORT
|
||||
} wups_loader_entry_type_t;
|
||||
|
||||
typedef struct wups_loader_entry_t {
|
||||
wups_loader_entry_type_t type;
|
||||
struct {
|
||||
const void *physical_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
|
||||
const void *virtual_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
|
||||
const char *name; /* Name of the function that will be replaced */
|
||||
const wups_loader_library_type_t library; /**/
|
||||
const char *my_function_name; /* Function name of your own, new function (my_XXX) */
|
||||
const void *target; /* Address of our own, new function (my_XXX)*/
|
||||
const void *call_addr; /* Address for calling the real function.(real_XXX) */
|
||||
} _function;
|
||||
} wups_loader_entry_t;
|
||||
|
||||
#define WUPS_MUST_REPLACE_PHYSICAL(x, physical_address, virtual_address) WUPS_MUST_REPLACE_EX(physical_address, virtual_address, real_ ## x, WUPS_LOADER_LIBRARY_OTHER, my_ ## x, x);
|
||||
|
||||
|
||||
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_EX(NULL, NULL, real_ ## x, lib, my_ ## x, function_name);
|
||||
|
||||
#define WUPS_MUST_REPLACE_EX(pAddress, vAddress, original_func, rpl_type, replace_func, replace_function_name) \
|
||||
extern const wups_loader_entry_t wups_load_ ## replace_func \
|
||||
WUPS_SECTION("load"); \
|
||||
const wups_loader_entry_t wups_load_ ## replace_func = { \
|
||||
.type = WUPS_LOADER_ENTRY_FUNCTION_MANDATORY, \
|
||||
._function = { \
|
||||
.physical_address = (const void*) pAddress, \
|
||||
.virtual_address = (const void*) vAddress, \
|
||||
.name = #replace_function_name, \
|
||||
.library = rpl_type, \
|
||||
.my_function_name = #replace_func, \
|
||||
.target = (const void*)&(replace_func), \
|
||||
.call_addr = (const void*)&(original_func) \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DECL_FUNCTION(res, name, ...) \
|
||||
res (* real_ ## name)(__VA_ARGS__) __attribute__((section(".data"))); \
|
||||
res my_ ## name(__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_FUNCTION_PATCHING_DEF_H_ */
|
||||
225
include/wups/hooks.h
Normal file
225
include/wups/hooks.h
Normal file
@@ -0,0 +1,225 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef WUPS_HOOKS_DEF_H_
|
||||
#define WUPS_HOOKS_DEF_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_HOOK_EX(type_def,original_func) \
|
||||
extern const wups_loader_hook_t wups_hooks_ ## original_func WUPS_SECTION("hooks"); \
|
||||
const wups_loader_hook_t wups_hooks_ ## original_func = { \
|
||||
.type = type_def, \
|
||||
.target = (const void*)&(original_func) \
|
||||
}
|
||||
|
||||
typedef enum wups_loader_hook_type_t {
|
||||
WUPS_LOADER_HOOK_INIT_OVERLAY, /* Only for internal usage */
|
||||
WUPS_LOADER_HOOK_INIT_KERNEL, /* Only for internal usage */
|
||||
WUPS_LOADER_HOOK_INIT_VID_MEM, /* Only for internal usage */
|
||||
WUPS_LOADER_HOOK_INIT_WUT_MALLOC,
|
||||
WUPS_LOADER_HOOK_FINI_WUT_MALLOC,
|
||||
WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB,
|
||||
WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB,
|
||||
WUPS_LOADER_HOOK_INIT_WUT_NEWLIB,
|
||||
WUPS_LOADER_HOOK_FINI_WUT_NEWLIB,
|
||||
WUPS_LOADER_HOOK_INIT_WUT_STDCPP,
|
||||
WUPS_LOADER_HOOK_FINI_WUT_STDCPP,
|
||||
|
||||
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
|
||||
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
|
||||
WUPS_LOADER_HOOK_APPLICATION_START, /* Called when an application gets started */
|
||||
WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, /* Called when the functions where patched */
|
||||
WUPS_LOADER_HOOK_RELEASE_FOREGROUND, /* Called when an foreground is going to be released */
|
||||
WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND, /* Called when an foreground is acquired */
|
||||
WUPS_LOADER_HOOK_APPLICATION_END, /* Called when an application ends */
|
||||
WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND, /* */
|
||||
WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE, /* */
|
||||
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
|
||||
WUPS_LOADER_HOOK_GET_CONFIG, /* Called when the config-menu will be loaded */
|
||||
WUPS_LOADER_HOOK_VID_DRC_DRAW, /* Called when the DRC was rendered */
|
||||
WUPS_LOADER_HOOK_VID_TV_DRAW, /* Called when the TV was rendered */
|
||||
WUPS_LOADER_HOOK_APPLET_START, /* Called when the an applet was started */
|
||||
} wups_loader_hook_type_t;
|
||||
|
||||
typedef struct wups_loader_hook_t {
|
||||
wups_loader_hook_type_t type; /* Defines the type of the hook */
|
||||
const void *target; /* Address of our own, new function */
|
||||
} wups_loader_hook_t;
|
||||
|
||||
typedef struct wups_loader_vid_buffer_t {
|
||||
const void * color_buffer_ptr;
|
||||
const void * tv_texture_ptr;
|
||||
const void * drc_texture_ptr;
|
||||
const void * sampler_ptr;
|
||||
} wups_loader_vid_buffer_t;
|
||||
|
||||
typedef struct wups_loader_app_started_args_t {
|
||||
bool kernel_access;
|
||||
} wups_loader_app_started_args_t;
|
||||
|
||||
#define WUPS_ALLOW_OVERLAY() \
|
||||
void init_overlay(wups_loader_init_overlay_args_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_OVERLAY,init_overlay); \
|
||||
void init_overlay(wups_loader_init_overlay_args_t args){ \
|
||||
WUPS_InitOverlay(args);\
|
||||
}
|
||||
|
||||
#define WUPS_USE_VIDEO_MEMORY() \
|
||||
void init_vid_mem(wups_loader_init_vid_mem_args_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_VID_MEM,init_vid_mem); \
|
||||
void init_vid_mem(wups_loader_init_vid_mem_args_t args){ \
|
||||
WUPS_InitVidMem(args);\
|
||||
}
|
||||
|
||||
#define WUPS_ALLOW_KERNEL() \
|
||||
void init_kernel(wups_loader_init_kernel_args_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_KERNEL,init_kernel); \
|
||||
void init_kernel(wups_loader_init_kernel_args_t args){ \
|
||||
WUPS_InitKernel(args);\
|
||||
}
|
||||
|
||||
#define INITIALIZE_PLUGIN() \
|
||||
void init_plugin(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_PLUGIN,init_plugin); \
|
||||
void init_plugin()
|
||||
|
||||
#define DEINITIALIZE_PLUGIN() \
|
||||
void deinit_plugin(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_DEINIT_PLUGIN,deinit_plugin); \
|
||||
void deinit_plugin()
|
||||
|
||||
#define ON_APPLICATION_START(myargs) \
|
||||
void on_app_starting(wups_loader_app_started_args_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_START,on_app_starting); \
|
||||
void on_app_starting(wups_loader_app_started_args_t myargs)
|
||||
|
||||
#define ON_FUNCTIONS_PATCHED() \
|
||||
void on_functions_patched();\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,on_functions_patched); \
|
||||
void on_functions_patched()
|
||||
|
||||
#define ON_RELEASE_FOREGROUND() \
|
||||
void on_release_foreground(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_RELEASE_FOREGROUND,on_release_foreground); \
|
||||
void on_release_foreground(void)
|
||||
|
||||
#define ON_ACQUIRED_FOREGROUND() \
|
||||
void on_acquired_foreground(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND,on_acquired_foreground); \
|
||||
void on_acquired_foreground(void)
|
||||
|
||||
#define ON_APPLICATION_END() \
|
||||
void on_app_ending(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_END,on_app_ending); \
|
||||
void on_app_ending(void)
|
||||
|
||||
#define ON_CONFIRM_RELEASE_FOREGROUND() \
|
||||
void on_confirm_release_foreground(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND,on_confirm_release_foreground); \
|
||||
void on_confirm_release_foreground(void)
|
||||
|
||||
#define ON_SAVES_DONE_READY_TO_RELEASE() \
|
||||
void on_saves_done_ready_to_release(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE,on_saves_done_ready_to_release); \
|
||||
void on_saves_done_ready_to_release(void)
|
||||
|
||||
#define ON_APPLET_START() \
|
||||
void on_applet_start(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLET_START,on_applet_start); \
|
||||
void on_applet_start(void)
|
||||
|
||||
#define ON_VYSNC() \
|
||||
void on_vsync(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VSYNC,on_vsync); \
|
||||
void on_vsync(void)
|
||||
|
||||
#define ON_DRC_TO_SCAN_BUFFER(myargs) \
|
||||
void on_drc_to_scan_buf(wups_loader_vid_buffer_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VID_DRC_DRAW,on_drc_to_scan_buf); \
|
||||
void on_drc_to_scan_buf(wups_loader_vid_buffer_t myargs)
|
||||
|
||||
#define ON_TV_TO_SCAN_BUFFER(myargs) \
|
||||
void on_tv_to_scan_buf(wups_loader_vid_buffer_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VID_TV_DRAW,on_tv_to_scan_buf); \
|
||||
void on_tv_to_scan_buf(wups_loader_vid_buffer_t myargs)
|
||||
|
||||
#define WUPS_USE_WUT_MALLOC() \
|
||||
extern "C" void __init_wut_malloc(); \
|
||||
void on_init_wut_malloc(){ \
|
||||
__init_wut_malloc(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_MALLOC,on_init_wut_malloc); \
|
||||
extern "C" void __fini_wut_malloc(); \
|
||||
void on_fini_wut_malloc(){ \
|
||||
__fini_wut_malloc(); \
|
||||
} \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_MALLOC,on_fini_wut_malloc); \
|
||||
|
||||
#define WUPS_USE_WUT_DEVOPTAB() \
|
||||
extern "C" void __init_wut_devoptab(); \
|
||||
void on_init_wut_devoptab(){ \
|
||||
__init_wut_devoptab(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB,on_init_wut_devoptab); \
|
||||
extern "C" void __fini_wut_devoptab(); \
|
||||
void on_fini_wut_devoptab(){ \
|
||||
__fini_wut_devoptab(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB,on_fini_wut_devoptab);
|
||||
|
||||
#define WUPS_USE_WUT_NEWLIB() \
|
||||
extern "C" void __init_wut_newlib(); \
|
||||
void on_init_wut_newlib(){ \
|
||||
__init_wut_newlib(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_NEWLIB,on_init_wut_newlib); \
|
||||
extern "C" void __fini_wut_newlib(); \
|
||||
void on_fini_wut_newlib(){ \
|
||||
__fini_wut_newlib(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_NEWLIB,on_fini_wut_newlib);
|
||||
|
||||
#define WUPS_USE_WUT_STDCPP() \
|
||||
extern "C" void __init_wut_stdcpp() __attribute__((weak)); \
|
||||
void on_init_wut_stdcpp(){ \
|
||||
__init_wut_stdcpp(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_STDCPP,on_init_wut_stdcpp); \
|
||||
extern "C" void __fini_wut_stdcpp() __attribute__((weak)); \
|
||||
void on_fini_wut_stdcpp(){ \
|
||||
__fini_wut_stdcpp(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_STDCPP,on_fini_wut_stdcpp);
|
||||
|
||||
#define WUPS_USE_WUT_CRT() \
|
||||
WUPS_USE_WUT_MALLOC() \
|
||||
WUPS_USE_WUT_DEVOPTAB() \
|
||||
WUPS_USE_WUT_NEWLIB() \
|
||||
WUPS_USE_WUT_STDCPP()
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_WUPS_H_ */
|
||||
143
include/wups/utils.h
Normal file
143
include/wups/utils.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef WUPS_UTILS_DEF_H_
|
||||
#define WUPS_UTILS_DEF_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum wups_overlay_options_type_t {
|
||||
WUPS_OVERLAY_NONE,
|
||||
WUPS_OVERLAY_DRC_ONLY, /* Tries to display only on gamepad screen */
|
||||
WUPS_OVERLAY_TV_ONLY, /* Tries to display only on tv screen */
|
||||
WUPS_OVERLAY_DRC_AND_TV, /* Tries to display on both screens. Prioritizes the TV screen if memory is low. */
|
||||
WUPS_OVERLAY_DRC_AND_TV_WITH_DRC_PRIO /* Tries to display on both screens. But if memory is low, prioritize the DRC screen.*/
|
||||
}
|
||||
wups_overlay_options_type_t;
|
||||
|
||||
typedef void (*overlay_callback)(wups_overlay_options_type_t, void*);
|
||||
|
||||
typedef void (*OverlayOpenFunction)(wups_overlay_options_type_t screen, overlay_callback callback, void*);
|
||||
typedef bool (*ConvertTextureFunction)(const uint8_t *img, int32_t imgSize, void * texture);
|
||||
typedef void (*DrawTextureFunction)(void * texture, void* sampler, float x, float y, int32_t width, int32_t height, float alpha);
|
||||
|
||||
typedef struct wups_loader_init_overlay_args_t {
|
||||
OverlayOpenFunction overlayfunction_ptr;
|
||||
ConvertTextureFunction textureconvertfunction_ptr;
|
||||
DrawTextureFunction drawtexturefunction_ptr;
|
||||
} wups_loader_init_overlay_args_t;
|
||||
|
||||
|
||||
typedef uint32_t (*KernelReadFunction)(const void *addr);
|
||||
typedef void (*KernelWriteFunction)(void *addr, uint32_t value);
|
||||
typedef void (*KernelCopyDataFunction)(uint32_t addr, uint32_t src, uint32_t len);
|
||||
|
||||
typedef struct wups_loader_init_kernel_args_t_ {
|
||||
KernelReadFunction kern_read_ptr;
|
||||
KernelWriteFunction kern_write_ptr;
|
||||
KernelCopyDataFunction kern_copy_data_ptr;
|
||||
} wups_loader_init_kernel_args_t;
|
||||
|
||||
typedef void* (*VideoMemoryAllocFunction)(uint32_t size, int32_t align);
|
||||
typedef void (*VideoMemoryFreeFunction)(void *addr);
|
||||
|
||||
typedef struct wups_loader_init_vid_mem_args_t_ {
|
||||
VideoMemoryAllocFunction vid_mem_alloc_ptr;
|
||||
VideoMemoryFreeFunction vid_mem_free_ptr;
|
||||
} wups_loader_init_vid_mem_args_t;
|
||||
|
||||
/*
|
||||
Gets called by the framework
|
||||
*/
|
||||
/**
|
||||
Sets the pointer for wrapping the fs functions.
|
||||
If NULL pointers are provided, the original function will be called.
|
||||
The whole point of replacing the fs functions is to inherit SD/USB access.
|
||||
The argument of the ON_APPLICATION_START hook provides information on the state of SD or USB access.
|
||||
**/
|
||||
//void WUPS_InitFS(wups_loader_init_fs_args_t args);
|
||||
|
||||
/**
|
||||
Sets the function pointer for opening the overlay.
|
||||
If none or a NULL pointer is provided, calling "WUPS_OpenOverlay" has no effect.
|
||||
**/
|
||||
void WUPS_InitOverlay(wups_loader_init_overlay_args_t args);
|
||||
|
||||
/**
|
||||
Sets the function pointers for kernel functions.
|
||||
If none or NULL pointers is provided, calling the corresponding function has no effect.
|
||||
**/
|
||||
void WUPS_InitKernel(wups_loader_init_kernel_args_t args);
|
||||
|
||||
/**
|
||||
Sets the function pointers for video mem functions.
|
||||
If none or NULL pointers is provided, calling the corresponding function has no effect.
|
||||
**/
|
||||
void WUPS_InitVidMem(wups_loader_init_vid_mem_args_t args);
|
||||
|
||||
/*
|
||||
Can be called by the user.
|
||||
*/
|
||||
void WUPS_Overlay_PrintTextOnScreen(wups_overlay_options_type_t screen, int x,int y, const char * msg, ...);
|
||||
|
||||
void WUPS_Overlay_OSScreenClear(wups_overlay_options_type_t screen);
|
||||
|
||||
void WUPS_Overlay_FlipBuffers(wups_overlay_options_type_t screen);
|
||||
|
||||
void WUPS_OpenOverlay(wups_overlay_options_type_t screen, overlay_callback callback, void* args);
|
||||
|
||||
// texture needs to be a GX2Texture
|
||||
bool WUPS_ConvertImageToTexture(const uint8_t *img, int32_t imgSize, void * texture);
|
||||
|
||||
/**
|
||||
Reads a 32bit value from a given address with kernel rights.
|
||||
This function only has an effect if the plugin has the "WUPS_ALLOW_KERNEL" hook and the loader is NOT blocking the kernel access.
|
||||
The argument of the ON_APPLICATION_START hook provides the information if the plugin has kernel access which should be checked before using/relying on this function.
|
||||
**/
|
||||
uint32_t WUPS_KernelRead(const void *addr);
|
||||
|
||||
/**
|
||||
Write a 32bit value from a given address with kernel rights.
|
||||
This function only has an effect if the plugin has the "WUPS_ALLOW_KERNEL" hook and the loader is NOT blocking the kernel access.
|
||||
The argument of the ON_APPLICATION_START hook provides the information if the plugin has kernel access which should be checked before using/relying on this function.
|
||||
**/
|
||||
void WUPS_KernelWrite(void *addr, uint32_t value);
|
||||
|
||||
/**
|
||||
Copies data from a source address to a destination address for a given lenght with kernel rights.
|
||||
This function only has an effect if the plugin has the "WUPS_ALLOW_KERNEL" hook and the loader is NOT blocking the kernel access.
|
||||
The argument of the ON_APPLICATION_START hook provides the information if the plugin has kernel access which should be checked before using/relying on this function.
|
||||
**/
|
||||
void WUPS_KernelCopyDataFunction(uint32_t addr, uint32_t src, uint32_t len);
|
||||
|
||||
void * WUPS_VideoMemAlloc(uint32_t size);
|
||||
|
||||
void * WUPS_VideoMemMemalign(uint32_t size, int32_t align);
|
||||
|
||||
void WUPS_VideoMemFree(void *addr);
|
||||
|
||||
void WUPS_DrawTexture(void * texture, void* sampler, float x, float y, int32_t width, int32_t height, float alpha);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_WUPS_H_ */
|
||||
Reference in New Issue
Block a user