标准且可靠的 GLUT 鼠标报告
我正在尝试在我的 OpenGL 应用程序中使用 GLUT (freeglut),并且我需要为鼠标滚轮事件注册一些回调。我设法挖掘出一个相当未记录的函数:
但是手册页和 API 条目对于这个函数来说,两者都声明了相同的事情:
注意:由于缺乏相关信息 鼠标,这是不可能的 在 X 上正确实现这一点 时间。使用此功能会限制 您的应用程序的可移植性。 (这 该功能在 X 上确实有效,但不行 可靠。)鼓励您使用 标准、可靠的鼠标按钮 报告,而不是车轮事件。
很公平,但是我如何使用这个标准的、可靠的鼠标报告呢?我怎么知道哪个是标准?我是否只使用 glutMouseFunc() 并分别使用 4 和 5 等按钮值作为向上和向下滚动值,假设 1、2 和 3 是左、中、右按钮?这是可靠的方法吗?
额外问题:“xev”工具似乎为我的按钮报告了不同的值。我的鼠标按钮用 xev 从 1 到 5 编号,但 glut 报告按钮从 0 到 4,即减一。这常见吗?
I'm trying to use GLUT (freeglut) in my OpenGL application, and I need to register some callbacks for mouse wheel events. I managed to dig out a fairly undocumented function:
But the man page and the API entry for this function both state the same thing:
Note: Due to lack of information about
the mouse, it is impossible to
implement this correctly on X at this
time. Use of this function limits the
portability of your application. (This
feature does work on X, just not
reliably.) You are encouraged to use
the standard, reliable mouse-button
reporting, rather than wheel events.
Fair enough, but how do I use this standard, reliable mouse-reporting? And how do I know which is the standard? Do I just use glutMouseFunc() and use button values like 4 and 5 for the scroll up and down values respectively, say if 1, 2 and 3 are the left, middle and right buttons? Is this the reliable method?
Bonus question: it seems the `xev' tool is reporting different values for my buttons. My mouse buttons are numbered from 1 to 5 with xev, but glut is reporting buttons from 0 to 4, i.e. an off-by-one. Is this common?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我可能会重新审视我自己的问题,因为我已经很久没有问过这个问题了,但没有得到任何答复。
更彻底地阅读上述文档,据我了解,我的猜测确实是真的。
我的猜测:
我还没有测试过它,但是从文档中的以下引用中,我认为这确实是他们的意思。
I thought I might revisit my own question since it has been a long time since I asked it without any replies.
Reading yet more thoroughly at aforementioned documentation, from what I understand it seems that my guess was indeed true.
My guess:
I haven't tested it yet, but from the following quote from the documentation, I gather that this is indeed what they meant.