2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-10-05 14:23:21 +00:00
|
|
|
|
|
|
|
#pragma once
|
2018-10-06 03:14:42 +00:00
|
|
|
|
2023-12-31 06:42:23 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-10-05 14:23:21 +00:00
|
|
|
#include "common/common_types.h"
|
2023-11-16 23:58:05 +00:00
|
|
|
#include "core/hle/result.h"
|
2024-01-05 02:37:43 +00:00
|
|
|
#include "hid_core/resources/applet_resource.h"
|
2018-10-05 14:23:21 +00:00
|
|
|
|
2019-02-14 17:42:58 +00:00
|
|
|
namespace Core::Timing {
|
|
|
|
class CoreTiming;
|
|
|
|
}
|
|
|
|
|
2021-11-05 01:05:58 +00:00
|
|
|
namespace Core::HID {
|
|
|
|
class HIDCore;
|
2023-12-31 06:42:23 +00:00
|
|
|
} // namespace Core::HID
|
2019-09-21 08:43:43 +00:00
|
|
|
|
2018-10-05 14:23:21 +00:00
|
|
|
namespace Service::HID {
|
|
|
|
class ControllerBase {
|
|
|
|
public:
|
2021-11-05 01:05:58 +00:00
|
|
|
explicit ControllerBase(Core::HID::HIDCore& hid_core_);
|
2018-10-18 00:28:16 +00:00
|
|
|
virtual ~ControllerBase();
|
2018-10-05 14:23:21 +00:00
|
|
|
|
|
|
|
// Called when the controller is initialized
|
2019-09-22 06:41:34 +00:00
|
|
|
virtual void OnInit() = 0;
|
2018-10-05 14:23:21 +00:00
|
|
|
|
|
|
|
// When the controller is released
|
|
|
|
virtual void OnRelease() = 0;
|
|
|
|
|
|
|
|
// When the controller is requesting an update for the shared memory
|
2022-04-19 20:30:32 +00:00
|
|
|
virtual void OnUpdate(const Core::Timing::CoreTiming& core_timing) = 0;
|
2018-10-05 14:23:21 +00:00
|
|
|
|
2020-09-23 22:51:09 +00:00
|
|
|
// When the controller is requesting a motion update for the shared memory
|
2022-04-19 20:30:32 +00:00
|
|
|
virtual void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {}
|
2020-09-23 22:51:09 +00:00
|
|
|
|
2023-11-16 23:58:05 +00:00
|
|
|
Result Activate();
|
|
|
|
Result Activate(u64 aruid);
|
2018-10-05 14:23:21 +00:00
|
|
|
|
|
|
|
void DeactivateController();
|
|
|
|
|
|
|
|
bool IsControllerActivated() const;
|
|
|
|
|
2024-01-02 03:33:07 +00:00
|
|
|
void SetAppletResource(std::shared_ptr<AppletResource> resource,
|
|
|
|
std::recursive_mutex* resource_mutex);
|
2023-12-31 06:42:23 +00:00
|
|
|
|
2018-10-05 14:23:21 +00:00
|
|
|
protected:
|
|
|
|
bool is_activated{false};
|
2023-12-31 06:42:23 +00:00
|
|
|
std::shared_ptr<AppletResource> applet_resource{nullptr};
|
2024-01-02 03:33:07 +00:00
|
|
|
std::recursive_mutex* shared_mutex{nullptr};
|
2018-10-05 14:23:21 +00:00
|
|
|
|
2021-11-05 01:05:58 +00:00
|
|
|
Core::HID::HIDCore& hid_core;
|
2018-10-05 14:23:21 +00:00
|
|
|
};
|
2018-10-06 03:14:42 +00:00
|
|
|
} // namespace Service::HID
|