public XI2MouseKeyboard() { window = new X11WindowInfo(); window.Display = Functions.XOpenDisplay(IntPtr.Zero); using (new XLock(window.Display)) { XSetWindowAttributes attr = new XSetWindowAttributes(); window.Screen = Functions.XDefaultScreen(window.Display); window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow, 0, 0, 1, 1, 0, 0, CreateWindowArgs.InputOnly, IntPtr.Zero, SetWindowValuemask.Nothing, attr); KeyMap = new X11KeyMap(window.Display); } if (!IsSupported(window.Display)) { throw new NotSupportedException("XInput2 not supported."); } // Enable XI2 mouse/keyboard events // Note: the input event loop blocks waiting for these events // *or* a custom ClientMessage event that instructs us to exit. // See SendExitEvent() below. using (new XLock(window.Display)) using (XIEventMask mask = new XIEventMask(1, XIEventMasks.RawKeyPressMask | XIEventMasks.RawKeyReleaseMask | XIEventMasks.RawButtonPressMask | XIEventMasks.RawButtonReleaseMask | XIEventMasks.RawMotionMask | XIEventMasks.MotionMask | XIEventMasks.DeviceChangedMask)) { XI.SelectEvents(window.Display, window.RootWindow, mask); UpdateDevices(); } ProcessingThread = new Thread(ProcessEvents); ProcessingThread.IsBackground = true; ProcessingThread.Start(); }
public XI2MouseKeyboard() { window = new X11WindowInfo(); window.Display = Functions.XOpenDisplay(IntPtr.Zero); using (new XLock(window.Display)) { window.Screen = Functions.XDefaultScreen(window.Display); window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); window.Handle = window.RootWindow; KeyMap = new X11KeyMap(window.Display); } if (!IsSupported(window.Display)) { throw new NotSupportedException("XInput2 not supported."); } using (new XLock(window.Display)) using (XIEventMask mask = new XIEventMask(1, XIEventMasks.RawKeyPressMask | XIEventMasks.RawKeyReleaseMask | XIEventMasks.RawButtonPressMask | XIEventMasks.RawButtonReleaseMask | XIEventMasks.RawMotionMask | XIEventMasks.MotionMask | XIEventMasks.DeviceChangedMask | (XIEventMasks)(1 << (int)ExitEvent))) { XI.SelectEvents(window.Display, window.Handle, mask); UpdateDevices(); } ProcessingThread = new Thread(ProcessEvents); ProcessingThread.IsBackground = true; ProcessingThread.Start(); }