From 7bac31e0777b971a7b62ca7b2fa9bca56551b407 Mon Sep 17 00:00:00 2001 From: Fyodor Ryzhov <53872073+Feodor0090@users.noreply.github.com> Date: Fri, 2 Feb 2024 02:14:02 +0300 Subject: [PATCH 1/4] Add output area and size to OTD handler --- .../Tablet/OpenTabletDriverHandler.cs | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/osu.Framework/Input/Handlers/Tablet/OpenTabletDriverHandler.cs b/osu.Framework/Input/Handlers/Tablet/OpenTabletDriverHandler.cs index 2f3b442139..f2678615c6 100644 --- a/osu.Framework/Input/Handlers/Tablet/OpenTabletDriverHandler.cs +++ b/osu.Framework/Input/Handlers/Tablet/OpenTabletDriverHandler.cs @@ -38,6 +38,10 @@ public class OpenTabletDriverHandler : InputHandler, IAbsolutePointer, IRelative public Bindable AreaSize { get; } = new Bindable(); + public Bindable OutputAreaPosition { get; } = new Bindable(); + + public Bindable OutputAreaSize { get; } = new Bindable(new Vector2(1f, 1f)); + public Bindable Rotation { get; } = new Bindable(); public IBindable Tablet => tablet; @@ -58,6 +62,11 @@ public override bool Initialize(GameHost host) AreaSize.BindValueChanged(_ => updateInputArea(device), true); Rotation.BindValueChanged(_ => updateInputArea(device), true); + OutputAreaPosition.BindValueChanged(_ => updateOutputArea(host.Window)); + OutputAreaSize.BindValueChanged(_ => updateOutputArea(host.Window)); + + updateOutputArea(host.Window); + Enabled.BindValueChanged(enabled => { if (enabled.NewValue) @@ -126,14 +135,26 @@ private void updateOutputArea(IWindow window) { case AbsoluteOutputMode absoluteOutputMode: { - float outputWidth, outputHeight; + // window size & pos + float outputWidth = window.ClientSize.Width; + float outputHeight = window.ClientSize.Height; + float posX = outputWidth / 2; + float posY = outputHeight / 2; + + // applying "output area" + float areaOffsX = (1f - OutputAreaSize.Value.X) * (OutputAreaPosition.Value.X - 0.5f) * outputWidth; + float areaOffsY = (1f - OutputAreaSize.Value.Y) * (OutputAreaPosition.Value.Y - 0.5f) * outputHeight; + outputWidth *= OutputAreaSize.Value.X; + outputHeight *= OutputAreaSize.Value.Y; + posX += areaOffsX; + posY += areaOffsY; // Set output area in pixels absoluteOutputMode.Output = new Area { - Width = outputWidth = window.ClientSize.Width, - Height = outputHeight = window.ClientSize.Height, - Position = new System.Numerics.Vector2(outputWidth / 2, outputHeight / 2) + Width = outputWidth, + Height = outputHeight, + Position = new System.Numerics.Vector2(posX, posY) }; break; } From 56db88494468e84d18cb748de7a658766e7737f1 Mon Sep 17 00:00:00 2001 From: Fyodor Ryzhov <53872073+Feodor0090@users.noreply.github.com> Date: Fri, 2 Feb 2024 02:14:22 +0300 Subject: [PATCH 2/4] Expose area properties via `ITabletHandler` --- osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs index 85870b2446..4e2b934916 100644 --- a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs +++ b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs @@ -22,6 +22,16 @@ public interface ITabletHandler /// Bindable AreaSize { get; } + /// + /// Position of output area inside game window, 0 is top-left position, 1 is bottom-right. + /// + Bindable OutputAreaPosition { get; } + + /// + /// Relative size of output area inside game window. + /// + Bindable OutputAreaSize { get; } + /// /// Information on the currently connected tablet device. May be null if no tablet is detected. /// From abc34ab956e8d6fc7780da12a1df5a242ddadac0 Mon Sep 17 00:00:00 2001 From: Fyodor Ryzhov <53872073+Feodor0090@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:59:08 +0300 Subject: [PATCH 3/4] Add better explanation how `OutputAreaPosition` works --- osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs index 4e2b934916..b6dbed8c8b 100644 --- a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs +++ b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs @@ -23,8 +23,13 @@ public interface ITabletHandler Bindable AreaSize { get; } /// - /// Position of output area inside game window, 0 is top-left position, 1 is bottom-right. + /// Relative position of center of output area in game window, padded by half of . + /// Values between zero and one for each axe will always place the area inside window: + /// (0; 0) is most top-left position, (1;1) is most bottom-right position. Does nothing if equals to (1; 1). /// + /// + /// This and behave like posX/posY/sizeX/sizeY properties on osu!'s ScalingContainer. + /// Bindable OutputAreaPosition { get; } /// From f8aab30845f865ca4bd356626fad04f9010a8fdb Mon Sep 17 00:00:00 2001 From: Fyodor Ryzhov <53872073+Feodor0090@users.noreply.github.com> Date: Thu, 7 Mar 2024 01:31:13 +0300 Subject: [PATCH 4/4] Remove mention about osu!'s component --- osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs index b6dbed8c8b..102eeda87f 100644 --- a/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs +++ b/osu.Framework/Input/Handlers/Tablet/ITabletHandler.cs @@ -27,9 +27,6 @@ public interface ITabletHandler /// Values between zero and one for each axe will always place the area inside window: /// (0; 0) is most top-left position, (1;1) is most bottom-right position. Does nothing if equals to (1; 1). /// - /// - /// This and behave like posX/posY/sizeX/sizeY properties on osu!'s ScalingContainer. - /// Bindable OutputAreaPosition { get; } ///