遊戲的輸入Input for games

本節說明有哪些不同類型的輸入裝置可用於 Windows 10 和 Xbox One 上的通用 Windows 平台 (UWP) 遊戲、示範基本用法,以及建議在遊戲中有效輸入程式設計所需的模式與技巧。This section describes the different kinds of input devices that can be used in Universal Windows Platform (UWP) games on Windows 10 and Xbox One, demonstrates their basic usage, and recommends patterns and techniques for effective input programming in games.

注意 現有及可用於 UWP 遊戲的其他類型輸入裝置,例如自訂輸入裝置,可能風格特異,或可能為遊戲專用。Note Other kinds of input devices exist and are available to be used in UWP games such as custom input devices that might be genre-specific or game-specific. 本節將不討論這類裝置及其程式設計。Such devices and their programming are not discussed in this section. 如需有關用於協助自訂輸入裝置的詳細資訊,請參閱 Windows.Gaming.Input.Custom 命名空間。For information on the interfaces used to facilitate custom input devices, see the Windows.Gaming.Input.Custom namespace.

遊戲輸入裝置Gaming input devices

在 UWP 遊戲和 Windows 10 及 Xbox One 的應用程式中,遊戲輸入裝置受到 Windows.Gaming.Input 命名空間的支援。Game input devices are supported in UWP games and apps for Windows 10 and Xbox One by the Windows.Gaming.Input namespace.

遊戲台Gamepads

遊戲台是 Xbox One 的標準輸入裝置,而且是不愛用鍵盤和滑鼠的 Windows 遊戲玩家的共通選擇。Gamepads are the standard input device on Xbox One and a common choice for Windows gamers when they don't favor a keyboard and mouse. 其提供各種數位及類比控制,幾乎所有類型的遊戲皆適用,同時還透過內嵌震動馬達提供了觸感反應。They provide a variety of digital and analog controls making them suitable for almost any kind of game and also provide tactile feedback through embedded vibration motors.

如需如何在 UWP 遊戲中使用遊戲台的詳細資訊,請參閱遊戲台與震動For information on how to use gamepads in your UWP game, see Gamepad and vibration.

機台搖桿Arcade sticks

機台搖桿是重新產生直立式機台風格的重要全數位輸入裝置,而且是面對面格鬥和其他機台樣式遊戲的完美輸入裝置。Arcade sticks are all-digital input devices valued for reproducing the feel of stand-up arcade machines and are the perfect input device for head-to-head-fighting or other arcade-style games.

如需如何在 UWP 遊戲中使用遊戲台的詳細資訊,請參閱機台搖桿For information on how to use arcade sticks in your UWP game, see Arcade stick.

賽車方向盤Racing wheels

賽車方向盤是與真正賽車的駕駛艙感覺類似的輸入裝置,對於以汽車或卡車為主的任何賽車遊戲而言,都是完美的輸入裝置。Racing wheels are input devices that resemble the feel of a real racecar cockpit and are the perfect input device for any racing game that features cars or trucks. 許多賽車方向盤配備可配備真正的力回饋,也就是說,它們可以在控制軸上施加實際力量 (像是方向盤),而不只是簡單的震動。Many racing wheels are equipped with true force feedback--that is, they can apply actual forces on an axis of control such as the steering wheel--not just simple vibration.

如需如何在 UWP 遊戲中使用賽車方向盤的詳細資訊,請參閱賽車方向盤與力回饋For information on how to use racing wheels in your UWP game, see Racing Wheel and force feedback.

飛行桿Flight sticks

飛行桿是遊戲輸入裝置,可重現飛機或太空船駕駛艙中的飛行桿風格。Flight sticks are gaming input devices that reproduce the feel of flight sticks that would be found in a plane or spaceship's cockpit. 它們是快速且準確控制飛行的完美輸入裝置。They're the perfect input device for quick and accurate control of flight.

如需如何在 UWP 遊戲中使用飛行桿的詳細資訊,請參閱飛行桿For more information on how to use flight sticks in your UWP game, see Flight stick.

原始遊戲控制器Raw game controllers

原始遊戲控制器是遊戲控制器的一般呈現,具有在許多不同類型的常見遊戲控制器上找到的輸入。A raw game controller is a generic representation of a game controller, with inputs found on many different kinds of common game controllers. 這些輸入作為未命名的按鈕、切換裝置和軸的簡單陣列而公開。These inputs are exposed as simple arrays of unnamed buttons, switches, and axes. 您可以使用原始遊戲控制器,讓客戶建立自訂輸入的對應,不論使用哪種類型的控制器。Using a raw game controller, you can allow customers to create custom input mappings no matter what type of controller they're using.

如需如何在 UWP 遊戲中使用原始遊戲控制器的詳細資訊,請參閱原始遊戲控制器For more information on how to use raw game controllers in your UWP game, see Raw game controller.

UI 瀏覽控制器UI navigation controllers

UI 瀏覽控制器是邏輯輸入裝置,存在目的是為 UI 瀏覽命令提供通用詞彙,促使在各種不同遊戲和實體輸入裝置間能夠一致的使用者經驗。UI Navigation controllers are a logical input device that exists to provide a common vocabulary for UI navigation commands that promotes a consistent user experience across different games and physical input devices. 遊戲的使用者介面應使用 UINavigationController 介面,而不是裝置特定的介面。A game's user interface should use the UINavigationController interfaces instead of device-specific interfaces.

如需如何在 UWP 遊戲中使用 UI 瀏覽控制器的詳細資訊,請參閱 UI 瀏覽控制器For information on how to use UI navigation controllers in your UWP game, see UI navigation controller.

車頭碗組Headsets

耳機是音訊擷取和播放裝置,當透過其輸入裝置連線時,就會和特定使用者產生關聯。Headsets are audio capture and playback devices that are associated with a specific user when connected through their input device. 線上遊戲普遍用它進行語音交談,同時也可用於加強沉浸的感受,或提供線上和離線遊戲功能。They're commonly used by online games for voice chat but can also be used to enhance immersion or provide gameplay features in both online and offline games.

如需如何在 UWP 遊戲中使用耳機的詳細資訊,請參閱耳機For information on how to use headsets in your UWP game, see Headset

使用者Users

每一種輸入裝置及其連線的耳機,可與特定使用者產生關聯,以將使用者的身分識別連結到他們的遊戲。Each input device and its connected headset can be associated with a specific user to link their identity to their gameplay. 使用者身分識別也是從實體輸入裝置輸入的相互關聯方式,如此才能從其邏輯 UI 瀏覽控制器輸入。The user identity is also the means by which input from a physical input device is correlated to input from its logical UI navigation controller.

如需如何管理使用者及其輸入裝置的詳細資訊,請參閱追蹤使用者及其裝置For information on how to manage users and their input devices, see Tracking users and their devices.

另請參閱See Also