summaryrefslogtreecommitdiff
path: root/src/components/FpsMultiplierControl.tsx
diff options
context:
space:
mode:
authorxXJSONDeruloXx <danielhimebauch@gmail.com>2026-09-06 23:12:28 -0400
committerxXJSONDeruloXx <danielhimebauch@gmail.com>2026-09-06 23:12:28 -0400
commitd1f8263bf9f22753ad53e1b0105172a3bd0faf5f (patch)
tree5e744fd0d2d61f6ea118d1d53b94a602fed3111b /src/components/FpsMultiplierControl.tsx
parent7bc5f685186b1ff03ce0f7c99e7bec411beabaeb (diff)
downloaddecky-lsfg-vk-d1f8263bf9f22753ad53e1b0105172a3bd0faf5f.tar.gz
decky-lsfg-vk-d1f8263bf9f22753ad53e1b0105172a3bd0faf5f.zip
feat: organize game profiles and focus enabled settings
Diffstat (limited to 'src/components/FpsMultiplierControl.tsx')
-rw-r--r--src/components/FpsMultiplierControl.tsx45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/components/FpsMultiplierControl.tsx b/src/components/FpsMultiplierControl.tsx
index e197dc3..1fd0e78 100644
--- a/src/components/FpsMultiplierControl.tsx
+++ b/src/components/FpsMultiplierControl.tsx
@@ -1,4 +1,5 @@
-import { PanelSectionRow, SliderField } from "@decky/ui";
+import { Focusable, PanelSectionRow, SliderField } from "@decky/ui";
+import { useEffect, useRef } from "react";
import { ConfigurationData } from "../config/configSchema";
import { MULTIPLIER } from "../config/generatedConfigSchema";
import t from "../i18n/i18n";
@@ -6,28 +7,48 @@ import t from "../i18n/i18n";
interface FpsMultiplierControlProps {
config: ConfigurationData;
onConfigChange: (fieldName: keyof ConfigurationData, value: boolean | number | string | string[]) => Promise<void>;
+ autoFocus?: boolean;
+ onAutoFocus?: () => void;
}
export function FpsMultiplierControl({
config,
- onConfigChange
+ onConfigChange,
+ autoFocus = false,
+ onAutoFocus,
}: FpsMultiplierControlProps) {
+ const focusableRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ if (!autoFocus) return;
+ const frame = requestAnimationFrame(() => {
+ const target = focusableRef.current?.querySelector<HTMLElement>(
+ '[role="button"], [role="slider"]',
+ );
+ target?.focus();
+ onAutoFocus?.();
+ });
+ return () => cancelAnimationFrame(frame);
+ }, [autoFocus, onAutoFocus]);
+
const multiplierLabel = config.multiplier === 1
? t("MULTIPLIER_OFF", "Off")
: `${config.multiplier}x`;
return (
<PanelSectionRow>
- <SliderField
- label={`FPS multiplier · ${multiplierLabel}`}
- value={config.multiplier}
- min={1}
- max={4}
- step={1}
- notchCount={4}
- showValue={false}
- onChange={(value) => void onConfigChange(MULTIPLIER, value)}
- />
+ <Focusable ref={focusableRef} noFocusRing>
+ <SliderField
+ label={`FPS multiplier · ${multiplierLabel}`}
+ value={config.multiplier}
+ min={1}
+ max={4}
+ step={1}
+ notchCount={4}
+ showValue={false}
+ onChange={(value) => void onConfigChange(MULTIPLIER, value)}
+ />
+ </Focusable>
</PanelSectionRow>
);
}