mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 14:20:21 +00:00
btdrv-mitm: add skeleton for xiaomi handler
This commit is contained in:
parent
9772de6abd
commit
eebfbb9da7
4 changed files with 88 additions and 0 deletions
|
@ -69,6 +69,12 @@ namespace ams::controller {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto hwId : XiaomiController::hardware_ids) {
|
||||
if ( (device->vid == hwId.vid) && (device->pid == hwId.pid) ) {
|
||||
return ControllerType_Xiaomi;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the case where joycons have been assigned random hardware ids when paired via rails
|
||||
if (IsJoyCon(device->name)) {
|
||||
return ControllerType_Switch;;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "dualshock4_controller.hpp"
|
||||
#include "xbox_one_controller.hpp"
|
||||
#include "ouya_controller.hpp"
|
||||
#include "xiaomi_controller.hpp"
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
|
@ -33,6 +34,7 @@ namespace ams::controller {
|
|||
ControllerType_Dualshock4,
|
||||
ControllerType_XboxOne,
|
||||
ControllerType_Ouya,
|
||||
ControllerType_Xiaomi,
|
||||
ControllerType_Unknown,
|
||||
};
|
||||
|
||||
|
|
38
btdrv-mitm/source/controllers/xiaomi_controller.cpp
Normal file
38
btdrv-mitm/source/controllers/xiaomi_controller.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 2020 ndeadly
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "xiaomi_controller.hpp"
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
void XiaomiController::ConvertReportFormat(const bluetooth::HidReport *in_report, bluetooth::HidReport *out_report) {
|
||||
auto xiaomi_report = reinterpret_cast<const XiaomiReportData *>(&in_report->data);
|
||||
auto switch_report = reinterpret_cast<SwitchReportData *>(&out_report->data);
|
||||
|
||||
switch(xiaomi_report->id) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out_report->size = sizeof(SwitchInputReport0x30) + 1;
|
||||
switch_report->id = 0x30;
|
||||
switch_report->input0x30.conn_info = 0x0;
|
||||
switch_report->input0x30.battery = m_battery | m_charging;
|
||||
switch_report->input0x30.timer = os::ConvertToTimeSpan(os::GetSystemTick()).GetMilliSeconds() & 0xff;
|
||||
}
|
||||
|
||||
}
|
42
btdrv-mitm/source/controllers/xiaomi_controller.hpp
Normal file
42
btdrv-mitm/source/controllers/xiaomi_controller.hpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2020 ndeadly
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include "emulated_switch_controller.hpp"
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
struct XiaomiReportData{
|
||||
uint8_t id;
|
||||
} __attribute__((packed));
|
||||
|
||||
class XiaomiController : public EmulatedSwitchController {
|
||||
|
||||
public:
|
||||
static constexpr const HardwareID hardware_ids[] = {
|
||||
{0x2717, 0x3144} // Xiaomi Mi Controller
|
||||
};
|
||||
|
||||
XiaomiController(const bluetooth::Address *address)
|
||||
: EmulatedSwitchController(address) { };
|
||||
|
||||
void ConvertReportFormat(const bluetooth::HidReport *in_report, bluetooth::HidReport *out_report);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue