Browse Source

starter 1

pull/2953/head
Maufeat 3 months ago
parent
commit
7dd1f4dc83
  1. 1
      src/core/hle/service/am/am_types.h
  2. 11
      src/core/hle/service/am/button_poller.cpp
  3. 33
      src/core/hle/service/am/service/application_creator.cpp
  4. 1
      src/core/hle/service/am/service/application_creator.h
  5. 25
      src/core/hle/service/am/service/common_state_getter.cpp
  6. 1
      src/core/hle/service/am/service/common_state_getter.h

1
src/core/hle/service/am/am_types.h

@ -150,6 +150,7 @@ enum class AppletMessage : u32 {
ForceHideApplicationLogo = 57,
FloatingApplicationDetected = 60,
DetectShortPressingCaptureButton = 90,
DetectLongPressingCaptureButton = 91,
AlbumScreenShotTaken = 92,
AlbumRecordingSaved = 93,
};

11
src/core/hle/service/am/button_poller.cpp

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "core/hle/service/am/am_types.h"
#include "core/hle/service/am/button_poller.h"
#include "core/hle/service/am/window_system.h"
#include "hid_core/frontend/emulated_controller.h"
@ -73,11 +74,17 @@ void ButtonPoller::OnButtonStateChanged() {
// Buttons released which were previously held
if (!home_button && m_home_button_press_start) {
m_window_system.OnHomeButtonPressed(ClassifyPressDuration(*m_home_button_press_start));
const auto duration = ClassifyPressDuration(*m_home_button_press_start);
m_window_system.OnSystemButtonPress(
duration == ButtonPressDuration::ShortPressing ? SystemButtonType::HomeButtonShortPressing
: SystemButtonType::HomeButtonLongPressing);
m_home_button_press_start = std::nullopt;
}
if (!capture_button && m_capture_button_press_start) {
// TODO
const auto duration = ClassifyPressDuration(*m_capture_button_press_start);
m_window_system.OnSystemButtonPress(
duration == ButtonPressDuration::ShortPressing ? SystemButtonType::CaptureButtonShortPressing
: SystemButtonType::CaptureButtonLongPressing);
m_capture_button_press_start = std::nullopt;
}
// if (!power_button && m_power_button_press_start) {

33
src/core/hle/service/am/service/application_creator.cpp

@ -60,7 +60,7 @@ IApplicationCreator::IApplicationCreator(Core::System& system_, WindowSystem& wi
static const FunctionInfo functions[] = {
{0, D<&IApplicationCreator::CreateApplication>, "CreateApplication"},
{1, nullptr, "PopLaunchRequestedApplication"},
{10, nullptr, "CreateSystemApplication"},
{10, D<&IApplicationCreator::CreateSystemApplication>, "CreateSystemApplication"},
{100, nullptr, "PopFloatingApplicationForDevelopment"},
};
// clang-format on
@ -77,4 +77,35 @@ Result IApplicationCreator::CreateApplication(
CreateGuestApplication(out_application_accessor, system, m_window_system, application_id));
}
Result IApplicationCreator::CreateSystemApplication(
Out<SharedPointer<IApplicationAccessor>> out_application_accessor, u64 application_id) {
FileSys::VirtualFile nca_raw{};
auto& storage = system.GetContentProviderUnion();
nca_raw = storage.GetEntryRaw(application_id, FileSys::ContentRecordType::Program);
R_UNLESS(nca_raw != nullptr, ResultUnknown);
std::vector<u8> control;
std::unique_ptr<Loader::AppLoader> loader;
Loader::ResultStatus result;
auto process =
CreateProcess(system, application_id, 1, 21);
R_UNLESS(process != nullptr, ResultUnknown);
const auto applet = std::make_shared<Applet>(system, std::move(process), true);
applet->program_id = application_id;
applet->applet_id = AppletId::Starter;
applet->type = AppletType::LibraryApplet;
applet->library_applet_mode = LibraryAppletMode::AllForeground;
m_window_system.TrackApplet(applet, true);
*out_application_accessor =
std::make_shared<IApplicationAccessor>(system, applet, m_window_system);
R_SUCCEED();
}
} // namespace Service::AM

1
src/core/hle/service/am/service/application_creator.h

@ -19,6 +19,7 @@ public:
private:
Result CreateApplication(Out<SharedPointer<IApplicationAccessor>>, u64 application_id);
Result CreateSystemApplication(Out<SharedPointer<IApplicationAccessor>>, u64 application_id);
WindowSystem& m_window_system;
};

25
src/core/hle/service/am/service/common_state_getter.cpp

@ -61,7 +61,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{80, D<&ICommonStateGetter::PerformSystemButtonPressingIfInFocus>, "PerformSystemButtonPressingIfInFocus"},
{90, nullptr, "SetPerformanceConfigurationChangedNotification"},
{91, nullptr, "GetCurrentPerformanceConfiguration"},
{100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
{100, D<&ICommonStateGetter::SetHandlingHomeButtonShortPressedEnabled>, "SetHandlingHomeButtonShortPressedEnabled"},
{110, nullptr, "OpenMyGpuErrorHandler"},
{120, D<&ICommonStateGetter::GetAppletLaunchedHistory>, "GetAppletLaunchedHistory"},
{200, D<&ICommonStateGetter::GetOperationModeSystemInfo>, "GetOperationModeSystemInfo"},
@ -268,6 +268,18 @@ Result ICommonStateGetter::PerformSystemButtonPressingIfInFocus(SystemButtonType
AppletMessage::DetectLongPressingHomeButton);
}
break;
case SystemButtonType::CaptureButtonShortPressing:
if (m_applet->handling_capture_button_short_pressed_message_enabled_for_applet) {
m_applet->lifecycle_manager.PushUnorderedMessage(
AppletMessage::DetectShortPressingCaptureButton);
}
break;
case SystemButtonType::CaptureButtonLongPressing:
if (m_applet->handling_capture_button_long_pressed_message_enabled_for_applet) {
m_applet->lifecycle_manager.PushUnorderedMessage(
AppletMessage::DetectLongPressingCaptureButton);
}
break;
default:
// Other buttons ignored for now
break;
@ -316,12 +328,15 @@ Result ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnab
Result ICommonStateGetter::PushToGeneralChannel(SharedPointer<IStorage> storage) {
LOG_DEBUG(Service_AM, "called");
system.PushGeneralChannelData(storage->GetData());
R_SUCCEED();
}
std::scoped_lock lk{m_applet->lock};
// Push to a general-purpose channel and notify listeners via event
m_applet->user_channel_launch_parameter.push_back(storage->GetData());
m_applet->pop_from_general_channel_event.Signal();
Result ICommonStateGetter::SetHandlingHomeButtonShortPressedEnabled(bool enabled) {
LOG_DEBUG(Service_AM, "called, enabled={} applet_id={}", enabled, m_applet->applet_id);
std::scoped_lock lk{m_applet->lock};
m_applet->home_button_short_pressed_blocked = !enabled;
R_SUCCEED();
}

1
src/core/hle/service/am/service/common_state_getter.h

@ -60,6 +60,7 @@ private:
Result GetSettingsPlatformRegion(Out<Set::PlatformRegion> out_settings_platform_region);
Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled();
Result PushToGeneralChannel(SharedPointer<IStorage> storage); // cmd 20
Result SetHandlingHomeButtonShortPressedEnabled(bool enabled);
void SetCpuBoostMode(HLERequestContext& ctx);

Loading…
Cancel
Save