From 21bcc5eae19aebb34cba4f0284dc3da3ae1bebbf Mon Sep 17 00:00:00 2001 From: thefiddler Date: Fri, 18 Jul 2014 09:02:01 +0200 Subject: [PATCH] [Linux] Print libinput seat for each detected device --- Source/OpenTK/Platform/Linux/Bindings/LibInput.cs | 23 +++++++++++++++ Source/OpenTK/Platform/Linux/LinuxInput.cs | 34 +++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/Linux/Bindings/LibInput.cs b/Source/OpenTK/Platform/Linux/Bindings/LibInput.cs index 15aa00d..9793841 100644 --- a/Source/OpenTK/Platform/Linux/Bindings/LibInput.cs +++ b/Source/OpenTK/Platform/Linux/Bindings/LibInput.cs @@ -82,6 +82,9 @@ namespace OpenTK.Platform.Linux } } + [DllImport(lib, EntryPoint = "libinput_device_get_seat", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr DeviceGetSeat(IntPtr device); + [DllImport(lib, EntryPoint = "libinput_device_has_capability", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DeviceHasCapability(IntPtr device, DeviceCapability capability); @@ -115,6 +118,26 @@ namespace OpenTK.Platform.Linux [DllImport(lib, EntryPoint = "libinput_suspend", CallingConvention = CallingConvention.Cdecl)] public static extern void Suspend(IntPtr libinput); + + [DllImport(lib, EntryPoint = "libinput_seat_get_logical_name", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr SeatGetLogicalNameInternal(IntPtr seat); + public static string SeatGetLogicalName(IntPtr seat) + { + unsafe + { + return new string((sbyte*)SeatGetLogicalNameInternal(seat)); + } + } + + [DllImport(lib, EntryPoint = "libinput_seat_get_physical_name", CallingConvention = CallingConvention.Cdecl)] + static extern public IntPtr SeatGetPhysicalNameInternal(IntPtr seat); + public static string SeatGetPhysicalName(IntPtr seat) + { + unsafe + { + return new string((sbyte*)SeatGetPhysicalName(seat)); + } + } } enum DeviceCapability diff --git a/Source/OpenTK/Platform/Linux/LinuxInput.cs b/Source/OpenTK/Platform/Linux/LinuxInput.cs index a79ec37..b421b56 100644 --- a/Source/OpenTK/Platform/Linux/LinuxInput.cs +++ b/Source/OpenTK/Platform/Linux/LinuxInput.cs @@ -44,6 +44,8 @@ namespace OpenTK.Platform.Linux readonly IntPtr Device; string name; string output; + string logical_seat; + string physical_seat; public DeviceBase(IntPtr device, int id) { @@ -72,6 +74,32 @@ namespace OpenTK.Platform.Linux } } + public IntPtr Seat + { + get + { + return LibInput.DeviceGetSeat(Device); + } + } + + public string LogicalSeatName + { + get + { + logical_seat = logical_seat ?? LibInput.SeatGetLogicalName(Seat); + return logical_seat; + } + } + + public string PhysicalSeatName + { + get + { + physical_seat = physical_seat ?? LibInput.SeatGetPhysicalName(Seat); + return physical_seat; + } + } + public string Output { get @@ -372,14 +400,16 @@ namespace OpenTK.Platform.Linux { KeyboardDevice keyboard = new KeyboardDevice(device, Keyboards.Count); Keyboards.Add(keyboard.Id, keyboard); - Debug.Print("[Input] Added keyboard device {0} '{1}'", keyboard.Id, keyboard.Name); + Debug.Print("[Input] Added keyboard device {0} '{1}' on '{2}' ('{3}')", + keyboard.Id, keyboard.Name, keyboard.LogicalSeatName, keyboard.PhysicalSeatName); } if (LibInput.DeviceHasCapability(device, DeviceCapability.Mouse)) { MouseDevice mouse = new MouseDevice(device, Mice.Count); Mice.Add(mouse.Id, mouse); - Debug.Print("[Input] Added mouse device {0} '{1}'", mouse.Id, mouse.Name); + Debug.Print("[Input] Added mouse device {0} '{1}' on '{2}' ('{3}')", + mouse.Id, mouse.Name, mouse.LogicalSeatName, mouse.PhysicalSeatName); } if (LibInput.DeviceHasCapability(device, DeviceCapability.Touch)) -- 2.7.4