Example #1
0
        /// <summary>Open a raw mouse device and wrap it into an adapter that will call the provided object when input happens.</summary>
        public static iInputEventTimeSource openRawMouse(this Dispatcher dispatcher, iMouseHandler handler, CRect clipRect, RawDevice device = null)
        {
            // Find the mouse
            if (null == device)
            {
                device = RawDevice.list().FirstOrDefault(isMouse);
                if (null == device)
                {
                    throw new ApplicationException("No mice are detected");
                }
            }

            // Create the adapter to translate raw events into mouse events
            RawMouse mouse = clipRect.isEmpty ? new RawMouse(device, handler) : new RawMouseClipped(device, clipRect, handler);

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

            return(mouse);
        }
Example #2
0
        internal RawMouse(RawDevice device, iMouseHandler handler)
        {
            this.handler = handler;

            buttons = device.buttons.ToArray();

            deviceName = device.name;
            if (deviceName.isEmpty())
            {
                deviceName = device.productDescription;
            }
            if (deviceName.isEmpty())
            {
                string mfg = device.manufacturer;
                if (mfg.notEmpty())
                {
                    deviceName = $"A mouse made by { mfg }";
                }
                else
                {
                    deviceName = $"Unidentified { device.bus } mouse";
                }
            }
        }
Example #3
0
 /// <summary>Open a raw mouse device and wrap it into an adapter that will call the provided object when input happens.</summary>
 public static iInputEventTimeSource openRawMouse(this Dispatcher dispatcher, iMouseHandler handler, RawDevice device = null)
 {
     return(openRawMouse(dispatcher, handler, CRect.empty, device));
 }
Example #4
0
 internal RawMouseClipped(RawDevice device, CRect clipRect, iMouseHandler handler) :
     base(device, handler)
 {
     this.clipRect = clipRect;
     position      = prevPosition = clipRect.center;
 }