支持游戏控制器
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以允许玩家使用游戏控制器来提升游戏中的用户体验。Android 框架提供了用于检测和处理来自游戏控制器的用户输入的 API。
本指南介绍了如何让您的游戏在各种 Android API 级别(API 级别 9 及更高级别)上以一致的方式与游戏控制器配合使用,以及如何在应用中同时支持多个控制器,从而改善玩家的游戏体验。
注意:如果您要开发游戏或编写 C++ 应用,请改用 Android Game Development Kit (AGDK) 中的 Game Controller 库。
课程
-
处理控制器操作
-
学习如何处理来自游戏控制器上常见输入元素(包括方向键按钮、游戏手柄按钮和操纵杆)的用户输入。
-
支持各种 Android 版本中的控制器
-
了解如何使游戏控制器在搭载不同 Android 版本的各种设备上以相同的方式运行。
-
支持多个游戏控制器
-
了解如何检测和使用同时连接的多个游戏控制器。
-
其他游戏控制器功能
-
了解如何使用其他控制器功能。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):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."]]