mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 14:20:21 +00:00
bluetooth-mitm: remove unnecessary Initialize/Finalize functions
This commit is contained in:
parent
ff9d6fe44b
commit
04a4d1fcd8
7 changed files with 45 additions and 49 deletions
|
@ -38,6 +38,10 @@ namespace ams::bluetooth::ble {
|
|||
return g_init_event.TryWait();
|
||||
}
|
||||
|
||||
void SignalInitialized(void) {
|
||||
g_init_event.Signal();
|
||||
}
|
||||
|
||||
void WaitInitialized(void) {
|
||||
g_init_event.Wait();
|
||||
}
|
||||
|
@ -54,17 +58,6 @@ namespace ams::bluetooth::ble {
|
|||
return &g_system_event_user_fwd;
|
||||
}
|
||||
|
||||
Result Initialize(Handle event_handle) {
|
||||
g_system_event.AttachReadableHandle(event_handle, false, os::EventClearMode_ManualClear);
|
||||
g_init_event.Signal();
|
||||
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
||||
void Finalize(void) {
|
||||
;
|
||||
}
|
||||
|
||||
Result GetEventInfo(bluetooth::BleEventType *type, void *buffer, size_t size) {
|
||||
std::scoped_lock lk(g_event_data_lock);
|
||||
|
||||
|
|
|
@ -21,15 +21,13 @@
|
|||
namespace ams::bluetooth::ble {
|
||||
|
||||
bool IsInitialized(void);
|
||||
void SignalInitialized(void);
|
||||
void WaitInitialized(void);
|
||||
|
||||
os::SystemEvent *GetSystemEvent(void);
|
||||
os::SystemEvent *GetForwardEvent(void);
|
||||
os::SystemEvent *GetUserForwardEvent(void);
|
||||
|
||||
Result Initialize(Handle event_handle);
|
||||
void Finalize(void);
|
||||
|
||||
Result GetEventInfo(bluetooth::BleEventType *type, void *buffer, size_t size);
|
||||
void HandleEvent(void);
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@ namespace ams::bluetooth::core {
|
|||
return g_init_event.TryWait();
|
||||
}
|
||||
|
||||
void SignalInitialized(void) {
|
||||
g_init_event.Signal();
|
||||
}
|
||||
|
||||
void WaitInitialized(void) {
|
||||
g_init_event.Wait();
|
||||
}
|
||||
|
@ -65,17 +69,6 @@ namespace ams::bluetooth::core {
|
|||
return &g_system_event_user_fwd;
|
||||
}
|
||||
|
||||
Result Initialize(Handle event_handle) {
|
||||
g_system_event.AttachReadableHandle(event_handle, false, os::EventClearMode_ManualClear);
|
||||
g_init_event.Signal();
|
||||
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
||||
void Finalize(void) {
|
||||
;
|
||||
}
|
||||
|
||||
Result GetEventInfo(bluetooth::EventType *type, void *buffer, size_t size) {
|
||||
std::scoped_lock lk(g_event_info_lock);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
namespace ams::bluetooth::core {
|
||||
|
||||
bool IsInitialized(void);
|
||||
void SignalInitialized(void);
|
||||
void WaitInitialized(void);
|
||||
void SignalEnabled(void);
|
||||
void WaitEnabled(void);
|
||||
|
@ -29,9 +30,6 @@ namespace ams::bluetooth::core {
|
|||
os::SystemEvent *GetForwardEvent(void);
|
||||
os::SystemEvent *GetUserForwardEvent(void);
|
||||
|
||||
Result Initialize(Handle event_handle);
|
||||
void Finalize(void);
|
||||
|
||||
Result GetEventInfo(bluetooth::EventType *type, void *buffer, size_t size);
|
||||
void HandleEvent(void);
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ namespace ams::bluetooth::hid {
|
|||
return g_init_event.TryWait();
|
||||
}
|
||||
|
||||
void SignalInitialized(void) {
|
||||
g_init_event.Signal();
|
||||
}
|
||||
|
||||
void WaitInitialized(void) {
|
||||
g_init_event.Wait();
|
||||
}
|
||||
|
@ -56,17 +60,6 @@ namespace ams::bluetooth::hid {
|
|||
return &g_system_event_user_fwd;
|
||||
}
|
||||
|
||||
Result Initialize(Handle event_handle) {
|
||||
g_system_event.AttachReadableHandle(event_handle, false, os::EventClearMode_ManualClear);
|
||||
g_init_event.Signal();
|
||||
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
||||
void Finalize(void) {
|
||||
;
|
||||
}
|
||||
|
||||
Result GetEventInfo(bluetooth::HidEventType *type, void *buffer, size_t size) {
|
||||
std::scoped_lock lk(g_event_info_lock);
|
||||
|
||||
|
|
|
@ -21,15 +21,13 @@
|
|||
namespace ams::bluetooth::hid {
|
||||
|
||||
bool IsInitialized(void);
|
||||
void SignalInitialized(void);
|
||||
void WaitInitialized(void);
|
||||
|
||||
os::SystemEvent *GetSystemEvent(void);
|
||||
os::SystemEvent *GetForwardEvent(void);
|
||||
os::SystemEvent *GetUserForwardEvent(void);
|
||||
|
||||
Result Initialize(Handle event_handle);
|
||||
void Finalize(void);
|
||||
|
||||
Result GetEventInfo(bluetooth::HidEventType *type, void *buffer, size_t size);
|
||||
void HandleEvent(void);
|
||||
|
||||
|
|
|
@ -28,12 +28,21 @@ namespace ams::mitm::bluetooth {
|
|||
|
||||
Result BtdrvMitmService::InitializeBluetooth(sf::OutCopyHandle out_handle) {
|
||||
if (!ams::bluetooth::core::IsInitialized()) {
|
||||
// Forward to the real function to obtain the system event handle
|
||||
Handle handle = INVALID_HANDLE;
|
||||
R_TRY(btdrvInitializeBluetoothFwd(this->forward_service.get(), &handle));
|
||||
R_TRY(ams::bluetooth::core::Initialize(handle));
|
||||
|
||||
// Attach the real system event handle to our own event
|
||||
ams::bluetooth::core::GetSystemEvent()->AttachReadableHandle(handle, false, os::EventClearMode_ManualClear);
|
||||
|
||||
// Return our forwarder event handle to the caller instead
|
||||
out_handle.SetValue(ams::bluetooth::core::GetForwardEvent()->GetReadableHandle());
|
||||
|
||||
// Initialise the hid report circular buffer
|
||||
R_TRY(ams::bluetooth::hid::report::InitializeReportBuffer());
|
||||
|
||||
out_handle.SetValue(ams::bluetooth::core::GetForwardEvent()->GetReadableHandle());
|
||||
// Signal that the interface is initialised
|
||||
ams::bluetooth::core::SignalInitialized();
|
||||
} else {
|
||||
out_handle.SetValue(ams::bluetooth::core::GetUserForwardEvent()->GetReadableHandle());
|
||||
}
|
||||
|
@ -73,11 +82,18 @@ namespace ams::mitm::bluetooth {
|
|||
|
||||
Result BtdrvMitmService::InitializeHid(sf::OutCopyHandle out_handle, u16 version) {
|
||||
if (!ams::bluetooth::hid::IsInitialized()) {
|
||||
// Forward to the real function to obtain the system event handle
|
||||
Handle handle = INVALID_HANDLE;
|
||||
R_TRY(btdrvInitializeHidFwd(this->forward_service.get(), &handle, version));
|
||||
R_TRY(ams::bluetooth::hid::Initialize(handle));
|
||||
|
||||
// Attach the real system event handle to our own event
|
||||
ams::bluetooth::hid::GetSystemEvent()->AttachReadableHandle(handle, false, os::EventClearMode_ManualClear);
|
||||
|
||||
// Return our forwarder event handle to the caller instead
|
||||
out_handle.SetValue(ams::bluetooth::hid::GetForwardEvent()->GetReadableHandle());
|
||||
|
||||
// Signal that the interface is initialised
|
||||
ams::bluetooth::hid::SignalInitialized();
|
||||
}
|
||||
else {
|
||||
out_handle.SetValue(ams::bluetooth::hid::GetUserForwardEvent()->GetReadableHandle());
|
||||
|
@ -201,11 +217,18 @@ namespace ams::mitm::bluetooth {
|
|||
|
||||
Result BtdrvMitmService::InitializeBle(sf::OutCopyHandle out_handle) {
|
||||
if (!ams::bluetooth::ble::IsInitialized()) {
|
||||
// Forward to the real function to obtain the system event handle
|
||||
Handle handle = INVALID_HANDLE;
|
||||
R_TRY(btdrvInitializeBleFwd(this->forward_service.get(), &handle));
|
||||
R_TRY(ams::bluetooth::ble::Initialize(handle));
|
||||
|
||||
// Attach the real system event handle to our own event
|
||||
ams::bluetooth::ble::GetSystemEvent()->AttachReadableHandle(handle, false, os::EventClearMode_ManualClear);
|
||||
|
||||
// Return our forwarder event handle to the caller instead
|
||||
out_handle.SetValue(ams::bluetooth::ble::GetForwardEvent()->GetReadableHandle());
|
||||
|
||||
// Signal that the interface is initialised
|
||||
ams::bluetooth::ble::SignalInitialized();
|
||||
}
|
||||
else {
|
||||
out_handle.SetValue(ams::bluetooth::ble::GetUserForwardEvent()->GetReadableHandle());
|
||||
|
|
Loading…
Reference in a new issue