Free() private method

private Free ( IntPtr buffer ) : void
buffer System.IntPtr
return void
Exemplo n.º 1
0
        public X11Input(IWindowInfo attach)
        {
            if (attach == null)
            {
                throw new ArgumentException("A valid parent window must be defined, in order to create an X11Input driver.");
            }
            X11WindowInfo x11WindowInfo = (X11WindowInfo)attach;

            this.mouse.Description     = "Default X11 mouse";
            this.mouse.DeviceID        = IntPtr.Zero;
            this.mouse.NumberOfButtons = 5;
            this.mouse.NumberOfWheels  = 1;
            this.dummy_mice_list.Add(this.mouse);
            using (new XLock(x11WindowInfo.Display))
            {
                API.DisplayKeycodes(x11WindowInfo.Display, ref this.firstKeyCode, ref this.lastKeyCode);
                IntPtr keyboardMapping = API.GetKeyboardMapping(x11WindowInfo.Display, (byte)this.firstKeyCode, this.lastKeyCode - this.firstKeyCode + 1, ref this.keysyms_per_keycode);
                this.keysyms = new IntPtr[(this.lastKeyCode - this.firstKeyCode + 1) * this.keysyms_per_keycode];
                Marshal.PtrToStructure(keyboardMapping, (object)this.keysyms);
                API.Free(keyboardMapping);
                KeyboardDevice keyboardDevice = new KeyboardDevice();
                this.keyboard.Description  = "Default X11 keyboard";
                this.keyboard.NumberOfKeys = this.lastKeyCode - this.firstKeyCode + 1;
                this.keyboard.DeviceID     = IntPtr.Zero;
                this.dummy_keyboard_list.Add(this.keyboard);
                bool supported;
                Functions.XkbSetDetectableAutoRepeat(x11WindowInfo.Display, true, out supported);
            }
        }
Exemplo n.º 2
0
        //bool disposed;

        #region --- Constructors ---

        /// <summary>
        /// Constructs a new X11Input driver. Creates a hidden InputOnly window, child to
        /// the main application window, which selects input events and routes them to
        /// the device specific drivers (Keyboard, Mouse, Hid).
        /// </summary>
        /// <param name="attach">The window which the InputDriver will attach itself on.</param>
        public X11Input(IWindowInfo attach)
        {
            Debug.WriteLine("Initalizing X11 input driver.");
            Debug.Indent();

            if (attach == null)
            {
                throw new ArgumentException("A valid parent window must be defined, in order to create an X11Input driver.");
            }

            //window = new X11WindowInfo(attach);
            X11WindowInfo window = (X11WindowInfo)attach;

            // Init mouse
            mouse.Description     = "Default X11 mouse";
            mouse.DeviceID        = IntPtr.Zero;
            mouse.NumberOfButtons = 5;
            mouse.NumberOfWheels  = 1;
            dummy_mice_list.Add(mouse);

            using (new XLock(window.Display))
            {
                // Init keyboard
                API.DisplayKeycodes(window.Display, ref firstKeyCode, ref lastKeyCode);
                Debug.Print("First keycode: {0}, last {1}", firstKeyCode, lastKeyCode);

                IntPtr keysym_ptr = API.GetKeyboardMapping(window.Display, (byte)firstKeyCode,
                                                           lastKeyCode - firstKeyCode + 1, ref keysyms_per_keycode);
                Debug.Print("{0} keysyms per keycode.", keysyms_per_keycode);

                keysyms = new IntPtr[(lastKeyCode - firstKeyCode + 1) * keysyms_per_keycode];
                Marshal.PtrToStructure(keysym_ptr, keysyms);
                API.Free(keysym_ptr);

                KeyboardDevice kb = new KeyboardDevice();
                keyboard.Description  = "Default X11 keyboard";
                keyboard.NumberOfKeys = lastKeyCode - firstKeyCode + 1;
                keyboard.DeviceID     = IntPtr.Zero;
                dummy_keyboard_list.Add(keyboard);

                // Request that auto-repeat is only set on devices that support it physically.
                // This typically means that it's turned off for keyboards (which is what we want).
                // We prefer this method over XAutoRepeatOff/On, because the latter needs to
                // be reset before the program exits.
                bool supported;
                Functions.XkbSetDetectableAutoRepeat(window.Display, true, out supported);
            }

            Debug.Unindent();
        }