controller_base.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include "common/common_types.h"
  6. #include "core/hle/result.h"
  7. #include "hid_core/resources/applet_resource.h"
  8. namespace Core::Timing {
  9. class CoreTiming;
  10. }
  11. namespace Core::HID {
  12. class HIDCore;
  13. } // namespace Core::HID
  14. namespace Service::HID {
  15. class ControllerBase {
  16. public:
  17. explicit ControllerBase(Core::HID::HIDCore& hid_core_);
  18. virtual ~ControllerBase();
  19. // Called when the controller is initialized
  20. virtual void OnInit() = 0;
  21. // When the controller is released
  22. virtual void OnRelease() = 0;
  23. // When the controller is requesting an update for the shared memory
  24. virtual void OnUpdate(const Core::Timing::CoreTiming& core_timing) = 0;
  25. // When the controller is requesting a motion update for the shared memory
  26. virtual void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) {}
  27. Result Activate();
  28. Result Activate(u64 aruid);
  29. void DeactivateController();
  30. bool IsControllerActivated() const;
  31. void SetAppletResource(std::shared_ptr<AppletResource> resource,
  32. std::recursive_mutex* resource_mutex);
  33. protected:
  34. bool is_activated{false};
  35. std::shared_ptr<AppletResource> applet_resource{nullptr};
  36. std::recursive_mutex* shared_mutex{nullptr};
  37. Core::HID::HIDCore& hid_core;
  38. };
  39. } // namespace Service::HID