如何模拟鼠标加速?
我编写了 iPhone - Mac、客户端 - 服务器应用程序,允许通过触摸板使用鼠标。
现在,在发送的每个数据包上,我将光标移动特定数量的像素(现在为 10px)。 这是不准确的。当我将灵敏度更改为 1px 时,速度会变慢。
我想知道如何增强可用性并模拟鼠标加速。
有什么想法吗?
I've written iPhone - Mac, Client - Server app that allows to use mouse via touchpad.
Now on every packet sent I move cursor by pecific amount of pixels (now 10px).
It isn't accurate. When i change sensitivity to 1px it's to slow.
I am wondering how to enhance usability and simulate mouse acceleration.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议执行以下过程:
在 IPHONE 上:
x
和y
方向上移动的距离,我们将其命名为dx和<代码>dy。
dr = sqrt(dx^2+dy^2)
。v_new = a * v + b * v^2
(以a=1
和开头b=0
没有加速,然后试验最佳值)dr_new = v_new * dt
。x
/y
方向的新距离:dx_new = dx * dr_new / dr
和dy_new = dy * dr_new / dr
。dx_new
和dy_new
发送到 Mac。在 MAC 上:
x
/y
dx_new 和dy_new
像素> 方向。注意:这可能会抖动很多,如果抖动太大,您可以尝试将步骤 (3) 后的速度与之前两到三个测量的速度进行平均。
I suggest the following procedure:
ON THE IPHONE:
x
andy
direction, let's name thisdx
anddy
.dr = sqrt(dx^2+dy^2)
.v = dr/dt
.v_new = a * v + b * v^2
(start witha=1
andb=0
for no acceleration, and then experiment for optimal values)dr_new = v_new * dt
.x
/y
direction:dx_new = dx * dr_new / dr
anddy_new = dy * dr_new / dr
.dx_new
anddy_new
to the Mac.ON THE MAC:
dx_new
anddy_new
pixels inx
/y
direction.NOTE: This might jitter a lot, you can try averaging the velocity after step (3) with the previous two or three measured velocities if it jitters to much.