2020-08-26 18:52:47 +00:00
|
|
|
/*
|
|
|
|
* 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 "switch_controller.hpp"
|
|
|
|
|
|
|
|
namespace ams::controller {
|
|
|
|
|
|
|
|
class EmulatedSwitchController : public SwitchController {
|
|
|
|
|
|
|
|
public:
|
2020-10-03 15:22:21 +00:00
|
|
|
EmulatedSwitchController(const bluetooth::Address *address);
|
2020-08-26 18:52:47 +00:00
|
|
|
|
|
|
|
Result HandleIncomingReport(const bluetooth::HidReport *report);
|
|
|
|
Result HandleOutgoingReport(const bluetooth::HidReport *report);
|
|
|
|
|
|
|
|
protected:
|
2020-10-03 15:50:07 +00:00
|
|
|
void ClearControllerState(void);
|
2020-10-04 15:16:07 +00:00
|
|
|
virtual void UpdateControllerState(const bluetooth::HidReport *report) {};
|
2020-10-04 16:26:02 +00:00
|
|
|
void ApplyButtonCombos(SwitchButtonData *buttons);
|
2020-08-26 18:52:47 +00:00
|
|
|
|
|
|
|
virtual Result SetVibration(void) { return ams::ResultSuccess(); };
|
|
|
|
virtual Result SetPlayerLed(uint8_t led_mask) { return ams::ResultSuccess(); };
|
|
|
|
|
2020-09-26 15:47:33 +00:00
|
|
|
constexpr void PackStickData(SwitchStickData *stick, uint16_t x, uint16_t y) {
|
|
|
|
*stick = (SwitchStickData){
|
|
|
|
static_cast<uint8_t>(x & 0xff),
|
|
|
|
static_cast<uint8_t>((x >> 8) | ((y & 0xff) << 4)),
|
|
|
|
static_cast<uint8_t>((y >> 4) & 0xff)
|
|
|
|
};
|
|
|
|
}
|
2020-08-26 18:52:47 +00:00
|
|
|
|
|
|
|
Result HandleSubCmdReport(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdRequestDeviceInfo(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSpiFlashRead(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSpiFlashWrite(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSpiSectorErase(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSetInputReportMode(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdTriggersElapsedTime(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSetShipPowerState(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSetMcuConfig(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSetMcuState(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdSetPlayerLeds(const bluetooth::HidReport *report);
|
2020-08-29 16:37:02 +00:00
|
|
|
Result SubCmdSetHomeLed(const bluetooth::HidReport *report);
|
2020-08-26 18:52:47 +00:00
|
|
|
Result SubCmdEnableImu(const bluetooth::HidReport *report);
|
|
|
|
Result SubCmdEnableVibration(const bluetooth::HidReport *report);
|
|
|
|
|
|
|
|
Result FakeSubCmdResponse(const uint8_t response[], size_t size);
|
|
|
|
|
|
|
|
bool m_charging;
|
|
|
|
uint8_t m_battery;
|
2020-10-03 15:22:21 +00:00
|
|
|
SwitchButtonData m_buttons;
|
|
|
|
SwitchStickData m_left_stick;
|
|
|
|
SwitchStickData m_right_stick;
|
|
|
|
Switch6AxisData m_motion_data[3];
|
2020-08-26 18:52:47 +00:00
|
|
|
|
2020-10-04 15:16:07 +00:00
|
|
|
ProControllerColours m_colours;
|
|
|
|
|
2020-08-26 18:52:47 +00:00
|
|
|
static bluetooth::HidReport s_input_report;
|
|
|
|
static bluetooth::HidReport s_output_report;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|