mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 06:10:20 +00:00
btdrv-mitm: move some functionality out of SwitchController and into EmulatedSwitchController
This commit is contained in:
parent
5ef5a2f143
commit
00b3bc98a4
2 changed files with 18 additions and 18 deletions
|
@ -3,11 +3,25 @@
|
|||
|
||||
namespace ams::controller {
|
||||
|
||||
inline bool bdcmp(const bluetooth::Address *addr1, const bluetooth::Address *addr2) {
|
||||
return std::memcmp(addr1, addr2, sizeof(bluetooth::Address)) == 0;
|
||||
}
|
||||
|
||||
inline 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)
|
||||
};
|
||||
}
|
||||
|
||||
class EmulatedSwitchController : public SwitchController {
|
||||
|
||||
public:
|
||||
EmulatedSwitchController(ControllerType type, const bluetooth::Address *address)
|
||||
: SwitchController(type, address) { };
|
||||
: SwitchController(type, address)
|
||||
, m_charging(false)
|
||||
, m_battery(BATTERY_MAX) { };
|
||||
|
||||
const bluetooth::HidReport * handleIncomingReport(const bluetooth::HidReport *report);
|
||||
const bluetooth::HidReport * handleOutgoingReport(const bluetooth::HidReport *report);
|
||||
|
@ -32,6 +46,8 @@ namespace ams::controller {
|
|||
|
||||
Result fakeSubCmdResponse(const u8 response[], size_t size);
|
||||
|
||||
bool m_charging;
|
||||
uint8_t m_battery;
|
||||
bluetooth::HidReport m_inputReport;
|
||||
bluetooth::HidReport m_outputReport;
|
||||
};
|
||||
|
|
|
@ -123,18 +123,6 @@ namespace ams::controller {
|
|||
};
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
inline 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)
|
||||
};
|
||||
}
|
||||
|
||||
inline bool bdcmp(const bluetooth::Address *addr1, const bluetooth::Address *addr2) {
|
||||
return std::memcmp(addr1, addr2, sizeof(bluetooth::Address)) == 0;
|
||||
}
|
||||
|
||||
class SwitchController {
|
||||
|
||||
public:
|
||||
|
@ -152,15 +140,11 @@ namespace ams::controller {
|
|||
SwitchController(ControllerType type, const bluetooth::Address *address)
|
||||
: m_type(type)
|
||||
, m_address(*address)
|
||||
, m_charging(false)
|
||||
, m_battery(BATTERY_MAX)
|
||||
, m_switchController((type == ControllerType_Joycon) || (type == ControllerType_SwitchPro)) { };
|
||||
|
||||
ControllerType m_type;
|
||||
bluetooth::Address m_address;
|
||||
bool m_charging;
|
||||
uint8_t m_battery;
|
||||
|
||||
|
||||
bool m_switchController;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue