Added virtual Mouse input
This commit is contained in:
parent
61d48be579
commit
867733cdfc
|
@ -32,16 +32,11 @@ public class NewInputTest {
|
|||
//TODO implement window close requests
|
||||
while(true) {
|
||||
GLFW.glfwPollEvents();
|
||||
window.update();
|
||||
window.beginFrame();
|
||||
window.handleInput();
|
||||
window.finishFrame();
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try { Thread.sleep(100); }
|
||||
catch(InterruptedException e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,16 @@ public class Mouse extends AbstractDevice<MouseData, MouseTask> {
|
|||
return data == null ? Vec2i.ZERO : data.scroll();
|
||||
}
|
||||
|
||||
public void setPosition(long windowId, int x, int y) {
|
||||
MouseData data = get(windowId);
|
||||
if(data == null || (data.position.x() == x && data.position.y() == y)) return;
|
||||
data.position.set(x, y);
|
||||
GLFW.glfwSetCursorPos(windowId, x, y);
|
||||
}
|
||||
|
||||
public void pressButton(long window, int button, boolean press) { click(window, button, press ? GLFW.GLFW_PRESS : GLFW.GLFW_RELEASE, 0); }
|
||||
public void scrollMouse(long window, int xScroll, int yScroll) { scroll(window, xScroll, yScroll); }
|
||||
|
||||
public interface MouseTask {
|
||||
public void process(Mouse mouse);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,8 @@ public class Window {
|
|||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
public void beginFrame() {
|
||||
GLFW.glfwMakeContextCurrent(id);
|
||||
if(flags.isFlagSet(WINDOW_CHANGE)) updateViewport();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue