private DisplayKeycodes ( Display display, int &min_keycodes_return, int &max_keycodes_return ) : void | ||
display | Display | |
min_keycodes_return | int | |
max_keycodes_return | int | |
return | void |
public X11Keyboard() { Debug.WriteLine("Using X11Keyboard."); state.IsConnected = true; var 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); var 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); } } }
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); } }
//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(); }
public X11Keyboard() { this.state.IsConnected = true; IntPtr defaultDisplay = API.DefaultDisplay; using (new XLock(defaultDisplay)) { int min_keycodes_return = 0; int max_keycodes_return = 0; API.DisplayKeycodes(defaultDisplay, ref min_keycodes_return, ref max_keycodes_return); Functions.XFree(API.GetKeyboardMapping(defaultDisplay, (byte)min_keycodes_return, max_keycodes_return - min_keycodes_return + 1, ref this.KeysymsPerKeycode)); try { bool supported; Functions.XkbSetDetectableAutoRepeat(defaultDisplay, true, out supported); } catch { } } }