mirror of
https://github.com/Maschell/hid_to_vpad.git
synced 2024-11-21 14:19:14 +01:00
- Added settings classes
- load language file from file set in the settings file - put brackets arround "empty" if-statement (when the logger is undefined) -
This commit is contained in:
parent
b6feb1d4d0
commit
f26144eced
1
Makefile
1
Makefile
@ -51,6 +51,7 @@ SOURCES := src \
|
||||
src/patcher \
|
||||
src/resources \
|
||||
src/sounds \
|
||||
src/settings \
|
||||
src/system \
|
||||
src/utils \
|
||||
src/video \
|
||||
|
@ -2,10 +2,10 @@
|
||||
<app version="1">
|
||||
<name>HID to VPAD</name>
|
||||
<coder>Maschell</coder>
|
||||
<version>v0.9h</version>
|
||||
<version>v0.9i</version>
|
||||
<category>tool</category>
|
||||
<url>https://gbatemp.net/threads/hid-to-vpad.424127/</url>
|
||||
<release_date>20170410173100</release_date>
|
||||
<release_date>20170427194500</release_date>
|
||||
<short_description>USB HID to gamepad input</short_description>
|
||||
<long_description>Emulate input using various USB HID devices.
|
||||
</long_description>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "resources/Resources.h"
|
||||
#include "sounds/SoundHandler.hpp"
|
||||
#include "utils/logger.h"
|
||||
#include "settings/CSettings.h"
|
||||
|
||||
Application *Application::applicationInstance = NULL;
|
||||
bool Application::exitApplication = false;
|
||||
@ -41,11 +42,13 @@ Application::Application()
|
||||
controller[3] = new WPadController(GuiTrigger::CHANNEL_4);
|
||||
controller[4] = new WPadController(GuiTrigger::CHANNEL_5);
|
||||
|
||||
CSettings::instance()->Load();
|
||||
|
||||
//! create bgMusic
|
||||
bgMusic = new GuiSound(Resources::GetFile("bgMusic.mp3"), Resources::GetFileSize("bgMusic.mp3"));
|
||||
|
||||
//std::string languagePath = "sd:/wiiu/apps/hidtovpad/languages/english.lang";
|
||||
//gettextLoadLanguage(languagePath.c_str());
|
||||
//! load language
|
||||
loadLanguageFromConfig();
|
||||
|
||||
exitApplication = false;
|
||||
}
|
||||
@ -215,3 +218,10 @@ void Application::executeThread(void){
|
||||
delete fontSystem;
|
||||
delete video;
|
||||
}
|
||||
|
||||
void Application::loadLanguageFromConfig(){
|
||||
if(!CSettings::getValueAsString(CSettings::AppLanguage).empty()){
|
||||
std::string languagePath = "sd:/wiiu/apps/hidtovpad/languages/" + CSettings::getValueAsString(CSettings::AppLanguage) + ".lang";
|
||||
gettextLoadLanguage(languagePath.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
}
|
||||
private:
|
||||
Application();
|
||||
|
||||
virtual ~Application();
|
||||
|
||||
static Application *applicationInstance;
|
||||
@ -67,6 +68,8 @@ private:
|
||||
|
||||
void executeThread(void);
|
||||
|
||||
void loadLanguageFromConfig();
|
||||
|
||||
GuiSound *bgMusic;
|
||||
CVideo *video;
|
||||
MainWindow *mainWindow;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 83b064108ecf49bf775ac636183c5f89672ae1f9
|
||||
Subproject commit 5c7be021d07e7d482accabbe686e3ff5927dde6b
|
@ -43,7 +43,7 @@ DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s3
|
||||
}
|
||||
|
||||
DECL(void, __PPCExit, void){
|
||||
if(HID_DEBUG) log_printf("__PPCExit\n");
|
||||
if(HID_DEBUG){ log_printf("__PPCExit\n"); }
|
||||
CursorDrawer::destroyInstance();
|
||||
|
||||
ControllerPatcher::destroyConfigHelper();
|
||||
@ -67,11 +67,11 @@ DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
|
||||
if(result > 0 && (buffer[0].btns_h & VPAD_BUTTON_TV) && gCallbackCooldown == 0){
|
||||
gCallbackCooldown = 0xFF;
|
||||
if(HID_DEBUG) log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!\n",__LINE__);
|
||||
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): Pressed the TV button. Maybe we can call the callbacks.!\n",__LINE__); }
|
||||
|
||||
if(HID_DEBUG) log_printf("my_VPADRead(line %d): gExtensionCallback = %08X %08X %08X %08X\n",__LINE__,gExtensionCallback[0],gExtensionCallback[1],gExtensionCallback[2],gExtensionCallback[3]);
|
||||
if(HID_DEBUG) log_printf("my_VPADRead(line %d): gWPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gWPADConnectCallback[0],gWPADConnectCallback[1],gWPADConnectCallback[2],gWPADConnectCallback[3]);
|
||||
if(HID_DEBUG) log_printf("my_VPADRead(line %d): gKPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gKPADConnectCallback[0],gKPADConnectCallback[1],gKPADConnectCallback[2],gKPADConnectCallback[3]);
|
||||
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gExtensionCallback = %08X %08X %08X %08X\n",__LINE__,gExtensionCallback[0],gExtensionCallback[1],gExtensionCallback[2],gExtensionCallback[3]); }
|
||||
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gWPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gWPADConnectCallback[0],gWPADConnectCallback[1],gWPADConnectCallback[2],gWPADConnectCallback[3]); }
|
||||
if(HID_DEBUG){ log_printf("my_VPADRead(line %d): gKPADConnectCallback = %08X %08X %08X %08X\n",__LINE__,gKPADConnectCallback[0],gKPADConnectCallback[1],gKPADConnectCallback[2],gKPADConnectCallback[3]); }
|
||||
|
||||
for(s32 i = 0;i<4;i++){
|
||||
bool doCall = false;
|
||||
|
243
src/settings/CSettings.cpp
Normal file
243
src/settings/CSettings.cpp
Normal file
@ -0,0 +1,243 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "CSettings.h"
|
||||
#include "SettingsEnums.h"
|
||||
#include "fs/CFile.hpp"
|
||||
#include "fs/fs_utils.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "language/gettext.h"
|
||||
|
||||
#define VERSION_LINE "# HID to VPAD - Main settings file v"
|
||||
#define VALID_VERSION 1
|
||||
|
||||
CSettings *CSettings::settingsInstance = NULL;
|
||||
|
||||
CSettings::CSettings(){
|
||||
bChanged = false;
|
||||
memset(&nullValue, 0, sizeof(nullValue));
|
||||
nullValue.strValue = new std::string();
|
||||
|
||||
configPath = SD_PATH WIIU_PATH "/apps/hidtovpad";
|
||||
this->SetDefault();
|
||||
}
|
||||
|
||||
CSettings::~CSettings(){
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
if(settingsValues[i].dataType == TypeString)
|
||||
delete settingsValues[i].strValue;
|
||||
}
|
||||
delete nullValue.strValue;
|
||||
}
|
||||
|
||||
void CSettings::SetDefault()
|
||||
{
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
if(settingsValues[i].dataType == TypeString)
|
||||
delete settingsValues[i].strValue;
|
||||
}
|
||||
|
||||
settingsNames.resize(MAX_VALUE);
|
||||
settingsValues.resize(MAX_VALUE);
|
||||
|
||||
settingsNames[AppLanguage] = "AppLanguage";
|
||||
settingsValues[AppLanguage].dataType = TypeString;
|
||||
settingsValues[AppLanguage].strValue = new std::string();
|
||||
|
||||
settingsNames[RumbleActivated] = "RumbleActivated";
|
||||
settingsValues[RumbleActivated].dataType = TypeU8;
|
||||
settingsValues[RumbleActivated].ucValue = SETTING_ON;
|
||||
}
|
||||
|
||||
bool CSettings::Load(){
|
||||
//! Reset default path variables to the right device
|
||||
SetDefault();
|
||||
|
||||
std::string filepath = configPath;
|
||||
filepath += "/hidtovpad.cfg";
|
||||
|
||||
CFile file(filepath, CFile::ReadOnly);
|
||||
if (!file.isOpen())
|
||||
return false;
|
||||
|
||||
std::string strBuffer;
|
||||
strBuffer.resize(file.size());
|
||||
file.read((u8 *) &strBuffer[0], strBuffer.size());
|
||||
file.close();
|
||||
|
||||
//! remove all windows crap signs
|
||||
size_t position;
|
||||
while(1)
|
||||
{
|
||||
position = strBuffer.find('\r');
|
||||
if(position == std::string::npos)
|
||||
break;
|
||||
|
||||
strBuffer.erase(position, 1);
|
||||
}
|
||||
|
||||
std::vector<std::string> lines = stringSplit(strBuffer, "\n");
|
||||
|
||||
|
||||
if(lines.empty() || !ValidVersion(lines[0]))
|
||||
return false;
|
||||
|
||||
for(u32 i = 0; i < lines.size(); ++i)
|
||||
{
|
||||
std::vector<std::string> valueSplit = stringSplit(lines[i], "=");
|
||||
if(valueSplit.size() != 2)
|
||||
continue;
|
||||
|
||||
while((valueSplit[0].size() > 0) && valueSplit[0][0] == ' ')
|
||||
valueSplit[0].erase(0, 1);
|
||||
|
||||
while((valueSplit[1].size() > 0) && valueSplit[1][ valueSplit[1].size() - 1 ] == ' ')
|
||||
valueSplit[1].resize(valueSplit[1].size() - 1);
|
||||
|
||||
for(u32 n = 0; n < settingsNames.size(); n++)
|
||||
{
|
||||
if(!settingsNames[n])
|
||||
continue;
|
||||
|
||||
if(valueSplit[0] == settingsNames[n])
|
||||
{
|
||||
switch(settingsValues[n].dataType)
|
||||
{
|
||||
case TypeBool:
|
||||
settingsValues[n].bValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeS8:
|
||||
settingsValues[n].cValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeU8:
|
||||
settingsValues[n].ucValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeS16:
|
||||
settingsValues[n].sValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeU16:
|
||||
settingsValues[n].usValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeS32:
|
||||
settingsValues[n].iValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeU32:
|
||||
settingsValues[n].uiValue = strtoul(valueSplit[1].c_str(), 0, 10);
|
||||
break;
|
||||
case TypeF32:
|
||||
settingsValues[n].fValue = atof(valueSplit[1].c_str());
|
||||
break;
|
||||
case TypeString:
|
||||
if(settingsValues[n].strValue == NULL)
|
||||
settingsValues[n].strValue = new std::string();
|
||||
|
||||
*settingsValues[n].strValue = valueSplit[1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSettings::ValidVersion(const std::string & versionString){
|
||||
int version = 0;
|
||||
|
||||
if(versionString.find(VERSION_LINE) != 0)
|
||||
return false;
|
||||
|
||||
version = atoi(versionString.c_str() + strlen(VERSION_LINE));
|
||||
|
||||
return version == VALID_VERSION;
|
||||
}
|
||||
|
||||
bool CSettings::Reset(){
|
||||
this->SetDefault();
|
||||
bChanged = true;
|
||||
|
||||
if (this->Save())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSettings::Save(){
|
||||
if(!bChanged)
|
||||
return true;
|
||||
|
||||
CreateSubfolder(configPath.c_str());
|
||||
|
||||
std::string filepath = configPath;
|
||||
filepath += "/hidtovpad.cfg";
|
||||
|
||||
CFile file(filepath, CFile::WriteOnly);
|
||||
if (!file.isOpen())
|
||||
return false;
|
||||
|
||||
file.fwrite("%s%i\n", VERSION_LINE, VALID_VERSION);
|
||||
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
switch(settingsValues[i].dataType)
|
||||
{
|
||||
case TypeBool:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].bValue);
|
||||
break;
|
||||
case TypeS8:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].cValue);
|
||||
break;
|
||||
case TypeU8:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].ucValue);
|
||||
break;
|
||||
case TypeS16:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].sValue);
|
||||
break;
|
||||
case TypeU16:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].usValue);
|
||||
break;
|
||||
case TypeS32:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].iValue);
|
||||
break;
|
||||
case TypeU32:
|
||||
file.fwrite("%s=%u\n", settingsNames[i], settingsValues[i].uiValue);
|
||||
break;
|
||||
case TypeF32:
|
||||
file.fwrite("%s=%f\n", settingsNames[i], settingsValues[i].fValue);
|
||||
break;
|
||||
case TypeString:
|
||||
if(settingsValues[i].strValue != NULL)
|
||||
file.fwrite("%s=%s\n", settingsNames[i], settingsValues[i].strValue->c_str());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
bChanged = false;
|
||||
|
||||
return true;
|
||||
}
|
255
src/settings/CSettings.h
Normal file
255
src/settings/CSettings.h
Normal file
@ -0,0 +1,255 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* Modified by Maschell, 2017 for HID to VPAD
|
||||
*
|
||||
* 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 _CSETTINGS_H_
|
||||
#define _CSETTINGS_H_
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <gctypes.h>
|
||||
#include <vector>
|
||||
#include "SettingsEnums.h"
|
||||
|
||||
class CSettings
|
||||
{
|
||||
public:
|
||||
static CSettings *instance() {
|
||||
if(!settingsInstance)
|
||||
settingsInstance = new CSettings();
|
||||
|
||||
return settingsInstance;
|
||||
}
|
||||
|
||||
static void destroyInstance() {
|
||||
if(settingsInstance){
|
||||
delete settingsInstance;
|
||||
settingsInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//!Set Default Settings
|
||||
void SetDefault();
|
||||
//!Load Settings
|
||||
bool Load();
|
||||
//!Save Settings
|
||||
bool Save();
|
||||
//!Reset Settings
|
||||
bool Reset();
|
||||
|
||||
enum DataTypes{
|
||||
TypeNone,
|
||||
TypeBool,
|
||||
TypeS8,
|
||||
TypeU8,
|
||||
TypeS16,
|
||||
TypeU16,
|
||||
TypeS32,
|
||||
TypeU32,
|
||||
TypeF32,
|
||||
TypeString
|
||||
};
|
||||
|
||||
|
||||
enum SettingsIdx{
|
||||
INVALID = -1,
|
||||
AppLanguage,
|
||||
RumbleActivated,
|
||||
MAX_VALUE
|
||||
};
|
||||
|
||||
static const u8 & getDataType(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE)
|
||||
return instance()->settingsValues[idx].dataType;
|
||||
|
||||
return instance()->nullValue.dataType;
|
||||
}
|
||||
|
||||
static const bool & getValueAsBool(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool)
|
||||
return instance()->settingsValues[idx].bValue;
|
||||
|
||||
return instance()->nullValue.bValue;
|
||||
}
|
||||
static const s8 & getValueAsS8(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8)
|
||||
return instance()->settingsValues[idx].cValue;
|
||||
|
||||
return instance()->nullValue.cValue;
|
||||
}
|
||||
static const u8 & getValueAsU8(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8)
|
||||
return instance()->settingsValues[idx].ucValue;
|
||||
|
||||
return instance()->nullValue.ucValue;
|
||||
}
|
||||
static const s16 & getValueAsS16(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16)
|
||||
return instance()->settingsValues[idx].sValue;
|
||||
|
||||
return instance()->nullValue.sValue;
|
||||
}
|
||||
static const u16 & getValueAsU16(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16)
|
||||
return instance()->settingsValues[idx].usValue;
|
||||
|
||||
return instance()->nullValue.usValue;
|
||||
}
|
||||
static const s32 & getValueAsS32(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32)
|
||||
return instance()->settingsValues[idx].iValue;
|
||||
|
||||
return instance()->nullValue.iValue;
|
||||
}
|
||||
static const u32 & getValueAsU32(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32)
|
||||
return instance()->settingsValues[idx].uiValue;
|
||||
|
||||
return instance()->nullValue.uiValue;
|
||||
}
|
||||
static const f32 & getValueAsF32(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32)
|
||||
return instance()->settingsValues[idx].fValue;
|
||||
|
||||
return instance()->nullValue.fValue;
|
||||
}
|
||||
static const std::string & getValueAsString(int idx)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue)
|
||||
return *(instance()->settingsValues[idx].strValue);
|
||||
|
||||
return *(instance()->nullValue.strValue);
|
||||
}
|
||||
|
||||
static void setValueAsBool(int idx, const bool & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool)
|
||||
{
|
||||
instance()->settingsValues[idx].bValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS8(int idx, const s8 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8)
|
||||
{
|
||||
instance()->settingsValues[idx].cValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU8(int idx, const u8 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8)
|
||||
{
|
||||
instance()->settingsValues[idx].ucValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS16(int idx, const s16 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16)
|
||||
{
|
||||
instance()->settingsValues[idx].sValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU16(int idx, const u16 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16)
|
||||
{
|
||||
instance()->settingsValues[idx].usValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS32(int idx, const s32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32)
|
||||
{
|
||||
instance()->settingsValues[idx].iValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU32(int idx, const u32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32)
|
||||
{
|
||||
instance()->settingsValues[idx].uiValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsF32(int idx, const f32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32)
|
||||
{
|
||||
instance()->settingsValues[idx].fValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsString(int idx, const std::string & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue)
|
||||
{
|
||||
*(instance()->settingsValues[idx].strValue) = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
protected:
|
||||
//!Constructor
|
||||
CSettings();
|
||||
//!Destructor
|
||||
~CSettings();
|
||||
|
||||
bool ValidVersion(const std::string & versionString);
|
||||
|
||||
static CSettings *settingsInstance;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 dataType;
|
||||
|
||||
union
|
||||
{
|
||||
bool bValue;
|
||||
s8 cValue;
|
||||
u8 ucValue;
|
||||
s16 sValue;
|
||||
u16 usValue;
|
||||
s32 iValue;
|
||||
u32 uiValue;
|
||||
f32 fValue;
|
||||
std::string *strValue;
|
||||
};
|
||||
} SettingValue;
|
||||
|
||||
SettingValue nullValue;
|
||||
std::string configPath;
|
||||
std::vector<SettingValue> settingsValues;
|
||||
std::vector<const char*> settingsNames;
|
||||
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
#endif
|
37
src/settings/SettingsDefs.h
Normal file
37
src/settings/SettingsDefs.h
Normal file
@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* Modified by Maschell, 2017 for HID to VPAD
|
||||
*
|
||||
* 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 __SETTINGS_DEFS_
|
||||
#define __SETTINGS_DEFS_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int value;
|
||||
const char *name;
|
||||
} ValueString;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
const ValueString *valueStrings;
|
||||
int type;
|
||||
int index;
|
||||
} SettingType;
|
||||
|
||||
|
||||
#endif // __SETTINGS_DEFS_
|
9
src/settings/SettingsEnums.h
Normal file
9
src/settings/SettingsEnums.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef SETTINGS_ENUMS_H_
|
||||
#define SETTINGS_ENUMS_H_
|
||||
|
||||
enum eOnOff{
|
||||
SETTING_OFF,
|
||||
SETTING_ON
|
||||
};
|
||||
|
||||
#endif // SETTINGS_ENUMS_H_
|
@ -74,7 +74,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN)log_printf("%s is located at %08X!\n", method_hooks[i].functionName,real_addr);
|
||||
if(DEBUG_LOG_DYN){ log_printf("%s is located at %08X!\n", method_hooks[i].functionName,real_addr); }
|
||||
|
||||
physical = (u32)OSEffectiveToPhysical((void*)real_addr);
|
||||
if(!physical){
|
||||
@ -83,7 +83,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN)log_printf("%s physical is located at %08X!\n", method_hooks[i].functionName,physical);
|
||||
if(DEBUG_LOG_DYN){ log_printf("%s physical is located at %08X!\n", method_hooks[i].functionName,physical); }
|
||||
|
||||
*(volatile u32 *)(call_addr) = (u32)(space) - CODE_RW_BASE_OFFSET;
|
||||
|
||||
@ -96,8 +96,8 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
|
||||
// fill the restore instruction section
|
||||
method_hooks[i].realAddr = real_addr;
|
||||
method_hooks[i].restoreInstruction = *(space-1);
|
||||
if(DEBUG_LOG_DYN)log_printf("method_hooks[i].realAddr = %08X!\n", method_hooks[i].realAddr);
|
||||
if(DEBUG_LOG_DYN)log_printf("method_hooks[i].restoreInstruction = %08X!\n",method_hooks[i].restoreInstruction) ;
|
||||
if(DEBUG_LOG_DYN){ log_printf("method_hooks[i].realAddr = %08X!\n", method_hooks[i].realAddr); }
|
||||
if(DEBUG_LOG_DYN){ log_printf("method_hooks[i].restoreInstruction = %08X!\n",method_hooks[i].restoreInstruction) ; }
|
||||
}
|
||||
else{
|
||||
log_printf("Error. Can't save %s for restoring!\n", method_hooks[i].functionName);
|
||||
@ -175,9 +175,9 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_informati
|
||||
else
|
||||
{
|
||||
physical = (u32)OSEffectiveToPhysical((void*)method_hooks[i].realAddr); //When its an static function, we need to use the old location
|
||||
if(DEBUG_LOG_DYN)log_printf("Restoring %08X to %08X\n",(u32)method_hooks[i].restoreInstruction,physical);
|
||||
if(DEBUG_LOG_DYN){ log_printf("Restoring %08X to %08X\n",(u32)method_hooks[i].restoreInstruction,physical); }
|
||||
SC0x25_KernelCopyData(physical,(u32)&method_hooks[i].restoreInstruction , 4);
|
||||
if(DEBUG_LOG_DYN)log_printf("ICInvalidateRange %08X\n",(void*)method_hooks[i].realAddr);
|
||||
if(DEBUG_LOG_DYN){ log_printf("ICInvalidateRange %08X\n",(void*)method_hooks[i].realAddr); }
|
||||
ICInvalidateRange((void*)method_hooks[i].realAddr, 4);
|
||||
log_printf("done\n");
|
||||
}
|
||||
@ -219,72 +219,72 @@ u32 GetAddressOfFunction(const char * functionName,u32 library){
|
||||
|
||||
u32 rpl_handle = 0;
|
||||
if(library == LIB_CORE_INIT){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_CORE_INIT\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_CORE_INIT\n", functionName); }
|
||||
if(coreinit_handle == 0){log_print("LIB_CORE_INIT not aquired\n"); return 0;}
|
||||
rpl_handle = coreinit_handle;
|
||||
}
|
||||
else if(library == LIB_NSYSNET){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_NSYSNET\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_NSYSNET\n", functionName); }
|
||||
if(nsysnet_handle == 0){log_print("LIB_NSYSNET not aquired\n"); return 0;}
|
||||
rpl_handle = nsysnet_handle;
|
||||
}
|
||||
else if(library == LIB_GX2){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_GX2\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_GX2\n", functionName); }
|
||||
if(gx2_handle == 0){log_print("LIB_GX2 not aquired\n"); return 0;}
|
||||
rpl_handle = gx2_handle;
|
||||
}
|
||||
else if(library == LIB_AOC){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_AOC\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_AOC\n", functionName); }
|
||||
if(aoc_handle == 0){log_print("LIB_AOC not aquired\n"); return 0;}
|
||||
rpl_handle = aoc_handle;
|
||||
}
|
||||
else if(library == LIB_AX){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_AX\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_AX\n", functionName); }
|
||||
if(sound_handle == 0){log_print("LIB_AX not aquired\n"); return 0;}
|
||||
rpl_handle = sound_handle;
|
||||
}
|
||||
else if(library == LIB_FS){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_FS\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_FS\n", functionName); }
|
||||
if(coreinit_handle == 0){log_print("LIB_FS not aquired\n"); return 0;}
|
||||
rpl_handle = coreinit_handle;
|
||||
}
|
||||
else if(library == LIB_OS){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_OS\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_OS\n", functionName); }
|
||||
if(coreinit_handle == 0){log_print("LIB_OS not aquired\n"); return 0;}
|
||||
rpl_handle = coreinit_handle;
|
||||
}
|
||||
else if(library == LIB_PADSCORE){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_PADSCORE\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_PADSCORE\n", functionName); }
|
||||
if(padscore_handle == 0){log_print("LIB_PADSCORE not aquired\n"); return 0;}
|
||||
rpl_handle = padscore_handle;
|
||||
}
|
||||
else if(library == LIB_SOCKET){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_SOCKET\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_SOCKET\n", functionName); }
|
||||
if(nsysnet_handle == 0){log_print("LIB_SOCKET not aquired\n"); return 0;}
|
||||
rpl_handle = nsysnet_handle;
|
||||
}
|
||||
else if(library == LIB_SYS){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_SYS\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_SYS\n", functionName); }
|
||||
if(sysapp_handle == 0){log_print("LIB_SYS not aquired\n"); return 0;}
|
||||
rpl_handle = sysapp_handle;
|
||||
}
|
||||
else if(library == LIB_VPAD){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_VPAD\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_VPAD\n", functionName); }
|
||||
if(vpad_handle == 0){log_print("LIB_VPAD not aquired\n"); return 0;}
|
||||
rpl_handle = vpad_handle;
|
||||
}
|
||||
else if(library == LIB_NN_ACP){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_NN_ACP\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_NN_ACP\n", functionName); }
|
||||
if(acp_handle == 0){log_print("LIB_NN_ACP not aquired\n"); return 0;}
|
||||
rpl_handle = acp_handle;
|
||||
}
|
||||
else if(library == LIB_SYSHID){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_SYSHID\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_SYSHID\n", functionName); }
|
||||
if(syshid_handle == 0){log_print("LIB_SYSHID not aquired\n"); return 0;}
|
||||
rpl_handle = syshid_handle;
|
||||
}
|
||||
else if(library == LIB_VPADBASE){
|
||||
if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_VPADBASE\n", functionName);
|
||||
if(DEBUG_LOG_DYN){ log_printf("FindExport of %s! From LIB_VPADBASE\n", functionName); }
|
||||
if(vpadbase_handle == 0){log_print("LIB_VPADBASE not aquired\n"); return 0;}
|
||||
rpl_handle = vpadbase_handle;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user