Browse Source

feat(LibInputBackend): minimal linux boot with no input

pull/8533/head
Giuseppe Lippolis 4 years ago
parent
commit
94ecd84c8f
  1. 15
      src/Linux/Avalonia.LinuxFramebuffer/Input/LibInput/LibInputBackend.cs

15
src/Linux/Avalonia.LinuxFramebuffer/Input/LibInput/LibInputBackend.cs

@ -1,16 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Threading;
using static Avalonia.LinuxFramebuffer.Input.LibInput.LibInputNativeUnsafeMethods; using static Avalonia.LinuxFramebuffer.Input.LibInput.LibInputNativeUnsafeMethods;
namespace Avalonia.LinuxFramebuffer.Input.LibInput namespace Avalonia.LinuxFramebuffer.Input.LibInput
{ {
public class LibInputBackend : IInputBackend public class LibInputBackend : IInputBackend
{ {
private const string LibInput = nameof(Logging.LogArea.X11Platform) + "/" + nameof(LibInput);
private IScreenInfoProvider _screen; private IScreenInfoProvider _screen;
private IInputRoot _inputRoot; private IInputRoot _inputRoot;
private readonly Queue<Action> _inputThreadActions = new Queue<Action>(); private readonly Queue<Action> _inputThreadActions = new Queue<Action>();
@ -29,15 +28,21 @@ namespace Avalonia.LinuxFramebuffer.Input.LibInput
new Thread(()=>InputThread(ctx)).Start(); new Thread(()=>InputThread(ctx)).Start();
} }
private unsafe void InputThread(IntPtr ctx) private unsafe void InputThread(IntPtr ctx)
{ {
var fd = libinput_get_fd(ctx); var fd = libinput_get_fd(ctx);
var timeval = stackalloc IntPtr[2]; var timeval = stackalloc IntPtr[2];
if (!Directory.Exists("/dev/input"))
{
if (Logging.Logger.IsEnabled(Logging.LogEventLevel.Warning,LibInput))
{
Logging.Logger.TryGet(Logging.LogEventLevel.Warning, LibInput)
?.Log(this, "Not connect any input device.");
}
return;
}
foreach (var f in Directory.GetFiles("/dev/input", "event*")) foreach (var f in Directory.GetFiles("/dev/input", "event*"))
libinput_path_add_device(ctx, f); libinput_path_add_device(ctx, f);
while (true) while (true)

Loading…
Cancel
Save