|
|
|
@ -9,6 +9,7 @@ import mightypork.gamecore.input.events.KeyEvent; |
|
|
|
|
import mightypork.gamecore.input.events.MouseButtonEvent; |
|
|
|
|
import mightypork.gamecore.input.events.MouseMotionEvent; |
|
|
|
|
import mightypork.utils.interfaces.Updateable; |
|
|
|
|
import mightypork.utils.logging.Log; |
|
|
|
|
import mightypork.utils.math.constraints.vect.Vect; |
|
|
|
|
import mightypork.utils.math.constraints.vect.var.VectVar; |
|
|
|
|
|
|
|
|
@ -51,15 +52,25 @@ public class LwjglInputModule extends InputModule implements Updateable { |
|
|
|
|
protected void initDevices() |
|
|
|
|
{ |
|
|
|
|
try { |
|
|
|
|
Mouse.create(); |
|
|
|
|
Keyboard.create(); |
|
|
|
|
tryCreate(); |
|
|
|
|
|
|
|
|
|
Keyboard.enableRepeatEvents(false); |
|
|
|
|
|
|
|
|
|
} catch (final LWJGLException e) { |
|
|
|
|
throw new RuntimeException("Failed to initialize input devices.", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void tryCreate() throws LWJGLException |
|
|
|
|
{ |
|
|
|
|
if (Display.isCreated()) { |
|
|
|
|
Mouse.create(); |
|
|
|
|
Keyboard.create(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initKeyCodes() |
|
|
|
|
{ |
|
|
|
@ -206,8 +217,16 @@ public class LwjglInputModule extends InputModule implements Updateable { |
|
|
|
|
{ |
|
|
|
|
// was destroyed or not initialized
|
|
|
|
|
if (!Display.isCreated()) return; |
|
|
|
|
if (!Mouse.isCreated()) return; |
|
|
|
|
if (!Keyboard.isCreated()) return; |
|
|
|
|
|
|
|
|
|
if (!Mouse.isCreated() || !Keyboard.isCreated()) { |
|
|
|
|
try { |
|
|
|
|
tryCreate(); |
|
|
|
|
} catch (final LWJGLException e) { |
|
|
|
|
Log.e(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!Mouse.isCreated() || !Keyboard.isCreated()) return; |
|
|
|
|
|
|
|
|
|
Display.processMessages(); |
|
|
|
|
|
|
|
|
|