Esempio n. 1
0
        internal RawKeyboard(RawDevice device, iKeyboardLayout layout, iKeyboardHandler handler)
        {
            this.layout  = layout;
            this.handler = handler;
            deviceName   = device.name;

            if (deviceName.isEmpty())
            {
                deviceName = device.productDescription;
            }
            if (deviceName.isEmpty())
            {
                string mfg = device.manufacturer;
                if (mfg.notEmpty())
                {
                    deviceName = $"A keyboard made by { mfg }";
                }
                else
                {
                    deviceName = $"Unidentified { device.bus } keyboard";
                }
            }
        }
Esempio n. 2
0
        /// <summary>Open a raw input device, interpret the input as a US English keyboard</summary>
        public static iInputEventTimeSource openRawKeyboard(this Dispatcher dispatcher, iKeyboardHandler handler, RawDevice device = null)
        {
            // Find the keyboard
            if (null == device)
            {
                device = RawDevice.list().FirstOrDefault(isQwertyKeyboard);
                if (null == device)
                {
                    throw new ApplicationException("No keyboards found");
                }
            }

            // Create the layout. That object also owns the state, i.e. shift/numlock/etc.
            iKeyboardLayout layout = new UsEnglishLayout();
            // Create the adapter to translate raw events into keyboard events
            var keyboard = new RawKeyboard(device, layout, handler);;

            // Open the device
            using (iLinuxDispatcher linuxDispatcher = ComLightCast.cast <iLinuxDispatcher>(dispatcher.nativeDispatcher))
                linuxDispatcher.openInputDevice(device.eventInterface, keyboard);

            return(keyboard);
        }