chromium/device/gamepad/gamepad_standard_mappings_linux.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <stddef.h>

#include <iterator>

#include "base/ranges/algorithm.h"
#include "device/gamepad/gamepad_id_list.h"
#include "device/gamepad/gamepad_standard_mappings.h"

namespace device {

namespace {
// The Linux kernel has been updated to improve the mapping exposed by Sony
// Playstation controllers. If the high bit of the bcdHID value is set it
// indicates that an improved mapping is used, otherwise the default mapping
// is used.
// Dualshock 4 devices are patched in 4.10:
// https://github.com/torvalds/linux/commit/9131f8cc2b4eaf7c08d402243429e0bfba9aa0d6
// Dualshock 3 and SIXAXIS devices are patched in 4.12:
// https://github.com/torvalds/linux/commit/e19a267b9987135c00155a51e683e434b9abb56b
// Dualsense devices are patched in 5.12:
// https://github.com/torvalds/linux/commit/bc2e15a9a0228b10fece576d4f6a974c002ff07b
const uint16_t kDualshockPatchedBcdHidMask =;

// Older versions of the Stadia Controller firmware use an alternate mapping
// function.
const uint16_t kStadiaControllerOldFirmwareVersion =;

enum StadiaGamepadButtons {};

enum XboxSeriesXGamepadButtons {};

void MapperXInputStyleGamepad(const Gamepad& input, Gamepad* mapped) {}

void MapperXboxBluetooth(const Gamepad& input, Gamepad* mapped) {}

void MapperXboxSeriesXBluetooth(const Gamepad& input, Gamepad* mapped) {}

void MapperXboxOneS(const Gamepad& input, Gamepad* mapped) {}

void MapperXboxOneS2016Firmware(const Gamepad& input, Gamepad* mapped) {}

void MapperXboxElite2Bluetooth(const Gamepad& input, Gamepad* mapped) {}

void MapperLakeviewResearch(const Gamepad& input, Gamepad* mapped) {}

void MapperDualshock3SixAxis(const Gamepad& input, Gamepad* mapped) {}

void MapperDualshock3SixAxisNew(const Gamepad& input, Gamepad* mapped) {}

void MapperDualshock4(const Gamepad& input, Gamepad* mapped) {}

// This mapping function is intended for Playstation 4 and 5 gamepads handled
// by hid-sony (kernel 4.10+) and hid-playstation (kernel 5.12+).
void MapperPs4Ps5(const Gamepad& input, Gamepad* mapped) {}

void MapperDualSense(const Gamepad& input, Gamepad* mapped) {}

void MapperIBuffalo(const Gamepad& input, Gamepad* mapped) {}

void MapperXGEAR(const Gamepad& input, Gamepad* mapped) {}

void MapperDragonRiseGeneric(const Gamepad& input, Gamepad* mapped) {}

void MapperOnLiveWireless(const Gamepad& input, Gamepad* mapped) {}

void MapperADT1(const Gamepad& input, Gamepad* mapped) {}

void MapperNvShield(const Gamepad& input, Gamepad* mapped) {}

void MapperNvShield2017(const Gamepad& input, Gamepad* mapped) {}

void MapperOUYA(const Gamepad& input, Gamepad* mapped) {}

void MapperRazerServal(const Gamepad& input, Gamepad* mapped) {}

void MapperMoga(const Gamepad& input, Gamepad* mapped) {}

void MapperSamsung_EI_GP20(const Gamepad& input, Gamepad* mapped) {}

void MapperSteelSeriesZeemote(const Gamepad& input, Gamepad* mapped) {}

void MapperSteelSeriesStratusXLUsb(const Gamepad& input, Gamepad* mapped) {}

void MapperSteelSeriesStratusBt(const Gamepad& input, Gamepad* mapped) {}

void MapperSteelSeriesStratusPlusBt(const Gamepad& input, Gamepad* mapped) {}

void MapperLogitechDInput(const Gamepad& input, Gamepad* mapped) {}

void MapperStadiaControllerOldFirmware(const Gamepad& input, Gamepad* mapped) {}

void MapperStadiaController(const Gamepad& input, Gamepad* mapped) {}

void MapperXSkills(const Gamepad& input, Gamepad* mapped) {}

void MapperBoomN64Psx(const Gamepad& input, Gamepad* mapped) {}

void MapperSnakebyteIDroidCon(const Gamepad& input, Gamepad* mapped) {}

void MapperHoripadSwitch(const Gamepad& input, Gamepad* mapped) {}

void MapperElecomWiredDirectInput(const Gamepad& input, Gamepad* mapped) {}

void MapperElecomWirelessDirectInput(const Gamepad& input, Gamepad* mapped) {}

void MapperDjiFpv(const Gamepad& input, Gamepad* mapped) {}

void MapperAcer(const Gamepad& input, Gamepad* mapped) {}

void MapperAcerAppMode(const Gamepad& input, Gamepad* mapped) {}

constexpr struct MappingData {} kAvailableMappings[] =;

}  // namespace

GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
    const std::string_view product_name,
    const uint16_t vendor_id,
    const uint16_t product_id,
    const uint16_t hid_specification_version,
    const uint16_t version_number,
    GamepadBusType bus_type) {}

}  // namespace device