简体   繁体   English

是否可以使用 Gamepad API 在 javascript 中注册自定义游戏手柄?

[英]Is it possible to register a custom gamepad in javascript with the Gamepad API?

Quick background快速背景

I am currently working on a VR application with A-frame to showcase VR hardware.我目前正在开发一个带有 A-frame 的 VR 应用程序来展示 VR 硬件。 We use custom controllers that connects through websocket/bluetooth and would like to make them compatible with the tracked-controls .我们使用通过 websocket/bluetooth 连接的自定义控制器,并希望使它们与tracked-controls兼容。 Those A-Frame components use the Gamepad API to update model positionning and orientation and are compatible with other components that simulate hands, etc.这些 A-Frame 组件使用 Gamepad API 来更新模型定位和方向,并与模拟手等的其他组件兼容。

Why register the gamepad using javascript?为什么要使用 javascript 注册游戏手柄?

The tracked-controls use the gamepad api to update themselves so being able to put our own gamepad in the navigator.getGamepads list and updating the data of the gamepad would be perfect.跟踪控件使用游戏手柄 api 来更新自己,因此能够将我们自己的游戏手柄放在 navigator.getGamepads 列表中并更新游戏手柄的数据将是完美的。 However, the current controllers are constantly changing and having a browser specific implementation like the vive is impossible.然而,当前的控制器在不断变化,像 vive 这样的浏览器特定实现是不可能的。

Is it possible to register a custom gamepad in javascript with the Gamepad API?是否可以使用 Gamepad API 在 javascript 中注册自定义游戏手柄?

It's not possible to add entries to navigator.getGamepads() .无法向navigator.getGamepads()添加条目。 Your custom controllers could potentially emulate a well-known controller using a project like this , but your mileage with this approach may vary and be OS-specific.您的自定义控制器可能效仿使用像一个项目一个众所周知的控制器,但这种方法您的里程可能有所不同,是操作系统相关的。

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

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