mirror of
https://github.com/ndeadly/MissionControl
synced 2025-02-16 21:28:25 +00:00
btdrv-mitm: misc. minor changes
This commit is contained in:
parent
00b3bc98a4
commit
30a8bed0cd
9 changed files with 19 additions and 23 deletions
|
@ -86,6 +86,7 @@ namespace ams::bluetooth::ble {
|
|||
}
|
||||
|
||||
if (g_systemEventUserFwd.state) {
|
||||
os::SignalSystemEvent(&g_systemEventUserFwd);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace ams::bluetooth::core {
|
|||
else {
|
||||
// This is what the bluetooth sysmodule hardcodes
|
||||
*reinterpret_cast<u32 *>(&pincode) = 0x30303030;
|
||||
pin_length = 4;
|
||||
pin_length = sizeof(u32);
|
||||
}
|
||||
|
||||
// Fuck BTM, we're sending the pin response ourselves if it won't.
|
||||
|
|
|
@ -77,12 +77,10 @@ namespace ams::bluetooth::hid {
|
|||
void handleConnectionStateEvent(HidEventData *eventData) {
|
||||
switch (eventData->connectionState.state) {
|
||||
case HidConnectionState_Connected:
|
||||
controller::attachDeviceHandler(&eventData->connectionState.address);
|
||||
//BTDRV_LOG_FMT("device connected");
|
||||
controller::attachHandler(&eventData->connectionState.address);
|
||||
break;
|
||||
case HidConnectionState_Disconnected:
|
||||
controller::removeDeviceHandler(&eventData->connectionState.address);
|
||||
//BTDRV_LOG_FMT("device disconnected");
|
||||
controller::removeHandler(&eventData->connectionState.address);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace ams::mitm::btdrv {
|
|||
auto requestData = reinterpret_cast<const bluetooth::HidReport *>(buffer.GetPointer());
|
||||
|
||||
if (this->client_info.program_id == ncm::SystemProgramId::Hid) {
|
||||
auto device = controller::locateController(&address);
|
||||
auto device = controller::locateHandler(&address);
|
||||
if (device) {
|
||||
requestData = device->handleOutgoingReport(requestData);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace ams::controller {
|
|||
return ControllerType_Unknown;
|
||||
}
|
||||
|
||||
SwitchController *locateController(const bluetooth::Address *address) {
|
||||
SwitchController *locateHandler(const bluetooth::Address *address) {
|
||||
std::scoped_lock lk(g_controllerLock);
|
||||
|
||||
for (auto it = g_controllers.begin(); it < g_controllers.end(); ++it) {
|
||||
|
@ -98,7 +98,7 @@ namespace ams::controller {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void attachDeviceHandler(const bluetooth::Address *address) {
|
||||
void attachHandler(const bluetooth::Address *address) {
|
||||
std::scoped_lock lk(g_controllerLock);
|
||||
|
||||
// Retrieve information about paired device
|
||||
|
@ -135,7 +135,7 @@ namespace ams::controller {
|
|||
g_controllers.back()->initialize();
|
||||
}
|
||||
|
||||
void removeDeviceHandler(const bluetooth::Address *address) {
|
||||
void removeHandler(const bluetooth::Address *address) {
|
||||
std::scoped_lock lk(g_controllerLock);
|
||||
|
||||
for (auto it = g_controllers.begin(); it < g_controllers.end(); ++it) {
|
||||
|
|
|
@ -15,10 +15,9 @@ namespace ams::controller {
|
|||
bool IsValidSwitchControllerName(const char *name);
|
||||
bool IsJoyCon(const char *name);
|
||||
|
||||
SwitchController *locateController(const bluetooth::Address *address);
|
||||
|
||||
void attachDeviceHandler(const bluetooth::Address *address);
|
||||
void removeDeviceHandler(const bluetooth::Address *address);
|
||||
SwitchController *locateHandler(const bluetooth::Address *address);
|
||||
void attachHandler(const bluetooth::Address *address);
|
||||
void removeHandler(const bluetooth::Address *address);
|
||||
|
||||
inline bool IsController(const bluetooth::DeviceClass *cod) {
|
||||
return ( (((uint8_t *)cod)[1] & 0x0f) == BTM_COD_MAJOR_PERIPHERAL) &&
|
||||
|
|
|
@ -43,9 +43,7 @@ namespace ams::controller {
|
|||
|
||||
Result Dualshock4Controller::setLightbarColour(Dualshock4LedColour colour) {
|
||||
m_ledColour = colour;
|
||||
R_TRY(this->updateControllerState());
|
||||
|
||||
return ams::ResultSuccess();
|
||||
return this->updateControllerState();
|
||||
}
|
||||
|
||||
void Dualshock4Controller::convertReportFormat(const bluetooth::HidReport *inReport, bluetooth::HidReport *outReport) {
|
||||
|
@ -64,7 +62,7 @@ namespace ams::controller {
|
|||
break;
|
||||
}
|
||||
|
||||
outReport->size = 0x31;
|
||||
outReport->size = sizeof(SwitchInputReport0x30) + 1;
|
||||
switchReport->id = 0x30;
|
||||
switchReport->input0x30.conn_info = 0x0;
|
||||
switchReport->input0x30.battery = m_battery | m_charging;
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <switch.h>
|
||||
#include <vapours.hpp>
|
||||
|
||||
#include "../btdrv_mitm_logging.hpp"
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
namespace {
|
||||
|
||||
const constexpr float nunchuckStickScaleFactor = float(0x7ff / 92);
|
||||
const constexpr float leftStickScaleFactor = float(UINT12_MAX) / 0x3f;
|
||||
const constexpr float rightStickScaleFactor = float(UINT12_MAX) / 0x1f;
|
||||
const constexpr float nunchuckStickScaleFactor = float(UINT12_MAX) / 0xb8;
|
||||
const constexpr float leftStickScaleFactor = float(UINT12_MAX) / 0x3f;
|
||||
const constexpr float rightStickScaleFactor = float(UINT12_MAX) / 0x1f;
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace ams::controller {
|
|||
break;
|
||||
}
|
||||
|
||||
outReport->size = 0x31;
|
||||
outReport->size = sizeof(SwitchInputReport0x30) + 1;
|
||||
switchReport->id = 0x30;
|
||||
switchReport->input0x30.conn_info = 0x0;
|
||||
switchReport->input0x30.battery = m_battery | m_charging;
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace ams::controller {
|
|||
break;
|
||||
}
|
||||
|
||||
outReport->size = 0x31;
|
||||
outReport->size = sizeof(SwitchInputReport0x30) + 1;
|
||||
switchReport->id = 0x30;
|
||||
switchReport->input0x30.conn_info = 0x0;
|
||||
switchReport->input0x30.battery = m_battery | m_charging;
|
||||
|
|
Loading…
Add table
Reference in a new issue