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

程式碼説明Reference

開發板預設模擬帶有 8 向 d-pad、6 軸和 16 個按鈕的遊戲控制器。 如何定義接收值取決於主機設備,並且設備之間的按鈕順序可能不同。 此外,主機設備上的某些軸或按鈕可能會被禁用。