Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 监视蓝牙外围设备命令_C#_Bluetooth_Iot_Windowsiot - Fatal编程技术网

C# 监视蓝牙外围设备命令

C# 监视蓝牙外围设备命令,c#,bluetooth,iot,windowsiot,C#,Bluetooth,Iot,Windowsiot,我正在Raspberry Pi 3上开发一个小小的Windows IOT应用程序,我购买了这个蓝牙设备: 我希望能够监听蓝牙设备命令并在我的UWP中处理它们。我找到了一个解决方案,尽管我无法获得所有功能,尤其是Gamepad模式 解决方案是通过以下方式收听输入的设备密钥: public MainPage() { Window.Current.Dispatcher.AcceleratorKeyActivated += Dispatcher_Acceler

我正在Raspberry Pi 3上开发一个小小的Windows IOT应用程序,我购买了这个蓝牙设备:


我希望能够监听蓝牙设备命令并在我的UWP中处理它们。

我找到了一个解决方案,尽管我无法获得所有功能,尤其是Gamepad模式

解决方案是通过以下方式收听输入的设备密钥:

public MainPage()
        {

            Window.Current.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;

            this.InitializeComponent();
        }

        private void Dispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender, Windows.UI.Core.AcceleratorKeyEventArgs args)
        {
            var eT = args.EventType;
            if (CoreAcceleratorKeyEventType.KeyUp == eT)
            {
                var key = args.VirtualKey.ToString();
                switch (key)
                {
                    case "Enter" :
                        //Do something
                        break;
                    case "255" :
                        //Do something
                        break;
                    default:
                        break;
                }
            }
        }
我发现分配了整数的密钥很难比较,因为似乎没有为它们注册虚拟密钥。因此,我将虚拟键转换为字符串以进行比较

我发现不同设备的整数值不同,因此在另一种设置中,“255”可能是“175”。我希望这不会因创业公司而异


总而言之,这是一个可以接受的解决方案。我确实觉得为设备编写自己的驱动程序可能是最好的情况,但在这个项目中我没有时间这样做,也没有意愿现在学习p/invoke和HID对象的细微之处

我找到了一个解决方案,尽管我无法获得所有功能,尤其是Gamepad模式

解决方案是通过以下方式收听输入的设备密钥:

public MainPage()
        {

            Window.Current.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;

            this.InitializeComponent();
        }

        private void Dispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender, Windows.UI.Core.AcceleratorKeyEventArgs args)
        {
            var eT = args.EventType;
            if (CoreAcceleratorKeyEventType.KeyUp == eT)
            {
                var key = args.VirtualKey.ToString();
                switch (key)
                {
                    case "Enter" :
                        //Do something
                        break;
                    case "255" :
                        //Do something
                        break;
                    default:
                        break;
                }
            }
        }
我发现分配了整数的密钥很难比较,因为似乎没有为它们注册虚拟密钥。因此,我将虚拟键转换为字符串以进行比较

我发现不同设备的整数值不同,因此在另一种设置中,“255”可能是“175”。我希望这不会因创业公司而异


总而言之,这是一个可以接受的解决方案。我确实觉得为设备编写自己的驱动程序可能是最好的情况,但在这个项目中我没有时间这样做,也没有意愿现在学习p/invoke和HID对象的细微之处

你做了什么?你遇到了什么问题?你做了什么?你遇到了什么问题?