2020-06-11 18:34:14 +00:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2020-07-11 18:26:55 +00:00
|
|
|
#include "controllers/switchcontroller.hpp"
|
2020-06-11 18:34:14 +00:00
|
|
|
|
2020-06-22 21:14:54 +00:00
|
|
|
#define BTM_COD_MAJOR_PERIPHERAL 0x05
|
|
|
|
#define BTM_COD_MINOR_GAMEPAD 0x08
|
|
|
|
#define BTM_COD_MINOR_JOYSTICK 0x04
|
|
|
|
|
2020-06-11 18:34:14 +00:00
|
|
|
namespace ams::mitm::btdrv {
|
|
|
|
|
|
|
|
controller::ControllerType identifyController(uint16_t vid, uint16_t pid);
|
2020-07-11 18:26:55 +00:00
|
|
|
controller::SwitchController *locateController(const bluetooth::Address *address);
|
2020-06-11 18:34:14 +00:00
|
|
|
|
2020-06-22 21:14:54 +00:00
|
|
|
bool IsValidSwitchControllerName(const char *name);
|
|
|
|
|
2020-07-11 18:26:55 +00:00
|
|
|
void attachDeviceHandler(const bluetooth::Address *address);
|
|
|
|
void removeDeviceHandler(const bluetooth::Address *address);
|
2020-06-11 18:34:14 +00:00
|
|
|
|
2020-06-22 21:14:54 +00:00
|
|
|
inline bool IsController(const BluetoothDeviceClass *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) );
|
|
|
|
}
|
|
|
|
|
2020-06-11 18:34:14 +00:00
|
|
|
}
|