Skip to content

Add 'Identify' button to Lighthouse dropdown menu#13

Merged
kurotu merged 1 commit intokurotu:masterfrom
aurycat:identify
Jul 5, 2025
Merged

Add 'Identify' button to Lighthouse dropdown menu#13
kurotu merged 1 commit intokurotu:masterfrom
aurycat:identify

Conversation

@aurycat
Copy link
Copy Markdown
Contributor

@aurycat aurycat commented Jun 28, 2025

One more little feature 😄 This one isn't really that important, feel free to reject the PR if you don't think it's necessary for this program. I'm just hooking up the Identify feature of the base stations to a button in the menu.


I'm reusing WritePowerCharacteristicAsync for this, which isn't quite accurate since Identify isn't a power characteristic. And the log messages issued by WritePowerCharacteristicAsync say "power characteristic" too. If you wanted to make it more accurate, you could just remove the word "Power" from that function.


I only supported V2 base stations. I think V1 base stations also have an Identify feature, but I couldn't find documentation for how to invoke it, and I don't have any to test with. So I just marked it as unsupported for V1.

One additional thing I could do is to set the Visibility to hidden for the Identify button on V1 base stations (that could also be done for the Standby button!). But when I tried to Bind visibility to the version of the lighthouse like this:

diff --git a/OVRLighthouseManager/Models/Lighthouse.cs b/OVRLighthouseManager/Models/Lighthouse.cs
index ff29bc5..9965482 100644
--- a/OVRLighthouseManager/Models/Lighthouse.cs
+++ b/OVRLighthouseManager/Models/Lighthouse.cs
@@ -45,4 +45,7 @@ public class Lighthouse
             return LighthouseVersion.Unknown;
         }
     }
+
+    [JsonIgnore]
+    public bool SupportsIdentify => Version == LighthouseVersion.V2;
 }
diff --git a/OVRLighthouseManager/Views/LighthouseControl.xaml b/OVRLighthouseManager/Views/LighthouseControl.xaml
index 57bfb63..b392d58 100644
--- a/OVRLighthouseManager/Views/LighthouseControl.xaml
+++ b/OVRLighthouseManager/Views/LighthouseControl.xaml
@@ -116,8 +116,9 @@
                         x:Uid="Menu_Identify"
                         Command="{StaticResource identifyCommand}"
                         CommandParameter="{x:Bind LighthouseObject, Mode=OneWay}"
+                        Visibility="{x:Bind LighthouseObject.Lighthouse.SupportsIdentify}"
                         />
-                    <MenuFlyoutSeparator />
+                    <MenuFlyoutSeparator Visibility="{x:Bind LighthouseObject.Lighthouse.SupportsIdentify}"/>
                     <MenuFlyoutItem
                         x:Uid="Menu_EditId"
                         Command="{x:Bind LighthouseObject.EditIdCommand, Mode=OneWay}"

it didn't have any effect. I put a break point on the property and it seems it was never being read. I also tried making a SupportsIdentify property in the LighthouseControl code-behind and Bind to that instead, and that time the code gets executed, but it gets executed before LighthouseObject is set, and never gets re-executed once LighthouseObject is set, so the visibility binding gets the wrong value. I'm sure there's a way to get it to refresh, but I didn't investigate further, since I'm not sure if you even want this feature in the program at all!

@kurotu
Copy link
Copy Markdown
Owner

kurotu commented Jun 29, 2025

Functionality looks good.

When binding a property in WPF, its changes should be notified by events or observable attribute.
Probably you need to add the property to LighthouseObject class then bind it.

And the visibility is not boolean, so you need to use Converter={StaticResource BooleanToVisibilityConverter} (see the button for EditIdCommand).

I can merge this as is, though do you continue to work?

@kurotu kurotu merged commit 14087de into kurotu:master Jul 5, 2025
2 checks passed
@aurycat
Copy link
Copy Markdown
Contributor Author

aurycat commented Jul 5, 2025

When binding a property in WPF, its changes should be notified by events or observable attribute.

Probably you need to add the property to LighthouseObject class then bind it.

And the visibility is not boolean, so you need to use Converter={StaticResource BooleanToVisibilityConverter} (see the button for EditIdCommand).

Ah, thank you!

I can merge this as is, though do you continue to work?

Yeah that's fine! Sorry for the delayed response -- was super busy and forgot 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants