在Dell Inspiron 15 3000上,触摸板没有任何物理左/右按钮。相反,它是一个压力敏感的巨型触摸板。我假设它根据触控板上的手位置检测到右/左咔嗒声。
在我的LWJGL应用程序中,我使用Mouse.isButtonDown(0)
检测鼠标按键单击。这在带有物理按钮的鼠标的计算机上工作正常,但在没有物理按钮的触摸板上不起作用。 Mouse.getButtonCount()
返回 0 。
如果用户使用没有物理按钮的触控板,是否有人在检测是否按下了鼠标按钮方面是否有任何成功?
答案 0 :(得分:0)
我认为,而不是使用
org.lwjgl.input.Mouse
这门课可能就是你要找的:
org.lwjgl.input.Controllers
http://legacy.lwjgl.org/javadoc/org/lwjgl/input/Controllers.html
我不完全确定,因为我只有一个鼠标,没有办法用触摸板测试它。
答案 1 :(得分:0)
对于那些将来发现这一点的人,我确实找到了解决办法:
如果没有物理按钮,则不能使用Mouse.isButtonDown()
方法。相反,您将不得不阅读事件缓冲区。为此,我编写了自己的帮助类:
public class Mouse{
private static boolean button_left = false, button_right = false;
public static boolean isButtonDown(int button){
if(button == 0) return button_left;
if(button == 1) return button_right;
return false;
}
public static void update(){
while(org.lwjgl.input.Mouse.next()){
if(org.lwjgl.input.Mouse.getEventButton() == 0) button_left = org.lwjgl.input.Mouse.getEventButtonState();
if(org.lwjgl.input.Mouse.getEventButton() == 1) button_right = org.lwjgl.input.Mouse.getEventButtonState();
}
}
}
每个tick都调用update()
方法,因此我可以使用Mouse.isButtonDown(button)
获取按钮状态。