/** A single mapping token target: physical button / axis / hat index. */ export type MappingToken = { readonly kind: 'button'; readonly index: number; } | { readonly kind: 'axis'; readonly index: number; readonly half?: '+' | '-'; } | { readonly kind: 'hat'; readonly index: number; readonly mask: number; }; /** * Parsed mapping tokens for one controller entry, keyed by the SDL logical * name (`a`, `b`, `leftx`, `dpup`, `lefttrigger`, ...). Values are the * physical source (button `bN`, axis `aN`, hat `hN.M`). */ export type MappingTokens = Readonly>; /** One controller-DB row: its platform section + parsed mapping tokens. */ export interface ControllerDbEntry { readonly platform: string | undefined; readonly tokens: MappingTokens; } /** * Parsed controller DB: SDL GUID (32-char hex) -> one entry per platform * section. The same GUID can appear in multiple platform sections, so the * value is an array. */ export type ControllerDb = Readonly>; /** Recognised web platform section labels (D-13). */ declare const CONTROLLER_PLATFORMS: readonly ["Windows", "Mac OS X", "Linux", "Android", "iOS"]; export type ControllerPlatform = (typeof CONTROLLER_PLATFORMS)[number]; /** * Parse a gamecontrollerdb.txt string into a ControllerDb map. Comment * (`#`) and blank lines are skipped. Each data line is * `GUID,Name,token:source,...,platform:PLATFORM,`. */ export declare function parseControllerDb(txt: string): ControllerDb; /** * Build a 32-char SDL GUID hex from a VID/PID pair (D-13 strategy 2): * bus (default USB 0x03) + CRC=0 + VID + fill + PID + fill + version=0 + * driver sig/data=0. Each 16-bit field is little-endian within the string. * * Example: buildGuidFromVidPid(0x045e, 0x028e) -> * '030000005e0400008e02000000000000' (Xbox 360). */ export declare function buildGuidFromVidPid(vid: number, pid: number, bus?: number): string; /** * Extract an SDL GUID from a browser `Gamepad.id` string. Handles the * Chrome/Edge (`Vendor: XXXX Product: YYYY`) and Firefox (`VID-PID-Name`, * leading-zero tolerant) formats. Returns undefined when VID/PID cannot be * extracted (Safari name-only strings, XInput devices) so the caller keeps * the Feat1 empty-signal (graceful degradation, R-3). */ export declare function extractGuidFromGamepadId(id: string): string | undefined; /** * Map a `navigator.userAgent` string to a gamecontrollerdb.txt platform * section label (D-13). Returns undefined when the UA is unrecognised, in * which case the caller falls back to any-platform entry selection. */ export declare function platformFromUserAgent(ua: string): ControllerPlatform | undefined; /** * Select the best mapping entry for a GUID: prefer the entry whose platform * section matches `platform`, else fall back to the first available entry * (any platform). Returns undefined when the GUID is absent from the DB. */ export declare function selectBestMappingEntry(db: ControllerDb, guid: string, platform: string | undefined): ControllerDbEntry | undefined; export {}; //# sourceMappingURL=controller-db.d.ts.map