Compare commits

...

9 Commits

Author SHA1 Message Date
Morph
8d86c37bf7 Merge branch 'am_notification' of https://github.com/Morph1984/yuzu into am_notification 2019-11-28 22:24:12 -05:00
Morph
b7bd8a764c Stub SetAlbumImageTakenNotificationEnabled since Screenshot is not implemented 2019-11-28 22:23:08 -05:00
Morph
def989cfe6 Fixed the accessing of methods 2019-11-28 22:21:28 -05:00
Morph
3d62387770 Create accessor methods and deglobalize variables 2019-11-28 22:21:28 -05:00
Morph
11184fd433 Implement SetOperationModeChangedNotification and SetAlbumImageTakenNotificationEnabled
These are typically set to true on application boot, these values determine whether an AppletMessage gets sent when certain actions are performed such as changing from docked to undocked, capturing a screenshot, etc.
2019-11-28 22:21:28 -05:00
Morph
09ff1a3c10 Stub SetAlbumImageTakenNotificationEnabled since Screenshot is not implemented 2019-11-27 02:41:43 -05:00
Morph
41ef97585a Fixed the accessing of methods 2019-11-27 02:41:43 -05:00
Morph
69f0b6e5c7 Create accessor methods and deglobalize variables 2019-11-27 02:41:43 -05:00
Morph
65d89cd553 Implement SetOperationModeChangedNotification and SetAlbumImageTakenNotificationEnabled
These are typically set to true on application boot, these values determine whether an AppletMessage gets sent when certain actions are performed such as changing from docked to undocked, capturing a screenshot, etc.
2019-11-27 02:41:08 -05:00
3 changed files with 76 additions and 29 deletions

View File

@@ -290,7 +290,7 @@ ISelfController::ISelfController(Core::System& system,
{80, nullptr, "SetWirelessPriorityMode"},
{90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
{91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
{100, nullptr, "SetAlbumImageTakenNotificationEnabled"},
{100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
{110, nullptr, "SetApplicationAlbumUserData"},
{1000, nullptr, "GetDebugStorageChannel"},
};
@@ -315,7 +315,7 @@ ISelfController::ISelfController(Core::System& system,
ISelfController::~ISelfController() = default;
void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
LOG_DEBUG(Service_AM, "called.");
system.Shutdown();
@@ -324,7 +324,7 @@ void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
}
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
LOG_DEBUG(Service_AM, "called.");
system.SetExitLock(true);
@@ -333,7 +333,7 @@ void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
}
void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
LOG_DEBUG(Service_AM, "called.");
system.SetExitLock(false);
@@ -366,7 +366,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
}
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
launchable_event.writable->Signal();
@@ -376,7 +376,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext&
}
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@@ -384,9 +384,10 @@ void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
operation_mode_changed_notification = rp.Pop<bool>();
bool flag = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
LOG_DEBUG(Service_AM, "called. operation_mode_changed_notification={}",
operation_mode_changed_notification);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@@ -394,9 +395,10 @@ void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestCont
void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
performance_mode_changed_notification = rp.Pop<bool>();
bool flag = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
LOG_WARNING(Service_AM, "(STUBBED) called. performance_mode_changed_notification={}",
performance_mode_changed_notification);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@@ -422,33 +424,37 @@ void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
}
void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::RequestParser rp{ctx};
restart_message_enabled = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called. restart_message_enabled={}",
restart_message_enabled);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
// Takes 3 input u8s with each field located immediately after the previous
// u8, these are bool flags. No output.
// Takes an input u8 bool flag. No output.
IPC::RequestParser rp{ctx};
out_of_focus_suspending_enabled = rp.Pop<bool>();
bool enabled = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
LOG_WARNING(Service_AM, "(STUBBED) called. out_of_focus_suspending_enabled={}",
out_of_focus_suspending_enabled);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
// TODO(Subv): Find out how AM determines the display to use, for now just
// create the layer in the Default display.
@@ -461,7 +467,7 @@ void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx)
}
void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
@@ -470,7 +476,7 @@ void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx)
void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
idle_time_detection_extension = rp.Pop<u32>();
LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}",
LOG_WARNING(Service_AM, "(STUBBED) called. idle_time_detection_extension={}",
idle_time_detection_extension);
IPC::ResponseBuilder rb{ctx, 2};
@@ -478,7 +484,7 @@ void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& c
}
void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS);
@@ -532,16 +538,39 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest
rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable);
}
void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
album_image_taken_notification_enabled = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called. album_image_taken_notification_enabled={}",
album_image_taken_notification_enabled);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
bool ISelfController::GetOperationModeChangedNotification() const {
return operation_mode_changed_notification;
}
bool ISelfController::GetPerformanceModeChangedNotification() const {
return performance_mode_changed_notification;
}
bool ISelfController::GetAlbumImageTakenNotificationEnabled() const {
return album_image_taken_notification_enabled;
}
AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) {
on_new_message =
Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageRecieved");
Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageReceived");
on_operation_mode_changed =
Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged");
}
AppletMessageQueue::~AppletMessageQueue() = default;
const std::shared_ptr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageRecieveEvent() const {
const std::shared_ptr<Kernel::ReadableEvent>& AppletMessageQueue::GetMessageReceiveEvent() const {
return on_new_message.readable;
}
@@ -572,14 +601,18 @@ std::size_t AppletMessageQueue::GetMessageCount() const {
return messages.size();
}
void AppletMessageQueue::RequestExit() {
PushMessage(AppletMessage::ExitRequested);
}
void AppletMessageQueue::OperationModeChanged() {
PushMessage(AppletMessage::OperationModeChanged);
PushMessage(AppletMessage::PerformanceModeChanged);
on_operation_mode_changed.writable->Signal();
}
void AppletMessageQueue::RequestExit() {
PushMessage(AppletMessage::ExitRequested);
void AppletMessageQueue::ScreenshotTaken() {
PushMessage(AppletMessage::ScreenshotTaken);
}
ICommonStateGetter::ICommonStateGetter(Core::System& system,
@@ -645,7 +678,7 @@ void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent());
rb.PushCopyObjects(msg_queue->GetMessageReceiveEvent());
}
void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {

View File

@@ -49,18 +49,20 @@ public:
FocusStateChanged = 15,
OperationModeChanged = 30,
PerformanceModeChanged = 31,
ScreenshotTaken = 92,
};
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
~AppletMessageQueue();
const std::shared_ptr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const;
const std::shared_ptr<Kernel::ReadableEvent>& GetMesssageReceiveEvent() const;
const std::shared_ptr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const;
void PushMessage(AppletMessage msg);
AppletMessage PopMessage();
std::size_t GetMessageCount() const;
void OperationModeChanged();
void RequestExit();
void OperationModeChanged();
void ScreenshotTaken();
private:
std::queue<AppletMessage> messages;
@@ -124,6 +126,10 @@ public:
std::shared_ptr<NVFlinger::NVFlinger> nvflinger_);
~ISelfController() override;
bool GetOperationModeChangedNotification() const;
bool GetPerformanceModeChangedNotification() const;
bool GetAlbumImageTakenNotificationEnabled() const;
private:
void Exit(Kernel::HLERequestContext& ctx);
void LockExit(Kernel::HLERequestContext& ctx);
@@ -146,6 +152,7 @@ private:
void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx);
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx);
Core::System& system;
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
@@ -154,6 +161,11 @@ private:
u32 idle_time_detection_extension = 0;
u64 num_fatal_sections_entered = 0;
bool operation_mode_changed_notification = false;
bool performance_mode_changed_notification = false;
bool restart_message_enabled = false;
bool out_of_focus_suspending_enabled = false;
bool album_image_taken_notification_enabled = false;
bool is_auto_sleep_disabled = false;
};

View File

@@ -36,14 +36,16 @@ void OnDockedModeChanged(bool last_state, bool new_state) {
// change to one and it will handle both automatically
auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
auto isc = sm.GetService<Service::AM::ISelfController>("ISelfController");
bool is_notification_enabled = isc->GetOperationModeChangedNotification();
bool has_signalled = false;
if (applet_oe != nullptr) {
if (applet_oe != nullptr && is_notification_enabled) {
applet_oe->GetMessageQueue()->OperationModeChanged();
has_signalled = true;
}
if (applet_ae != nullptr && !has_signalled) {
if (applet_ae != nullptr && !has_signalled && is_notification_enabled) {
applet_ae->GetMessageQueue()->OperationModeChanged();
}
}