Пример #1
0
        public X11Keyboard()
        {
            Debug.WriteLine("Using X11Keyboard.");
            state.IsConnected = true;

            IntPtr display = API.DefaultDisplay;

            using (new XLock(display))
            {
                // Find the number of keysyms per keycode.
                int first = 0, last = 0;
                API.DisplayKeycodes(display, ref first, ref last);
                IntPtr keysym_ptr =
                    API.GetKeyboardMapping(display,
                                           (byte)first,
                                           last - first + 1,
                                           ref KeysymsPerKeycode);
                Functions.XFree(keysym_ptr);

                if (Xkb.IsSupported(display))
                {
                    // Request that auto-repeat is only set on devices that support it physically.
                    // This typically means that it's turned off for keyboards what we want).
                    // We prefer this method over XAutoRepeatOff/On, because the latter needs to
                    // be reset before the program exits.
                    bool supported;
                    Xkb.SetDetectableAutoRepeat(display, true, out supported);
                    KeyMap = new X11KeyMap(display);
                }
            }
        }
Пример #2
0
 internal X11KeyMap(IntPtr display)
 {
     xkb_supported = Xkb.IsSupported(display);
     if (xkb_supported)
     {
         RefreshKeycodes(display);
     }
 }