2020-06-11 18:34:14 +00:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2020-07-11 19:10:38 +00:00
|
|
|
#include "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-07-11 19:10:38 +00:00
|
|
|
namespace ams::controller {
|
2020-06-11 18:34:14 +00:00
|
|
|
|
2020-07-27 22:57:59 +00:00
|
|
|
const constexpr char* proControllerName = "Pro Controller";
|
|
|
|
|
2020-07-11 19:10:38 +00:00
|
|
|
ControllerType identifyController(uint16_t vid, uint16_t pid);
|
2020-06-11 18:34:14 +00:00
|
|
|
|
2020-06-22 21:14:54 +00:00
|
|
|
bool IsValidSwitchControllerName(const char *name);
|
2020-07-11 19:10:38 +00:00
|
|
|
bool IsJoyCon(const char *name);
|
2020-06-22 21:14:54 +00:00
|
|
|
|
2020-08-04 20:19:12 +00:00
|
|
|
SwitchController *locateController(const bluetooth::Address *address);
|
|
|
|
|
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-08-04 20:19:12 +00:00
|
|
|
inline bool IsController(const bluetooth::DeviceClass *cod) {
|
2020-06-22 21:14:54 +00:00
|
|
|
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
|
|
|
}
|