2020-05-11 20:30:08 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
|
2020-06-13 17:15:59 +00:00
|
|
|
#include "btdrv_mitm_logging.hpp"
|
2020-05-22 10:29:36 +00:00
|
|
|
|
|
|
|
namespace ams::mitm::btdrv {
|
2020-05-11 20:30:08 +00:00
|
|
|
|
|
|
|
class BtdrvMitmService : public sf::IMitmServiceObject {
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum class CommandId {
|
2020-06-12 21:25:09 +00:00
|
|
|
InitializeBluetooth = 1,
|
|
|
|
FinalizeBluetooth = 4,
|
|
|
|
GetEventInfo = 15,
|
|
|
|
InitializeHid = 16,
|
|
|
|
WriteHidData = 19,
|
2020-06-22 21:14:54 +00:00
|
|
|
SetHidReport = 21,
|
|
|
|
GetHidReport = 22,
|
|
|
|
GetPairedDeviceInfo = 25,
|
2020-06-12 21:25:09 +00:00
|
|
|
FinalizeHid = 26,
|
|
|
|
GetHidEventInfo = 27,
|
2020-06-22 21:14:54 +00:00
|
|
|
//SetTsi = 28,
|
2020-06-12 21:25:09 +00:00
|
|
|
RegisterHidReportEventDeprecated = 36,
|
|
|
|
RegisterHidReportEvent = 37,
|
|
|
|
GetHidReportEventInfoDeprecated1 = 37,
|
|
|
|
GetHidReportEventInfoDeprecated2 = 38,
|
|
|
|
GetHidReportEventInfo = 38,
|
2020-05-22 10:29:36 +00:00
|
|
|
/* 5.0.0+ */
|
2020-06-13 00:08:43 +00:00
|
|
|
InitializeBle = 46,
|
|
|
|
FinalizeBle = 49,
|
2020-06-14 23:14:09 +00:00
|
|
|
GetBleManagedEventInfoDeprecated = 78,
|
|
|
|
GetBleManagedEventInfo = 79,
|
2020-06-02 21:24:40 +00:00
|
|
|
|
|
|
|
/* Extensions */
|
2020-06-13 00:08:43 +00:00
|
|
|
RedirectSystemEvents = 65000,
|
2020-05-11 20:30:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-06-22 21:14:54 +00:00
|
|
|
SF_MITM_SERVICE_OBJECT_CTOR(BtdrvMitmService) {
|
|
|
|
u32 ver = hosversionGet();
|
|
|
|
BTDRV_LOG_FMT("*** btdrv-mitm [%d.%d.%d] ***", HOSVER_MAJOR(ver), HOSVER_MINOR(ver), HOSVER_MICRO(ver));
|
|
|
|
}
|
2020-05-11 20:30:08 +00:00
|
|
|
|
|
|
|
protected:
|
2020-05-22 10:29:36 +00:00
|
|
|
Result InitializeBluetooth(sf::OutCopyHandle out_handle);
|
|
|
|
Result FinalizeBluetooth(void);
|
2020-06-14 22:18:46 +00:00
|
|
|
Result GetEventInfo(sf::Out<BluetoothEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-22 10:29:36 +00:00
|
|
|
Result InitializeHid(sf::OutCopyHandle out_handle, u16 version);
|
|
|
|
Result WriteHidData(BluetoothAddress address, const sf::InPointerBuffer &buffer);
|
2020-06-22 21:14:54 +00:00
|
|
|
Result SetHidReport(BluetoothAddress address, BluetoothHhReportType type, const sf::InPointerBuffer &buffer);
|
|
|
|
Result GetHidReport(BluetoothAddress address, BluetoothHhReportType type, u8 id);
|
|
|
|
Result GetPairedDeviceInfo(BluetoothAddress address, const sf::OutPointerBuffer &out_buffer);
|
2020-05-22 10:29:36 +00:00
|
|
|
Result FinalizeHid(void);
|
2020-06-14 22:18:46 +00:00
|
|
|
Result GetHidEventInfo(sf::Out<HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-06-22 21:14:54 +00:00
|
|
|
|
|
|
|
//Result SetTsi(BluetoothAddress address, u8 tsi);
|
|
|
|
|
2020-06-12 21:25:09 +00:00
|
|
|
Result RegisterHidReportEventDeprecated(sf::OutCopyHandle out_handle);
|
2020-05-22 10:29:36 +00:00
|
|
|
Result RegisterHidReportEvent(sf::OutCopyHandle out_handle);
|
2020-06-14 22:18:46 +00:00
|
|
|
Result GetHidReportEventInfoDeprecated1(sf::Out<HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
|
|
|
Result GetHidReportEventInfoDeprecated2(sf::Out<HidEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-22 10:29:36 +00:00
|
|
|
Result GetHidReportEventInfo(sf::OutCopyHandle out_handle);
|
|
|
|
Result InitializeBle(sf::OutCopyHandle out_handle);
|
|
|
|
Result FinalizeBle(void);
|
2020-06-14 23:14:09 +00:00
|
|
|
Result GetBleManagedEventInfoDeprecated(sf::Out<BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
|
|
|
Result GetBleManagedEventInfo(sf::Out<BleEventType> out_type, const sf::OutPointerBuffer &out_buffer);
|
2020-05-11 20:30:08 +00:00
|
|
|
|
2020-06-14 14:28:46 +00:00
|
|
|
void RedirectSystemEvents(bool redirect);
|
2020-06-02 21:24:40 +00:00
|
|
|
|
2020-05-11 20:30:08 +00:00
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
MAKE_SERVICE_COMMAND_META(InitializeBluetooth),
|
2020-05-22 10:29:36 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(FinalizeBluetooth),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetEventInfo),
|
|
|
|
MAKE_SERVICE_COMMAND_META(InitializeHid),
|
|
|
|
MAKE_SERVICE_COMMAND_META(WriteHidData),
|
2020-06-22 21:14:54 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(SetHidReport),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetHidReport),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetPairedDeviceInfo),
|
2020-05-22 10:29:36 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(FinalizeHid),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetHidEventInfo),
|
2020-06-22 21:14:54 +00:00
|
|
|
//MAKE_SERVICE_COMMAND_META(SetTsi),
|
2020-06-12 21:25:09 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(RegisterHidReportEventDeprecated, hos::Version_1_0_0, hos::Version_3_0_2),
|
|
|
|
MAKE_SERVICE_COMMAND_META(RegisterHidReportEvent, hos::Version_4_0_0),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfoDeprecated1, hos::Version_1_0_0, hos::Version_3_0_2),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfoDeprecated2, hos::Version_4_0_0, hos::Version_6_2_0),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetHidReportEventInfo, hos::Version_7_0_0),
|
2020-06-13 00:08:43 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(InitializeBle, hos::Version_5_0_0),
|
|
|
|
MAKE_SERVICE_COMMAND_META(FinalizeBle, hos::Version_5_0_0),
|
2020-06-14 23:14:09 +00:00
|
|
|
MAKE_SERVICE_COMMAND_META(GetBleManagedEventInfoDeprecated, hos::Version_5_0_0, hos::Version_5_0_2),
|
|
|
|
MAKE_SERVICE_COMMAND_META(GetBleManagedEventInfo, hos::Version_5_1_0),
|
2020-06-02 21:24:40 +00:00
|
|
|
|
|
|
|
MAKE_SERVICE_COMMAND_META(RedirectSystemEvents),
|
2020-05-11 20:30:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|