Stub bt and btm:u

Stub BT services which is required by titles such as Pokémon Let's GO Pikachu and Eevee (non-Demo versions).
This commit is contained in:
shutterbug2000 2022-05-11 04:12:53 -05:00 committed by ◱ Mark
parent 588b4529ee
commit f078a5d1ec
8 changed files with 158 additions and 0 deletions

View File

@ -253,6 +253,9 @@ add_library(skyline SHARED
${source_DIR}/skyline/services/am/applet/IApplet.cpp
${source_DIR}/skyline/services/bcat/IServiceCreator.cpp
${source_DIR}/skyline/services/bcat/IBcatService.cpp
${source_DIR}/skyline/services/bt/IBluetoothUser.cpp
${source_DIR}/skyline/services/btm/IBtmUser.cpp
${source_DIR}/skyline/services/btm/IBtmUserCore.cpp
${source_DIR}/skyline/applet/applet_creator.cpp
${source_DIR}/skyline/applet/controller_applet.cpp
${source_DIR}/skyline/services/codec/IHardwareOpusDecoder.cpp

View File

@ -0,0 +1,8 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IBluetoothUser.h"
namespace skyline::service::bt {
IBluetoothUser::IBluetoothUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
}

View File

@ -0,0 +1,17 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/serviceman.h>
namespace skyline::service::bt {
/**
* @brief IBluetoothUser is used to interact with BLE (Bluetooth Low Energy) devices
* @url https://switchbrew.org/wiki/BTM_services#btm:u
*/
class IBluetoothUser : public BaseService {
public:
IBluetoothUser(const DeviceState &state, ServiceManager &manager);
};
}

View File

@ -0,0 +1,13 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IBtmUser.h"
namespace skyline::service::btm {
IBtmUser::IBtmUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
Result IBtmUser::GetCore(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(SRVREG(IBtmUserCore), session, response);
return {};
}
}

View File

@ -0,0 +1,27 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/serviceman.h>
#include "IBtmUserCore.h"
namespace skyline::service::btm {
/**
* @brief IBtmUser is used to create a BtmUserCore instance
* @url https://switchbrew.org/wiki/BTM_services#btm:u
*/
class IBtmUser : public BaseService {
public:
IBtmUser(const DeviceState &state, ServiceManager &manager);
/**
* @url https://switchbrew.org/wiki/BTM_services#GetCore_2
*/
Result GetCore(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
SERVICE_DECL(
SFUNC(0x0, IBtmUser, GetCore)
)
};
}

View File

@ -0,0 +1,36 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IBtmUserCore.h"
namespace skyline::service::btm {
IBtmUserCore::IBtmUserCore(const DeviceState &state, ServiceManager &manager) : bleScanEvent(std::make_shared<type::KEvent>(state, false)), bleConnectionEvent(std::make_shared<type::KEvent>(state, false)), bleServiceDiscoveryEvent(std::make_shared<type::KEvent>(state, false)), bleMtuConfigEvent(std::make_shared<type::KEvent>(state, false)), BaseService(state, manager) {}
Result IBtmUserCore::AcquireBleScanEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle{state.process->InsertItem(bleScanEvent)};
response.copyHandles.push_back(handle);
response.Push(true); // Success flag
return {};
}
Result IBtmUserCore::AcquireBleConnectionEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle{state.process->InsertItem(bleConnectionEvent)};
response.copyHandles.push_back(handle);
response.Push(true); // Success flag
return {};
}
Result IBtmUserCore::AcquireBleServiceDiscoveryEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle{state.process->InsertItem(bleServiceDiscoveryEvent)};
response.copyHandles.push_back(handle);
response.Push(true); // Success flag
return {};
}
Result IBtmUserCore::AcquireBleMtuConfigEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle{state.process->InsertItem(bleMtuConfigEvent)};
response.copyHandles.push_back(handle);
response.Push(true); // Success flag
return {};
}
}

View File

@ -0,0 +1,50 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <services/serviceman.h>
namespace skyline::service::btm {
/**
* @brief IBcatService is used to interact BLE (Bluetooth Low Energy) devices
* @url https://switchbrew.org/wiki/BTM_services#IBtmUserCore
*/
class IBtmUserCore : public BaseService {
private:
std::shared_ptr<type::KEvent> bleScanEvent;
std::shared_ptr<type::KEvent> bleConnectionEvent;
std::shared_ptr<type::KEvent> bleServiceDiscoveryEvent;
std::shared_ptr<type::KEvent> bleMtuConfigEvent;
public:
IBtmUserCore(const DeviceState &state, ServiceManager &manager);
/**
* @url https://switchbrew.org/wiki/BTM_services#AcquireBleScanEvent_2
*/
Result AcquireBleScanEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/BTM_services#AcquireBleConnectionEvent_2
*/
Result AcquireBleConnectionEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/BTM_services#AcquireBleServiceDiscoveryEvent_2
*/
Result AcquireBleServiceDiscoveryEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @url https://switchbrew.org/wiki/BTM_services#AcquireBleMtuConfigEvent_2
*/
Result AcquireBleMtuConfigEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
SERVICE_DECL(
SFUNC(0x0, IBtmUserCore, AcquireBleScanEvent),
SFUNC(0x11, IBtmUserCore, AcquireBleConnectionEvent),
SFUNC(0x1A, IBtmUserCore, AcquireBleServiceDiscoveryEvent),
SFUNC(0x21, IBtmUserCore, AcquireBleMtuConfigEvent)
)
};
}

View File

@ -42,6 +42,8 @@
#include "ssl/ISslService.h"
#include "prepo/IPrepoService.h"
#include "mmnv/IRequest.h"
#include "bt/IBluetoothUser.h"
#include "btm/IBtmUser.h"
#include "serviceman.h"
#define SERVICE_CASE(class, name, ...) \
@ -111,6 +113,8 @@ namespace skyline::service {
SERVICE_CASE(prepo::IPrepoService, "prepo:u")
SERVICE_CASE(mmnv::IRequest, "mm:u")
SERVICE_CASE(bcat::IServiceCreator, "bcat:u")
SERVICE_CASE(bt::IBluetoothUser, "bt")
SERVICE_CASE(btm::IBtmUser, "btm:u")
default:
std::string_view nameString(span(reinterpret_cast<char *>(&name), sizeof(name)).as_string(true));
throw std::out_of_range(fmt::format("CreateService called with an unknown service name: {}", nameString));