public RawGenericInputReport(PresentationSource inputSource,
                 GenericEvent genericEvent, UIElement destTarget)
     : base(inputSource, genericEvent.Time)
 {
     InternalEvent = genericEvent;
     Target = destTarget;
 }
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.Left  , Meridian.Pins.GPIO6),
                new ButtonPad(this, Button.Right , Meridian.Pins.GPIO8),
                new ButtonPad(this, Button.Up    , Meridian.Pins.GPIO5),
                new ButtonPad(this, Button.Select, Meridian.Pins.GPIO7),
                new ButtonPad(this, Button.Down  , Meridian.Pins.GPIO9),
            };

            this.buttons = buttons;
        }
        /// <summary>
        /// Maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation.
        /// </summary>
        /// <param name="source"></param>
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            
            // Register the object as an input source with the input manager and 
            // get back an InputProviderSite object.  The InputProviderSite 
            // object forwards the input report to the input manager.  The input 
            // manager then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);

            // Create a delegate that refers to the InputProviderSite object's 
            // ReportInput method.
            callback = new DispatcherOperationCallback(delegate(object report)
                    {
                        InputReportArgs args = (InputReportArgs)report;
                        return site.ReportInput(args.Device, args.Report);
                    });
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Create a hardware provider.
            HardwareProvider hwProvider = new HardwareProvider();

            // Create the pins that are needed for the buttons.  Default their 
            // values for the emulator.
            Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0;
            Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1;
            Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2;
            Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3;
            Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4;

            // Use the hardware provider to get the pins.  If the left pin is 
            // not set, assume none of the pins are set and set the left pin 
            // back to the default emulator value.
            if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) ==
                Cpu.Pin.GPIO_NONE)
                pinLeft = Cpu.Pin.GPIO_Pin0;
            else
            {
                pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT);
                pinUp = hwProvider.GetButtonPins(Button.VK_UP);
                pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT);
                pinDown = hwProvider.GetButtonPins(Button.VK_DOWN);
            }

            // Allocate button pads and assign the (emulated) hardware pins as 
            // input from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons with the pins as discovered or set 
                // above.
                new ButtonPad(this, Button.VK_LEFT  , pinLeft  ),
                new ButtonPad(this, Button.VK_RIGHT , pinRight ),
                new ButtonPad(this, Button.VK_UP    , pinUp    ),
                new ButtonPad(this, Button.VK_SELECT, pinSelect),
                new ButtonPad(this, Button.VK_DOWN  , pinDown  ),
            };

            this.buttons = buttons;
        }
 public RawTouchInputReport(PresentationSource inputSource,
             DateTime timestamp, byte eventMessage, TouchInput[] touches, UIElement destTarget)
     : base(inputSource, timestamp)
 {
     EventMessage = eventMessage;
     Touches = touches;
     Target = destTarget;
 }
示例#5
0
        /// <summary>
        ///     Constructs an instance of the InputReport class.
        /// </summary>
        /// <param name="inputSource">
        ///     The type of input that is being reported.
        /// </param>
        /// <param name="timestamp">
        ///     The time when the input occured.
        /// </param>
        protected InputReport(PresentationSource inputSource, DateTime timestamp)
        {
            /* We need to allow a null presentation source for now, since the root input system doesn't have a presentationsource.
                        if (inputSource == null)
                            throw new ArgumentNullException("inputSource");
            */

            InputSource = inputSource;
            Timestamp = timestamp;
        }
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Create a hardware provider
            HardwareProvider hwProvider = new HardwareProvider();

            // Create the pins we will need for the buttons
            // Default their values for the emulator
            Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0;
            Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1;
            Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2;
            Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3;
            Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4;

            // Use the hardware provider to get the pins
            // If the left pin is not set then assume none of them are
            // and set the left pin back to the default emulator value
            if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE)
                pinLeft = Cpu.Pin.GPIO_Pin0;
            else
            {
                pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT);
                pinUp = hwProvider.GetButtonPins(Button.VK_UP);
                pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT);
                pinDown = hwProvider.GetButtonPins(Button.VK_DOWN);
            }

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as discovered or set above
                new ButtonPad(this, Button.VK_LEFT  , pinLeft),
                new ButtonPad(this, Button.VK_RIGHT , pinRight),
                new ButtonPad(this, Button.VK_UP    , pinUp),
                new ButtonPad(this, Button.VK_SELECT, pinSelect),
                new ButtonPad(this, Button.VK_DOWN  , pinDown),
            };

            this.buttons = buttons;
        }
        public GPIOButtonInputProvider(PresentationSource source, ButtonDefinition[] ButtonDefinitions)
        {
            this.RepeatDelay = 500;
            this.RepeatPeriod = 150;
            this.PresentationSource = source;
            this.InputSite = InputManager.CurrentInputManager.RegisterInputProvider(this);
            this.ReportInputFunc = new DispatcherOperationCallback( ReportInputCallback );

            this.Dispatcher = Microsoft.SPOT.Dispatcher.CurrentDispatcher;
            this.Buttons = new GpioButtonHandler[ButtonDefinitions.Length];
            for( int i = 0; i < ButtonDefinitions.Length; i++ )
            {
                ButtonDefinition btnDef = ButtonDefinitions[i];
                this.Buttons[i] = new GpioButtonHandler( this, btnDef);
            }
        }
        /// <summary>
        /// Creates new instance of input provider
        /// </summary>
        /// <param name="source">Presentation source</param>
        /// <param name="controller">TV Remote Receiver controller driver</param>
        /// <param name="address">Address of device. Use -1 for everything.</param>
        /// <param name="buttons">Command to WPF button maping</param>
        public TVRemoteInputProvider(PresentationSource source, TVRemoteReceiver controller, int address, TVRemoteButtonPad[] buttons)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            deviceAddress = address;
            this.buttons = buttons;

            ButtonAction = RawButtonActions.ButtonUp;

            controller.DataReceived += new TVRemoteReceiver.TVRemoteDataHandler(controller_DataReceived);
        }
        public GPIOButtonInputProvider(PresentationSource source)
        {
            _source   = source;
            _site     = InputManager.CurrentInputManager.RegisterInputProvider(this);
            _callback = new DispatcherOperationCallback(delegate(object report)
                    {
                        InputReportArgs args = (InputReportArgs)report;
                        return _site.ReportInput(args.Device, args.Report);
                    });
            Dispatcher = Dispatcher.CurrentDispatcher;

            ButtonPad[] buttons = new ButtonPad[]
            {
                new ButtonPad(this, Button.VK_MENU,   Pins.GPIO_PORT_A_3, Port.InterruptMode.InterruptEdgeBoth),
                new ButtonPad(this, Button.VK_SELECT, Pins.GPIO_PORT_A_8, Port.InterruptMode.InterruptEdgeBoth),
                new ButtonPad(this, Button.VK_LEFT,   Pins.GPIO_PORT_A_7, Port.InterruptMode.InterruptEdgeBoth),
                new ButtonPad(this, Button.VK_RIGHT,  Pins.GPIO_PORT_A_5, Port.InterruptMode.InterruptEdgeBoth),
                new ButtonPad(this, Button.VK_UP,     Pins.GPIO_PORT_A_4, Port.InterruptMode.InterruptEdgeBoth),
                new ButtonPad(this, Button.VK_DOWN,   Pins.GPIO_PORT_A_6, Port.InterruptMode.InterruptEdgeBoth),
                };

            _buttons = buttons;
        }
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input 
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.VK_LEFT  , (Cpu.Pin)86),
                new ButtonPad(this, Button.VK_RIGHT , (Cpu.Pin)87),
                new ButtonPad(this, Button.VK_UP    , (Cpu.Pin)88),
                new ButtonPad(this, Button.VK_SELECT, (Cpu.Pin)89),
                new ButtonPad(this, Button.VK_DOWN  , (Cpu.Pin)90),

                // For a hardware board that has predefined buttons,  can use the 
                // Microsoft.SPOT.Hardware.GetButtonPin to retrieve the GPIO pin number associate 
                // with button name
                //      new ButtonPad(this, Button.Left  , hwProvider.GetButtonPins(Button.Left)),
                //      new ButtonPad(this, Button.Right , hwProvider.GetButtonPins(Button.Right)),
                //      new ButtonPad(this, Button.Up    , hwProvider.GetButtonPins(Button.Up)),
                //      new ButtonPad(this, Button.Select, hwProvider.GetButtonPins(Button.Select)),
                //      new ButtonPad(this, Button.Down  , hwProvider.GetButtonPins(Button.Down)),
                
                
            };

            this.buttons = buttons;
        }
 /// <summary>
 ///     Constructs an instance of the RawKeyboardInputReport class.
 /// </summary>
 /// <param name="inputSource">
 ///     source of the input
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 public RawButtonInputReport(PresentationSource inputSource, DateTime timestamp, Button button, RawButtonActions actions)
     : base(inputSource, timestamp)
 {
     Button = button;
     Actions = actions;
 }
 /// <summary>
 ///     Constructs an instance of the RawKeyboardInputReport class.
 /// </summary>
 /// <param name="inputSource">
 ///     source of the input
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 public RawGenericInputReport(PresentationSource inputSource, GenericEvent genericEvent)
     : base(inputSource, genericEvent.Time)
 {
     InternalEvent = genericEvent;
     Target = null;
 }
 /// <summary>
 ///     Constructs an instance of the RawKeyboardInputReport class.
 /// </summary>
 /// <param name="inputSource">
 ///     source of the input
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 public RawTouchInputReport(PresentationSource inputSource, DateTime timestamp, byte eventMessage, TouchInput[] touches)
     : base(inputSource, timestamp)
 {
     EventMessage = eventMessage;
     Touches = touches;
 }
示例#14
0
 /// <summary>
 ///     Constructs an instance of the ButtonEventArgs class.
 /// </summary>
 /// <param name="buttonDevice">
 ///     The button device associated with this event.
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured. (machine time)
 /// </param>
 /// <param name="button">
 ///     The button referenced by the event.
 /// </param>
 public ButtonEventArgs(ButtonDevice buttonDevice, PresentationSource inputSource, DateTime timestamp, Button button)
     : base(buttonDevice, timestamp)
 {
     InputSource = inputSource;
     Button = button;
 }