找到你要的答案

Q:Is there a way to get full 2D mouse precision with JavaScript

Q:有没有办法用JavaScript得到完整的2D鼠标精度

High performance 2D Mice these days have 1000Hz sampling rate and 10000+ DPI. Inferring mouse input by checking what pixel the pointer is on isn't receiving the maximum precision of these 2D Mice. Is there a way that JavaScript can tap into the full precision?

While it wouldn't be practical for JavaScript itself to collect all 1000 samples every second, the browser could collect them all. Then when JavaScript queries, say every 16ms, the browser could give it the average of the last 16 samples. Like GamePad API it could give axis data directly without having to infer.

Why? WebGL games and simulations could really take advantage of it.

高性能2D小鼠这几天有1000Hz采样率和10000 dpi。通过检查指针是什么像素来推断鼠标输入,并没有得到这些2D鼠标的最大精度。有没有一种方式,可以充分发挥精度呢?

而不实用的JavaScript来收集所有的1000个样本的每一秒,浏览器可以收集他们所有。当JavaScript查询,说每16ms,浏览器可以给它的最后16个样品的平均。像游戏手柄API可以使轴的数据而不必直接推断。

为什么?WebGL游戏和模拟真的可以利用它。

answer1: 回答1:

I have at least a partial answer. Apparently you can with pointer lock http://www.html5rocks.com/en/tutorials/pointerlock/intro/ "Get access to raw mouse data including relative mouse movements" The Quake3 map link has a good demonstration http://media.tojicode.com/q3bsp/

However is it also possible to get raw mouse data without having to perform pointer lock? For cases where you want to go in and out of the window constantly, though I suppose it's not a big deal to press escape to unlock the pointer.

UPDATE: http://www.w3.org/TR/pointerlock/#high-resolution-deltas-high-frequency-updates I'm not sure about update frequency, though this article hasn't been updated recently. While JavaScript may only sample at say every 16ms, it should be able to obtain an average of the last 16 samples from a 1000hz mouse. As I find out more details I'll post it here.

I have at least a partial answer. Apparently you can with pointer lock http://www.html5rocks.com/en/tutorials/pointerlock/intro/ "Get access to raw mouse data including relative mouse movements" The Quake3 map link has a good demonstration http://media.tojicode.com/q3bsp/

然而,它也可以得到RAW鼠标数据,而不必执行指针锁?如果你想不断进出窗口的话,我想按一下逃生键来解锁指针并不是什么大不了的事情。

UPDATE: http://www.w3.org/TR/pointerlock/#high-resolution-deltas-high-frequency-updates I'm not sure about update frequency, though this article hasn't been updated recently. While JavaScript may only sample at say every 16ms, it should be able to obtain an average of the last 16 samples from a 1000hz mouse. As I find out more details I'll post it here.

javascript