using XFESystem.Desktop;
namespace XFESystem.NativeRuntime.Application;
public enum NativeInputKind { Pointer, Key, BrowserKey, ReportsLost }
public readonly record struct NativeInputEvent(NativeInputKind Kind, int X = 0, int Y = 0, bool LeftButton = false,
int Wheel = 0, DesktopKey Key = DesktopKey.Character, char Character = '\0', BrowserKeyboardInput BrowserKey = default);
/// <summary>The future hardware adapter supplies layout-coordinate reports on this single owner thread.</summary>
public interface INativeInputSource
{
bool IsAvailable { get; }
bool TryRead(out NativeInputEvent report);
}
public static class NativeInput
{
public static void Dispatch(DesktopSession desktop, NativeInputEvent report, long monotonicMilliseconds)
{
switch (report.Kind)
{
case NativeInputKind.Pointer: desktop.Pointer(report.X, report.Y, report.LeftButton, report.Wheel, monotonicMilliseconds); break;
case NativeInputKind.Key: desktop.Key(report.Key, report.Character); break;
case NativeInputKind.BrowserKey: desktop.BrowserKey(report.BrowserKey); break;
case NativeInputKind.ReportsLost:
desktop.Key(DesktopKey.EndWindowSwitch);
desktop.PointerReportsLost(report.X, report.Y, report.LeftButton, monotonicMilliseconds);
break;
default: throw new InvalidDataException("The native input report kind is unknown.");
}
}
}
using XFESystem.Desktop;
namespace XFESystem.NativeRuntime.Application;
public enum NativeInputKind { Pointer, Key, BrowserKey, ReportsLost }
public readonly record struct NativeInputEvent(NativeInputKind Kind, int X = 0, int Y = 0, bool LeftButton = false,
int Wheel = 0, DesktopKey Key = DesktopKey.Character, char Character = '\0', BrowserKeyboardInput BrowserKey = default);
/// <summary>The future hardware adapter supplies layout-coordinate reports on this single owner thread.</summary>
public interface INativeInputSource
{
bool IsAvailable { get; }
bool TryRead(out NativeInputEvent report);
}
public static class NativeInput
{
public static void Dispatch(DesktopSession desktop, NativeInputEvent report, long monotonicMilliseconds)
{
switch (report.Kind)
{
case NativeInputKind.Pointer: desktop.Pointer(report.X, report.Y, report.LeftButton, report.Wheel, monotonicMilliseconds); break;
case NativeInputKind.Key: desktop.Key(report.Key, report.Character); break;
case NativeInputKind.BrowserKey: desktop.BrowserKey(report.BrowserKey); break;
case NativeInputKind.ReportsLost:
desktop.Key(DesktopKey.EndWindowSwitch);
desktop.PointerReportsLost(report.X, report.Y, report.LeftButton, monotonicMilliseconds);
break;
default: throw new InvalidDataException("The native input report kind is unknown.");
}
}
}