2020-08-25 21:23:38 +02:00
|
|
|
/*
|
2021-01-26 04:03:26 +01:00
|
|
|
* Copyright (c) 2020-2021 ndeadly
|
2020-08-25 21:23:38 +02:00
|
|
|
*
|
2020-08-27 00:50:34 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
2020-08-25 21:23:38 +02:00
|
|
|
*
|
2020-08-27 00:50:34 +02:00
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
2020-08-25 21:23:38 +02:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-05-11 22:30:08 +02:00
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
2020-06-30 10:05:33 +02:00
|
|
|
#include "bluetooth/bluetooth_types.hpp"
|
2020-05-11 22:30:08 +02:00
|
|
|
|
2021-02-03 23:21:59 +01:00
|
|
|
#define AMS_BTDRV_MITM_INTERFACE_INFO(C, H) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 1, Result, InitializeBluetooth, (sf::OutCopyHandle out_handle), (out_handle)) \
|
2021-02-21 00:16:23 +01:00
|
|
|
AMS_SF_METHOD_INFO(C, H, 2, Result, EnableBluetooth, (void), ()) \
|
2021-02-03 23:21:59 +01:00
|
|
|
AMS_SF_METHOD_INFO(C, H, 15, Result, GetEventInfo, (sf::Out<ams::bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 16, Result, InitializeHid, (sf::OutCopyHandle out_handle, u16 version), (out_handle, version)) \
|
|
|
|
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, 27, Result, GetHidEventInfo, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer)) \
|
2021-02-09 21:52:43 +01:00
|
|
|
AMS_SF_METHOD_INFO(C, H, 28, Result, SetTsi, (ams::bluetooth::Address address, u8 tsi), (address, tsi)) \
|
2021-02-03 23:21:59 +01:00
|
|
|
AMS_SF_METHOD_INFO(C, H, 36, Result, RegisterHidReportEventDeprecated, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_1_0_0, hos::Version_3_0_2) \
|
|
|
|
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, 37, Result, GetHidReportEventInfoDeprecated1, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_1_0_0, hos::Version_3_0_2) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 38, Result, GetHidReportEventInfoDeprecated2, (sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_4_0_0, hos::Version_6_2_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) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 78, Result, GetBleManagedEventInfoDeprecated, (sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_5_0_0, hos::Version_5_0_2) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 79, Result, GetBleManagedEventInfo, (sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer), (out_type, out_buffer), hos::Version_5_1_0) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65000, Result, GetRealSharedMemory, (sf::OutCopyHandle out_handle), (out_handle), hos::Version_7_0_0) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65001, Result, GetFakeSharedMemory, (sf::OutCopyHandle out_handle), (out_handle)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65002, void, RedirectCoreEvents, (bool redirect), (redirect)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65003, void, RedirectHidEvents, (bool redirect), (redirect)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65004, void, RedirectHidReportEvents, (bool redirect), (redirect)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65005, void, RedirectBleEvents, (bool redirect), (redirect)) \
|
2021-06-23 02:10:05 +02:00
|
|
|
AMS_SF_METHOD_INFO(C, H, 65006, void, SignalHidReportRead, (void), ()) \
|
|
|
|
|
2021-02-03 23:52:39 +01:00
|
|
|
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::bluetooth, IBtdrvMitmInterface, AMS_BTDRV_MITM_INTERFACE_INFO)
|
2020-05-11 22:30:08 +02:00
|
|
|
|
2021-02-03 23:52:39 +01:00
|
|
|
namespace ams::mitm::bluetooth {
|
2020-08-05 00:04:52 +02:00
|
|
|
|
2021-02-03 23:21:59 +01:00
|
|
|
class BtdrvMitmService : public sf::MitmServiceImplBase {
|
2020-08-05 00:04:52 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
using MitmServiceImplBase::MitmServiceImplBase;
|
2020-05-11 22:30:08 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-05-22 12:29:36 +02:00
|
|
|
Result InitializeBluetooth(sf::OutCopyHandle out_handle);
|
2021-02-21 00:16:23 +01:00
|
|
|
Result EnableBluetooth(void);
|
2021-02-03 23:21:59 +01:00
|
|
|
Result GetEventInfo(sf::Out<ams::bluetooth::EventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-22 12:29:36 +02:00
|
|
|
Result InitializeHid(sf::OutCopyHandle out_handle, u16 version);
|
2021-02-03 23:21:59 +01:00
|
|
|
Result WriteHidData(ams::bluetooth::Address address, const sf::InPointerBuffer &buffer);
|
2021-02-09 21:52:43 +01:00
|
|
|
Result GetHidEventInfo(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
|
|
|
Result SetTsi(ams::bluetooth::Address address, u8 tsi);
|
2020-06-12 23:25:09 +02:00
|
|
|
Result RegisterHidReportEventDeprecated(sf::OutCopyHandle out_handle);
|
2020-05-22 12:29:36 +02:00
|
|
|
Result RegisterHidReportEvent(sf::OutCopyHandle out_handle);
|
2021-02-03 23:21:59 +01:00
|
|
|
Result GetHidReportEventInfoDeprecated1(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
|
|
|
Result GetHidReportEventInfoDeprecated2(sf::Out<ams::bluetooth::HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-22 12:29:36 +02:00
|
|
|
Result GetHidReportEventInfo(sf::OutCopyHandle out_handle);
|
2020-07-27 23:31:03 +02:00
|
|
|
/* 5.0.0+ */
|
2020-05-22 12:29:36 +02:00
|
|
|
Result InitializeBle(sf::OutCopyHandle out_handle);
|
2021-02-03 23:21:59 +01:00
|
|
|
Result GetBleManagedEventInfoDeprecated(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
|
|
|
Result GetBleManagedEventInfo(sf::Out<ams::bluetooth::BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-11 22:30:08 +02:00
|
|
|
|
2020-07-27 23:31:03 +02:00
|
|
|
/* Extensions */
|
2020-08-26 20:52:47 +02:00
|
|
|
Result GetRealSharedMemory(sf::OutCopyHandle out_handle);
|
|
|
|
Result GetFakeSharedMemory(sf::OutCopyHandle out_handle);
|
2020-08-04 22:18:15 +02:00
|
|
|
void RedirectCoreEvents(bool redirect);
|
|
|
|
void RedirectHidEvents(bool redirect);
|
2020-07-09 19:38:53 +02:00
|
|
|
void RedirectHidReportEvents(bool redirect);
|
2020-08-04 22:18:15 +02:00
|
|
|
void RedirectBleEvents(bool redirect);
|
2021-06-23 02:10:05 +02:00
|
|
|
void SignalHidReportRead(void);
|
2020-05-11 22:30:08 +02:00
|
|
|
};
|
2020-08-05 00:04:52 +02:00
|
|
|
static_assert(IsIBtdrvMitmInterface<BtdrvMitmService>);
|
2020-05-11 22:30:08 +02:00
|
|
|
|
|
|
|
}
|