space-game/src/stores/controllerMapping.ts
Michael Mainguy 123b341ed7 Replace debugLog and console.* with loglevel logger
- Create centralized logger module (src/core/logger.ts)
- Replace all debugLog() calls with log.debug()
- Replace console.log() with log.info()
- Replace console.warn() with log.warn()
- Replace console.error() with log.error()
- Delete deprecated src/core/debug.ts
- Configure log levels: debug for dev, warn for production
- Add localStorage override for production debugging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:24:18 -06:00

40 lines
1.1 KiB
TypeScript

import { writable, get } from 'svelte/store';
import type { ControllerMapping } from '../ship/input/controllerMapping';
import { ControllerMappingConfig } from '../ship/input/controllerMapping';
import log from '../core/logger';
const _STORAGE_KEY = 'space-game-controller-mapping';
function createControllerMappingStore() {
const config = ControllerMappingConfig.getInstance();
const initial = config.getMapping();
const { subscribe, set, update } = writable<ControllerMapping>(initial);
return {
subscribe,
update,
set: (value: ControllerMapping) => {
set(value);
config.setMapping(value);
},
save: () => {
const mapping = get(controllerMappingStore);
config.setMapping(mapping);
config.save();
log.info('[ControllerMapping Store] Saved');
},
reset: () => {
config.resetToDefault();
config.save();
set(config.getMapping());
log.info('[ControllerMapping Store] Reset to defaults');
},
validate: () => {
return config.validate();
},
};
}
export const controllerMappingStore = createControllerMappingStore();