mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-18 12:54:10 +00:00
added isStateKeySet for checking LOCK keys
This commit is contained in:
parent
caed320677
commit
61305f4107
4 changed files with 45 additions and 1 deletions
|
|
@ -397,6 +397,18 @@ public class Keyboard {
|
|||
assert created : "The keyboard has not been created.";
|
||||
return keyDownBuffer.get(key) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether one of the state keys are "active"
|
||||
*
|
||||
* @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ)
|
||||
* @return true if state key is on
|
||||
*/
|
||||
public static boolean isStateKeySet(int key) {
|
||||
assert created : "The keyboard has not been created.";
|
||||
return nisStateKeySet(key);
|
||||
}
|
||||
private static native boolean nisStateKeySet(int key);
|
||||
|
||||
/**
|
||||
* Gets a key's name
|
||||
|
|
|
|||
|
|
@ -133,7 +133,6 @@ public class KeyboardTest {
|
|||
Keyboard.read();
|
||||
|
||||
int count = Keyboard.getNumKeyboardEvents();
|
||||
System.out.println("Read " + count + " events");
|
||||
while(Keyboard.next()) {
|
||||
System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.key));
|
||||
if(Keyboard.key == Keyboard.KEY_ESCAPE) {
|
||||
|
|
@ -160,6 +159,17 @@ public class KeyboardTest {
|
|||
position.y -= 1;
|
||||
}
|
||||
|
||||
if(Keyboard.isStateKeySet(Keyboard.KEY_SCROLL)) {
|
||||
System.out.println("SCROLL lock on");
|
||||
}
|
||||
|
||||
if(Keyboard.isStateKeySet(Keyboard.KEY_CAPITAL)) {
|
||||
System.out.println("CAPS lock on");
|
||||
}
|
||||
|
||||
if(Keyboard.isStateKeySet(Keyboard.KEY_NUMLOCK)) {
|
||||
System.out.println("NUM lock on");
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
System.out.println();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue