gpt4 book ai didi

javascript - 有人可以解释我如何在 Electron 中使用NodeRT(Windows.Gaming.Input)模块吗?

转载 作者:行者123 更新时间:2023-12-03 12:37:20 27 4
gpt4 key购买 nike

我正在尝试从此模块导入Gamepad类,但总是收到错误消息“无效的参数,找不到合适的构造函数”
这是我的代码:

const { Gamepad } = require('@nodert-win10-20h1/windows.gaming.input')

const gamepad = new Gamepad()
如果我尝试console.log 游戏板我在控制台中得到了这个:
Gamepad [Function: Gamepad] {
castFrom: [Function: castFrom],
fromGameController: [Function: fromGameController],
gamepads: Windows::Foundation::Collections:IVectorView {
__winRtInstance__: true
}
}
其中Gamepad是一个功能。
也许有人可以给我链接到该模块的文档,或者向我解释如何使用它。

最佳答案

Here,我可以读到:

The API exposed by this module is (almost) the same as the API that islisted in:http://msdn.microsoft.com/en-us/library/windows/apps/Windows.Gaming.Input.aspx


在API中,您可以阅读:

Instances of the Gamepad class cannot be created directly; instead,instances of the Gamepad class are retrieved through theGamepad.Gamepads property listing all connected gamepads or throughthe Gamepad.GamepadAdded event.


所以我认为用途应该是(非常非常粗略):
const { Gamepad } = require('@nodert-win10-20h1/windows.gaming.input');
const firstGamePad = GamePad.gamepads.IndexOf(0); //retrieve the first GP found
let currentInput = firstGamePad.GetCurrentReading();// or something like this, just check firstGamePad properties

关于javascript - 有人可以解释我如何在 Electron 中使用NodeRT(Windows.Gaming.Input)模块吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66101303/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com