如何检查 Xbox 系列控制器 "share" 按钮是否被按下?

How to check if Xbox series controller "share" button is pressed?

新的 Xbox 游戏手柄有一个新的“分享”按钮,我找不到检查它是否被按下的方法。 有可能吗?

是的,Xbox 无线控制器型号 1914(又名“Xbox Series X|S 控制器”)将“共享”按钮作为控制器数据报告最后一个字节的第一位发送。通过蓝牙 HID,该按钮使用消费者使用页面中的记录使用情况。

大多数平台游戏手柄 API 不支持共享按钮。这包括 XInput and Windows.Gaming.Input on Windows and joydev on Linux. Also on Linux, the xpad module (the driver for USB-connected Xbox controllers) doesn't support the Share button over USB. You'd need to install xpad-neo, which maps it to the KEY_RECORD input event code. (This is the same event code that the Consumer Record HID usage is normally mapped to.) macOS supposedly supports the Share button through the Game Controller framework but I haven't seen this working yet. Recent versions of Android include a keylayout file 将按钮映射到 MEDIA_RECORD。