mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-04 19:21:33 -07:00
23 lines
701 B
TypeScript
23 lines
701 B
TypeScript
import type { ResolvedControllerConfig, ResolvedControllerProfileConfig } from '../types';
|
|
|
|
export function getControllerProfile(
|
|
config: ResolvedControllerConfig | null,
|
|
gamepadId: string | null | undefined,
|
|
): ResolvedControllerProfileConfig | null {
|
|
if (!config || !gamepadId) return null;
|
|
return config.profiles[gamepadId] ?? null;
|
|
}
|
|
|
|
export function resolveControllerConfigForGamepad(
|
|
config: ResolvedControllerConfig,
|
|
gamepadId: string | null | undefined,
|
|
): ResolvedControllerConfig {
|
|
const profile = getControllerProfile(config, gamepadId);
|
|
if (!profile) return config;
|
|
return {
|
|
...config,
|
|
buttonIndices: profile.buttonIndices,
|
|
bindings: profile.bindings,
|
|
};
|
|
}
|