mirror of
https://github.com/ndeadly/MissionControl
synced 2025-02-16 21:28:25 +00:00
btdrv-mitm: add default controller handler for unrecognised controllers
(cherry picked from commit 6d183f9d25ac3346c57a590a6b004372acce13f2)
This commit is contained in:
parent
7fbbc64c7a
commit
94c110001e
4 changed files with 77 additions and 1 deletions
|
@ -157,7 +157,8 @@ namespace ams::controller {
|
|||
g_controllers.push_back(std::make_unique<XiaomiController>(address));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
g_controllers.push_back(std::make_unique<DefaultController>(address));
|
||||
break;
|
||||
}
|
||||
|
||||
g_controllers.back()->Initialize();
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include "default_controller.hpp"
|
||||
#include "switch_controller.hpp"
|
||||
#include "wii_controller.hpp"
|
||||
#include "dualshock4_controller.hpp"
|
||||
|
|
41
btdrv-mitm/source/controllers/default_controller.cpp
Normal file
41
btdrv-mitm/source/controllers/default_controller.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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 "default_controller.hpp"
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
Result DefaultController::Initialize(void) {
|
||||
// Write empty Switch report into buffer to kick off connection
|
||||
R_TRY(EmulatedSwitchController::Initialize());
|
||||
s_output_report.size = sizeof(SwitchInputReport0x30) + 1;
|
||||
auto switch_report = reinterpret_cast<SwitchReportData *>(s_output_report.data);
|
||||
switch_report->id = 0x30;
|
||||
switch_report->input0x30.conn_info = 0x0;
|
||||
switch_report->input0x30.battery = BATTERY_MAX;
|
||||
std::memset(switch_report->input0x30.motion, 0, sizeof(switch_report->input0x30.motion));
|
||||
switch_report->input0x30.timer = os::ConvertToTimeSpan(os::GetSystemTick()).GetMilliSeconds() & 0xff;
|
||||
R_TRY(bluetooth::hid::report::WriteHidReportBuffer(&m_address, &s_output_report));
|
||||
return ams::ResultSuccess();
|
||||
}
|
||||
|
||||
Result DefaultController::HandleIncomingReport(const bluetooth::HidReport *report) {
|
||||
// Drop all incoming data for now
|
||||
return ams::ResultSuccess();
|
||||
};
|
||||
|
||||
}
|
33
btdrv-mitm/source/controllers/default_controller.hpp
Normal file
33
btdrv-mitm/source/controllers/default_controller.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 {
|
||||
|
||||
class DefaultController : public EmulatedSwitchController {
|
||||
|
||||
public:
|
||||
DefaultController(const bluetooth::Address *address)
|
||||
: EmulatedSwitchController(address) { };
|
||||
|
||||
Result Initialize(void);
|
||||
Result HandleIncomingReport(const bluetooth::HidReport *report) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue