This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Program.cs
89 lines (71 loc) · 2.03 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using WlxOverlay.Backend;
using WlxOverlay.Core;
using WlxOverlay.Core.Interactions;
using WlxOverlay.Core.Subsystem;
using WlxOverlay.Extras;
using WlxOverlay.GFX.OpenGL;
using WlxOverlay.Input;
using WlxOverlay.Overlays;
using WlxOverlay.Types;
var version = "unknown-version";
try
{
version = File.ReadAllText(Path.Combine(Config.AppDir, "Resources", "version.txt")).Trim();
}
catch { /* */ }
Console.WriteLine($"WlxOverlay {version}");
if (!Config.Load())
return;
if (Config.Instance.OverrideEnv != null)
foreach (var pair in Config.Instance.OverrideEnv)
Environment.SetEnvironmentVariable(pair.Key, pair.Value);
Session.Initialize();
if (args.Contains("--xr"))
XrBackend.UseOpenXR();
else
XrBackend.UseOpenVR();
try
{
InputProvider.UseUInput();
}
catch (Exception)
{
InputProvider.UseDummy();
}
void SignalHandler(PosixSignalContext context)
{
context.Cancel = true;
Console.WriteLine($"Received signal {context.Signal}. Exiting...");
MainLoop.Shutdown();
}
PosixSignalRegistration.Create(PosixSignal.SIGINT, SignalHandler);
PosixSignalRegistration.Create(PosixSignal.SIGHUP, SignalHandler);
PosixSignalRegistration.Create(PosixSignal.SIGTERM, SignalHandler);
if (Config.Instance.LeftUsePtt)
PttHandler.Add(LeftRight.Left);
if (Config.Instance.RightUsePtt)
PttHandler.Add(LeftRight.Right);
if (!KeyboardLayout.Load())
{
Console.WriteLine("[Fatal] Keyboard layout is invalid.");
Environment.Exit(1);
}
var keyboard = new KeyboardOverlay();
OverlayRegistry.Register(keyboard);
if (WaylandSubsystem.TryInitialize(out var wayland))
{
MainLoop.AddSubsystem(wayland);
await wayland.CreateScreensAsync();
}
else if (XshmSubsystem.TryInitialize(out var xshm))
{
MainLoop.AddSubsystem(xshm);
xshm.CreateScreens();
}
AudioManager.Initialize();
if (!string.IsNullOrWhiteSpace(Config.Instance.NotificationsEndpoint))
NotificationsManager.Initialize();
var watch = new Watch(keyboard);
OverlayRegistry.Register(watch);
var engine = new GlGraphicsEngine();
engine.StartEventLoop();