Skip to content

Commit

Permalink
take a controldeck in
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai committed Dec 16, 2024
1 parent ff1f97e commit 13e427b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ Context::~Context() {
std::shared_ptr<Context>
Context::CreateInstance(const std::string name, const std::string shortName, const std::string configFilePath,
const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window) {
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window, std::shared_ptr<ControlDeck> controlDeck) {
if (mContext.expired()) {
auto shared = std::make_shared<Context>(name, shortName, configFilePath);
mContext = shared;
if (shared->Init(archivePaths, validHashes, reservedThreadCount, audioSettings, window)) {
if (shared->Init(archivePaths, validHashes, reservedThreadCount, audioSettings, window, controlDeck)) {
return shared;
} else {
SPDLOG_ERROR("Failed to initialize");
Expand Down Expand Up @@ -79,9 +79,9 @@ Context::Context(std::string name, std::string shortName, std::string configFile
}

bool Context::Init(const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window) {
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window, std::shared_ptr<ControlDeck> controlDeck) {
return InitLogging() && InitConfiguration() && InitConsoleVariables() &&
InitResourceManager(archivePaths, validHashes, reservedThreadCount) && InitControlDeck() &&
InitResourceManager(archivePaths, validHashes, reservedThreadCount) && InitControlDeck(controlDeck) &&
InitCrashHandler() && InitConsole() && InitWindow(window) && InitAudio(audioSettings) && InitGfxDebugger();
}

Expand Down Expand Up @@ -228,12 +228,12 @@ bool Context::InitResourceManager(const std::vector<std::string>& archivePaths,
return true;
}

bool Context::InitControlDeck(std::vector<CONTROLLERBUTTONS_T> additionalBitmasks) {
bool Context::InitControlDeck(std::shared_ptr<ControlDeck> controlDeck) {
if (GetControlDeck() != nullptr) {
return true;
}

mControlDeck = std::make_shared<ControlDeck>(additionalBitmasks);
mControlDeck = controlDeck;

if (GetControlDeck() == nullptr) {
SPDLOG_ERROR("Failed to initialize control deck");
Expand Down
6 changes: 3 additions & 3 deletions src/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Context {
const std::vector<std::string>& archivePaths = {},
const std::unordered_set<uint32_t>& validHashes = {},
uint32_t reservedThreadCount = 1, AudioSettings audioSettings = {},
std::shared_ptr<Window> window = nullptr);
std::shared_ptr<Window> window = nullptr, std::shared_ptr<ControlDeck> controlDeck = nullptr);
static std::shared_ptr<Context> CreateUninitializedInstance(const std::string name, const std::string shortName,
const std::string configFilePath);
static std::string GetAppBundlePath();
Expand All @@ -39,7 +39,7 @@ class Context {
~Context();

bool Init(const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window = nullptr);
uint32_t reservedThreadCount, AudioSettings audioSettings, std::shared_ptr<Window> window = nullptr, std::shared_ptr<ControlDeck> controlDeck = nullptr);

std::shared_ptr<spdlog::logger> GetLogger();
std::shared_ptr<Config> GetConfig();
Expand All @@ -60,7 +60,7 @@ class Context {
bool InitConsoleVariables();
bool InitResourceManager(const std::vector<std::string>& archivePaths = {},
const std::unordered_set<uint32_t>& validHashes = {}, uint32_t reservedThreadCount = 1);
bool InitControlDeck(std::vector<CONTROLLERBUTTONS_T> additionalBitmasks = {});
bool InitControlDeck(std::shared_ptr<ControlDeck> controlDeck = nullptr);
bool InitCrashHandler();
bool InitAudio(AudioSettings settings);
bool InitGfxDebugger();
Expand Down

0 comments on commit 13e427b

Please sign in to comment.