Skip to content

Commit

Permalink
Misc: Split core and util Host
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Aug 29, 2023
1 parent 779e78a commit e23c987
Show file tree
Hide file tree
Showing 25 changed files with 425 additions and 302 deletions.
1 change: 1 addition & 0 deletions src/core/achievements.cpp
Expand Up @@ -22,6 +22,7 @@

#include "util/cd_image.h"
#include "util/imgui_fullscreen.h"
#include "util/imgui_manager.h"
#include "util/platform_misc.h"
#include "util/state_wrapper.h"

Expand Down
12 changes: 9 additions & 3 deletions src/core/analog_controller.cpp
Expand Up @@ -2,15 +2,21 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)

#include "analog_controller.h"
#include "IconsFontAwesome5.h"
#include "common/log.h"
#include "common/string_util.h"
#include "host.h"
#include "settings.h"
#include "system.h"

#include "util/imgui_manager.h"
#include "util/input_manager.h"
#include "util/state_wrapper.h"

#include "common/log.h"
#include "common/string_util.h"

#include "IconsFontAwesome5.h"

#include <cmath>

Log_SetChannel(AnalogController);

AnalogController::AnalogController(u32 index) : Controller(index)
Expand Down
27 changes: 15 additions & 12 deletions src/core/analog_joystick.cpp
Expand Up @@ -2,12 +2,17 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)

#include "analog_joystick.h"
#include "common/log.h"
#include "common/string_util.h"
#include "host.h"
#include "system.h"

#include "util/imgui_manager.h"
#include "util/state_wrapper.h"

#include "common/log.h"
#include "common/string_util.h"

#include <cmath>

Log_SetChannel(AnalogJoystick);

AnalogJoystick::AnalogJoystick(u32 index) : Controller(index)
Expand Down Expand Up @@ -58,9 +63,8 @@ bool AnalogJoystick::DoState(StateWrapper& sw, bool apply_input_state)
if (sw.IsReading() && (old_analog_mode != m_analog_mode))
{
Host::AddFormattedOSDMessage(5.0f,
m_analog_mode ?
TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_analog_mode ? TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_index + 1u);
}
return true;
Expand Down Expand Up @@ -234,9 +238,8 @@ void AnalogJoystick::ToggleAnalogMode()

Log_InfoPrintf("Joystick %u switched to %s mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
Host::AddFormattedOSDMessage(5.0f,
m_analog_mode ?
TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_analog_mode ? TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_index + 1u);
}

Expand Down Expand Up @@ -370,7 +373,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = {
AXIS("RRight", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Right"), AnalogJoystick::HalfAxis::RRight, GenericInputBinding::RightStickRight),
AXIS("RDown", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Down"), AnalogJoystick::HalfAxis::RDown, GenericInputBinding::RightStickDown),
AXIS("RUp", TRANSLATE_NOOP("AnalogJoystick", "Right Stick Up"), AnalogJoystick::HalfAxis::RUp, GenericInputBinding::RightStickUp),
// clang-format on
// clang-format on

#undef AXIS
#undef BUTTON
Expand All @@ -384,7 +387,7 @@ static const char* s_invert_settings[] = {TRANSLATE_NOOP("AnalogJoystick", "Not
static const SettingInfo s_settings[] = {
{SettingInfo::Type::Float, "AnalogDeadzone", TRANSLATE_NOOP("AnalogJoystick", "Analog Deadzone"),
TRANSLATE_NOOP("AnalogJoystick",
"Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."),
"Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."),
"1.00f", "0.00f", "1.00f", "0.01f", "%.0f%%", nullptr, 100.0f},
{SettingInfo::Type::Float, "AnalogSensitivity", TRANSLATE_NOOP("AnalogJoystick", "Analog Sensitivity"),
TRANSLATE_NOOP(
Expand All @@ -396,8 +399,8 @@ static const SettingInfo s_settings[] = {
TRANSLATE_NOOP("AnalogJoystick", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr, nullptr,
s_invert_settings, 0.0f},
{SettingInfo::Type::IntegerList, "InvertRightStick", TRANSLATE_NOOP("AnalogJoystick", "Invert Right Stick"),
TRANSLATE_NOOP("AnalogJoystick", "Inverts the direction of the right analog stick."), "0", "0", "3", nullptr, nullptr,
s_invert_settings, 0.0f},
TRANSLATE_NOOP("AnalogJoystick", "Inverts the direction of the right analog stick."), "0", "0", "3", nullptr,
nullptr, s_invert_settings, 0.0f},
};

const Controller::ControllerInfo AnalogJoystick::INFO = {ControllerType::AnalogJoystick,
Expand Down
34 changes: 19 additions & 15 deletions src/core/cdrom.cpp
Expand Up @@ -3,24 +3,29 @@

#include "cdrom.h"
#include "cdrom_async_reader.h"
#include "common/align.h"
#include "common/bitfield.h"
#include "common/fifo_queue.h"
#include "common/file_system.h"
#include "common/heap_array.h"
#include "common/log.h"
#include "common/platform.h"
#include "dma.h"
#include "host.h"
#include "host_interface_progress_callback.h"
#include "imgui.h"
#include "interrupt_controller.h"
#include "settings.h"
#include "spu.h"
#include "system.h"

#include "util/cd_image.h"
#include "util/cd_xa.h"
#include "util/imgui_manager.h"
#include "util/state_wrapper.h"

#include "common/align.h"
#include "common/bitfield.h"
#include "common/fifo_queue.h"
#include "common/file_system.h"
#include "common/heap_array.h"
#include "common/log.h"
#include "common/platform.h"

#include "imgui.h"

#include <cmath>
#include <vector>
Log_SetChannel(CDROM);
Expand Down Expand Up @@ -719,8 +724,8 @@ void CDROM::InsertMedia(std::unique_ptr<CDImage> media, DiscRegion region)
if (CanReadMedia())
RemoveMedia(true);

Log_InfoPrintf("Inserting new media, disc region: %s, console region: %s",
Settings::GetDiscRegionName(region), Settings::GetConsoleRegionName(System::GetRegion()));
Log_InfoPrintf("Inserting new media, disc region: %s, console region: %s", Settings::GetDiscRegionName(region),
Settings::GetConsoleRegionName(System::GetRegion()));

s_disc_region = region;
m_reader.SetMedia(std::move(media));
Expand Down Expand Up @@ -779,17 +784,16 @@ bool CDROM::PrecacheMedia()

if (m_reader.GetMedia()->HasSubImages() && m_reader.GetMedia()->GetSubImageCount() > 1)
{
Host::AddFormattedOSDMessage(
15.0f, TRANSLATE("OSDMessage", "CD image preloading not available for multi-disc image '%s'"),
FileSystem::GetDisplayNameFromPath(m_reader.GetMedia()->GetFileName()).c_str());
Host::AddFormattedOSDMessage(15.0f,
TRANSLATE("OSDMessage", "CD image preloading not available for multi-disc image '%s'"),
FileSystem::GetDisplayNameFromPath(m_reader.GetMedia()->GetFileName()).c_str());
return false;
}

HostInterfaceProgressCallback callback;
if (!m_reader.Precache(&callback))
{
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Precaching CD image failed, it may be unreliable."),
15.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Precaching CD image failed, it may be unreliable."), 15.0f);
return false;
}

Expand Down
11 changes: 8 additions & 3 deletions src/core/dma.cpp
Expand Up @@ -4,9 +4,6 @@
#include "dma.h"
#include "bus.h"
#include "cdrom.h"
#include "common/bitfield.h"
#include "common/log.h"
#include "common/string_util.h"
#include "cpu_code_cache.h"
#include "cpu_core.h"
#include "gpu.h"
Expand All @@ -17,10 +14,18 @@
#include "pad.h"
#include "spu.h"
#include "system.h"

#include "util/imgui_manager.h"
#include "util/state_wrapper.h"

#include "common/bitfield.h"
#include "common/log.h"
#include "common/string_util.h"

#include <array>
#include <memory>
#include <vector>

Log_SetChannel(DMA);

namespace DMA {
Expand Down
12 changes: 9 additions & 3 deletions src/core/game_database.cpp
Expand Up @@ -2,22 +2,28 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)

#include "game_database.h"
#include "host.h"
#include "system.h"

#include "util/cd_image.h"
#include "util/imgui_manager.h"

#include "common/assert.h"
#include "common/byte_stream.h"
#include "common/heterogeneous_containers.h"
#include "common/log.h"
#include "common/path.h"
#include "common/string_util.h"
#include "common/timer.h"
#include "host.h"

#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include "system.h"
#include "util/cd_image.h"

#include <iomanip>
#include <memory>
#include <optional>
#include <sstream>

Log_SetChannel(GameDatabase);

#ifdef _WIN32
Expand Down
16 changes: 11 additions & 5 deletions src/core/gpu.cpp
Expand Up @@ -2,21 +2,27 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)

#include "gpu.h"
#include "common/file_system.h"
#include "common/heap_array.h"
#include "common/log.h"
#include "common/string_util.h"
#include "dma.h"
#include "host.h"
#include "imgui.h"
#include "interrupt_controller.h"
#include "settings.h"
#include "stb_image_write.h"
#include "system.h"
#include "timers.h"

#include "util/gpu_device.h"
#include "util/imgui_manager.h"
#include "util/state_wrapper.h"

#include "common/file_system.h"
#include "common/heap_array.h"
#include "common/log.h"
#include "common/string_util.h"

#include "stb_image_write.h"

#include <cmath>

Log_SetChannel(GPU);

std::unique_ptr<GPU> g_gpu;
Expand Down
18 changes: 12 additions & 6 deletions src/core/gpu_hw.cpp
Expand Up @@ -2,23 +2,29 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)

#include "gpu_hw.h"
#include "common/align.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/scoped_guard.h"
#include "common/string_util.h"
#include "cpu_core.h"
#include "gpu_hw_shadergen.h"
#include "gpu_sw_backend.h"
#include "host.h"
#include "imgui.h"
#include "pgxp.h"
#include "settings.h"
#include "system.h"

#include "util/imgui_manager.h"
#include "util/state_wrapper.h"

#include "common/align.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/scoped_guard.h"
#include "common/string_util.h"

#include "imgui.h"

#include <cmath>
#include <sstream>
#include <tuple>

Log_SetChannel(GPU_HW);

// TODO: instead of full state restore, only restore what changed
Expand Down

0 comments on commit e23c987

Please sign in to comment.