suyu/src/hid_core/resources/controller_base.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
C++
Raw Normal View History

// 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
#include <memory>
2018-10-05 14:23:21 +00:00
#include "common/common_types.h"
#include "core/hle/result.h"
#include "hid_core/resources/applet_resource.h"
2018-10-05 14:23:21 +00:00
namespace Core::Timing {
class CoreTiming;
}
namespace Core::HID {
class HIDCore;
} // 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:
explicit ControllerBase(Core::HID::HIDCore& hid_core_);
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
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
virtual void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {}
2020-09-23 22:51:09 +00:00
Result Activate();
Result Activate(u64 aruid);
2018-10-05 14:23:21 +00:00
void DeactivateController();
bool IsControllerActivated() const;
void SetAppletResource(std::shared_ptr<AppletResource> resource,
std::recursive_mutex* resource_mutex);
2018-10-05 14:23:21 +00:00
protected:
bool is_activated{false};
std::shared_ptr<AppletResource> applet_resource{nullptr};
std::recursive_mutex* shared_mutex{nullptr};
2018-10-05 14:23:21 +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