当前位置: 首页>>代码示例>>Java>>正文


Java Mouse.getButtonCount方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:20,代码来源:Keys.java

示例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();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:41,代码来源:MinecraftGuiProxy.java

示例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;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:8,代码来源:Keys.java

示例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;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:8,代码来源:Keys.java


注:本文中的org.lwjgl.input.Mouse.getButtonCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。