From 6a68ad64b1fa101c094ad9bc7db4f4e7b9ae8804 Mon Sep 17 00:00:00 2001 From: Alex Zorzi Date: Thu, 18 Aug 2022 14:21:22 +0200 Subject: [PATCH 1/2] Handle no DLSS support error --- main.go | 4 ++-- reg.go | 24 +++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index a5dc440..d38be40 100644 --- a/main.go +++ b/main.go @@ -38,9 +38,9 @@ func main() { OnClicked: func() { if indicatorStatus == 1024 { - setKeyOff() + setKey(0) } else { - setKeyOn() + setKey(1) } getKey() indicatorTextLabel.SetText(indicatorStatusString) diff --git a/reg.go b/reg.go index 4a78f00..ae944fc 100644 --- a/reg.go +++ b/reg.go @@ -5,8 +5,11 @@ import ( ) func getKey() { - key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.QUERY_VALUE) - + key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.QUERY_VALUE) + if err != nil { + indicatorStatusString = "Error: DLSS not supported!" + return + } value, _, _ := key.GetIntegerValue("ShowDlssIndicator") defer key.Close() @@ -20,18 +23,9 @@ func getKey() { indicatorStatusString = "NOT SET" } } -func setKeyOn() { + +func setKey(value int) { key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.SET_VALUE) - - key.SetDWordValue("ShowDlssIndicator", uint32(1024)) + key.SetDWordValue("ShowDlssIndicator", uint32(value * 1024)) defer key.Close() - -} - -func setKeyOff() { - key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.SET_VALUE) - - key.SetDWordValue("ShowDlssIndicator", uint32(0)) - defer key.Close() - -} +} \ No newline at end of file -- 2.45.2 From 85b7d1be115745c310e4c3d4e4621fd4fa5eeab7 Mon Sep 17 00:00:00 2001 From: Watn3y Date: Thu, 18 Aug 2022 14:43:02 +0200 Subject: [PATCH 2/2] Small readability changes --- main.go | 3 ++- reg.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index d38be40..215bb79 100644 --- a/main.go +++ b/main.go @@ -37,10 +37,11 @@ func main() { Text: "Toggle Indicator", OnClicked: func() { + // a value of 1024 activates the overlay, a value of 0 deactivates it. Other values seem to deactivate it as well but you never know if indicatorStatus == 1024 { setKey(0) } else { - setKey(1) + setKey(1024) } getKey() indicatorTextLabel.SetText(indicatorStatusString) diff --git a/reg.go b/reg.go index ae944fc..c8c73df 100644 --- a/reg.go +++ b/reg.go @@ -7,7 +7,7 @@ import ( func getKey() { key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.QUERY_VALUE) if err != nil { - indicatorStatusString = "Error: DLSS not supported!" + indicatorStatusString = "Error: DLSS not supported or registry path not accessible" return } value, _, _ := key.GetIntegerValue("ShowDlssIndicator") @@ -26,6 +26,6 @@ func getKey() { func setKey(value int) { key, _ := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\NVIDIA Corporation\Global\NGXCore`, registry.SET_VALUE) - key.SetDWordValue("ShowDlssIndicator", uint32(value * 1024)) + key.SetDWordValue("ShowDlssIndicator", uint32(value)) defer key.Close() -} \ No newline at end of file +} -- 2.45.2