Exemplo n.º 1
0
        public static EvDevDevice Open(string device)
        {
            var fd = NativeUnsafeMethods.open(device, 2048, 0);

            if (fd <= 0)
            {
                throw new Exception($"Unable to open {device} code {Marshal.GetLastWin32Error()}");
            }
            IntPtr dev;
            var    rc = NativeUnsafeMethods.libevdev_new_from_fd(fd, out dev);

            if (rc < 0)
            {
                NativeUnsafeMethods.close(fd);
                throw new Exception($"Unable to initialize evdev for {device} code {Marshal.GetLastWin32Error()}");
            }
            return(new EvDevDevice(fd, dev));
        }
 static void CloseRestricted(int fd, IntPtr userData)
 {
     NativeUnsafeMethods.close(fd);
 }