void Interrupt(uint data1, uint data2, TimeSpan time)
            {
                RawButtonActions action = (data2 != 0) ? RawButtonActions.ButtonUp : RawButtonActions.ButtonDown;

                RawButtonInputReport report = new RawButtonInputReport(sink.source, time, button, action);

                // Queue the button press to the input provider site.
                sink.Dispatcher.BeginInvoke(sink.callback, report);
            }
            void Interrupt( uint data1, uint data2, DateTime time )
            {
                // queue the button press to the input provider site.
                RawButtonActions action = (data2 != 0) ? 
                    RawButtonActions.ButtonUp : RawButtonActions.ButtonDown;

                RawButtonInputReport report = 
                    new RawButtonInputReport(_sink._source, time, _button, action);

                _sink.Dispatcher.BeginInvoke(_sink._callback, new InputReportArgs(_buttonDevice, report));
            }
Example #3
0
        private RawButtonInputReport ExtractRawButtonInputReport(NotifyInputEventArgs e, RoutedEvent Event)
        {
            RawButtonInputReport buttonInput = null;

            InputReportEventArgs input = e.StagingItem.Input as InputReportEventArgs;

            if (input != null)
            {
                if (input.Report is RawButtonInputReport && input.RoutedEvent == Event)
                {
                    buttonInput = (RawButtonInputReport)input.Report;
                }
            }

            return(buttonInput);
        }
            void Interrupt(uint data1, uint data2, DateTime time)
#endif
            {
                RawButtonActions action = (data2 != 0) ? 
                    RawButtonActions.ButtonUp : RawButtonActions.ButtonDown;

                RawButtonInputReport report = 
                    new RawButtonInputReport(sink.source, time, button, action);

                // Queue the button press to the input provider site.
#if MF_FRAMEWORK_VERSION_V3_0
                sink.Dispatcher.BeginInvoke(sink.callback, report);
#else
                sink.Dispatcher.BeginInvoke(sink.callback, new InputReportArgs(buttonDevice, report));
#endif
            }
            void Interrupt(Cpu.Pin port, bool state, TimeSpan time)
            {
                RawButtonActions action = state ? RawButtonActions.ButtonUp : RawButtonActions.ButtonDown;

                RawButtonInputReport report = new RawButtonInputReport(sink.source, time, button, action);

                // Queue the button press to the input provider site.
                sink.Dispatcher.BeginInvoke(sink.callback, report);
            }
Example #6
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // PreviewButtonDown --> ButtonDown
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonDown = (ButtonEventArgs)e.StagingItem.Input;
                    ButtonEventArgs buttonDown        = new ButtonEventArgs(this, previewButtonDown.InputSource, previewButtonDown.Timestamp, previewButtonDown.Button);

                    buttonDown._isRepeat   = previewButtonDown.IsRepeat;
                    buttonDown.RoutedEvent = Buttons.ButtonDownEvent;

                    e.PushInput(buttonDown, e.StagingItem);
                }
            }

            // PreviewButtonUp --> ButtonUp
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonUp = (ButtonEventArgs)e.StagingItem.Input;

                    ButtonEventArgs buttonUp = new ButtonEventArgs(this, previewButtonUp.InputSource, previewButtonUp.Timestamp, previewButtonUp.Button);

                    buttonUp.RoutedEvent = Buttons.ButtonUpEvent;

                    e.PushInput(buttonUp, e.StagingItem);
                }
            }

            RawButtonInputReport buttonInput = ExtractRawButtonInputReport(e, InputManager.InputReportEvent);

            if (buttonInput != null)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    // In general, this is where we promote the non-redundant
                    // reported actions to our premier events.
                    RawButtonActions actions = GetNonRedundantActions(e);

                    // Raw --> PreviewButtonDown
                    if ((actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonDown = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonDown.RoutedEvent = Buttons.PreviewButtonDownEvent;
                            e.PushInput(previewButtonDown, e.StagingItem);
                        }
                    }

                    // Raw --> PreviewButtonUp
                    if ((actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonUp = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonUp.RoutedEvent = Buttons.PreviewButtonUpEvent;
                            e.PushInput(previewButtonUp, e.StagingItem);
                        }
                    }
                }

                // Deactivate
                if ((buttonInput.Actions & RawButtonActions.Deactivate) == RawButtonActions.Deactivate)
                {
                    if (_isActive)
                    {
                        _isActive = false;

                        // Even if handled, a button deactivate results in a lost focus.
                        ChangeFocus(null, e.StagingItem.Input.Timestamp);
                    }
                }
            }
        }
Example #7
0
        private void PreNotifyInput(object sender, NotifyInputEventArgs e)
        {
            RawButtonInputReport buttonInput = ExtractRawButtonInputReport(e, InputManager.PreviewInputReportEvent);

            if (buttonInput != null)
            {
                CheckForDisconnectedFocus();

                /*
                 *
                 * REFACTOR --
                 *
                 * the keyboard device is only active per app domain basis -- so like if your app domain doesn't have
                 * focus your keyboard device is not going to give you the real state of the keyboard.
                 *
                 * When it gets focus, it needs to know about this somehow.   We could use this keyboard action
                 * type stuff to do so.  Though this design really seem to be influenced a lot from living in
                 * the windows world.
                 *
                 * Essentially the input stack is being used like a message pump to say, hey dude you can
                 * use the keyboard now -- it's not real input, it's more or less a message.
                 *
                 * It could be interesting for elements to know about this -- since I think
                 * they will probalby still have focus (or do they get a Got and Lost Focus when the keyboard activates -- I don't think so,
                 * we need to know what we were focused on when the window gets focus again.
                 *
                 * So maybe elements want to stop some animation or something when input focus moves away from the activesource, and
                 * start them again later.  Could be interesting.
                 */

                if ((buttonInput.Actions & RawButtonActions.Activate) == RawButtonActions.Activate)
                {
                    //System.Console.WriteLine("Initializing the button state.");

#if TRACK_BUTTON_STATE
                    // Clear out our key state storage.
                    for (int i = 0; i < _buttonState.Length; i++)
                    {
                        _buttonState[i] = 0;
                    }
#endif
                    // we are now active.
                    // we should track which source is active so we don't confuse deactivations.
                    _isActive = true;
                }

                // Generally, we need to check against redundant actions.
                // We never prevet the raw event from going through, but we
                // will only generate the high-level events for non-redundant
                // actions.  We store the set of non-redundant actions in
                // the dictionary of this event.

                // If the input is reporting a button down, the action is never
                // considered redundant.
                if ((buttonInput.Actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown)
                {
                    RawButtonActions actions = GetNonRedundantActions(e);
                    actions |= RawButtonActions.ButtonDown;
                    e.StagingItem.SetData(_tagNonRedundantActions, actions);

                    // Pass along the button that was pressed, and update our state.
                    e.StagingItem.SetData(_tagButton, buttonInput.Button);

#if TRACK_BUTTON_STATE
                    ButtonState buttonState = GetButtonState(buttonInput.Button);

                    if ((buttonState & ButtonState.Down) == ButtonState.Down)
                    {
                        buttonState = ButtonState.Down | ButtonState.Held;
                    }
                    else
                    {
                        buttonState |= ButtonState.Down;
                    }

                    SetButtonState(buttonInput.Button, buttonState);
#endif

                    // Tell the InputManager that the MostRecentDevice is us.
                    if (_inputManager != null)
                    {
                        _inputManager.MostRecentInputDevice = (InputDevice)this;
                    }
                }

                // need to detect redundant ups.
                if ((buttonInput.Actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp)
                {
                    RawButtonActions actions = GetNonRedundantActions(e);
                    actions |= RawButtonActions.ButtonUp;
                    e.StagingItem.SetData(_tagNonRedundantActions, actions);

                    // Pass along the button that was pressed, and update our state.
                    e.StagingItem.SetData(_tagButton, buttonInput.Button);

#if TRACK_BUTTON_STATE
                    ButtonState buttonState = GetButtonState(buttonInput.Button);

                    if ((buttonState & ButtonState.Down) == ButtonState.Down)
                    {
                        buttonState &= (~ButtonState.Down) & (ButtonState.Down | ButtonState.Held);
                    }
                    else
                    {
                        buttonState |= ButtonState.Held;
                    }

                    SetButtonState(buttonInput.Button, buttonState);
#endif

                    // Tell the InputManager that the MostRecentDevice is us.
                    if (_inputManager != null)
                    {
                        _inputManager.MostRecentInputDevice = (InputDevice)this;
                    }
                }
            }

            // On ButtonDown, we might need to set the Repeat flag

            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent)
            {
                CheckForDisconnectedFocus();

                ButtonEventArgs args = (ButtonEventArgs)e.StagingItem.Input;

                // Is this the same as the previous button?
                if (_previousButton == args.Button)
                {
                    // Yes, this is a repeat (we got the buttondown for it twice, with no ButtonUp in between)
                    // what about chording?
                    args._isRepeat = true;
                }

                // Otherwise, keep this button to check against next time.
                else
                {
                    _previousButton = args.Button;
                    args._isRepeat  = false;
                }
            }

            // On ButtonUp, we clear Repeat flag
            else if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent)
            {
                CheckForDisconnectedFocus();

                ButtonEventArgs args = (ButtonEventArgs)e.StagingItem.Input;
                args._isRepeat = false;

                // Clear _previousButton, so that down/up/down/up doesn't look like a repeat
                _previousButton = Button.None;
            }
        }
 void ReportInput( DateTime TimeStamp, Button TheButton, RawButtonActions Actions )
 {
     RawButtonInputReport report = new RawButtonInputReport( this.PresentationSource, TimeStamp, TheButton, Actions );
     this.Dispatcher.BeginInvoke( this.ReportInputFunc, new object[ ] { report } );
 }
 /// <summary>
 /// Data received handler.
 /// Fires WPF button pressed evet according to command received
 /// </summary>
 private void controller_DataReceived(TVRemoteReceiver sender, int command, int address)
 {
     for (int i = 0; i < buttons.Length; i++)
     {
         if (command == buttons[i].Command && (deviceAddress == -1 || deviceAddress == address))
         {
             RawButtonInputReport report = new RawButtonInputReport(source, new TimeSpan(DateTime.Now.Ticks), buttons[i].Button, ButtonAction);
             // Queue the button press to the input provider site.
             Dispatcher.BeginInvoke(callback, report);
             break;
         }
     }
 }