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

标签 javascript node.js windows electron

我正在尝试从此模块导入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 is listed 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 the Gamepad.Gamepads property listing all connected gamepads or through the 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/

相关文章:

javascript - 数据表中的多列过滤器( Bootstrap )

php - 网站连接到本地 MySQL 服务器

windows - 如何在 Windows 上以编程方式添加菜单项分隔符?

javascript - 无法弄清楚 WEB API 如何调用 URLS

javascript - 如何触发jquery输入文件?

javascript - 如何在 android softkeyboard 上获取 Next 按钮代替 phonegap 中的 Go Button

javascript - 嵌套foreach/forloops,循环遍历JSON提取值

node.js - 如何防止 Gulp 输出缓冲

node.js - Websocket (node.js) 连接限制,客户端在达到 400-450 个连接后断开连接

windows - echo -e 在 Windows 中等效?