Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8318 from iwubcode/dynamic_input_textures
InputCommon: Dynamic Input Textures
  • Loading branch information
leoetlino committed Oct 20, 2020
2 parents b26c2e7 + 4fff04d commit fc3b474
Show file tree
Hide file tree
Showing 25 changed files with 1,134 additions and 20 deletions.
1 change: 1 addition & 0 deletions Source/Core/Common/CommonPaths.h
Expand Up @@ -69,6 +69,7 @@
#define WFSROOT_DIR "WFS"
#define BACKUP_DIR "Backup"
#define RESOURCEPACK_DIR "ResourcePacks"
#define DYNAMICINPUT_DIR "DynamicInputTextures"

// This one is only used to remove it if it was present
#define SHADERCACHE_LEGACY_DIR "ShaderCache"
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Common/FileUtil.cpp
Expand Up @@ -813,6 +813,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[D_WFSROOT_IDX] = s_user_paths[D_USER_IDX] + WFSROOT_DIR DIR_SEP;
s_user_paths[D_BACKUP_IDX] = s_user_paths[D_USER_IDX] + BACKUP_DIR DIR_SEP;
s_user_paths[D_RESOURCEPACK_IDX] = s_user_paths[D_USER_IDX] + RESOURCEPACK_DIR DIR_SEP;
s_user_paths[D_DYNAMICINPUT_IDX] = s_user_paths[D_LOAD_IDX] + DYNAMICINPUT_DIR DIR_SEP;
s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
s_user_paths[F_GCPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + GCPAD_CONFIG;
s_user_paths[F_WIIPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + WIIPAD_CONFIG;
Expand Down Expand Up @@ -880,6 +881,7 @@ static void RebuildUserDirectories(unsigned int dir_index)

case D_LOAD_IDX:
s_user_paths[D_HIRESTEXTURES_IDX] = s_user_paths[D_LOAD_IDX] + HIRES_TEXTURES_DIR DIR_SEP;
s_user_paths[D_DYNAMICINPUT_IDX] = s_user_paths[D_LOAD_IDX] + DYNAMICINPUT_DIR DIR_SEP;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.h
Expand Up @@ -54,6 +54,7 @@ enum
D_WFSROOT_IDX,
D_BACKUP_IDX,
D_RESOURCEPACK_IDX,
D_DYNAMICINPUT_IDX,
F_DOLPHINCONFIG_IDX,
F_GCPADCONFIG_IDX,
F_WIIPADCONFIG_IDX,
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/Core.cpp
Expand Up @@ -79,6 +79,7 @@

#include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/HiresTextures.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoBackendBase.h"
Expand Down Expand Up @@ -547,6 +548,10 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
return;
}

// Inputs loading may have generated custom dynamic textures
// it's now ok to initialize any custom textures
HiresTexture::Update();

AudioCommon::InitSoundStream();
Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};

Expand Down
7 changes: 4 additions & 3 deletions Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp
Expand Up @@ -232,9 +232,10 @@ void AdvancedWidget::AddDescriptions()
"User/Dump/Textures/<game_id>/. This includes arbitrary base textures if 'Arbitrary "
"Mipmap Detection' is enabled in Enhancements.\n\nIf unsure, leave "
"this checked.");
static const char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Loads custom textures from User/Load/Textures/<game_id>/.\n\nIf unsure, leave this "
"unchecked.");
static const char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] =
QT_TR_NOOP("Loads custom textures from User/Load/Textures/<game_id>/ and "
"User/Load/DynamicInputTextures/<game_id>/.\n\nIf unsure, leave this "
"unchecked.");
static const char TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Caches custom textures to system RAM on startup.\n\nThis can require exponentially "
"more RAM but fixes possible stuttering.\n\nIf unsure, leave this unchecked.");
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/InputCommon/CMakeLists.txt
@@ -1,4 +1,10 @@
add_library(inputcommon
DynamicInputTextureConfiguration.cpp
DynamicInputTextureConfiguration.h
DynamicInputTextureManager.cpp
DynamicInputTextureManager.h
ImageOperations.cpp
ImageOperations.h
InputConfig.cpp
InputConfig.h
InputProfile.cpp
Expand Down Expand Up @@ -66,6 +72,7 @@ PUBLIC

PRIVATE
fmt::fmt
png
)

if(WIN32)
Expand Down
24 changes: 24 additions & 0 deletions Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp
Expand Up @@ -112,6 +112,12 @@ void EmulatedController::SetDefaultDevice(ciface::Core::DeviceQualifier devq)
}
}

void EmulatedController::SetDynamicInputTextureManager(
InputCommon::DynamicInputTextureManager* dynamic_input_tex_config_manager)
{
m_dynamic_input_tex_config_manager = dynamic_input_tex_config_manager;
}

void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& base)
{
std::string defdev = GetDefaultDevice().ToString();
Expand All @@ -123,6 +129,11 @@ void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& ba

for (auto& cg : groups)
cg->LoadConfig(sec, defdev, base);

if (base.empty())
{
GenerateTextures(sec);
}
}

void EmulatedController::SaveConfig(IniFile::Section* sec, const std::string& base)
Expand All @@ -133,6 +144,11 @@ void EmulatedController::SaveConfig(IniFile::Section* sec, const std::string& ba

for (auto& ctrlGroup : groups)
ctrlGroup->SaveConfig(sec, defdev, base);

if (base.empty())
{
GenerateTextures(sec);
}
}

void EmulatedController::LoadDefaults(const ControllerInterface& ciface)
Expand All @@ -147,4 +163,12 @@ void EmulatedController::LoadDefaults(const ControllerInterface& ciface)
SetDefaultDevice(default_device_string);
}
}

void EmulatedController::GenerateTextures(IniFile::Section* sec)
{
if (m_dynamic_input_tex_config_manager)
{
m_dynamic_input_tex_config_manager->GenerateTextures(sec, GetName());
}
}
} // namespace ControllerEmu
4 changes: 4 additions & 0 deletions Source/Core/InputCommon/ControllerEmu/ControllerEmu.h
Expand Up @@ -17,6 +17,7 @@
#include "Common/MathUtil.h"
#include "InputCommon/ControlReference/ExpressionParser.h"
#include "InputCommon/ControllerInterface/Device.h"
#include "InputCommon/DynamicInputTextureManager.h"

class ControllerInterface;

Expand Down Expand Up @@ -182,6 +183,7 @@ class EmulatedController
const ciface::Core::DeviceQualifier& GetDefaultDevice() const;
void SetDefaultDevice(const std::string& device);
void SetDefaultDevice(ciface::Core::DeviceQualifier devq);
void SetDynamicInputTextureManager(InputCommon::DynamicInputTextureManager*);

void UpdateReferences(const ControllerInterface& devi);
void UpdateSingleControlReference(const ControllerInterface& devi, ControlReference* ref);
Expand Down Expand Up @@ -224,6 +226,8 @@ class EmulatedController
void UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env);

private:
void GenerateTextures(IniFile::Section* sec);
InputCommon::DynamicInputTextureManager* m_dynamic_input_tex_config_manager = nullptr;
ciface::Core::DeviceQualifier m_default_device;
bool m_default_device_is_connected{false};
};
Expand Down

0 comments on commit fc3b474

Please sign in to comment.