Cleaned up Mouse and Keyboard now that buffering and translation are always enabled

This commit is contained in:
Elias Naur 2005-01-18 16:42:31 +00:00
parent 250a87767f
commit f4180a214d
11 changed files with 22 additions and 159 deletions

View file

@ -247,9 +247,6 @@ public class Keyboard {
*/
private static IntBuffer readBuffer;
/** True if translation is enabled */
private static boolean translationEnabled;
/** The current keyboard character being examined */
private static char eventCharacter;
@ -293,8 +290,8 @@ public class Keyboard {
return;
Display.getImplementation().createKeyboard();
created = true;
enableBuffer();
enableTranslation();
readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE*BUFFER_SIZE);
readBuffer.limit(0);
}
/**
@ -337,8 +334,7 @@ public class Keyboard {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can poll the device");
Display.getImplementation().pollKeyboard(keyDownBuffer);
if (readBuffer != null)
read();
read();
}
private static void read() {
@ -348,30 +344,6 @@ public class Keyboard {
readBuffer.flip();
}
/**
* Enable keyboard translation. Must be called after the keyboard is created,
* and keyboard buffering must be enabled.
*/
private static void enableTranslation() throws LWJGLException {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can read events");
if (readBuffer == null)
throw new IllegalStateException("Event buffering must be enabled before you can read events");
Display.getImplementation().enableTranslation();
translationEnabled = true;
}
/**
* Enable keyboard buffering. Must be called after the keyboard is created.
*/
private static void enableBuffer() throws LWJGLException {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can enable buffering");
readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE*BUFFER_SIZE);
readBuffer.limit(0);
Display.getImplementation().enableKeyboardBuffer();
}
/**
* Checks to see if a key is down.
* @param key Keycode to check
@ -440,8 +412,6 @@ public class Keyboard {
public static boolean next() {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can read events");
if (readBuffer == null)
throw new IllegalStateException("Event buffering must be enabled before you can read events");
if (readBuffer.hasRemaining()) {
eventKey = readBuffer.get() & 0xFF;