mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-22 20:33:07 +00:00
bluetooth-mitm: rename IsGamepad function to IsAllowedDevice and add keyboard device class to allowed devices
This commit is contained in:
parent
a313b71a9d
commit
2798d05564
3 changed files with 5 additions and 4 deletions
|
@ -84,7 +84,7 @@ namespace ams::bluetooth::core {
|
|||
if (program_id == ncm::SystemProgramId::Btm) {
|
||||
switch (g_current_event_type) {
|
||||
case BluetoothEvent_DeviceFound:
|
||||
if (controller::IsGamepad(&event_data->deviceFound.cod) && !controller::IsOfficialSwitchControllerName(event_data->deviceFound.name, sizeof(BluetoothName))) {
|
||||
if (controller::IsAllowedDevice(&event_data->deviceFound.cod) && !controller::IsOfficialSwitchControllerName(event_data->deviceFound.name, sizeof(BluetoothName))) {
|
||||
std::strncpy(event_data->deviceFound.name, controller::pro_controller_name, sizeof(BluetoothName) - 1);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace ams::controller {
|
|||
constexpr auto cod_major_peripheral = 0x05;
|
||||
constexpr auto cod_minor_gamepad = 0x08;
|
||||
constexpr auto cod_minor_joystick = 0x04;
|
||||
constexpr auto cod_minor_keyboard = 0x40;
|
||||
|
||||
os::Mutex g_controller_lock(false);
|
||||
std::vector<std::unique_ptr<SwitchController>> g_controllers;
|
||||
|
@ -118,9 +119,9 @@ namespace ams::controller {
|
|||
return ControllerType_Unknown;
|
||||
}
|
||||
|
||||
bool IsGamepad(const bluetooth::DeviceClass *cod) {
|
||||
bool IsAllowedDevice(const bluetooth::DeviceClass *cod) {
|
||||
return ((cod->cod[1] & 0x0f) == cod_major_peripheral) &&
|
||||
(((cod->cod[2] & 0x0f) == cod_minor_gamepad) || ((cod->cod[2] & 0x0f) == cod_minor_joystick));
|
||||
(((cod->cod[2] & 0x0f) == cod_minor_gamepad) || ((cod->cod[2] & 0x0f) == cod_minor_joystick) || ((cod->cod[2] & 0x40) == cod_minor_keyboard));
|
||||
}
|
||||
|
||||
bool IsOfficialSwitchControllerName(const char *name, size_t size) {
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace ams::controller {
|
|||
};
|
||||
|
||||
ControllerType Identify(const BluetoothDevicesSettings *device);
|
||||
bool IsGamepad(const bluetooth::DeviceClass *cod);
|
||||
bool IsAllowedDevice(const bluetooth::DeviceClass *cod);
|
||||
bool IsOfficialSwitchControllerName(const char *name, size_t size);
|
||||
|
||||
void AttachHandler(const bluetooth::Address *address);
|
||||
|
|
Loading…
Reference in a new issue