mc.mitm: reintroduce fake response for SetTsi command

This commit is contained in:
ndeadly 2023-04-29 18:58:57 +02:00
parent ddf4424d5f
commit 7d16199122
2 changed files with 40 additions and 0 deletions

View file

@ -116,6 +116,44 @@ namespace ams::mitm::bluetooth {
R_RETURN(ams::bluetooth::hid::GetEventInfo(out_type.GetPointer(), out_buffer.GetPointer(), out_buffer.GetSize()));
}
Result BtdrvMitmService::SetTsi(ams::bluetooth::Address address, u8 tsi) {
auto device = controller::LocateHandler(&address);
if (!device || device->IsOfficialController()) {
return sm::mitm::ResultShouldForwardToSession();
}
if (hos::GetVersion() < hos::Version_9_0_0) {
const struct {
u32 type;
ams::bluetooth::Address address;
u8 pad[2];
u32 status;
} event_data = {tsi == 0xff ? 1u : 0u, address, {0, 0}, 0};
ams::bluetooth::hid::SignalFakeEvent(BtdrvHidEventTypeOld_Ext, &event_data, sizeof(event_data));
} else if (hos::GetVersion() < hos::Version_12_0_0) {
const struct {
u32 type;
u32 status;
ams::bluetooth::Address address;
u8 pad[2];
} event_data = {tsi == 0xff ? 1u : 0u, 0, address, {0, 0}};
ams::bluetooth::hid::SignalFakeEvent(BtdrvHidEventTypeOld_Ext, &event_data, sizeof(event_data));
} else {
const struct {
ams::bluetooth::Address address;
u8 flag;
u8 tsi;
} event_data = { address, 1, tsi };
ams::bluetooth::core::SignalFakeEvent(BtdrvEventType_Tsi, &event_data, sizeof(event_data));
}
R_SUCCEED();
}
Result BtdrvMitmService::RegisterHidReportEvent(sf::OutCopyHandle out_handle) {
if (!ams::bluetooth::hid::report::IsInitialized()) {
// Forward to the real function to obtain the system event handle

View file

@ -25,6 +25,7 @@
AMS_SF_METHOD_INFO(C, H, 19, Result, WriteHidData, (ams::bluetooth::Address address, const sf::InPointerBuffer &buffer), (address, buffer)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, WriteHidData2, (ams::bluetooth::Address address, const sf::InPointerBuffer &buffer), (address, buffer)) \
AMS_SF_METHOD_INFO(C, H, 27, Result, GetHidEventInfo, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer)) \
AMS_SF_METHOD_INFO(C, H, 28, Result, SetTsi, (ams::bluetooth::Address address, u8 tsi), (address, tsi)) \
AMS_SF_METHOD_INFO(C, H, 37, Result, RegisterHidReportEvent, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_4_0_0) \
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfo, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_7_0_0) \
AMS_SF_METHOD_INFO(C, H, 46, Result, InitializeBle, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_5_0_0) \
@ -64,6 +65,7 @@ namespace ams::mitm::bluetooth {
Result WriteHidData(ams::bluetooth::Address address, const sf::InPointerBuffer &buffer);
Result WriteHidData2(ams::bluetooth::Address address, const sf::InPointerBuffer &buffer);
Result GetHidEventInfo(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
Result SetTsi(ams::bluetooth::Address address, u8 tsi);
Result RegisterHidReportEvent(sf::OutCopyHandle out_handle);
Result GetHidReportEventInfo(sf::OutCopyHandle out_handle);
/* 5.0.0+ */