applet_oe.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/logging/log.h"
  4. #include "core/hle/service/am/am.h"
  5. #include "core/hle/service/am/applet_oe.h"
  6. #include "core/hle/service/ipc_helpers.h"
  7. #include "core/hle/service/nvnflinger/nvnflinger.h"
  8. namespace Service::AM {
  9. class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
  10. public:
  11. explicit IApplicationProxy(Nvnflinger::Nvnflinger& nvnflinger_,
  12. std::shared_ptr<AppletMessageQueue> msg_queue_,
  13. Core::System& system_)
  14. : ServiceFramework{system_, "IApplicationProxy"},
  15. nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} {
  16. // clang-format off
  17. static const FunctionInfo functions[] = {
  18. {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"},
  19. {1, &IApplicationProxy::GetSelfController, "GetSelfController"},
  20. {2, &IApplicationProxy::GetWindowController, "GetWindowController"},
  21. {3, &IApplicationProxy::GetAudioController, "GetAudioController"},
  22. {4, &IApplicationProxy::GetDisplayController, "GetDisplayController"},
  23. {10, nullptr, "GetProcessWindingController"},
  24. {11, &IApplicationProxy::GetLibraryAppletCreator, "GetLibraryAppletCreator"},
  25. {20, &IApplicationProxy::GetApplicationFunctions, "GetApplicationFunctions"},
  26. {1000, &IApplicationProxy::GetDebugFunctions, "GetDebugFunctions"},
  27. };
  28. // clang-format on
  29. RegisterHandlers(functions);
  30. }
  31. private:
  32. void GetAudioController(HLERequestContext& ctx) {
  33. LOG_DEBUG(Service_AM, "called");
  34. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  35. rb.Push(ResultSuccess);
  36. rb.PushIpcInterface<IAudioController>(system);
  37. }
  38. void GetDisplayController(HLERequestContext& ctx) {
  39. LOG_DEBUG(Service_AM, "called");
  40. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  41. rb.Push(ResultSuccess);
  42. rb.PushIpcInterface<IDisplayController>(system);
  43. }
  44. void GetDebugFunctions(HLERequestContext& ctx) {
  45. LOG_DEBUG(Service_AM, "called");
  46. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  47. rb.Push(ResultSuccess);
  48. rb.PushIpcInterface<IDebugFunctions>(system);
  49. }
  50. void GetWindowController(HLERequestContext& ctx) {
  51. LOG_DEBUG(Service_AM, "called");
  52. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  53. rb.Push(ResultSuccess);
  54. rb.PushIpcInterface<IWindowController>(system);
  55. }
  56. void GetSelfController(HLERequestContext& ctx) {
  57. LOG_DEBUG(Service_AM, "called");
  58. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  59. rb.Push(ResultSuccess);
  60. rb.PushIpcInterface<ISelfController>(system, nvnflinger);
  61. }
  62. void GetCommonStateGetter(HLERequestContext& ctx) {
  63. LOG_DEBUG(Service_AM, "called");
  64. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  65. rb.Push(ResultSuccess);
  66. rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue);
  67. }
  68. void GetLibraryAppletCreator(HLERequestContext& ctx) {
  69. LOG_DEBUG(Service_AM, "called");
  70. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  71. rb.Push(ResultSuccess);
  72. rb.PushIpcInterface<ILibraryAppletCreator>(system);
  73. }
  74. void GetApplicationFunctions(HLERequestContext& ctx) {
  75. LOG_DEBUG(Service_AM, "called");
  76. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  77. rb.Push(ResultSuccess);
  78. rb.PushIpcInterface<IApplicationFunctions>(system);
  79. }
  80. Nvnflinger::Nvnflinger& nvnflinger;
  81. std::shared_ptr<AppletMessageQueue> msg_queue;
  82. };
  83. void AppletOE::OpenApplicationProxy(HLERequestContext& ctx) {
  84. LOG_DEBUG(Service_AM, "called");
  85. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  86. rb.Push(ResultSuccess);
  87. rb.PushIpcInterface<IApplicationProxy>(nvnflinger, msg_queue, system);
  88. }
  89. AppletOE::AppletOE(Nvnflinger::Nvnflinger& nvnflinger_,
  90. std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_)
  91. : ServiceFramework{system_, "appletOE"}, nvnflinger{nvnflinger_}, msg_queue{
  92. std::move(msg_queue_)} {
  93. static const FunctionInfo functions[] = {
  94. {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"},
  95. };
  96. RegisterHandlers(functions);
  97. }
  98. AppletOE::~AppletOE() = default;
  99. const std::shared_ptr<AppletMessageQueue>& AppletOE::GetMessageQueue() const {
  100. return msg_queue;
  101. }
  102. } // namespace Service::AM