Bug 1854367 - Mark storage-access-permission.sub.https.window.html subtest as intermi...
[gecko.git] / dom / gamepad / GamepadRemapping.h
blob8b2038889fb239791682ef9061a35a47b5ece1bc
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::dom {
17 // GamepadId is (vendorId << 16) | productId)
18 enum class GamepadId : uint32_t {
19 // Nexus Player Controller
20 kAsusTekProduct4500 = 0x0b054500,
21 // 2Axes 8Keys Game Pad
22 kDragonRiseProduct0011 = 0x00790011,
23 // ADT-1 Controller
24 kGoogleProduct2c40 = 0x18d12c40,
25 // Stadia Controller
26 kGoogleProduct9400 = 0x18d19400,
27 // Logitech F310, D-mode
28 kLogitechProductc216 = 0x046dc216,
29 // Logitech F510, D-mode
30 kLogitechProductc218 = 0x046dc218,
31 // Logitech F710, D-mode
32 kLogitechProductc219 = 0x046dc219,
33 // Microsoft Xbox 360
34 kMicrosoftProductXbox360 = 0x045e028e,
35 // Microsoft Xbox 360 Wireless
36 kMicrosoftProductXbox360Wireless = 0x045e028f,
37 // Microsoft Xbox 360 Wireless
38 kMicrosoftProductXbox360Wireless2 = 0x045e0719,
39 // Microsoft Xbox One 2013
40 kMicrosoftProductXbox2013 = 0x045e02d1,
41 // Microsoft Xbox One (2015 FW)
42 kMicrosoftProductXbox2015 = 0x045e02dd,
43 // Microsoft Xbox One S
44 kMicrosoftProductXboxOneS = 0x045e02ea,
45 // Microsoft Xbox One S Wireless
46 kMicrosoftProductXboxOneSWireless = 0x045e02e0,
47 // Microsoft Xbox One Elite
48 kMicrosoftProductXboxOneElite = 0x045e02e3,
49 // Microsoft Xbox One Elite 2
50 kMicrosoftProductXboxOneElite2 = 0x045e0b00,
51 // Microsoft Xbox One Elite 2 Wireless
52 kMicrosoftProductXboxOneElite2Wireless = 0x045e0b05,
53 // Xbox One S Wireless (2016 FW)
54 kMicrosoftProductXboxOneSWireless2016 = 0x045e02fd,
55 // Microsoft Xbox Adaptive
56 kMicrosoftProductXboxAdaptive = 0x045e0b0a,
57 // Microsoft Xbox Adaptive Wireless
58 kMicrosoftProductXboxAdaptiveWireless = 0x045e0b0c,
59 // Microsoft Xbox Series X Wireless
60 kMicrosoftProductXboxSeriesXWireless = 0x045e0b13,
61 // Switch Joy-Con L
62 kNintendoProduct2006 = 0x057e2006,
63 // Switch Joy-Con R
64 kNintendoProduct2007 = 0x057e2007,
65 // Switch Pro Controller
66 kNintendoProduct2009 = 0x057e2009,
67 // Switch Charging Grip
68 kNintendoProduct200e = 0x057e200e,
69 // Nvidia Shield gamepad (2015)
70 kNvidiaProduct7210 = 0x09557210,
71 // Nvidia Shield gamepad (2017)
72 kNvidiaProduct7214 = 0x09557214,
73 // iBuffalo Classic
74 kPadixProduct2060 = 0x05832060,
75 // XSkills Gamecube USB adapter
76 kPlayComProduct0005 = 0x0b430005,
77 // boom PSX+N64 USB Converter
78 kPrototypeVendorProduct0667 = 0x66660667,
79 // Analog game controller
80 kPrototypeVendorProduct9401 = 0x66669401,
81 // Razer Serval Controller
82 kRazer1532Product0900 = 0x15320900,
83 // Playstation 3 Controller
84 kSonyProduct0268 = 0x054c0268,
85 // Playstation Dualshock 4
86 kSonyProduct05c4 = 0x054c05c4,
87 // Dualshock 4 (PS4 Slim)
88 kSonyProduct09cc = 0x054c09cc,
89 // Dualshock 4 USB receiver
90 kSonyProduct0ba0 = 0x054c0ba0,
91 // Moga Pro Controller (HID mode)
92 kVendor20d6Product6271 = 0x20d66271,
93 // OnLive Controller (Bluetooth)
94 kVendor2378Product1008 = 0x23781008,
95 // OnLive Controller (Wired)
96 kVendor2378Product100a = 0x2378100a,
97 // OUYA Controller
98 kVendor2836Product0001 = 0x28360001,
101 class GamepadRemapper {
102 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadRemapper)
104 public:
105 virtual uint32_t GetAxisCount() const = 0;
106 virtual uint32_t GetButtonCount() const = 0;
107 virtual uint32_t GetLightIndicatorCount() const { return 0; }
108 virtual void GetLightIndicators(
109 nsTArray<GamepadLightIndicatorType>& aTypes) const {}
110 virtual uint32_t GetTouchEventCount() const { return 0; }
111 virtual void GetLightColorReport(uint8_t aRed, uint8_t aGreen, uint8_t aBlue,
112 std::vector<uint8_t>& aReport) const {}
113 virtual uint32_t GetMaxInputReportLength() const { return 0; }
115 virtual void SetAxisCount(uint32_t aButtonCount) {}
116 virtual void SetButtonCount(uint32_t aButtonCount) {}
117 virtual GamepadMappingType GetMappingType() const {
118 return GamepadMappingType::Standard;
120 virtual void ProcessTouchData(GamepadHandle aHandle, void* aInput) {}
121 virtual void RemapAxisMoveEvent(GamepadHandle aHandle, uint32_t aAxis,
122 double aValue) const = 0;
123 virtual void RemapButtonEvent(GamepadHandle aHandle, uint32_t aButton,
124 bool aPressed) const = 0;
126 protected:
127 GamepadRemapper() = default;
128 virtual ~GamepadRemapper() = default;
131 struct GamepadRemappingData {
132 GamepadId id;
133 RefPtr<GamepadRemapper> remapping;
136 already_AddRefed<GamepadRemapper> GetGamepadRemapper(const uint16_t aVendorId,
137 const uint16_t aProductId,
138 bool& aUsingDefault);
140 } // namespace mozilla::dom
142 #endif // mozilla_dom_GamepadRemapping_h_