MissionControl/btdrv-mitm/source/controllers/controllermanager.hpp

30 lines
959 B
C++
Raw Normal View History

#pragma once
#include <switch.h>
#include "switchcontroller.hpp"
#define BTM_COD_MAJOR_PERIPHERAL 0x05
#define BTM_COD_MINOR_GAMEPAD 0x08
#define BTM_COD_MINOR_JOYSTICK 0x04
namespace ams::controller {
const constexpr char* proControllerName = "Pro Controller";
ControllerType identifyController(uint16_t vid, uint16_t pid);
bool IsValidSwitchControllerName(const char *name);
bool IsJoyCon(const char *name);
2020-08-04 20:19:12 +00:00
SwitchController *locateController(const bluetooth::Address *address);
void attachDeviceHandler(const bluetooth::Address *address);
void removeDeviceHandler(const bluetooth::Address *address);
2020-08-04 20:19:12 +00:00
inline bool IsController(const bluetooth::DeviceClass *cod) {
return ( (((uint8_t *)cod)[1] & 0x0f) == BTM_COD_MAJOR_PERIPHERAL) &&
( ((((uint8_t *)cod)[2] & 0x0f) == BTM_COD_MINOR_GAMEPAD) ||
( (((uint8_t *)cod)[2] & 0x0f) == BTM_COD_MINOR_JOYSTICK) );
}
}