支援遊戲控制器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以讓玩家使用遊戲控制器,提升遊戲的使用者體驗。Android 架構提供 API,用於偵測及處理遊戲控制器的使用者輸入內容。
本指南說明如何在不同的 Android API 級別 (API 級別 9 以上) 的遊戲控制器中一致地運作遊戲,以及如何在應用程式中同時支援多個控制器,改善玩家的遊戲體驗。
注意:如要開發遊戲或編寫 C++ 應用程式,請改用 Android Game Development Kit (AGDK) 提供的遊戲控制器程式庫。
課程
-
處理控制器動作
-
瞭解如何透過遊戲控制器上的常用輸入元素處理使用者輸入內容,包括方向鍵 (D-Pad) 按鈕、遊戲手把按鈕和搖桿。
-
在各種 Android 版本上支援控制器
- 瞭解如何讓遊戲控制器在搭載不同 Android 版本的裝置上運作相同。
-
支援多個遊戲控制器
- 瞭解如何偵測及使用多個同時連線的遊戲控制器。
-
其他遊戲控制器功能
- 瞭解如何使用其他控制器功能。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Support game controllers\n\nYou can enhance the user experience in your game by letting\nplayers use game controllers. The Android framework\nprovides APIs for detecting and processing user input from game\ncontrollers.\n\n\nThis guide shows how to make your game work consistently with game\ncontrollers across different Android API levels (API level 9 and up) and\nhow to enhance the gaming experience for players by supporting multiple\ncontrollers simultaneously in your app.\n\n**Note:**\nIf you are developing games or writing a C++ app, use the\n[Game Controller Library](/games/sdk/game-controller)\nthat is part of the\n[Android Game Development Kit (AGDK)](/games/agdk) instead.\n\nLessons\n-------\n\n\n**[Handle controller actions](/develop/ui/views/touch-and-input/game-controllers/controller-input)**\n:\n Learn how to handle user input from common input elements on game\n controllers, including directional pad (D-pad) buttons, gamepad buttons,\n and joysticks.\n\n\n**[Support controllers across Android versions](/develop/ui/views/touch-and-input/game-controllers/compatibility)**\n:\n Learn how to make game controllers behave the same across devices\n running different versions of Android.\n\n\n**[Support multiple game controllers](/develop/ui/views/touch-and-input/game-controllers/multiple-controllers)**\n:\n Learn how to detect and use multiple game controllers that are\n simultaneously connected.\n\n\n**[Additional game controller features](/develop/ui/views/touch-and-input/game-controllers/controller-features)**\n:\n Learn how to use additional controller features."]]