示例#1
0
        protected override void Initialize(IObservable <WMEventArgs> windowMessages)
        {
            var keyNotifications = windowMessages
                                   .Select <WMEventArgs, KeyNotification>(e =>
            {
                switch (e.Message)
                {
                case WM.KEYDOWN:
                case WM.SYSKEYDOWN:
                    return(new KeyDownNotification((Keys)e.WParam));

                case WM.CHAR:
                case WM.SYSCHAR:
                    return(new KeyPressNotification((char)e.WParam));

                case WM.KEYUP:
                case WM.SYSKEYUP:
                    return(new KeyUpNotification((Keys)e.WParam));
                }
                return(null);
            }
                                                                          )
                                   .OfType <KeyNotification>();

            KeyboardOut[0] = new Keyboard(keyNotifications);

            // Create a keyboard states node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyStates" && n.Category == "Keyboard" && n.Version == "Split");

            FKeyboardStatesSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => KeyboardOut);
        }
示例#2
0
        protected override void Initialize(IObservable <EventPattern <WMEventArgs> > windowMessages, IObservable <bool> disabled)
        {
            var keyNotifications = windowMessages
                                   .Select <EventPattern <WMEventArgs>, KeyNotification>(e =>
            {
                var a = e.EventArgs;
                switch (a.Message)
                {
                case WM.KEYDOWN:
                case WM.SYSKEYDOWN:
                    return(new KeyDownNotification((Keys)a.WParam, this));

                case WM.CHAR:
                case WM.SYSCHAR:
                    return(new KeyPressNotification((char)a.WParam, this));

                case WM.KEYUP:
                case WM.SYSKEYUP:
                    return(new KeyUpNotification((Keys)a.WParam, this));
                }
                return(null);
            }
                                                                                         )
                                   .OfType <KeyNotification>();
            var keyboard = new Keyboard(keyNotifications);

            FKeyboardOut[0] = keyboard;

            // Subscribe to the keyboard so we can write the legacy keyboard string output
            FKeyboardSubscription = keyboard.KeyNotifications
                                    .OfType <KeyCodeNotification>()
                                    .Subscribe(keyNotification =>
            {
                var keyCode = keyNotification.KeyCode;
                var keyName = LegacyKeyboardHelper.VirtualKeycodeToString(keyCode);
                switch (keyNotification.Kind)
                {
                case KeyNotificationKind.KeyDown:
                    if (!FLegacyKeyStringOut.Contains(keyName))
                    {
                        FLegacyKeyStringOut.Add(keyName);
                    }
                    break;

                case KeyNotificationKind.KeyUp:
                    FLegacyKeyStringOut.Remove(keyName);
                    break;

                default:
                    break;
                }
            }
                                               );

            // Create a keyboard split node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyboardState" && n.Category == "System" && n.Version == "Split Legacy");

            FKeyboardSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => FKeyboardOut);
        }
示例#3
0
        public override void OnImportsSatisfied()
        {
            // Create a keyboard split node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyboardState" && n.Category == "System" && n.Version == "Split");

            FKeyboardSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => FKeyboardOut);
            base.OnImportsSatisfied();
        }
示例#4
0
        public override void OnImportsSatisfied()
        {
            // Create a mouse split node for us and connect our mouse out to its mouse in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "MouseState" && n.Category == "System" && n.Version == "Split");

            FMouseSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Mouse", c => FMouseOut);
            base.OnImportsSatisfied();
        }
示例#5
0
        protected override void Initialize(IObservable <WMEventArgs> windowMessages, IObservable <bool> disabled)
        {
            var notifications = windowMessages
                                .Where(e => e.Message == WM.TOUCH)
                                .SelectMany <WMEventArgs, TouchNotification>(e => GenerateTouchNotifications(e));

            TouchDeviceOut[0] = new TouchDevice(notifications);

            // Create a touch states split node for us and connect our touch device out to its touch device in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "TouchStates" && n.Category == "Touch" && n.Version == "Split");

            FTouchStatesSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Touch Device", c => TouchDeviceOut);

            ModeIn.Changed += ModeIn_Changed;
        }
        private bool CreateMouseEventsOut()
        {
            bool isOlderMouse;
            var  constructor = FindMouseConstructor(out isOlderMouse);

            if (constructor == null)
            {
                return(false);
            }

            var oa = new OutputAttribute("Mouse Events");

            oa.IsSingle = true;
            var mouseEventOut = FIOFactory.CreatePin <Mouse>(oa);

            var mouseDowns = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseDown")
                             .Select(p => p.EventArgs.ToMouseDownNotification(this));
            var mouseMoves = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseMove")
                             .Select(p => p.EventArgs.ToMouseMoveNotification(this));
            var mouseUps = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseUp")
                           .Select(p => p.EventArgs.ToMouseUpNotification(this));
            var mouseClicks = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseClick")
                              .Select(p => p.EventArgs.ToMouseClickNotification(this));
            var mouseDoubleClicks = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseDoubleClick")
                                    .Select(p => p.EventArgs.ToMouseDoubleClickNotification(this));
            var mouseWheels = Observable.FromEventPattern <FormsMouseEventArgs>(this, "MouseWheel")
                              .Select(p => p.EventArgs.ToMouseWheelNotification(this));

            var mouseStream = mouseDowns
                              .Merge <MouseNotification>(mouseMoves)
                              .Merge(mouseUps)
                              .Merge(mouseClicks)
                              .Merge(mouseDoubleClicks)
                              .Merge(mouseWheels);

            if (isOlderMouse)
            {
                mouseEventOut[0] = (Mouse)constructor.Invoke(new object[] { mouseStream, false });
            }
            else
            {
                mouseEventOut[0] = (Mouse)constructor.Invoke(new object[] { mouseStream, false, true });
            }

            return(true);
        }
        public void CreateEnumPin(string pinName, IEnumerable <string> entries)
        {
            EnumName = "Enum_" + this.GetHashCode().ToString();

            EnumManager.UpdateEnum(EnumName, entries.First(), entries.ToArray());

            var attr = new InputAttribute(pinName);

            attr.Order        = 2;
            attr.AutoValidate = true;

            attr.EnumName = EnumName;

            Type pinType = typeof(IDiffSpread <EnumEntry>);
            var  pin     = FIOFactory.CreateIOContainer(pinType, attr);

            FUseAsID = (IDiffSpread <EnumEntry>)(pin.RawIOObject);
        }
示例#8
0
        protected override void Initialize(IObservable <EventPattern <WMEventArgs> > windowMessages, IObservable <bool> disabled)
        {
            var keyNotifications = windowMessages
                                   .Select <EventPattern <WMEventArgs>, KeyNotification>(e =>
            {
                var a = e.EventArgs;
                // DX9 does not send regular key up and DX11 does not send regular key down for TAB key - no idea why, so hack it (issue #3269)
                var msg = ApplyTabHack(a);
                switch (msg)
                {
                case WM.KEYDOWN:
                case WM.SYSKEYDOWN:
                    return(new KeyDownNotification((Keys)a.WParam, e.Sender));

                case WM.CHAR:
                case WM.SYSCHAR:
                    return(new KeyPressNotification((char)a.WParam, e.Sender));

                case WM.KEYUP:
                case WM.SYSKEYUP:
                    return(new KeyUpNotification((Keys)a.WParam, e.Sender));
                }
                return(null);
            }
                                                                                         )
                                   .OfType <KeyNotification>();
            var deviceLostNotifications = Observable.FromEventPattern <WindowEventArgs>(FHost, "WindowSelectionChanged")
                                          .Select(p => p.EventArgs.Window)
                                          .OfType <Window>()
                                          .Select(w => w.UserInputWindow != null)
                                          .DistinctUntilChanged()
                                          .Where(assigned => !assigned)
                                          .Select(_ => new KeyboardLostNotification(null));
            var disabledNotifications = disabled.Select(_ => new KeyboardLostNotification(null));

            KeyboardOut[0] = new Keyboard(keyNotifications.Merge(deviceLostNotifications).Merge(disabledNotifications));

            // Create a keyboard states node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyStates" && n.Category == "Keyboard" && n.Version == "Split");

            FKeyboardStatesSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => KeyboardOut);
        }
示例#9
0
        protected override void OnConfigChange(IDiffSpread <string> configSpread)
        {
            base.OnConfigChange(configSpread);

            var attr = new InputAttribute("AvoidNil");

            attr.BinVisibility  = PinVisibility.OnlyInspector;
            attr.Order          = 6;
            attr.BinOrder       = 7;
            attr.BinSize        = 1;
            attr.CheckIfChanged = true;

            Type pinType = typeof(ISpread <>).MakeGenericType((typeof(ISpread <>)).MakeGenericType(TargetDynamicType)); // the Pin is always a binsized one

            if (FAvoidNil != null)
            {
                FAvoidNil.Dispose();
            }
            FAvoidNil = FIOFactory.CreateIOContainer(pinType, attr);
        }
        private void CreateTouchEventsOut()
        {
            var oa = new OutputAttribute("Touch Events");

            oa.IsSingle = true;
            var touchEventOut = FIOFactory.CreatePin <TouchDevice>(oa);

            var touchDowns = Observable.FromEventPattern <WMTouchEventArgs>(this, "TouchDown")
                             .Select(p => p.EventArgs.ToTouchDownNotification(this));
            var touchMoves = Observable.FromEventPattern <WMTouchEventArgs>(this, "TouchMove")
                             .Select(p => p.EventArgs.ToTouchMoveNotification(this));
            var touchUps = Observable.FromEventPattern <WMTouchEventArgs>(this, "TouchUp")
                           .Select(p => p.EventArgs.ToTouchUpNotification(this));

            var touchStream = touchDowns
                              .Merge <TouchNotification>(touchMoves)
                              .Merge(touchUps);

            touchEventOut[0] = new TouchDevice(touchStream);
        }
        private void CreateKeyboardEventsOut()
        {
            var oa = new OutputAttribute("Keyboard Events");

            oa.IsSingle = true;
            var keyboardEventOut = FIOFactory.CreatePin <Keyboard>(oa);

            var keyDowns = Observable.FromEventPattern <KeyEventArgs>(this, "KeyDown")
                           .Select(p => p.EventArgs.ToKeyDownNotification());
            var keyUps = Observable.FromEventPattern <KeyEventArgs>(this, "KeyUp")
                         .Select(p => p.EventArgs.ToKeyUpNotification());
            var keyPresses = Observable.FromEventPattern <KeyPressEventArgs>(this, "KeyPress")
                             .Select(p => p.EventArgs.ToKeyPressNotification());

            var keyboardStream = keyDowns
                                 .Merge <KeyNotification>(keyUps)
                                 .Merge(keyPresses);

            keyboardEventOut[0] = new Keyboard(keyboardStream);
        }
示例#12
0
        public override void OnImportsSatisfied()
        {
            FLegacyInputKeyboard       = new Keyboard(FLegacyInputKeyboardSubject, true);
            FInputKeyboardSubscription = new Subscription <Keyboard, KeyNotification>(
                keyboard => keyboard.KeyNotifications,
                (keyboard, notification) =>
            {
                unchecked
                {
                    switch (notification.Kind)
                    {
                    case KeyNotificationKind.KeyDown:
                        InputSimulator.Keyboard.KeyDown((VirtualKeyCode)((KeyDownNotification)notification).KeyCode);
                        break;

                    case KeyNotificationKind.KeyPress:
                        InputSimulator.Keyboard.TextEntry(((KeyPressNotification)notification).KeyChar);
                        break;

                    case KeyNotificationKind.KeyUp:
                        InputSimulator.Keyboard.KeyUp((VirtualKeyCode)((KeyUpNotification)notification).KeyCode);
                        break;

                    default:
                        break;
                    }
                }
            }
                );
            FKeyboardOut[0] = new Keyboard(FKeyNotificationSubject, true);
            // Create a keyboard split node for us and connect our keyboard out to its keyboard in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyboardState" && n.Category == "System" && n.Version == "Split Legacy");

            FKeyboardSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Keyboard", c => FKeyboardOut);
            base.OnImportsSatisfied();
        }
示例#13
0
        protected override void Initialize(IObservable <WMEventArgs> windowMessages, IObservable <bool> disabled)
        {
            var mouseNotifications = windowMessages
                                     .Where(e => e.Message >= WM.MOUSEFIRST && e.Message <= WM.MOUSELAST)
                                     .Select <WMEventArgs, MouseNotification>(e =>
            {
                RECT cr;
                if (User32.GetClientRect(e.HWnd, out cr))
                {
                    var pos        = e.LParam.ToInt32();
                    var lParam     = e.LParam;
                    var wParam     = e.WParam;
                    var position   = new Point(lParam.LoWord(), lParam.HiWord());
                    var clientArea = new Size(cr.Width, cr.Height);

                    switch (e.Message)
                    {
                    case WM.MOUSEWHEEL:
                        unchecked
                        {
                            var wheel = wParam.HiWord();
                            return(new MouseWheelNotification(position, clientArea, wheel));
                        }

                    case WM.MOUSEMOVE:
                        return(new MouseMoveNotification(position, clientArea));

                    case WM.LBUTTONDOWN:
                    case WM.LBUTTONDBLCLK:
                        return(new MouseDownNotification(position, clientArea, MouseButtons.Left));

                    case WM.LBUTTONUP:
                        return(new MouseUpNotification(position, clientArea, MouseButtons.Left));

                    case WM.MBUTTONDOWN:
                    case WM.MBUTTONDBLCLK:
                        return(new MouseDownNotification(position, clientArea, MouseButtons.Middle));

                    case WM.MBUTTONUP:
                        return(new MouseUpNotification(position, clientArea, MouseButtons.Middle));

                    case WM.RBUTTONDOWN:
                    case WM.RBUTTONDBLCLK:
                        return(new MouseDownNotification(position, clientArea, MouseButtons.Right));

                    case WM.RBUTTONUP:
                        return(new MouseUpNotification(position, clientArea, MouseButtons.Right));

                    case WM.XBUTTONDOWN:
                    case WM.XBUTTONDBLCLK:
                        if ((wParam.HiWord() & 0x0001) > 0)
                        {
                            return(new MouseDownNotification(position, clientArea, MouseButtons.XButton1));
                        }
                        else
                        {
                            return(new MouseDownNotification(position, clientArea, MouseButtons.XButton2));
                        }

                    case WM.XBUTTONUP:
                        if ((wParam.HiWord() & 0x0001) > 0)
                        {
                            return(new MouseUpNotification(position, clientArea, MouseButtons.XButton1));
                        }
                        else
                        {
                            return(new MouseUpNotification(position, clientArea, MouseButtons.XButton2));
                        }
                    }
                }
                return(null);
            }
                                                                              )
                                     .OfType <MouseNotification>();

            FMouseOut[0] = new Mouse(mouseNotifications);

            // Create a mouse split node for us and connect our mouse out to its mouse in
            var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "MouseState" && n.Category == "System" && n.Version == "Split Legacy");

            FMouseSplitNode = FIOFactory.CreatePlugin(nodeInfo, c => c.IOAttribute.Name == "Mouse", c => FMouseOut);
        }
示例#14
0
        //create pins
        public override void OnImportsSatisfied()
        {
            base.OnImportsSatisfied();

            var tempSig = new TSignal();

            var t     = tempSig.GetType();
            var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            //Retrieve all FieldInfos
            var fields = t.GetFields(flags);

            foreach (var fi in fields)
            {
                if (typeof(SigParamBase).IsAssignableFrom(fi.FieldType))
                {
                    var param   = (SigParamBase)fi.GetValue(tempSig);
                    var valType = param.GetValueType();

                    if (!param.IsOutput)
                    {
                        var ia = new InputAttribute(param.Name);
                        ia.Order = param.PinOrder;
                        var spreadType = typeof(IDiffSpread <>).MakeGenericType(valType);

                        if (valType == typeof(double))
                        {
                            ia.DefaultValue = (double)param.GetDefaultValue();
                        }
                        else if (valType == typeof(float))
                        {
                            ia.DefaultValue = (float)param.GetDefaultValue();
                        }
                        else if (valType == typeof(int))
                        {
                            ia.DefaultValue = (int)param.GetDefaultValue();
                        }
                        else if (valType == typeof(long))
                        {
                            ia.DefaultValue = (long)param.GetDefaultValue();
                        }
                        else if (valType == typeof(float[]))
                        {
                            spreadType = typeof(IDiffSpread <>).MakeGenericType(typeof(ISpread <float>));
                        }
                        else if (valType == typeof(int[]))
                        {
                            spreadType = typeof(IDiffSpread <>).MakeGenericType(typeof(ISpread <int>));
                        }
                        else if (valType == typeof(double[]))
                        {
                            spreadType = typeof(IDiffSpread <>).MakeGenericType(typeof(ISpread <double>));
                        }
                        else if (typeof(Enum).IsAssignableFrom(valType))
                        {
                            ia.DefaultEnumEntry = param.GetDefaultValue().ToString();
                        }
                        else
                        {
                            if (param is SigParamBang)
                            {
                                ia.IsBang = true;
                            }
                        }

                        var inPin = (IDiffSpread)FIOFactory.CreateIO(spreadType, ia);
                        FInputPins[param.Name] = inPin;
                        FDiffInputs.Add(inPin);
                    }
                    else                 //output
                    {
                        var oa = new OutputAttribute(param.Name);
                        oa.Order = param.PinOrder;
                        var spreadType = typeof(ISpread <>).MakeGenericType(valType);

                        //array types need Spread<Spread<T>>
                        if (valType == typeof(float[]))
                        {
                            spreadType = typeof(ISpread <>).MakeGenericType(typeof(ISpread <float>));
                        }
                        else if (valType == typeof(int[]))
                        {
                            spreadType = typeof(ISpread <>).MakeGenericType(typeof(ISpread <int>));
                        }
                        else if (valType == typeof(double[]))
                        {
                            spreadType = typeof(ISpread <>).MakeGenericType(typeof(ISpread <double>));
                        }

                        var outPin = (ISpread)FIOFactory.CreateIO(spreadType, oa);
                        FOutputPins[param.Name] = outPin;
                    }
                }
            }

            tempSig.Dispose();
        }