mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 22:30:21 +00:00
btdrv-mitm: misc. code cleanup
This commit is contained in:
parent
f20631dbbc
commit
b9747b5f95
10 changed files with 16 additions and 26 deletions
|
@ -13,8 +13,7 @@ namespace ams::bluetooth::core {
|
|||
|
||||
namespace {
|
||||
|
||||
//const constexpr char* g_licProControllerName = "Lic Pro Controller";
|
||||
const constexpr char* g_licProControllerName = "Pro Controller";
|
||||
const constexpr char* g_proControllerName = "Pro Controller";
|
||||
|
||||
std::atomic<bool> g_isInitialized(false);
|
||||
|
||||
|
@ -101,22 +100,19 @@ namespace ams::bluetooth::core {
|
|||
|
||||
void handleDeviceFoundEvent(EventData *eventData) {
|
||||
if (controller::IsController(&eventData->deviceFound.cod) && !controller::IsValidSwitchControllerName(eventData->deviceFound.name)) {
|
||||
std::strncpy(eventData->deviceFound.name, g_licProControllerName, sizeof(BluetoothName) - 1);
|
||||
eventData->pinReply.cod = {0x00, 0x25, 0x08};
|
||||
std::strncpy(eventData->deviceFound.name, g_proControllerName, sizeof(BluetoothName) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void handlePinRequesEvent(EventData *eventData) {
|
||||
if (controller::IsController(&eventData->pinReply.cod) && !controller::IsValidSwitchControllerName(eventData->pinReply.name)) {
|
||||
std::strncpy(eventData->pinReply.name, g_licProControllerName, sizeof(BluetoothName) - 1);
|
||||
eventData->pinReply.cod = {0x00, 0x25, 0x08};
|
||||
std::strncpy(eventData->pinReply.name, g_proControllerName, sizeof(BluetoothName) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void handleSspRequesEvent(EventData *eventData) {
|
||||
if (controller::IsController(&eventData->sspReply.cod) && !controller::IsValidSwitchControllerName(eventData->sspReply.name)) {
|
||||
std::strncpy(eventData->sspReply.name, g_licProControllerName, sizeof(BluetoothName) - 1);
|
||||
eventData->pinReply.cod = {0x00, 0x25, 0x08};
|
||||
std::strncpy(eventData->sspReply.name, g_proControllerName, sizeof(BluetoothName) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,12 +166,16 @@ namespace ams::bluetooth::core {
|
|||
os::WaitEvent(&g_dataReadEvent);
|
||||
}
|
||||
else {
|
||||
// Todo: set this to what it should be if we ever enable bluetooth to actually read the pincode parameter
|
||||
PinCode pincode = {};
|
||||
bluetooth::PinCode pincode = {};
|
||||
|
||||
BluetoothAdapterProperty props;
|
||||
R_ABORT_UNLESS(btdrvGetAdapterProperties(&props));
|
||||
// Reverse host address as pincode for wii devices
|
||||
*reinterpret_cast<u64 *>(&pincode) = util::SwapBytes(*reinterpret_cast<u64 *>(&props.address)) >> 16;
|
||||
|
||||
// Fuck BTM, we're sending the pin response. What it doesn't know won't hurt it
|
||||
auto eventData = reinterpret_cast<EventData *>(g_eventDataBuffer);
|
||||
R_ABORT_UNLESS(btdrvRespondToPinRequest(&eventData->pinReply.address, false, &pincode, sizeof(Address)));
|
||||
R_ABORT_UNLESS(btdrvRespondToPinRequest(&eventData->pinReply.address, false, &pincode, sizeof(bluetooth::Address)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ namespace ams::bluetooth::hid::report {
|
|||
shmemLoadRemote(&g_realBtShmem, handle, BLUETOOTH_SHAREDMEM_SIZE, Perm_Rw);
|
||||
R_TRY(shmemMap(&g_realBtShmem));
|
||||
g_realBuffer = reinterpret_cast<bluetooth::CircularBuffer *>(shmemGetAddr(&g_realBtShmem));
|
||||
BTDRV_LOG_FMT("Real shmem @ 0x%p", (void *)g_realBuffer);
|
||||
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
|
|
@ -33,15 +33,14 @@ namespace ams::bluetooth {
|
|||
typedef BluetoothEventType EventType;
|
||||
typedef BluetoothHidEventType HidEventType;
|
||||
typedef BluetoothBleEventType BleEventType;
|
||||
//typedef BluetoothHidReportEventType HidReportEventType;
|
||||
|
||||
typedef BluetoothEventData EventData;
|
||||
typedef BluetoothHidEventData HidEventData;
|
||||
typedef BluetoothBleEventData BleEventData;
|
||||
//typedef BluetoothHidReportEventData HidReportEventData;
|
||||
|
||||
typedef BluetoothAddress Address;
|
||||
typedef BluetoothPinCode PinCode;
|
||||
typedef BluetoothAddress Address;
|
||||
typedef BluetoothDeviceClass DeviceClass;
|
||||
typedef BluetoothPinCode PinCode;
|
||||
|
||||
typedef BluetoothHidReport HidReport;
|
||||
typedef BluetoothHidReportData HidReportData;
|
||||
|
|
|
@ -283,15 +283,11 @@ namespace ams::mitm::btdrv {
|
|||
if (this->client_info.program_id == ncm::SystemProgramId::Btm) {
|
||||
|
||||
if (!controller::IsValidSwitchControllerName(device->name)) {
|
||||
//std::strncpy(device->name, "Lic Pro Controller", sizeof(BluetoothLocalName) - 1);
|
||||
std::strncpy(device->name, "Pro Controller", sizeof(BluetoothLocalName) - 1);
|
||||
device->device_class = {0x00, 0x25, 0x08};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//BTDRV_LOG_FMT("name: %s\nvid: %04x\npid: %04x", device->name, device->vid, device->pid);
|
||||
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "controllermanager.hpp"
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "controllermanager.hpp"
|
||||
#include "switchcontroller.hpp"
|
||||
#include "wiimote.hpp"
|
||||
#include "wiiupro.hpp"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "dualshock4.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
|
|
@ -68,7 +68,6 @@ namespace ams::controller {
|
|||
uint8_t right_trigger;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* This report is sent once the GET REPORT FEATURE 0x02 is received */
|
||||
struct Dualshock4InputReport0x11 {
|
||||
uint8_t _unk[2];
|
||||
Dualshock4StickData left_stick;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "wiicontroller.hpp"
|
||||
#include <cstring>
|
||||
#include <switch.h>
|
||||
#include <vapours.hpp>
|
||||
#include "wiicontroller.hpp"
|
||||
|
||||
#include "../btdrv_mitm_logging.hpp"
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "wiiupro.hpp"
|
||||
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "../btdrv_mitm_logging.hpp"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "xboxone.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
|
|
Loading…
Reference in a new issue