BLE - HID 游戏控制器

材料准备

  • AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1

  • 支援 BLE 的设备 [Windows / Linux / MacOS / Android

范例说明

介绍

在此范例中,RTL8722 开发板用来模拟使用 BLE 连接的 HID 游戏控制器。

流程

Open the example, “Files” “Examples” “AmebaBLE” BLEHIDGamepad.

../../../../_images/1.png

Upload the code and press the reset button once the upload is finished. Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. On your host device, go to the Bluetooth settings menu, scan, and connect to the board. You should ensure that the connection process is completed before proceeding. On Windows, ensure that any driver installation is finished, and the board shows up in the Bluetooth menu under the “Mouse, keyboard & pen” category.

../../../../_images/2.png

在 Android 上,确保为开发板启用“Input device”。

../../../../_images/3.png

After the Bluetooth connection process is completed, the board is ready to send gamepad input to the host device. Connect digital pin 8 to 3.3V to start sending input, and connect to GND to stop. To view the input, open a browser window and go to Gamepad Tester. The connected gamepad device should show up here, and some of the buttons and axes should show changing values.

../../../../_images/4.png

在 Windows 上,也可以通过“Control Panel” -> “Devices and Printers” -> “AMEBA_BLE_HID” -> “Game Controller Settings” -> “Properties”来查看游戏控制器。

../../../../_images/5.png ../../../../_images/6.png

在 Android 上,游戏控制器测试应用程序,例如 https://play.google.com/store/apps/details?id=com.chimera.saturday.evogamepadtester 也可以来查看资讯。

../../../../_images/7.png

程式码说明

开发板预设模拟带有 8 向 d-pad、6 轴和 16 个按钮的游戏控制器。如何定义接收值取决于主机设备,并且设备之间的按钮顺序可能不同。此外,主机设备上的某些轴或按钮可能会被禁用。