Skip to content

Commit 1919442

Browse files
committed
New windowing proposal
1 parent dd103f5 commit 1919442

File tree

2 files changed

+1313
-781
lines changed

2 files changed

+1313
-781
lines changed

documentation/proposals/Proposal - Multi-Backend Input.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Cases where the **user** word is used without the **end** prefix can be assumed
3333

3434
# Usage Examples
3535
```cs
36-
IWindowHandlesSource someWindow = null!;
36+
INativeWindow someWindow = null!;
3737
var inputContext = someWindow.CreateInput();
3838
inputContext.Update();
3939
inputContext.Gamepads.ThumbstickMove += @event =>
@@ -43,27 +43,27 @@ inputContext.Gamepads.ThumbstickMove += @event =>
4343
var isButtonDown = inputContext.Gamepads.Any(gamepadState => gamepadState.Buttons[JoystickButton.A]);
4444
```
4545
```cs
46-
IWindowHandlesSource someWindow = null!;
46+
INativeWindow someWindow = null!;
4747
var inputContext = new InputContext();
4848
inputContext.Update();
4949
inputContext.Backends.Add(someWindow.CreateInputBackend());
5050
// in future:
5151
// inputContext.Backends.Add(new OpenXRInputBackend(...));
5252
```
5353
```cs
54-
class MyThing
54+
class Program : ISurfaceApplication
5555
{
56-
[SilkEntryPoint]
57-
public static void Run(ISurface surface)
56+
public static void Initialize<TSurface>(TSurface surface) where TSurface : Surface
5857
{
5958
var inputContext = surface.CreateInput();
6059
surface.Update += _ => inputContext.Update();
6160
inputContext.Gamepads.ThumbstickMove += @event =>
6261
{
6362
Console.WriteLine($"Thumbstick {@event.Index} moved from {@event.OldValue} to {@event.NewValue}");
6463
};
65-
surface.Run();
6664
}
65+
66+
public static void Main() => ISurfaceApplication.Run<Program>();
6767
}
6868
```
6969

@@ -74,18 +74,16 @@ Similar to Windowing 3.0, a reference implementation will be included in the mai
7474
```cs
7575
public static class InputWindowExtensions
7676
{
77-
public static IInputBackend CreateInputBackend(this WindowHandles window);
78-
public static IInputBackend CreateInputBackend(this IWindowHandlesSource window);
79-
public static InputContext CreateInput(this WindowHandles window);
80-
public static InputContext CreateInput(this IWindowHandlesSource window);
77+
public static IInputBackend CreateInputBackend(this INativeWindow window);
78+
public static InputContext CreateInput(this INativeWindow window);
8179
}
8280
```
8381

84-
The `CreateInputBackend` will create an instance of the reference implementation for the given `WindowHandles`. The `IWindowHandlesSource` overloads just forward to the `WindowHandles` overload. This is because `ISurface` will implement `IWindowHandlesSource`, so the extension methods will be usable on an `ISurface` without having a hard reference between Windowing and Input.
82+
The `CreateInputBackend` will create an instance of the reference implementation for the given `INativeWindow`. `Surface` will implement `INativeWindow`, so the extension methods will be usable on a `Surface` without having a hard reference between Windowing and Input.
8583

8684
The `CreateInput` methods simply return an `InputContext` preconfigured with the backend created by `CreateInputBackend` for ease of use.
8785

88-
Please see the Windowing 3.0 proposal for `IWindowHandlesSource` and `WindowHandles`.
86+
Please see the Windowing 3.0 proposal for `INativeWindow`.
8987

9088
# Devices
9189

0 commit comments

Comments
 (0)