#include "device/gamepad/gamepad_blocklist.h"
#include <stddef.h>
#include <iterator>
#include "base/containers/contains.h"
#include "base/ranges/algorithm.h"
namespace device {
namespace {
constexpr uint16_t kVendorAlps = 0x044e;
constexpr uint16_t kVendorApple = 0x05ac;
constexpr uint16_t kVendorAtmel = 0x03eb;
constexpr uint16_t kVendorAwardSoftware = 0x0412;
constexpr uint16_t kVendorBlue = 0xb58e;
constexpr uint16_t kVendorCorsair = 0x1b3c;
constexpr uint16_t kVendorCypressSemiconductor = 0x04b4;
constexpr uint16_t kVendorDarfonElectronics = 0x0d62;
constexpr uint16_t kVendorDWav = 0x0eef;
constexpr uint16_t kVendorElanMicroelectronics = 0x04f3;
constexpr uint16_t kVendorEloTouchSystems = 0x04e7;
constexpr uint16_t kVendorHoltekSemiconductor = 0x04d9;
constexpr uint16_t kVendorLenovo = 0x17ef;
constexpr uint16_t kVendorLgd = 0x1fd2;
constexpr uint16_t kVendorMicrosoft = 0x045e;
constexpr uint16_t kVendorOculus = 0x2833;
constexpr uint16_t kVendorQuantaComputer = 0x0408;
constexpr uint16_t kVendorSiliconIntegratedSystems = 0x0457;
constexpr uint16_t kVendorSunMicrosystems = 0x0430;
constexpr uint16_t kVendorSynaptics = 0x06cb;
constexpr uint16_t kVendorWacom = 0x056a;
constexpr struct VendorProductPair {
uint16_t vendor;
uint16_t product;
} kBlockedDevices[] = {
{kVendorApple, 0x3232},
{kVendorAtmel, 0xff01},
{kVendorAtmel, 0xff02},
{kVendorAwardSoftware, 0x7121},
{kVendorCorsair, 0x1b3c},
{kVendorCypressSemiconductor, 0xfef3},
{kVendorDarfonElectronics, 0x9a1a},
{kVendorHoltekSemiconductor, 0x8008},
{kVendorHoltekSemiconductor, 0x8009},
{kVendorHoltekSemiconductor, 0xa292},
{kVendorLenovo, 0x6009},
{kVendorLenovo, 0x6099},
{kVendorMicrosoft, 0x0750},
{kVendorMicrosoft, 0x07cd},
{kVendorMicrosoft, 0x0922},
{kVendorMicrosoft, 0x09af},
{kVendorMicrosoft, 0x09c0},
};
constexpr uint16_t kBlockedVendors[] = {
kVendorBlue,
kVendorOculus,
kVendorAlps,
kVendorDWav,
kVendorElanMicroelectronics,
kVendorEloTouchSystems,
kVendorLgd,
kVendorQuantaComputer,
kVendorSiliconIntegratedSystems,
kVendorSunMicrosystems,
kVendorSynaptics,
kVendorWacom,
};
}
bool GamepadIsExcluded(uint16_t vendor_id, uint16_t product_id) {
return base::Contains(kBlockedVendors, vendor_id) ||
base::ranges::any_of(
kBlockedDevices, [=](const VendorProductPair& item) {
return vendor_id == item.vendor && product_id == item.product;
});
}
}