// 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;
        }
        // This class maps GPIOs to Buttons processable by nanoFramework.UI.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;


            GpioPin pinLeft   = Gpio.OpenPin(1);
            GpioPin pinRight  = Gpio.OpenPin(2);
            GpioPin pinUp     = Gpio.OpenPin(3);
            GpioPin pinSelect = Gpio.OpenPin(4);
            GpioPin pinDown   = Gpio.OpenPin(5);


            // 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;
        }
        // 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;
        }
        // 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;
        }
Example #5
0
        /// <summary>
        /// Maps GPIOs to Buttons that can be processed by
        /// Microsoft.SPOT.Presentation.
        /// </summary>
        /// <param name="source"></param>
        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 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.
            GpioPin pinLeft   = Gpio.OpenPin(1);
            GpioPin pinRight  = Gpio.OpenPin(2);
            GpioPin pinUp     = Gpio.OpenPin(3);
            GpioPin pinSelect = Gpio.OpenPin(4);
            GpioPin pinDown   = Gpio.OpenPin(5);


            // 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 void InitializeForEventSource()
 {
     if (Application._inputManager != null)
     {
         return;
     }
     Application._inputManager      = InputManager.CurrentInputManager;
     this._inputProviderSite        = Application._inputManager.RegisterInputProvider((object)this);
     Application._reportInputMethod = (DispatcherOperationCallback)(o =>
     {
         InputReportArgs inputReportArgs = (InputReportArgs)o;
         return((object)this._inputProviderSite.ReportInput(inputReportArgs.Device, inputReportArgs.Report));
     });
 }
Example #7
0
        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>
        /// Maps GPIOs to Buttons that can be processed by
        /// nanoFramework.Presentation.
        /// </summary>
        /// <param name="source"></param>
        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 DispatcherOperationCallback(delegate(object report)
            {
                InputReportArgs args = (InputReportArgs)report;
                return(site.ReportInput(args.Device, args.Report));
            });

            Dispatcher = Dispatcher.CurrentDispatcher;

            this.buttons = new ArrayList();
        }
        public TouchSimulatedButtonInputProvider(PresentationSource presentationSource)
        {
            this.presentationSource = presentationSource;
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);

            this.dispatcher   = Dispatcher.CurrentDispatcher;
            this.buttonDevice = InputManager.CurrentInputManager.ButtonDevice;

            TouchScreen touchScreen = new TouchScreen(new TouchScreen.ActiveRectangle[] {
                new TouchScreen.ActiveRectangle(0, SystemMetrics.ScreenHeight / 3, (2 * SystemMetrics.ScreenWidth) / 3, SystemMetrics.ScreenHeight / 3, Button.VK_SELECT),
                new TouchScreen.ActiveRectangle((2 * SystemMetrics.ScreenWidth) / 3, SystemMetrics.ScreenHeight / 3, SystemMetrics.ScreenWidth / 3, SystemMetrics.ScreenHeight / 3, Button.VK_RIGHT),
                new TouchScreen.ActiveRectangle(0, 0, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight / 3, Button.VK_UP),
                new TouchScreen.ActiveRectangle(0, (2 * SystemMetrics.ScreenHeight) / 3, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight / 3, Button.VK_DOWN),
            });

            Touch.Initialize(touchScreen);
            TouchCollectorConfiguration.CollectionMethod = CollectionMethod.Native;
            TouchCollectorConfiguration.CollectionMode   = CollectionMode.InkAndGesture;
            //TouchCollectorConfiguration.SamplingFrequency = 20000;
            //TouchCollectorConfiguration.TouchMoveFrequency = 5;
            touchScreen.OnTouchUp   += new TouchScreenEventHandler(this.TouchScreen_OnTouchUp);
            touchScreen.OnTouchDown += new TouchScreenEventHandler(this.TouchScreen_OnTouchDown);
        }
        /// <summary>
        /// Maps GPIOs to Buttons that can be processed by
        /// Microsoft.SPOT.Presentation.
        /// </summary>
        /// <param name="source"></param>
        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 DispatcherOperationCallback(delegate(object report)
            {
#if MF_FRAMEWORK_VERSION_V3_0
                return(site.ReportInput((InputReport)report));
#else
                InputReportArgs args = (InputReportArgs)report;
                return(site.ReportInput(args.Device, args.Report));
#endif
            });
            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 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;
        }