透過集合功能整理內容
你可以依據偏好儲存及分類內容。
遊戲控制器程式庫 (又稱為 Paddleboat) 可協助您針對遊戲控制器提供完善的支援。程式庫提供以下功能:
- 用於偵測控制器連線和中斷連線的回呼
- 控制器裝置資訊,包括按鈕樣式和版面配置
- 控管器輸入資料,根據現代化的雙貼圖控制器設計進行標準化
- 支援控制器上的額外功能,包括震動、光線、動作軸資料和電池狀態
- 能夠讀取虛擬和實體滑鼠裝置的輸入資料
- 能夠指定特定裝置的自訂控制器對應資料
相容性需求
遊戲控制器程式庫的最低相容性需求如下:
整合
遊戲控制器程式庫採用兩種格式發布:作為使用以 Gradle 為基礎的建構系統 (包括 Android Studio) 的遊戲的 Jetpack 程式庫,以及作為使用自訂建構系統的遊戲的離散檔案。
如需整合遊戲控制器程式庫的範例,請參閱遊戲範例存放區。
Jetpack 程式庫
Jetpack Android Games 頁面提供整合操作說明,將遊戲控制器程式庫依附元件新增至遊戲的 build.gradle
檔案。
遊戲控制器的 Jetpack 程式庫版本是根據 C++ 執行階段共用資料庫建構的靜態程式庫。
更新 build.gradle
檔案後,您必須在遊戲的主要 CMakeLists.txt
檔案中加入以下這行文字:
find_package(games-controller REQUIRED CONFIG)
您也需要將下列條目加入遊戲主要共用資料庫的 target_link_libraries
指令中的程式庫清單:
games-controller::paddleboat_static
離散檔案
Android Game Development Kit 的 .zip
封存檔發布包含遊戲控制器程式庫的標頭和程式庫檔案。專案中必須包含下列檔案,才能使用遊戲控制器程式庫:
- 包含遊戲控制器程式庫中 Dalvik 位元組代碼部分的
classes.jar
檔案。這個檔案位於 libs/classes.jar
paddleboat.h
介面標頭檔案。這個檔案位於 include/paddleboat/paddleboat.h
libpaddleboat.so
共用資料庫檔案或 libpaddleboat-static.a
靜態資料庫檔案。這些檔案位於 libs
目錄下的建構設定子目錄中。
根 libs
目錄底下的建構設定子目錄將依據以下條件分類:
- ABI 架構
- 最低 Android API 級別
- Android NDK 版本
- C++ 執行階段程式庫版本
- 發布版本或偵錯版本設定
舉例來說,arm64-v8a_API16_NDK21_cpp_shared_Release
子目錄包含以下項目的程式庫檔案:
- ARM 64 位元 ABI
- 最低 API 級別:16
- 依據 NDK 21 版建構
- 以 C++ 執行階段的共用資料庫版本為基礎
- 版本建構設定
libpaddleboat_static.a
檔案位於子目錄中。libpaddleboat.so
檔案位於子目錄的 lib/paddleboat/
中。
後續步驟
請參閱下列指南,繼續將遊戲控制器程式庫整合至遊戲中:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-26 (世界標準時間)。
[null,null,["上次更新時間:2025-08-26 (世界標準時間)。"],[],[],null,["Game Controller Library\nPart of [Android Game Development Kit](/games/agdk/overview).\n\nThe Game Controller library, also known as Paddleboat, helps you implement robust support\nfor game controllers. The library provides the following:\n\n- Callbacks for detecting controller connections and disconnections\n- Controller device information, including button style and layout\n- Controller input data, standardized around modern dual-stick controller designs\n- Extended features on supported controllers, including vibration, lights, motion axis data, and battery status\n- Ability to read input from virtual and physical mouse devices\n- Ability to specify custom controller mapping data for particular devices\n\nCompatibility requirements\n\nThe Game Controller library has minimum compatibility requirements of:\n\n- Android 4.4 (API level 19) or higher\n- [Android NDK](/ndk) version 21 or higher\n\nIntegrate\n\nThe Game Controller library is distributed in two formats: As a [Jetpack](/jetpack)\nlibrary for games using a Gradle-based build system (including Android Studio),\nand as discrete files for games using custom build systems.\n\nFor a sample that integrates the Game Controller library, see the\n[games-samples repository](https://github.com/android/games-samples).\n\nJetpack library\n\nThe [Jetpack Android Games](/jetpack/androidx/releases/games) page has\nintegration instructions to add the Game Controller library dependency to your\ngame's `build.gradle` file.\n\nThe Jetpack library release of Game Controller is a static\nlibrary built against the C++ runtime shared library.\n\nAfter updating your `build.gradle` file, you will need to add the following\nline to your game's main `CMakeLists.txt` file: \n\n find_package(games-controller REQUIRED CONFIG)\n\nYou will also need to add the following entry to the list of libraries\nin the `target_link_libraries` command of your game's main shared\nlibrary: \n\n games-controller::paddleboat_static\n\nDiscrete files\n\nThe `.zip` archive distribution of the Android Game Development Kit includes\nheader and library files for the Game Controller library. The following files\nmust be included in your project to use the Game Controller library:\n\n- The `classes.jar` file containing the Dalvik bytecode portions of the Game Controller library. This file is located at `libs/classes.jar`\n- The `paddleboat.h` interface header file. This file is located at `include/paddleboat/paddleboat.h`\n- Either the `libpaddleboat.so` shared library file or the `libpaddleboat-static.a` static library file. These files are found in the build configuration subdirectories under the `libs` directory.\n\nThe build configuration subdirectories under the root `libs` directory are\ncategorized by:\n\n- ABI architecture\n- Minimum Android API level\n- Android NDK version\n- C++ runtime library version\n- Release or debug build configuration\n\nAs an example, the `arm64-v8a_API16_NDK21_cpp_shared_Release` subdirectory\ncontains library files for:\n\n- ARM 64-bit ABI\n- Minimum API level 16\n- Built against NDK version 21\n- Built against shared library version of C++ runtime\n- Release build configuration\n\nThe `libpaddleboat_static.a` file is located directly in the subdirectory. The\n`libpaddleboat.so` file is located at `lib/paddleboat/` within the subdirectory.\n\nNext steps\n\nSee the following guides to continue integrating the Game Controller library into your game:\n\n- [Use the Game Controller library](/games/sdk/game-controller/controller)\n- [Add mouse support](/games/sdk/game-controller/mouse)\n- [Add custom controller device mappings](/games/sdk/game-controller/custom-mapping)"]]