예제 #1
0
        public X11Mouse(WindowInfo window)
        {
            this.window = window;

            // Just create one mouse now.
            // TODO: support for multiple devices through evdev.
            // TODO: Should call XSelectInput for mouse pointer events.
            MouseDevice m = new MouseDevice();
            m.Description = "Default X11 mouse";
            m.DeviceID = IntPtr.Zero;
            m.NumberOfButtons = 5;
            m.NumberOfWheels = 1;
            mice.Add(m);
        }
예제 #2
0
        /// <summary>
        /// Not used yet.
        /// Registers the necessary atoms for GameWindow.
        /// </summary>
        private static void RegisterAtoms(WindowInfo window)
        {
            string[] atom_names = new string[] 
            {
                "WM_TITLE",
                "UTF8_STRING"
            };
            IntPtr[] atoms = new IntPtr[atom_names.Length];
            //Functions.XInternAtoms(window.Display, atom_names, atom_names.Length, false, atoms);

            int offset = 0;
            WMTitle = atoms[offset++];
            UTF8String = atoms[offset++];
        }
예제 #3
0
        internal X11Keyboard(WindowInfo window)
        {
            if (window == null)
                throw new ArgumentNullException("window");

            this.window = window;
            Initialize();

            //Debug.Print("Info: {0}", window.ToString());

            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);
            //keysyms = (IntPtr[])Marshal.PtrToStructure(keysym_ptr, typeof(IntPtr[]));

            API.Free(keysym_ptr);
            
            KeyboardDevice kb = new KeyboardDevice();
            kb.Description = "Default X11 keyboard";
            kb.NumberOfKeys = lastKeyCode - firstKeyCode + 1;
            kb.DeviceID = IntPtr.Zero;
            keyboards.Add(kb);
            Debug.Print("Keyboard added: {0}", kb.ToString());
        }