mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-06 07:21:33 -07:00
fix(controller): save remaps per profile, gate modals on enabled (#69)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user