Permalink
Browse files

[Linux] Print libinput seat for each detected device

  • Loading branch information...
1 parent 2074766 commit 21bcc5eae19aebb34cba4f0284dc3da3ae1bebbf @thefiddler thefiddler committed Jul 18, 2014
Showing with 55 additions and 2 deletions.
  1. +23 −0 Source/OpenTK/Platform/Linux/Bindings/LibInput.cs
  2. +32 −2 Source/OpenTK/Platform/Linux/LinuxInput.cs
@@ -82,6 +82,9 @@ public static string DeviceGetOutputName(IntPtr device)
}
}
+ [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 @@ public static string DeviceGetOutputName(IntPtr device)
[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
@@ -44,6 +44,8 @@ class DeviceBase
readonly IntPtr Device;
string name;
string output;
+ string logical_seat;
+ string physical_seat;
public DeviceBase(IntPtr device, int id)
{
@@ -72,6 +74,32 @@ public string Name
}
}
+ 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 @@ void HandleDeviceAdded(IntPtr context, IntPtr device)
{
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))

0 comments on commit 21bcc5e

Please sign in to comment.