mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-07 23:44:06 +00:00
Added Keyboard.getEventNanoseconds() and Mouse.getEventNanoseconds()
This commit is contained in:
parent
e28bde351b
commit
4e68c787b3
17 changed files with 166 additions and 115 deletions
|
|
@ -56,7 +56,7 @@ import org.lwjgl.opengl.Display;
|
|||
*/
|
||||
public class Keyboard {
|
||||
/** Internal use - event size in bytes */
|
||||
public static final int EVENT_SIZE = 4 + 1 + 4;
|
||||
public static final int EVENT_SIZE = 4 + 1 + 4 + 8;
|
||||
|
||||
/**
|
||||
* The special character meaning that no
|
||||
|
|
@ -256,6 +256,9 @@ public class Keyboard {
|
|||
|
||||
/** The current state of the key being examined in the event queue */
|
||||
private static boolean eventState;
|
||||
|
||||
/** The current event time */
|
||||
private static long eventNanos;
|
||||
|
||||
/** One time initialization */
|
||||
private static boolean initialized;
|
||||
|
|
@ -426,6 +429,7 @@ public class Keyboard {
|
|||
eventKey = readBuffer.getInt() & 0xFF;
|
||||
eventState = readBuffer.get() != 0;
|
||||
eventCharacter = readBuffer.getInt();
|
||||
eventNanos = readBuffer.getLong();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -466,4 +470,15 @@ public class Keyboard {
|
|||
public static boolean getEventKeyState() {
|
||||
return eventState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time in nanoseconds of the current event.
|
||||
* Only useful for relative comparisons with other
|
||||
* Keyboard events, as the absolute time has no defined
|
||||
* origin.
|
||||
* @return The time in nanoseconds of the current event
|
||||
*/
|
||||
public static long getEventNanoseconds() {
|
||||
return eventNanos;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue