Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to manage output area of tablet handler #6166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Feodor0090
Copy link
Contributor

Partially does #6150 .

Exposes area position / size bindables, implements their application.

Manually tested this in different scaling modes with different window sizes/positions on display, seems to work as expected.

Ad-hoc diff for osu!:

diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index c244708385..e82abc233e 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -68,6 +68,7 @@
 using osu.Game.Updater;
 using osu.Game.Users;
 using osu.Game.Utils;
+using osuTK;
 using osuTK.Graphics;
 using Sentry;
 
@@ -1134,10 +1135,46 @@ protected override void LoadComplete()
                 if (mode.NewValue != OverlayActivation.All) CloseAllOverlays();
             };
 
+            {
+                var tablet = Host.AvailableInputHandlers.OfType<ITabletHandler>().FirstOrDefault();
+
+                if (tablet != null)
+                {
+                    scalingMode = LocalConfig.GetBindable<ScalingMode>(OsuSetting.Scaling);
+                    scalingSizeX = LocalConfig.GetBindable<float>(OsuSetting.ScalingSizeX);
+                    scalingSizeY = LocalConfig.GetBindable<float>(OsuSetting.ScalingSizeY);
+                    scalingPositionX = LocalConfig.GetBindable<float>(OsuSetting.ScalingPositionX);
+                    scalingPositionY = LocalConfig.GetBindable<float>(OsuSetting.ScalingPositionY);
+
+                    void updateAreaSize(ValueChangedEvent<float> _)
+                    {
+                        if (scalingMode.Value == ScalingMode.Everything)
+                            tablet.OutputAreaSize.Value = new Vector2(scalingSizeX.Value, scalingSizeY.Value);
+                        else
+                            tablet.OutputAreaSize.Value = new Vector2(1, 1);
+                    }
+
+                    scalingMode.ValueChanged += _ => updateAreaSize(null!);
+                    scalingSizeX.ValueChanged += updateAreaSize;
+                    scalingSizeY.ValueChanged += updateAreaSize;
+                    scalingPositionX.ValueChanged += _ => tablet.OutputAreaPosition.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value);
+                    scalingPositionY.ValueChanged += _ => tablet.OutputAreaPosition.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value);
+
+                    updateAreaSize(null!);
+                    tablet.OutputAreaPosition.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value);
+                }
+            }
+
             // Importantly, this should be run after binding PostNotification to the import handlers so they can present the import after game startup.
             handleStartupImport();
         }
 
+        private Bindable<ScalingMode> scalingMode = null!;
+        private Bindable<float> scalingPositionX = null!;
+        private Bindable<float> scalingPositionY = null!;
+        private Bindable<float> scalingSizeX = null!;
+        private Bindable<float> scalingSizeY = null!;
+
         private void handleStartupImport()
         {
             if (args?.Length > 0)

/// <summary>
/// Position of output area inside game window, 0 is top-left position, 1 is bottom-right.
/// </summary>
Bindable<Vector2> OutputAreaPosition { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this is the relative position of the centre of the output area? It should probably be mentioned as such in the xmldoc.

@Feodor0090 Feodor0090 requested a review from smoogipoo March 6, 2024 19:11
/// </summary>
/// <remarks>
/// This and <see cref="OutputAreaSize"/> behave like posX/posY/sizeX/sizeY properties on osu!'s ScalingContainer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't reference game-side classes in framework xmldoc, that's backwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants