mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-26 04:46:07 -08:00
Controller: layouts for the media timing review and duplicate card dialogs (#313)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
696462a82e
commit
6d0f37ac21
50 files changed
+4555
-46
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import { CONTROLLER_SCREENS, type ControllerScreenId } from '../../shared/controller-screens';
|
||||
import { ResolvedConfig } from '../../types/config';
|
||||
import type { ControllerReviewInput, ResolvedControllerReviewBinding } from '../../types/runtime';
|
||||
import {
|
||||
NOTIFICATION_TYPE_VALUES,
|
||||
OVERLAY_NOTIFICATION_POSITION_VALUES,
|
||||
@@ -6,6 +8,12 @@ import {
|
||||
} from '../../types/notification';
|
||||
import { ConfigOptionRegistryEntry } from './shared';
|
||||
|
||||
const CONTROLLER_SCREEN_INTROS: Record<ControllerScreenId, string> = {
|
||||
review: 'Controller layout for the media timing review dialog, one entry per action.',
|
||||
fieldGrouping:
|
||||
'Controller layout for the duplicate card (field grouping) dialog, one entry per action.',
|
||||
};
|
||||
|
||||
export function buildCoreConfigOptionRegistry(
|
||||
defaultConfig: ResolvedConfig,
|
||||
): ConfigOptionRegistryEntry[] {
|
||||
@@ -224,6 +232,14 @@ export function buildCoreConfigOptionRegistry(
|
||||
description:
|
||||
'How controller triggers are interpreted: auto, pressed-only, or thresholded analog.',
|
||||
},
|
||||
{
|
||||
path: 'controller.faceButtonLabels',
|
||||
kind: 'enum',
|
||||
enumValues: ['xbox', 'nintendo'],
|
||||
defaultValue: defaultConfig.controller.faceButtonLabels,
|
||||
description:
|
||||
"Letters printed on your controller's face buttons: xbox (A at the bottom; also PlayStation) or nintendo (A on the right, B at the bottom; Switch-style and many 8BitDo pads). Used by fixed controller layouts and button names in Alt+C.",
|
||||
},
|
||||
{
|
||||
path: 'controller.triggerDeadzone',
|
||||
kind: 'number',
|
||||
@@ -330,6 +346,96 @@ export function buildCoreConfigOptionRegistry(
|
||||
description:
|
||||
'Per-controller binding and button-index overrides keyed by the controller id reported by the Gamepad API.',
|
||||
},
|
||||
...CONTROLLER_SCREENS.flatMap((screen) => {
|
||||
const defaults = defaultConfig.controller[screen.configKey] as Record<
|
||||
string,
|
||||
ResolvedControllerReviewBinding
|
||||
>;
|
||||
const stepLabels = new Map(screen.steps.map((step, index) => [step.id, index]));
|
||||
return [
|
||||
{
|
||||
path: `controller.${screen.configKey}`,
|
||||
kind: 'object' as const,
|
||||
defaultValue: defaults,
|
||||
description: `${CONTROLLER_SCREEN_INTROS[screen.id]} Set it with the ${screen.title} group in Alt+C. Each entry is {"kind": "none"} or {"press": input, "hold": input}, where an input is {"kind": "button", "buttonIndex"}, {"kind": "axis", "axisIndex", "direction"}, {"kind": "face", "letter": "a"|"b"|"x"|"y"} (printed letter) or {"kind": "dpad", "direction": "left"|"right"|"up"|"down"}.`,
|
||||
},
|
||||
...screen.actions.flatMap((action): ConfigOptionRegistryEntry[] => {
|
||||
const path = `controller.${screen.configKey}.${action.id}`;
|
||||
const binding = defaults[action.id]!;
|
||||
const press = binding.kind === 'combo' ? binding.press : undefined;
|
||||
const hold = binding.kind === 'combo' ? binding.hold : undefined;
|
||||
// Steps after the first are named, e.g. "(after Cancel)".
|
||||
const stepNote =
|
||||
(stepLabels.get(action.step) ?? 0) > 0
|
||||
? ` (${screen.steps.find((step) => step.id === action.step)!.label.toLowerCase()})`
|
||||
: '';
|
||||
const inputFields = (
|
||||
name: 'press' | 'hold',
|
||||
input: ControllerReviewInput | null | undefined,
|
||||
): ConfigOptionRegistryEntry[] => [
|
||||
{
|
||||
path: `${path}.${name}.kind`,
|
||||
kind: 'enum',
|
||||
enumValues: ['button', 'axis', 'face', 'dpad'],
|
||||
defaultValue: input?.kind,
|
||||
description:
|
||||
'Input kind: a raw button or axis recorded by Alt+C, a printed face letter, or a D-pad direction.',
|
||||
},
|
||||
{
|
||||
path: `${path}.${name}.buttonIndex`,
|
||||
kind: 'number',
|
||||
defaultValue: input?.kind === 'button' ? input.buttonIndex : undefined,
|
||||
description: 'Raw button index.',
|
||||
},
|
||||
{
|
||||
path: `${path}.${name}.letter`,
|
||||
kind: 'enum',
|
||||
enumValues: ['a', 'b', 'x', 'y'],
|
||||
defaultValue: input?.kind === 'face' ? input.letter : undefined,
|
||||
description: 'Printed face letter, placed by controller.faceButtonLabels.',
|
||||
},
|
||||
{
|
||||
path: `${path}.${name}.direction`,
|
||||
kind: 'enum',
|
||||
enumValues: ['left', 'right', 'up', 'down', 'negative', 'positive'],
|
||||
defaultValue:
|
||||
input?.kind === 'dpad' || input?.kind === 'axis' ? input.direction : undefined,
|
||||
description: 'D-pad direction, or axis direction for raw axis inputs.',
|
||||
},
|
||||
];
|
||||
return [
|
||||
{
|
||||
path,
|
||||
kind: 'object',
|
||||
defaultValue: binding,
|
||||
description: `${screen.describe}: ${action.label}${stepNote}.${action.repeat ? ' Repeats while held.' : ''}`,
|
||||
},
|
||||
{
|
||||
path: `${path}.kind`,
|
||||
kind: 'enum',
|
||||
enumValues: ['none', 'combo'],
|
||||
defaultValue: binding.kind,
|
||||
description:
|
||||
'none disables the action; combo presses "press" (while holding "hold", if set).',
|
||||
},
|
||||
{
|
||||
path: `${path}.press`,
|
||||
kind: 'object',
|
||||
defaultValue: press,
|
||||
description: 'Input that triggers the action.',
|
||||
},
|
||||
{
|
||||
path: `${path}.hold`,
|
||||
kind: 'object',
|
||||
defaultValue: hold,
|
||||
description: 'Optional input held while pressing; null for none.',
|
||||
},
|
||||
...inputFields('press', press),
|
||||
...inputFields('hold', hold),
|
||||
];
|
||||
}),
|
||||
];
|
||||
}),
|
||||
...discreteBindings.flatMap((binding) => [
|
||||
{
|
||||
path: `controller.bindings.${binding.id}`,
|
||||
|
||||
Reference in new issue
Block a user