@antha/gamepad-type 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE-CC0 +121 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +102 -0
  4. package/dist/create.d.ts +10 -0
  5. package/dist/create.js +20 -0
  6. package/dist/default-layouts.d.ts +8 -0
  7. package/dist/default-layouts.js +339 -0
  8. package/dist/default-models.d.ts +14 -0
  9. package/dist/default-models.js +46 -0
  10. package/dist/demo/elements/gamepad/vir-gamepad-axe.element.d.ts +7 -0
  11. package/dist/demo/elements/gamepad/vir-gamepad-axe.element.js +61 -0
  12. package/dist/demo/elements/gamepad/vir-gamepad-button.element.d.ts +7 -0
  13. package/dist/demo/elements/gamepad/vir-gamepad-button.element.js +87 -0
  14. package/dist/demo/elements/gamepad/vir-gamepad-input.element.d.ts +7 -0
  15. package/dist/demo/elements/gamepad/vir-gamepad-input.element.js +38 -0
  16. package/dist/demo/elements/gamepad/vir-gamepad-inputs.element.d.ts +20 -0
  17. package/dist/demo/elements/gamepad/vir-gamepad-inputs.element.js +110 -0
  18. package/dist/demo/elements/gamepad/vir-gamepad-name.element.d.ts +11 -0
  19. package/dist/demo/elements/gamepad/vir-gamepad-name.element.js +158 -0
  20. package/dist/demo/elements/gamepad/vir-gamepad.element.d.ts +8 -0
  21. package/dist/demo/elements/gamepad/vir-gamepad.element.js +41 -0
  22. package/dist/demo/elements/modals/vir-create-new-type.modal.element.d.ts +9 -0
  23. package/dist/demo/elements/modals/vir-create-new-type.modal.element.js +135 -0
  24. package/dist/demo/elements/modals/vir-edit-mappings.modal.element.d.ts +29 -0
  25. package/dist/demo/elements/modals/vir-edit-mappings.modal.element.js +185 -0
  26. package/dist/demo/elements/modals/vir-modal.element.d.ts +3 -0
  27. package/dist/demo/elements/modals/vir-modal.element.js +88 -0
  28. package/dist/demo/elements/vir-demo.element.d.ts +27 -0
  29. package/dist/demo/elements/vir-demo.element.js +469 -0
  30. package/dist/demo/events/modal-close.event.d.ts +1 -0
  31. package/dist/demo/events/modal-close.event.js +2 -0
  32. package/dist/demo/events/selected-gamepad-index-change.event.d.ts +1 -0
  33. package/dist/demo/events/selected-gamepad-index-change.event.js +2 -0
  34. package/dist/demo/gamepad-brand-color.d.ts +1 -0
  35. package/dist/demo/gamepad-brand-color.js +14 -0
  36. package/dist/demo/global-vars.d.ts +6 -0
  37. package/dist/demo/global-vars.js +3 -0
  38. package/dist/demo/overrides.d.ts +7 -0
  39. package/dist/demo/overrides.js +1 -0
  40. package/dist/demo/sentry-setup.d.ts +1 -0
  41. package/dist/demo/sentry-setup.js +11 -0
  42. package/dist/demo/util/casing.d.ts +1 -0
  43. package/dist/demo/util/casing.js +7 -0
  44. package/dist/demo/util/check-changes.d.ts +6 -0
  45. package/dist/demo/util/check-changes.js +28 -0
  46. package/dist/demo/util/local-save-data.d.ts +9 -0
  47. package/dist/demo/util/local-save-data.js +36 -0
  48. package/dist/demo/util/user-agent.d.ts +6 -0
  49. package/dist/demo/util/user-agent.js +2 -0
  50. package/dist/demo/util/window-listener.d.ts +1 -0
  51. package/dist/demo/util/window-listener.js +6 -0
  52. package/dist/find-matches.d.ts +42 -0
  53. package/dist/find-matches.js +77 -0
  54. package/dist/gamepad-layout.d.ts +29 -0
  55. package/dist/gamepad-layout.js +1 -0
  56. package/dist/gamepad-model.d.ts +67 -0
  57. package/dist/gamepad-model.js +69 -0
  58. package/dist/index.d.ts +8 -0
  59. package/dist/index.js +8 -0
  60. package/dist/known-input.d.ts +126 -0
  61. package/dist/known-input.js +128 -0
  62. package/dist/system-versions.d.ts +25 -0
  63. package/dist/system-versions.js +26 -0
  64. package/dist/util/lowercase-keys.d.ts +2 -0
  65. package/dist/util/lowercase-keys.js +10 -0
  66. package/package.json +67 -0
package/LICENSE-CC0 ADDED
@@ -0,0 +1,121 @@
1
+ CC0 1.0 Universal
2
+
3
+ Creative Commons Legal Code
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 electrovir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @antha/gamepad-type
2
+
3
+ Determine gamepad models, brands, and layouts based on the user operating system.
4
+
5
+ Detects the following per gamepad:
6
+
7
+ - gamepad model
8
+ - gamepad brand
9
+ - gamepad input names
10
+
11
+ based on hardcoded, pre-collected data. You are also able to define new values for each in case any data is missing.
12
+
13
+ If you notice incorrect mappings, please enter updated information [on the demo page](https://zorp.fun/gamepad-tester). Every browser, browser version, operating system, and operating system version combination produces different values so it's impossible for me to single-handedly account for them all.
14
+
15
+ It is encouraged that you use the package [`input-device-handler`](https://www.npmjs.com/package/input-device-handler) in conjunction with this one, but it is not required.
16
+
17
+ # links
18
+
19
+ - [demo page](https://electrovir.github.io/gamepad-type) (allows submitting gamepad mapping fixes)
20
+ - [full API docs](https://electrovir.github.io/gamepad-type/docs)
21
+ - [GitHub repo](https://github.com/electrovir/gamepad-type) (please open issues for gamepad mapping updates)
22
+ - [npm package](https://www.npmjs.com/package/gamepad-type)
23
+
24
+ # install
25
+
26
+ ```sh
27
+ npm i @antha/gamepad-type
28
+ ```
29
+
30
+ # usage
31
+
32
+ The primary exports of this package are the following:
33
+
34
+ - [`findMatchingGamepadModel`](https://electrovir.github.io/gamepad-type/functions/findMatchingGamepadModel.html): given the system-level gamepad id, determines the gamepad's model and brand. Also includes a model description string. Allows custom model and brand map inputs to handle edge cases that this package doesn't cover. (If you find those edge cases please either [open a ticket in the GitHub repo](https://github.com/electrovir/gamepad-type/issues/new) or submit your fixed data on [the demo page](https://zorp.fun/gamepad-tester).)
35
+ - [`findMatchingGamepadLayout`](https://electrovir.github.io/gamepad-type/functions/findMatchingGamepadLayout.html): given the system-level gamepad id, determines the gamepad's button and axe names (based on gamepad model and user operating system). Allows custom model and input map inputs to handle edge cases that this package doesn't cover. (If you find those edge cases please either [open a ticket in the GitHub repo](https://github.com/electrovir/gamepad-type/issues/new) or submit your fixed data on [the demo page](https://zorp.fun/gamepad-tester).)
36
+
37
+ ## examples
38
+
39
+ - `findMatchingGamepadModel`
40
+
41
+ <!-- example-link: src/readme-examples/getting-model.example.ts -->
42
+
43
+ ```TypeScript
44
+ import {InputDeviceHandler} from 'input-device-handler';
45
+ import {findMatchingGamepadModel} from '@antha/gamepad-type';
46
+
47
+ // using window.navigator directly
48
+ {
49
+ const {gamepadBrand, gamepadModel, gamepadModelDescription} = findMatchingGamepadModel({
50
+ gamepad: window.navigator.getGamepads()[0]?.id,
51
+ });
52
+ }
53
+
54
+ // using InputDeviceHandler
55
+ {
56
+ const deviceHandler = new InputDeviceHandler();
57
+
58
+ const {gamepadBrand, gamepadModel, gamepadModelDescription} = findMatchingGamepadModel({
59
+ gamepad: deviceHandler.readAllDevices()[0],
60
+ });
61
+ }
62
+ ```
63
+
64
+ - `findMatchingGamepadLayout`
65
+
66
+ <!-- example-link: src/readme-examples/getting-layout.example.ts -->
67
+
68
+ ```TypeScript
69
+ import {InputDeviceHandler} from 'input-device-handler';
70
+ import {findMatchingGamepadLayout} from '@antha/gamepad-type';
71
+
72
+ // using window.navigator directly
73
+ {
74
+ const maybeLayout = findMatchingGamepadLayout({
75
+ gamepad: window.navigator.getGamepads()[0]?.id,
76
+ });
77
+
78
+ maybeLayout?.inputMappings;
79
+ }
80
+
81
+ // using InputDeviceHandler
82
+ {
83
+ const deviceHandler = new InputDeviceHandler();
84
+
85
+ const maybeLayout = findMatchingGamepadLayout({
86
+ gamepad: deviceHandler.readAllDevices()[0],
87
+ });
88
+
89
+ maybeLayout?.inputMappings;
90
+ }
91
+ ```
92
+
93
+ ## predefined mappings
94
+
95
+ You can access all predefined mappings and values with the following exported values:
96
+
97
+ - `PredefinedGamepadModel`: an enum of known gamepad models.
98
+ - `PredefinedGamepadBrand`: an enum of known gamepad brands.
99
+ - `predefinedGamepadModelDescriptions`: a map of `PredefinedGamepadModel` to description strings.
100
+ - `defaultGamepadModelMap`: a map of known gamepad ids / names to their known gamepad models.
101
+ - `defaultGamepadBrandMap`: a map of known gamepad models to their known gamepad brands.
102
+ - `defaultGamepadLayouts`: an array of all known gamepad layouts.
@@ -0,0 +1,10 @@
1
+ import { type GamepadDevice } from 'input-device-handler';
2
+ import { type GamepadLayout } from './gamepad-layout.js';
3
+ import { type GamepadModelMap } from './gamepad-model.js';
4
+ /**
5
+ * Creates an empty layout as a starting point for building a new one. Includes the correct system
6
+ * versions already.
7
+ *
8
+ * @category Util
9
+ */
10
+ export declare function createEmptyGamepadLayout(gamepad: Readonly<Pick<GamepadDevice, 'deviceName'>>, gamepadModelMap?: GamepadModelMap | undefined): GamepadLayout;
package/dist/create.js ADDED
@@ -0,0 +1,20 @@
1
+ import { findMatchingGamepadModel } from './find-matches.js';
2
+ import { getSystemVersions } from './system-versions.js';
3
+ /**
4
+ * Creates an empty layout as a starting point for building a new one. Includes the correct system
5
+ * versions already.
6
+ *
7
+ * @category Util
8
+ */
9
+ export function createEmptyGamepadLayout(gamepad, gamepadModelMap) {
10
+ const { gamepadModel } = findMatchingGamepadModel({
11
+ gamepad: gamepad.deviceName,
12
+ gamepadModelMap,
13
+ });
14
+ return {
15
+ inputMappings: {},
16
+ gamepadModels: gamepadModel ? [gamepadModel] : [],
17
+ systemVersions: [getSystemVersions()],
18
+ notes: undefined,
19
+ };
20
+ }
@@ -0,0 +1,8 @@
1
+ import { type GamepadLayout } from './gamepad-layout.js';
2
+ /**
3
+ * Gamepad layouts defined by the [gamepad-type](https://www.npmjs.com/package/gamepad-type) package
4
+ * that have already been determined for most major OEM gamepads.
5
+ *
6
+ * @category Defaults
7
+ */
8
+ export declare const defaultGamepadLayouts: ReadonlyArray<Readonly<GamepadLayout>>;
@@ -0,0 +1,339 @@
1
+ /* eslint-disable sonarjs/no-hardcoded-ip */
2
+ import { PredefinedGamepadModel } from './gamepad-model.js';
3
+ import { KnownInput } from './known-input.js';
4
+ /**
5
+ * Gamepad layouts defined by the [gamepad-type](https://www.npmjs.com/package/gamepad-type) package
6
+ * that have already been determined for most major OEM gamepads.
7
+ *
8
+ * @category Defaults
9
+ */
10
+ export const defaultGamepadLayouts = [
11
+ {
12
+ gamepadModels: [PredefinedGamepadModel.SwitchPro],
13
+ inputMappings: {
14
+ 'axe-0': KnownInput.LeftStickX,
15
+ 'axe-1': KnownInput.LeftStickY,
16
+ 'axe-2': KnownInput.RightStickX,
17
+ 'axe-3': KnownInput.RightStickY,
18
+ 'button-0': KnownInput.FaceAccept,
19
+ 'button-1': KnownInput.FaceCancel,
20
+ 'button-2': KnownInput.FaceAlt1,
21
+ 'button-3': KnownInput.FaceAlt2,
22
+ 'button-4': KnownInput.L1,
23
+ 'button-5': KnownInput.R1,
24
+ 'button-6': KnownInput.L2,
25
+ 'button-7': KnownInput.R2,
26
+ 'button-8': KnownInput.Select,
27
+ 'button-9': KnownInput.Start,
28
+ 'button-10': KnownInput.L3,
29
+ 'button-11': KnownInput.R3,
30
+ 'button-12': KnownInput.DPadUp,
31
+ 'button-13': KnownInput.DPadDown,
32
+ 'button-14': KnownInput.DPadLeft,
33
+ 'button-15': KnownInput.DPadRight,
34
+ 'button-16': KnownInput.Home,
35
+ },
36
+ systemVersions: [
37
+ {
38
+ browserVersion: '17.2.1',
39
+ browserName: 'Safari',
40
+ osName: 'macOS',
41
+ osVersion: '10.15.7',
42
+ },
43
+ ],
44
+ notes: {
45
+ info: 'The capture / screenshot button is not detected by this browser.',
46
+ },
47
+ },
48
+ {
49
+ gamepadModels: [PredefinedGamepadModel.XboxWireless],
50
+ inputMappings: {
51
+ 'axe-0': KnownInput.LeftStickX,
52
+ 'axe-1': KnownInput.LeftStickY,
53
+ 'axe-2': KnownInput.RightStickX,
54
+ 'axe-3': KnownInput.RightStickY,
55
+ 'button-0': KnownInput.FaceAccept,
56
+ 'button-1': KnownInput.FaceCancel,
57
+ 'button-2': KnownInput.FaceAlt1,
58
+ 'button-3': KnownInput.FaceAlt2,
59
+ 'button-4': KnownInput.L1,
60
+ 'button-5': KnownInput.R1,
61
+ 'button-6': KnownInput.L2,
62
+ 'button-7': KnownInput.R2,
63
+ 'button-8': KnownInput.Select,
64
+ 'button-9': KnownInput.Start,
65
+ 'button-10': KnownInput.L3,
66
+ 'button-11': KnownInput.R3,
67
+ 'button-12': KnownInput.DPadUp,
68
+ 'button-13': KnownInput.DPadDown,
69
+ 'button-14': KnownInput.DPadLeft,
70
+ 'button-15': KnownInput.DPadRight,
71
+ 'button-16': KnownInput.Logo,
72
+ },
73
+ systemVersions: [
74
+ {
75
+ browserVersion: '17.2.1',
76
+ browserName: 'Safari',
77
+ osName: 'macOS',
78
+ osVersion: '10.15.7',
79
+ },
80
+ ],
81
+ notes: {
82
+ info: 'The share button is not detected by this browser.',
83
+ },
84
+ },
85
+ {
86
+ gamepadModels: [PredefinedGamepadModel.SwitchPro],
87
+ inputMappings: {
88
+ 'axe-0': KnownInput.LeftStickX,
89
+ 'axe-1': KnownInput.LeftStickY,
90
+ 'axe-2': KnownInput.RightStickX,
91
+ 'axe-3': KnownInput.RightStickY,
92
+ 'button-0': KnownInput.FaceCancel,
93
+ 'button-1': KnownInput.FaceAccept,
94
+ 'button-2': KnownInput.FaceAlt2,
95
+ 'button-3': KnownInput.FaceAlt1,
96
+ 'button-4': KnownInput.L1,
97
+ 'button-5': KnownInput.R1,
98
+ 'button-6': KnownInput.L2,
99
+ 'button-7': KnownInput.R2,
100
+ 'button-8': KnownInput.Select,
101
+ 'button-9': KnownInput.Start,
102
+ 'button-10': KnownInput.L3,
103
+ 'button-11': KnownInput.R3,
104
+ 'button-12': KnownInput.DPadUp,
105
+ 'button-13': KnownInput.DPadDown,
106
+ 'button-14': KnownInput.DPadLeft,
107
+ 'button-15': KnownInput.DPadRight,
108
+ 'button-16': KnownInput.Home,
109
+ 'button-17': KnownInput.Capture,
110
+ },
111
+ systemVersions: [
112
+ {
113
+ browserVersion: '117.0.0.0',
114
+ browserName: 'Chrome',
115
+ osName: 'macOS',
116
+ osVersion: '10.15.7',
117
+ },
118
+ ],
119
+ notes: undefined,
120
+ },
121
+ {
122
+ inputMappings: {
123
+ 'axe-0': KnownInput.LeftStickX,
124
+ 'axe-1': KnownInput.LeftStickY,
125
+ 'axe-2': KnownInput.RightStickX,
126
+ 'axe-3': KnownInput.RightStickY,
127
+ 'button-0': KnownInput.FaceAccept,
128
+ 'button-1': KnownInput.FaceCancel,
129
+ 'button-2': KnownInput.FaceAlt1,
130
+ 'button-3': KnownInput.FaceAlt2,
131
+ 'button-4': KnownInput.L1,
132
+ 'button-5': KnownInput.R1,
133
+ 'button-6': KnownInput.L2,
134
+ 'button-7': KnownInput.R2,
135
+ 'button-8': KnownInput.Select,
136
+ 'button-9': KnownInput.Start,
137
+ 'button-10': KnownInput.L3,
138
+ 'button-11': KnownInput.R3,
139
+ 'button-12': KnownInput.DPadUp,
140
+ 'button-13': KnownInput.DPadDown,
141
+ 'button-14': KnownInput.DPadLeft,
142
+ 'button-15': KnownInput.DPadRight,
143
+ 'button-16': KnownInput.Logo,
144
+ 'button-17': KnownInput.TouchPad,
145
+ },
146
+ gamepadModels: [PredefinedGamepadModel.PlaystationDualSense],
147
+ systemVersions: [
148
+ {
149
+ browserVersion: '117.0.0.0',
150
+ browserName: 'Chrome',
151
+ osName: 'macOS',
152
+ osVersion: '10.15.7',
153
+ },
154
+ ],
155
+ notes: {
156
+ info: 'Touch pad navigation and the mute button are not detected by this browser.',
157
+ },
158
+ },
159
+ {
160
+ inputMappings: {
161
+ 'axe-0': KnownInput.LeftStickX,
162
+ 'axe-1': KnownInput.LeftStickY,
163
+ 'axe-2': KnownInput.RightStickX,
164
+ 'axe-3': KnownInput.RightStickY,
165
+ 'button-0': KnownInput.FaceAccept,
166
+ 'button-1': KnownInput.FaceCancel,
167
+ 'button-2': KnownInput.FaceAlt1,
168
+ 'button-3': KnownInput.FaceAlt2,
169
+ 'button-4': KnownInput.L1,
170
+ 'button-5': KnownInput.R1,
171
+ 'button-6': KnownInput.L2,
172
+ 'button-7': KnownInput.R2,
173
+ 'button-8': KnownInput.Select,
174
+ 'button-9': KnownInput.Start,
175
+ 'button-10': KnownInput.L3,
176
+ 'button-11': KnownInput.R3,
177
+ 'button-12': KnownInput.DPadUp,
178
+ 'button-13': KnownInput.DPadDown,
179
+ 'button-14': KnownInput.DPadLeft,
180
+ 'button-15': KnownInput.DPadRight,
181
+ 'button-16': KnownInput.Logo,
182
+ },
183
+ gamepadModels: [PredefinedGamepadModel.PlaystationDualSense],
184
+ systemVersions: [
185
+ {
186
+ browserVersion: '17.2.1',
187
+ browserName: 'Safari',
188
+ osName: 'macOS',
189
+ osVersion: '10.15.7',
190
+ },
191
+ ],
192
+ notes: {
193
+ info: 'Touch pad navigation, the touch pad button, and the mute button are not detected by this browser.',
194
+ },
195
+ },
196
+ {
197
+ /**
198
+ * Firefox has the following messed up mappings:
199
+ *
200
+ * - R2 and L2 are buttons (6,7) but also axes (4,5) (the buttons don't use gradual values,
201
+ * just 0 or 1 and then the value is mapped to the axes)
202
+ * - The d-pad is mapped to a single axe with the following values
203
+ *
204
+ * - 0 before the d-pad has been used
205
+ * - 1.3 at rest after the d-pad has been used
206
+ * - -1.0 for up
207
+ * - 0.1 for down
208
+ * - 0.7 for left
209
+ * - -0.4 for right
210
+ */
211
+ inputMappings: {
212
+ 'axe-0': KnownInput.LeftStickX,
213
+ 'axe-1': KnownInput.LeftStickY,
214
+ 'axe-2': KnownInput.RightStickX,
215
+ 'axe-3': KnownInput.RightStickY,
216
+ 'axe-4': KnownInput.L2,
217
+ 'axe-5': KnownInput.R2,
218
+ 'axe-6': KnownInput.DPad,
219
+ 'button-0': KnownInput.FaceAlt1,
220
+ 'button-1': KnownInput.FaceAccept,
221
+ 'button-2': KnownInput.FaceCancel,
222
+ 'button-3': KnownInput.FaceAlt2,
223
+ 'button-4': KnownInput.L1,
224
+ 'button-5': KnownInput.R1,
225
+ 'button-6': KnownInput.L2,
226
+ 'button-7': KnownInput.R2,
227
+ 'button-8': KnownInput.Select,
228
+ 'button-9': KnownInput.Start,
229
+ 'button-10': KnownInput.L3,
230
+ 'button-11': KnownInput.R3,
231
+ 'button-12': KnownInput.Logo,
232
+ 'button-13': KnownInput.TouchPad,
233
+ 'button-14': KnownInput.Mute,
234
+ 'button-15': KnownInput.DPadRight,
235
+ 'button-16': KnownInput.Logo,
236
+ 'button-17': KnownInput.TouchPad,
237
+ },
238
+ gamepadModels: [PredefinedGamepadModel.PlaystationDualSense],
239
+ systemVersions: [
240
+ {
241
+ browserVersion: '109.0',
242
+ browserName: 'Firefox',
243
+ osName: 'macOS',
244
+ osVersion: '10.15',
245
+ },
246
+ ],
247
+ notes: {
248
+ warning: 'This browser has major issues reading this gamepad.',
249
+ },
250
+ },
251
+ {
252
+ /**
253
+ * Firefox has the following messed up mappings:
254
+ *
255
+ * - A bunch of buttons aren't mapped to anything on my controller
256
+ * - The triggers have no intermediate values at all
257
+ * - The d-pad is mapped to a single axe with the following values
258
+ *
259
+ * - 0 before the d-pad has been used
260
+ * - -1.3 at rest after the d-pad has been used
261
+ * - -1.0 for up
262
+ * - 0.1 for down
263
+ * - 0.7 for left
264
+ * - -0.4 for right
265
+ */
266
+ gamepadModels: [PredefinedGamepadModel.XboxWireless],
267
+ inputMappings: {
268
+ 'axe-0': KnownInput.LeftStickX,
269
+ 'axe-1': KnownInput.LeftStickY,
270
+ 'axe-2': KnownInput.RightStickX,
271
+ 'axe-3': KnownInput.RightStickY,
272
+ 'axe-4': KnownInput.DPad,
273
+ 'button-0': KnownInput.FaceAccept,
274
+ 'button-1': KnownInput.FaceCancel,
275
+ 'button-2': 'unknown',
276
+ 'button-3': KnownInput.FaceAlt1,
277
+ 'button-4': KnownInput.FaceAlt2,
278
+ 'button-5': 'unknown',
279
+ 'button-6': KnownInput.L1,
280
+ 'button-7': KnownInput.R1,
281
+ 'button-8': 'unknown',
282
+ 'button-9': 'unknown',
283
+ 'button-10': KnownInput.Select,
284
+ 'button-11': KnownInput.Start,
285
+ 'button-12': KnownInput.Logo,
286
+ 'button-13': KnownInput.L3,
287
+ 'button-14': KnownInput.R3,
288
+ 'button-15': KnownInput.L2,
289
+ 'button-16': KnownInput.R2,
290
+ },
291
+ systemVersions: [
292
+ {
293
+ browserVersion: '109.0',
294
+ browserName: 'Firefox',
295
+ osName: 'macOS',
296
+ osVersion: '10.15',
297
+ },
298
+ ],
299
+ notes: {
300
+ warning: 'This browser has major issues reading this gamepad.',
301
+ },
302
+ },
303
+ {
304
+ gamepadModels: [PredefinedGamepadModel.XboxWireless],
305
+ inputMappings: {
306
+ 'axe-0': KnownInput.LeftStickX,
307
+ 'axe-1': KnownInput.LeftStickY,
308
+ 'axe-2': KnownInput.RightStickX,
309
+ 'axe-3': KnownInput.RightStickY,
310
+ 'button-0': KnownInput.FaceAccept,
311
+ 'button-1': KnownInput.FaceCancel,
312
+ 'button-10': KnownInput.L3,
313
+ 'button-11': KnownInput.R3,
314
+ 'button-12': KnownInput.DPadUp,
315
+ 'button-13': KnownInput.DPadDown,
316
+ 'button-14': KnownInput.DPadLeft,
317
+ 'button-15': KnownInput.DPadRight,
318
+ 'button-16': KnownInput.Logo,
319
+ 'button-2': KnownInput.FaceAlt1,
320
+ 'button-3': KnownInput.FaceAlt2,
321
+ 'button-4': KnownInput.L1,
322
+ 'button-5': KnownInput.R1,
323
+ 'button-6': KnownInput.L2,
324
+ 'button-7': KnownInput.R2,
325
+ 'button-8': KnownInput.Select,
326
+ 'button-9': KnownInput.Start,
327
+ 'button-17': KnownInput.Share,
328
+ },
329
+ systemVersions: [
330
+ {
331
+ browserVersion: '117.0.0.0',
332
+ browserName: 'Chrome',
333
+ osName: 'macOS',
334
+ osVersion: '10.15.7',
335
+ },
336
+ ],
337
+ notes: undefined,
338
+ },
339
+ ];
@@ -0,0 +1,14 @@
1
+ import { type GamepadBrandMap, type GamepadModelMap } from './gamepad-model.js';
2
+ /**
3
+ * Gamepad mappings of gamepad ids / names to GamepadModel defined by the
4
+ * [gamepad-type](https://www.npmjs.com/package/gamepad-type) package.
5
+ *
6
+ * @category Defaults
7
+ */
8
+ export declare const defaultGamepadModelMap: Readonly<GamepadModelMap>;
9
+ /**
10
+ * PredefinedGamepadBrand for each PredefinedGamepadModel.
11
+ *
12
+ * @category Defaults
13
+ */
14
+ export declare const defaultGamepadBrandMap: GamepadBrandMap;