Я пытаюсь напечатать положения мыши с помощью Jinput:Jinput - Получить мышь Место
public static void main(String[] args) {
input = new InputManager();
while (true) {
for (Mouse mouse : input.getMice()) {
mouse.poll();
System.out.println("Mouse X: " + mouse.getX().getPollData());
System.out.println("Mouse Y: " + mouse.getY().getPollData());
System.out.println("---------");
}
try {
Thread.sleep(100);
} catch (Exception e) {
// DO NOTHING < BAD
}
}
}
Вот мой InputManager, который при инициализации сканирования для всех устройств ввода и разделяет всех мышей в отдельный список:
public class InputManager {
public ArrayList<Mouse> mice;
public InputManager() {
mice = new ArrayList<Mouse>();
Controller[] inputs = ControllerEnvironment.getDefaultEnvironment()
.getControllers();
for (int i = 0; i < inputs.length; i++) {
Mouse mouse;
if (inputs[i].getType() == Controller.Type.MOUSE) {
mouse = (Mouse) inputs[i];
mice.add(mouse);
}
}
System.out.println("Discovered " + mice.size() + " mice.");
}
public ArrayList<Mouse> getMice() {
return mice;
}
}
Информация, которая печатается, всегда равна 0 для x и y. Я запускаю это в Windows 10, это вызывает какие-либо проблемы? Как получить данные мыши от мыши с помощью Jinput?