How would I get the mouse position and keyboard events? I chose JInput because someone said that it can detect keypresses/keyreleases straight from the hardware, and AWT only detects keypresses/keyreleases when the AWT window is the one on top…
I’ve tried some code…
public class ControllerHandler {
private static Controller mouse = null;
private static Controller keyboard = null;
public static void main(String args[]) {
Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
for (Controller controller : ca) {
if (controller.getType() == Type.MOUSE) {
mouse = controller;
} else if (controller.getType() == Type.KEYBOARD) {
keyboard = controller;
}
}
if (mouse == null || keyboard == null) {
throw new NullPointerException("You either don't have a keyboard or mouse..");
}
while (true) {
mouse.poll();
EventQueue queue = mouse.getEventQueue();
Event event = new Event();
while(queue.getNextEvent(event)) {
}
}
}
}
Yeah… help is appreciated! ;D
Also, is it possible to use JInput to call AWT events? so if Jinput detects an event it can call keyPressed/keyReleased/etc on AWT?