Hello,
I am trying to controller connection listener but there is a primary problem when disconnect the connected gamepad.
In this case Logger spamming like this;
Jan 12, 2018 9:04:44 PM net.java.games.input.ControllerEnvironment log
INFO: Failed to poll device: Failed to poll device (8007000c)
Jan 12, 2018 9:04:44 PM net.java.games.input.ControllerEnvironment log
INFO: Failed to poll device: Failed to poll device (8007000c)
Jan 12, 2018 9:04:44 PM net.java.games.input.ControllerEnvironment log
INFO: Failed to poll device: Failed to poll device (8007000c)
I searched the spamming reason in source codes and i think i found it.
com.jme3.input.lwjgl.JInputJoyInput.update() method contains
if( !c.poll() )
continue;
if we must to look at poll method. Here;
net.java.games.input.AbstractController.poll()
public synchronized boolean poll() {
Component[] components = getComponents();
try {
pollDevice();
for (int i = 0; i < components.length; i++) {
AbstractComponent component = (AbstractComponent)components[i];
if (component.isRelative()) {
component.setPollData(0);
} else {
// Let the component poll itself lazily
component.resetHasPolled();
}
}
while (getNextDeviceEvent(event)) {
AbstractComponent component = (AbstractComponent)event.getComponent();
float value = event.getValue();
if (component.isRelative()) {
if (value == 0)
continue;
component.setPollData(component.getPollData() + value);
} else {
if (value == component.getEventValue())
continue;
component.setEventValue(value);
}
if (!event_queue.isFull())
event_queue.add(event);
}
return true;
} catch (IOException e) {
ControllerEnvironment.logln("Failed to poll device: " + e.getMessage());
return false;
}
}
Why this notification being more than once? is not enough a notification that the connection is broken? Why does it have to spamming console trough the whole game? By the way if re-connect the gamepad, notifications are not stopping.
thanks for reading.