/// <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 Program() { SonyReceiver sonyRemote = new SonyReceiver(Meridian.Pins.GPIO1); TVRemoteButtonPad[] buttons = new TVRemoteButtonPad[] { new TVRemoteButtonPad(0, Button.VK_1), new TVRemoteButtonPad(1, Button.VK_2), new TVRemoteButtonPad(2, Button.VK_3), new TVRemoteButtonPad(3, Button.VK_4), new TVRemoteButtonPad(4, Button.VK_5), new TVRemoteButtonPad(5, Button.VK_6), new TVRemoteButtonPad(6, Button.VK_7), new TVRemoteButtonPad(7, Button.VK_8), new TVRemoteButtonPad(8, Button.VK_9), new TVRemoteButtonPad(9, Button.VK_0), new TVRemoteButtonPad(16, Button.VK_NEXT), new TVRemoteButtonPad(17, Button.VK_PRIOR), new TVRemoteButtonPad(18, Button.VK_VOLUME_UP), new TVRemoteButtonPad(19, Button.VK_VOLUME_DOWN), }; TVRemoteInputProvider inputProvider = new TVRemoteInputProvider(null, sonyRemote, (int)SonyReceiver.Devices.TV, buttons); }