Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import...
[gecko.git] / dom / gamepad / GamepadRemapping.h
blob36a06942eca1821fa70a89170f9d7c356f4f7d27
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_GamepadRemapping_h_
8 #define mozilla_dom_GamepadRemapping_h_
10 #include "mozilla/dom/GamepadBinding.h"
11 #include "mozilla/dom/GamepadLightIndicator.h"
12 #include "mozilla/dom/GamepadPoseState.h"
13 #include "mozilla/dom/GamepadTouchState.h"
15 namespace mozilla {
16 namespace dom {
18 // GamepadId is (vendorId << 16) | productId)
19 enum class GamepadId : uint32_t {
20 // Nexus Player Controller
21 kAsusTekProduct4500 = 0x0b054500,
22 // 2Axes 8Keys Game Pad
23 kDragonRiseProduct0011 = 0x00790011,
24 // ADT-1 Controller
25 kGoogleProduct2c40 = 0x18d12c40,
26 // Stadia Controller
27 kGoogleProduct9400 = 0x18d19400,
28 // Logitech F310, D-mode
29 kLogitechProductc216 = 0x046dc216,
30 // Logitech F510, D-mode
31 kLogitechProductc218 = 0x046dc218,
32 // Logitech F710, D-mode
33 kLogitechProductc219 = 0x046dc219,
34 // Microsoft Xbox 360
35 kMicrosoftProductXbox360 = 0x045e028e,
36 // Microsoft Xbox 360 Wireless
37 kMicrosoftProductXbox360Wireless = 0x045e028f,
38 // Microsoft Xbox 360 Wireless
39 kMicrosoftProductXbox360Wireless2 = 0x045e0719,
40 // Microsoft Xbox One 2013
41 kMicrosoftProductXbox2013 = 0x045e02d1,
42 // Microsoft Xbox One (2015 FW)
43 kMicrosoftProductXbox2015 = 0x045e02dd,
44 // Microsoft Xbox One S
45 kMicrosoftProductXboxOneS = 0x045e02ea,
46 // Microsoft Xbox One S Wireless
47 kMicrosoftProductXboxOneSWireless = 0x045e02e0,
48 // Microsoft Xbox One Elite
49 kMicrosoftProductXboxOneElite = 0x045e02e3,
50 // Microsoft Xbox One Elite 2
51 kMicrosoftProductXboxOneElite2 = 0x045e0b00,
52 // Microsoft Xbox One Elite 2 Wireless
53 kMicrosoftProductXboxOneElite2Wireless = 0x045e0b05,
54 // Xbox One S Wireless (2016 FW)
55 kMicrosoftProductXboxOneSWireless2016 = 0x045e02fd,
56 // Microsoft Xbox Adaptive
57 kMicrosoftProductXboxAdaptive = 0x045e0b0a,
58 // Microsoft Xbox Adaptive Wireless
59 kMicrosoftProductXboxAdaptiveWireless = 0x045e0b0c,
60 // Switch Joy-Con L
61 kNintendoProduct2006 = 0x057e2006,
62 // Switch Joy-Con R
63 kNintendoProduct2007 = 0x057e2007,
64 // Switch Pro Controller
65 kNintendoProduct2009 = 0x057e2009,
66 // Switch Charging Grip
67 kNintendoProduct200e = 0x057e200e,
68 // Nvidia Shield gamepad (2015)
69 kNvidiaProduct7210 = 0x09557210,
70 // Nvidia Shield gamepad (2017)
71 kNvidiaProduct7214 = 0x09557214,
72 // iBuffalo Classic
73 kPadixProduct2060 = 0x05832060,
74 // XSkills Gamecube USB adapter
75 kPlayComProduct0005 = 0x0b430005,
76 // boom PSX+N64 USB Converter
77 kPrototypeVendorProduct0667 = 0x66660667,
78 // Analog game controller
79 kPrototypeVendorProduct9401 = 0x66669401,
80 // Razer Serval Controller
81 kRazer1532Product0900 = 0x15320900,
82 // Playstation 3 Controller
83 kSonyProduct0268 = 0x054c0268,
84 // Playstation Dualshock 4
85 kSonyProduct05c4 = 0x054c05c4,
86 // Dualshock 4 (PS4 Slim)
87 kSonyProduct09cc = 0x054c09cc,
88 // Dualshock 4 USB receiver
89 kSonyProduct0ba0 = 0x054c0ba0,
90 // Moga Pro Controller (HID mode)
91 kVendor20d6Product6271 = 0x20d66271,
92 // OnLive Controller (Bluetooth)
93 kVendor2378Product1008 = 0x23781008,
94 // OnLive Controller (Wired)
95 kVendor2378Product100a = 0x2378100a,
96 // OUYA Controller
97 kVendor2836Product0001 = 0x28360001,
100 class GamepadRemapper {
101 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadRemapper)
103 public:
104 virtual uint32_t GetAxisCount() const = 0;
105 virtual uint32_t GetButtonCount() const = 0;
106 virtual uint32_t GetLightIndicatorCount() const { return 0; }
107 virtual void GetLightIndicators(
108 nsTArray<GamepadLightIndicatorType>& aTypes) const {}
109 virtual uint32_t GetTouchEventCount() const { return 0; }
110 virtual void GetLightColorReport(uint8_t aRed, uint8_t aGreen, uint8_t aBlue,
111 std::vector<uint8_t>& aReport) const {}
112 virtual uint32_t GetMaxInputReportLength() const { return 0; }
114 virtual void SetAxisCount(uint32_t aButtonCount) {}
115 virtual void SetButtonCount(uint32_t aButtonCount) {}
116 virtual GamepadMappingType GetMappingType() const {
117 return GamepadMappingType::Standard;
119 virtual void ProcessTouchData(GamepadHandle aHandle, void* aInput) {}
120 virtual void RemapAxisMoveEvent(GamepadHandle aHandle, uint32_t aAxis,
121 double aValue) const = 0;
122 virtual void RemapButtonEvent(GamepadHandle aHandle, uint32_t aButton,
123 bool aPressed) const = 0;
125 protected:
126 GamepadRemapper() = default;
127 virtual ~GamepadRemapper() = default;
130 struct GamepadRemappingData {
131 GamepadId id;
132 RefPtr<GamepadRemapper> remapping;
135 already_AddRefed<GamepadRemapper> GetGamepadRemapper(const uint16_t aVendorId,
136 const uint16_t aProductId,
137 bool& aUsingDefault);
139 } // namespace dom
140 } // namespace mozilla
142 #endif // mozilla_dom_GamepadRemapping_h_