Ejemplo 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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a Linux frame buffer device output
        /// </summary>
        /// <param name="fileName">The frame buffer device name.
        /// Defaults to the value in environment variable FRAMEBUFFER or /dev/fb0 when FRAMEBUFFER is not set</param>
        /// <param name="format">The required pixel format for the frame buffer.
        /// A null value will leave the frame buffer in the current pixel format.
        /// Otherwise sets the frame buffer to the required format</param>
        public FbdevOutput(string fileName, PixelFormat?format)
        {
            fileName ??= Environment.GetEnvironmentVariable("FRAMEBUFFER") ?? "/dev/fb0";
            _fd = NativeUnsafeMethods.open(fileName, 2, 0);
            if (_fd <= 0)
            {
                throw new Exception("Error: " + Marshal.GetLastWin32Error());
            }

            try
            {
                Init(format);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Ejemplo n.º 3
0
        public LinuxFramebuffer(string fileName = null, Vector?dpi = null)
        {
            _dpi     = dpi ?? new Vector(96, 96);
            fileName = fileName ?? Environment.GetEnvironmentVariable("FRAMEBUFFER") ?? "/dev/fb0";
            _fd      = NativeUnsafeMethods.open(fileName, 2, 0);
            if (_fd <= 0)
            {
                throw new Exception("Error: " + Marshal.GetLastWin32Error());
            }

            try
            {
                Init();
            }
            catch
            {
                Dispose();
                throw;
            }
        }