本文整理汇总了Java中org.lwjgl.input.Mouse.getButtonCount方法的典型用法代码示例。如果您正苦于以下问题:Java Mouse.getButtonCount方法的具体用法?Java Mouse.getButtonCount怎么用?Java Mouse.getButtonCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.input.Mouse
的用法示例。
在下文中一共展示了Mouse.getButtonCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flip
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void flip() {
boolean[] tmp;
tmp = keysPrev;
keysPrev = keysDown;
keysDown = tmp;
for (int i = 1; i < keysDown.length; ++i) {
keysDown[i] = Keyboard.isKeyDown(i);
}
tmp = mousePrev;
mousePrev = mouseDown;
mouseDown = tmp;
for (int i = 0; i < mouseDown.length && i < Mouse.getButtonCount(); ++i) {
mouseDown[i] = Mouse.isButtonDown(i);
}
}
示例2: handleMouseInput
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
public void handleMouseInput() throws IOException {
int mouseCode = Mouse.getEventButton();
if(mouseCode < 0 || mouseCode >= Mouse.getButtonCount()) return; // only allow number of buttons supported by mouse (for mouse event, 0 is not an unknown button)
InputEntry entry = inputs.computeIfAbsent(Keyboard.KEYBOARD_SIZE + 1 + mouseCode, i -> new InputEntry(InputEntry.MOUSE, mouseCode));
boolean down = Mouse.getEventButtonState();
long currentTimeMS = System.currentTimeMillis();
GuiMouseEvent.Type type;
if(entry.getTicks() < 0) { // initially pressed
if(!down) return; // stop executing if key hasnt been initially pressed AND the key is being released (double release event)
type = GuiMouseEvent.Type.PRESSED;
entry.setTimePressed(currentTimeMS); // update last click time
} else {
type = down ? GuiMouseEvent.Type.DOWN : GuiMouseEvent.Type.RELEASED;
}
// update ticks
entry.incrementTicks();
int[] mpos = getMousePos();
element.onMouseEvent(new GuiMouseEvent(
type,
mouseCode,
mpos[0], mpos[1],
Mouse.getEventDWheel(),
entry.getTime(),
currentTimeMS - entry.getTimePressed())
);
if(type == GuiMouseEvent.Type.RELEASED) {
entry.setTime(entry.getTimePressed());
entry.setTimePressed(-1);
entry.resetTicks(); // reset ticks after event
}
super.handleMouseInput();
}
示例3: getKeyDown
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private int getKeyDown() {
for (int i = 1; i < keysDown.length; ++i)
if (keysDown[i]) return i;
for (int i = 0; i < mouseDown.length && i < Mouse.getButtonCount(); ++i)
if (mouseDown[i]) return i | KeyHelper.MOUSE;
return Keyboard.KEY_NONE;
}
示例4: getKeyPressed
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private int getKeyPressed() {
for (int i = 1; i < keysDown.length; ++i)
if (keysDown[i] && !keysPrev[i]) return i;
for (int i = 0; i < mouseDown.length && i < Mouse.getButtonCount(); ++i)
if (mouseDown[i] && !mousePrev[i]) return i | KeyHelper.MOUSE;
return Keyboard.KEY_NONE;
}