diff --git a/backend/Cargo.lock b/backend/Cargo.lock index bd0c8b9..61c7515 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1170,7 +1170,7 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "powertools" -version = "2.0.0-alpha1" +version = "2.0.0-alpha2" dependencies = [ "async-trait", "chrono", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index dffea73..0c13046 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "2.0.0-alpha1" +version = "2.0.0-alpha2" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/default_settings.ron b/default_settings.ron index fbc356a..b0a7583 100644 --- a/default_settings.ron +++ b/default_settings.ron @@ -1,58 +1,8 @@ FileJson( version: 0, name: "Main", + app_id: 0, variants: { - 0: SettingsJson( - version: 0, - name: "Primary", - variant: 0, - persistent: false, - cpus: [CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - ), CpuJson( - online: true, - clock_limits: None, - governor: "schedutil", - )], - gpu: GpuJson( - fast_ppt: None, - slow_ppt: None, - clock_limits: None, - slow_memory: false, - ), - battery: BatteryJson( - charge_rate: None, - charge_mode: None, - events: [], -), - provider: None, - ), 42: SettingsJson( version: 0, name: "FortySecondary", @@ -94,8 +44,63 @@ FileJson( gpu: GpuJson( fast_ppt: None, slow_ppt: None, + tdp: None, + tdp_boost: None, clock_limits: None, - slow_memory: false, + memory_clock: None, + ), + battery: BatteryJson( + charge_rate: None, + charge_mode: None, + events: [], +), + provider: None, + ), + 0: SettingsJson( + version: 0, + name: "Primary", + variant: 0, + persistent: false, + cpus: [CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + ), CpuJson( + online: true, + clock_limits: None, + governor: "schedutil", + )], + gpu: GpuJson( + fast_ppt: None, + slow_ppt: None, + tdp: None, + tdp_boost: None, + clock_limits: None, + memory_clock: None, ), battery: BatteryJson( charge_rate: None, diff --git a/limits_override.ron b/limits_override.ron index 2d74572..e963283 100644 --- a/limits_override.ron +++ b/limits_override.ron @@ -12,7 +12,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -23,7 +28,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -34,7 +44,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -45,7 +60,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -56,7 +76,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -67,7 +92,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -78,7 +108,12 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, ), GenericCpuLimit( clock_min: Some(RangeLimit( min: Some(1400), @@ -89,9 +124,18 @@ Limits( max: Some(3500), )), clock_step: Some(100), + tdp: None, + tdp_boost: None, + tdp_divisor: None, + tdp_step: None, skip_resume_reclock: false, + experiments: false, )], global_governors: true, + extras: LimitExtras( + experiments: false, + quirks: [], +), ), ), gpu: Limit( @@ -111,6 +155,7 @@ Limits( ppt_step: Some(1), tdp: None, tdp_boost: None, + tdp_divisor: None, tdp_step: None, clock_min: Some(RangeLimit( min: Some(400), @@ -121,7 +166,16 @@ Limits( max: Some(1600), )), clock_step: Some(100), + memory_clock: Some(RangeLimit( + min: Some(400), + max: Some(800), + )), + memory_clock_step: Some(400), skip_resume_reclock: false, + extras: LimitExtras( + experiments: false, + quirks: ["pp_dpm_fclk-not-updated-on-LCD", "pp_dpm_fclk-reversed"], + ), ), ), battery: Limit( @@ -137,6 +191,10 @@ Limits( max: Some(90.0), )), extra_readouts: false, + extras: LimitExtras( + experiments: false, + quirks: [], +), ), ), ) \ No newline at end of file diff --git a/package.json b/package.json index bddc88d..04f659b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "2.0.0-alpha1", + "version": "2.0.0-alpha2", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/components/text_field_modal.tsx b/src/components/text_field_modal.tsx new file mode 100644 index 0000000..c5ff5d6 --- /dev/null +++ b/src/components/text_field_modal.tsx @@ -0,0 +1,65 @@ +// Based on https://github.com/isiah-lloyd/radiyo-steam-deck/blob/main/src/TextFieldModal.tsx + +import { ModalRoot, ModalRootProps, Router, TextField, Focusable, DialogButton } from 'decky-frontend-lib'; +import { useEffect, useRef, useState } from 'react'; +import { HiCheck, HiX } from "react-icons/hi"; +type props = ModalRootProps & { + label: string, + placeholder: string, + onClosed: (inputText: string) => void; +} +export const TextFieldModal = ({ closeModal, onClosed, label, placeholder }: props) => { + const [inputText, setInputText] = useState(''); + const handleText = (e: React.ChangeEvent) => { + setInputText(e.target.value); + }; + const textField = useRef(); + useEffect(() => { + Router.CloseSideMenus(); + //This will open up the virtual keyboard + textField.current?.element?.click(); + }, []); + const submit = () => onClosed(inputText); + return ( + +
+ + + { submit() }} + > + + + { if (closeModal) { closeModal() } }} + > + + + + +
+ ); +}; diff --git a/src/index.tsx b/src/index.tsx index 8fb9f4d..fb54817 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,25 +2,20 @@ import { ButtonItem, definePlugin, DialogButton, - //Menu, - //MenuItem, PanelSection, PanelSectionRow, ServerAPI, - //showContextMenu, staticClasses, - //SliderField, ToggleField, - //Dropdown, Field, Dropdown, SingleDropdownOption, Navigation, Focusable, Spinner, - //NotchLabel - //gamepadDialogClasses, - //joinClassNames, + showModal, + QuickAccessTab, + ShowModalResult, } from "decky-frontend-lib"; import { VFC, useState } from "react"; import { GiDrill, GiFireExtinguisher, GiFireBomb, GiMineExplosion } from "react-icons/gi"; @@ -83,6 +78,8 @@ import { Battery } from "./components/battery"; import { Cpus } from "./components/cpus"; import { DevMessages } from "./components/message"; +import { TextFieldModal } from "./components/text_field_modal"; + import { StoreResultsPage } from "./store/page"; var periodicHook: NodeJS.Timeout | null = null; @@ -346,12 +343,29 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => { data: elem, label: {elem.name}, };}); - console.log("variant options", variantOptions); - console.log("current variant", get_value(CURRENT_VARIANT_GEN)); - console.log("variant selected", variantOptions.find((val: SingleDropdownOption, _index, _arr) => { - backend.log(backend.LogLevel.Debug, "POWERTOOLS: looking for variant data.id " + (get_value(CURRENT_VARIANT_GEN) as backend.VariantInfo).id.toString()); - return (val.data as backend.VariantInfo).id == (get_value(CURRENT_VARIANT_GEN) as backend.VariantInfo).id; - })); + + var modalResult: ShowModalResult | undefined = undefined; + + const onNewVariantModelClosed = (name: string) => { + if (modalResult) { + modalResult.Close(); + } + console.log("POWERTOOLS: variant name", name); + isVariantLoading = true; + backend.resolve( + backend.loadGeneralSettingsVariant("please give me a new ID k thx bye" /* anything that cannot be parsed as a u64 will be set to u64::MAX, which will cause the back-end to auto-generate an ID */, name), + (ok: boolean) => { + isVariantLoading = false; + backend.log(backend.LogLevel.Debug, "New settings variant ok? " + ok); + reload(); + backend.resolve(backend.waitForComplete(), (_) => { + backend.log(backend.LogLevel.Debug, "Trying to tell UI to re-render due to new settings variant"); + tryNotifyProfileChange(); + }); + } + ); + Navigation.OpenQuickAccessMenu(QuickAccessTab.Decky); + }; return ( @@ -441,17 +455,7 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => { //layout="below" onClick={(_: MouseEvent) => { backend.log(backend.LogLevel.Debug, "Creating new PowerTools settings variant"); - backend.resolve( - backend.loadGeneralSettingsVariant("please give me a new ID k thx bye" /* anything that cannot be parsed as a u64 will be set to u64::MAX, which will cause the back-end to auto-generate an ID */, undefined), - (ok: boolean) => { - backend.log(backend.LogLevel.Debug, "New settings variant ok? " + ok); - reload(); - backend.resolve(backend.waitForComplete(), (_) => { - backend.log(backend.LogLevel.Debug, "Trying to tell UI to re-render due to new settings variant"); - tryNotifyProfileChange(); - }); - } - ); + modalResult = showModal( { modalResult?.Close(); Navigation.OpenQuickAccessMenu(QuickAccessTab.Decky)}}/>, window); }} >