简体   繁体   English

在xbox游戏手柄上收听事件-UWP

[英]Listen to events on xbox gamepad - UWP

What is the correct way to listen on keypress events from the Xbox gamepad? 在Xbox游戏手柄上侦听按键事件的正确方法是什么?

Buzzwords: UWP, HTML/CSS/JS, React, Typescript 流行词:UWP,HTML / CSS / JS,React,Typescript

You could first listen to the GamepadAdded event. 您可以先听GamepadAdded事件。 You would get the Gamepad class object by the event args when the the GamepadAdded event is fired. 当触发GamepadAdded事件时,您将通过事件args获得Gamepad类对象。

Then, you could call its GetCurrentReading() method to get which button is pressed. 然后,您可以调用其GetCurrentReading()方法来获取按下了哪个按钮。

没有尝试使用Xavier的方法,我们这样做:

const systemMediaControls = Windows.Media.SystemMediaTransportControls.getForCurrentView(); systemMediaControls.addEventListener('buttonpressed', eventHandler)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM