Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
63 lines (56 loc) · 2 KB
/
Copy pathindex.js
File metadata and controls
63 lines (56 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
*
* Generated by: npm run process_controller_defs
* Source captures: 054c-0ce6_PS5.json
*/
import { parseGamepadId } from '../gamepad-profiles.js';
import profile0 from './profiles/054c-0ce6.js';
export const controllerProfiles = {
'054c-0ce6': profile0,
};
/**
* Return all generated controller profiles.
*/
export function getControllerProfiles() {
return controllerProfiles;
}
/**
* Return one generated controller profile by exact key.
*/
export function getControllerProfile(key) {
if (typeof key !== "string") return null;
return controllerProfiles[key.toLowerCase()] ?? null;
}
/**
* Return generated controller profiles belonging to a family.
*/
export function findControllerProfilesByFamily(family) {
const f = typeof family === "string" ? family.toLowerCase() : null;
if (!f) return [];
return Object.values(controllerProfiles).filter((profile) => {
if (!profile) return false;
const candidate = typeof profile.family === "string" ? profile.family : profile.profileHint;
return typeof candidate === "string" && candidate.toLowerCase() === f;
});
}
/**
* Return the profile for exactly this (vendorId, productId), or null.
* There is no vendor-only fallback: another product of the same vendor
* has its own raw layout.
*/
export function findControllerProfile(vendorId, productId) {
const v = typeof vendorId === "string" ? vendorId.toLowerCase() : null;
const p = typeof productId === "string" ? productId.toLowerCase() : null;
if (!v || !p) return null;
return controllerProfiles[`${v}-${p}`] ?? null;
}
/**
* Parse VID/PID from a browser gamepad id (Chrome or Firefox form) and return
* the profile for exactly that device, or null. Whether the profile applies to
* the connected pad is decided by the resolver (mapping and button/axis counts).
*/
export function findControllerProfileByGamepadId(gamepadId) {
const { vendorId, productId } = parseGamepadId(gamepadId);
return findControllerProfile(vendorId, productId);
}