This commit is contained in:
David Marcec 2019-09-22 16:41:34 +10:00
parent fcdbf0bc53
commit bd1c4ec9a0
25 changed files with 74 additions and 61 deletions

View file

@ -14,7 +14,7 @@ namespace Service::AOC {
class AOC_U final : public ServiceFramework<AOC_U> { class AOC_U final : public ServiceFramework<AOC_U> {
public: public:
AOC_U(Core::System& system); explicit AOC_U(Core::System& system);
~AOC_U() override; ~AOC_U() override;
private: private:

View file

@ -6,15 +6,15 @@
namespace Service::HID { namespace Service::HID {
ControllerBase::ControllerBase() = default; ControllerBase::ControllerBase(Core::System& system) : system(system){};
ControllerBase::~ControllerBase() = default; ControllerBase::~ControllerBase() = default;
void ControllerBase::ActivateController(Core::System& system) { void ControllerBase::ActivateController() {
if (is_activated) { if (is_activated) {
OnRelease(); OnRelease();
} }
is_activated = true; is_activated = true;
OnInit(system); OnInit();
} }
void ControllerBase::DeactivateController() { void ControllerBase::DeactivateController() {

View file

@ -18,11 +18,11 @@ class System;
namespace Service::HID { namespace Service::HID {
class ControllerBase { class ControllerBase {
public: public:
ControllerBase(); ControllerBase(Core::System& system);
virtual ~ControllerBase(); virtual ~ControllerBase();
// Called when the controller is initialized // Called when the controller is initialized
virtual void OnInit(Core::System& system) = 0; virtual void OnInit() = 0;
// When the controller is released // When the controller is released
virtual void OnRelease() = 0; virtual void OnRelease() = 0;
@ -34,7 +34,7 @@ public:
// Called when input devices should be loaded // Called when input devices should be loaded
virtual void OnLoadInputDevices() = 0; virtual void OnLoadInputDevices() = 0;
void ActivateController(Core::System& system); void ActivateController();
void DeactivateController(); void DeactivateController();
@ -50,5 +50,7 @@ protected:
s64_le entry_count; s64_le entry_count;
}; };
static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -14,10 +14,11 @@ constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
constexpr s32 HID_JOYSTICK_MIN = -0x7fff; constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right }; enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
Controller_DebugPad::Controller_DebugPad() = default; Controller_DebugPad::Controller_DebugPad(Core::System& system)
: ControllerBase(system), system(system) {}
Controller_DebugPad::~Controller_DebugPad() = default; Controller_DebugPad::~Controller_DebugPad() = default;
void Controller_DebugPad::OnInit(Core::System& system) {} void Controller_DebugPad::OnInit() {}
void Controller_DebugPad::OnRelease() {} void Controller_DebugPad::OnRelease() {}

View file

@ -16,11 +16,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_DebugPad final : public ControllerBase { class Controller_DebugPad final : public ControllerBase {
public: public:
Controller_DebugPad(); explicit Controller_DebugPad(Core::System& system);
~Controller_DebugPad() override; ~Controller_DebugPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -89,5 +89,6 @@ private:
buttons; buttons;
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>
analogs; analogs;
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -10,10 +10,11 @@
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
Controller_Gesture::Controller_Gesture() = default; Controller_Gesture::Controller_Gesture(Core::System& system)
: ControllerBase(system), system(system) {}
Controller_Gesture::~Controller_Gesture() = default; Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit(Core::System& system) {} void Controller_Gesture::OnInit() {}
void Controller_Gesture::OnRelease() {} void Controller_Gesture::OnRelease() {}

View file

@ -12,11 +12,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_Gesture final : public ControllerBase { class Controller_Gesture final : public ControllerBase {
public: public:
Controller_Gesture(); Controller_Gesture(Core::System& system);
~Controller_Gesture() override; ~Controller_Gesture() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -59,5 +59,6 @@ private:
std::array<GestureState, 17> gesture_states; std::array<GestureState, 17> gesture_states;
}; };
SharedMemory shared_memory{}; SharedMemory shared_memory{};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -12,10 +12,11 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
constexpr u8 KEYS_PER_BYTE = 8; constexpr u8 KEYS_PER_BYTE = 8;
Controller_Keyboard::Controller_Keyboard() = default; Controller_Keyboard::Controller_Keyboard(Core::System& system)
: ControllerBase(system), system(system) {}
Controller_Keyboard::~Controller_Keyboard() = default; Controller_Keyboard::~Controller_Keyboard() = default;
void Controller_Keyboard::OnInit(Core::System& system) {} void Controller_Keyboard::OnInit() {}
void Controller_Keyboard::OnRelease() {} void Controller_Keyboard::OnRelease() {}

View file

@ -15,11 +15,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_Keyboard final : public ControllerBase { class Controller_Keyboard final : public ControllerBase {
public: public:
Controller_Keyboard(); Controller_Keyboard(Core::System& system);
~Controller_Keyboard() override; ~Controller_Keyboard() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -53,5 +53,6 @@ private:
keyboard_keys; keyboard_keys;
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeKeyboard::NumKeyboardMods> std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeKeyboard::NumKeyboardMods>
keyboard_mods; keyboard_mods;
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -11,10 +11,10 @@
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
Controller_Mouse::Controller_Mouse() = default; Controller_Mouse::Controller_Mouse(Core::System& system) : ControllerBase(system), system(system) {}
Controller_Mouse::~Controller_Mouse() = default; Controller_Mouse::~Controller_Mouse() = default;
void Controller_Mouse::OnInit(Core::System& system) {} void Controller_Mouse::OnInit() {}
void Controller_Mouse::OnRelease() {} void Controller_Mouse::OnRelease() {}
void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,

View file

@ -14,11 +14,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_Mouse final : public ControllerBase { class Controller_Mouse final : public ControllerBase {
public: public:
Controller_Mouse(); Controller_Mouse(Core::System& system);
~Controller_Mouse() override; ~Controller_Mouse() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -53,5 +53,6 @@ private:
std::unique_ptr<Input::MouseDevice> mouse_device; std::unique_ptr<Input::MouseDevice> mouse_device;
std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeMouseButton::NumMouseButtons> std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeMouseButton::NumMouseButtons>
mouse_button_devices; mouse_button_devices;
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -93,7 +93,7 @@ u32 Controller_NPad::IndexToNPad(std::size_t index) {
}; };
} }
Controller_NPad::Controller_NPad() = default; Controller_NPad::Controller_NPad(Core::System& system) : ControllerBase(system), system(system) {}
Controller_NPad::~Controller_NPad() = default; Controller_NPad::~Controller_NPad() = default;
void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) { void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
@ -167,7 +167,7 @@ void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
controller.battery_level[2] = BATTERY_FULL; controller.battery_level[2] = BATTERY_FULL;
} }
void Controller_NPad::OnInit(Core::System& system) { void Controller_NPad::OnInit() {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
styleset_changed_event = Kernel::WritableEvent::CreateEventPair( styleset_changed_event = Kernel::WritableEvent::CreateEventPair(
kernel, Kernel::ResetType::Automatic, "npad:NpadStyleSetChanged"); kernel, Kernel::ResetType::Automatic, "npad:NpadStyleSetChanged");

View file

@ -20,11 +20,11 @@ constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this?
class Controller_NPad final : public ControllerBase { class Controller_NPad final : public ControllerBase {
public: public:
Controller_NPad(); Controller_NPad(Core::System& system);
~Controller_NPad() override; ~Controller_NPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -327,5 +327,6 @@ private:
std::array<ControllerPad, 10> npad_pad_states{}; std::array<ControllerPad, 10> npad_pad_states{};
bool IsControllerSupported(NPadControllerType controller); bool IsControllerSupported(NPadControllerType controller);
bool is_in_lr_assignment_mode{false}; bool is_in_lr_assignment_mode{false};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -9,10 +9,11 @@
namespace Service::HID { namespace Service::HID {
Controller_Stubbed::Controller_Stubbed() = default; Controller_Stubbed::Controller_Stubbed(Core::System& system)
: ControllerBase(system), system(system) {}
Controller_Stubbed::~Controller_Stubbed() = default; Controller_Stubbed::~Controller_Stubbed() = default;
void Controller_Stubbed::OnInit(Core::System& system) {} void Controller_Stubbed::OnInit() {}
void Controller_Stubbed::OnRelease() {} void Controller_Stubbed::OnRelease() {}

View file

@ -10,11 +10,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_Stubbed final : public ControllerBase { class Controller_Stubbed final : public ControllerBase {
public: public:
Controller_Stubbed(); Controller_Stubbed(Core::System& system);
~Controller_Stubbed() override; ~Controller_Stubbed() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -30,5 +30,6 @@ public:
private: private:
bool smart_update{}; bool smart_update{};
std::size_t common_offset{}; std::size_t common_offset{};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -13,10 +13,11 @@
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
Controller_Touchscreen::Controller_Touchscreen() = default; Controller_Touchscreen::Controller_Touchscreen(Core::System& system)
: ControllerBase(system), system(system) {}
Controller_Touchscreen::~Controller_Touchscreen() = default; Controller_Touchscreen::~Controller_Touchscreen() = default;
void Controller_Touchscreen::OnInit(Core::System& system) {} void Controller_Touchscreen::OnInit() {}
void Controller_Touchscreen::OnRelease() {} void Controller_Touchscreen::OnRelease() {}

View file

@ -14,11 +14,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_Touchscreen final : public ControllerBase { class Controller_Touchscreen final : public ControllerBase {
public: public:
Controller_Touchscreen(); Controller_Touchscreen(Core::System& system);
~Controller_Touchscreen() override; ~Controller_Touchscreen() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -69,5 +69,6 @@ private:
TouchScreenSharedMemory shared_memory{}; TouchScreenSharedMemory shared_memory{};
std::unique_ptr<Input::TouchDevice> touch_device; std::unique_ptr<Input::TouchDevice> touch_device;
s64_le last_touch{}; s64_le last_touch{};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -10,10 +10,10 @@
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
Controller_XPad::Controller_XPad() = default; Controller_XPad::Controller_XPad(Core::System& system) : ControllerBase(system), system(system) {}
Controller_XPad::~Controller_XPad() = default; Controller_XPad::~Controller_XPad() = default;
void Controller_XPad::OnInit(Core::System& system) {} void Controller_XPad::OnInit() {}
void Controller_XPad::OnRelease() {} void Controller_XPad::OnRelease() {}

View file

@ -12,11 +12,11 @@
namespace Service::HID { namespace Service::HID {
class Controller_XPad final : public ControllerBase { class Controller_XPad final : public ControllerBase {
public: public:
Controller_XPad(); Controller_XPad(Core::System& system);
~Controller_XPad() override; ~Controller_XPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit(Core::System& system) override; void OnInit() override;
// When the controller is released // When the controller is released
void OnRelease() override; void OnRelease() override;
@ -56,5 +56,6 @@ private:
}; };
static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size"); static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
SharedMemory shared_memory{}; SharedMemory shared_memory{};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -67,8 +67,8 @@ IAppletResource::IAppletResource(Core::System& system)
MakeController<Controller_Gesture>(HidController::Gesture); MakeController<Controller_Gesture>(HidController::Gesture);
// Homebrew doesn't try to activate some controllers, so we activate them by default // Homebrew doesn't try to activate some controllers, so we activate them by default
GetController<Controller_NPad>(HidController::NPad).ActivateController(system); GetController<Controller_NPad>(HidController::NPad).ActivateController();
GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController(system); GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController();
GetController<Controller_Stubbed>(HidController::Unknown1).SetCommonHeaderOffset(0x4c00); GetController<Controller_Stubbed>(HidController::Unknown1).SetCommonHeaderOffset(0x4c00);
GetController<Controller_Stubbed>(HidController::Unknown2).SetCommonHeaderOffset(0x4e00); GetController<Controller_Stubbed>(HidController::Unknown2).SetCommonHeaderOffset(0x4e00);
@ -89,7 +89,7 @@ IAppletResource::IAppletResource(Core::System& system)
} }
void IAppletResource::ActivateController(HidController controller) { void IAppletResource::ActivateController(HidController controller) {
controllers[static_cast<size_t>(controller)]->ActivateController(system); controllers[static_cast<size_t>(controller)]->ActivateController();
} }
void IAppletResource::DeactivateController(HidController controller) { void IAppletResource::DeactivateController(HidController controller) {

View file

@ -42,7 +42,7 @@ enum class HidController : std::size_t {
class IAppletResource final : public ServiceFramework<IAppletResource> { class IAppletResource final : public ServiceFramework<IAppletResource> {
public: public:
IAppletResource(Core::System& system); explicit IAppletResource(Core::System& system);
~IAppletResource() override; ~IAppletResource() override;
void ActivateController(HidController controller); void ActivateController(HidController controller);
@ -61,7 +61,7 @@ public:
private: private:
template <typename T> template <typename T>
void MakeController(HidController controller) { void MakeController(HidController controller) {
controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(); controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>(system);
} }
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx); void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
@ -78,7 +78,7 @@ private:
class Hid final : public ServiceFramework<Hid> { class Hid final : public ServiceFramework<Hid> {
public: public:
Hid(Core::System& system); explicit Hid(Core::System& system);
~Hid() override; ~Hid() override;
std::shared_ptr<IAppletResource> GetAppletResource(); std::shared_ptr<IAppletResource> GetAppletResource();

View file

@ -126,7 +126,7 @@ public:
class IEnsureNetworkClockAvailabilityService final class IEnsureNetworkClockAvailabilityService final
: public ServiceFramework<IEnsureNetworkClockAvailabilityService> { : public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
public: public:
IEnsureNetworkClockAvailabilityService(Core::System& system) explicit IEnsureNetworkClockAvailabilityService(Core::System& system)
: ServiceFramework("IEnsureNetworkClockAvailabilityService") { : ServiceFramework("IEnsureNetworkClockAvailabilityService") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},

View file

@ -20,7 +20,7 @@ void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& out
class PL_U final : public ServiceFramework<PL_U> { class PL_U final : public ServiceFramework<PL_U> {
public: public:
PL_U(Core::System& system); explicit PL_U(Core::System& system);
~PL_U() override; ~PL_U() override;
private: private:

View file

@ -29,8 +29,7 @@ namespace Service::NVFlinger {
constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60); constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60);
constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 30); constexpr s64 frame_ticks_30fps = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 30);
NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing, Core::System& system) NVFlinger::NVFlinger(Core::System& system) : system(system) {
: core_timing{core_timing}, system(system) {
displays.emplace_back(0, "Default", system); displays.emplace_back(0, "Default", system);
displays.emplace_back(1, "External", system); displays.emplace_back(1, "External", system);
displays.emplace_back(2, "Edid", system); displays.emplace_back(2, "Edid", system);
@ -38,18 +37,20 @@ NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing, Core::System& system
displays.emplace_back(4, "Null", system); displays.emplace_back(4, "Null", system);
// Schedule the screen composition events // Schedule the screen composition events
composition_event = core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, composition_event = system.CoreTiming().RegisterEvent(
s64 cycles_late) { "ScreenComposition", [this](u64 userdata, s64 cycles_late) {
Compose(); Compose();
const auto ticks = Settings::values.force_30fps_mode ? frame_ticks_30fps : GetNextTicks(); const auto ticks =
this->core_timing.ScheduleEvent(std::max<s64>(0LL, ticks - cycles_late), composition_event); Settings::values.force_30fps_mode ? frame_ticks_30fps : GetNextTicks();
this->system.CoreTiming().ScheduleEvent(std::max<s64>(0LL, ticks - cycles_late),
composition_event);
}); });
core_timing.ScheduleEvent(frame_ticks, composition_event); system.CoreTiming().ScheduleEvent(frame_ticks, composition_event);
} }
NVFlinger::~NVFlinger() { NVFlinger::~NVFlinger() {
core_timing.UnscheduleEvent(composition_event, 0); system.CoreTiming().UnscheduleEvent(composition_event, 0);
} }
void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {

View file

@ -38,7 +38,7 @@ class BufferQueue;
class NVFlinger final { class NVFlinger final {
public: public:
explicit NVFlinger(Core::Timing::CoreTiming& core_timing, Core::System& system); explicit NVFlinger(Core::System& system);
~NVFlinger(); ~NVFlinger();
/// Sets the NVDrv module instance to use to send buffers to the GPU. /// Sets the NVDrv module instance to use to send buffers to the GPU.
@ -105,9 +105,6 @@ private:
/// Event that handles screen composition. /// Event that handles screen composition.
Core::Timing::EventType* composition_event; Core::Timing::EventType* composition_event;
/// Core timing instance for registering/unregistering the composition event.
Core::Timing::CoreTiming& core_timing;
Core::System& system; Core::System& system;
}; };