Fixed GetAsyncKeyState usage. We read the MSB, not the LSB.

This commit is contained in:
Ioannis Tsakpinis 2012-11-19 18:49:34 +02:00
parent 1cfdd27184
commit f57c236373
1 changed files with 5 additions and 1 deletions

View File

@ -154,6 +154,10 @@ final class WindowsKeyboard {
return (state & 1) == 1;
}
private static boolean isKeyPressedAsync(int state) {
return (state >>> 31) == 1;
}
public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis, boolean repeat) {
virt_key = translateExtended(virt_key, scan_code, event_state, extended);
if ( !repeat && isKeyPressed(event_state) == isKeyPressed(virt_key_down_buffer[virt_key]) )
@ -176,7 +180,7 @@ final class WindowsKeyboard {
public void fireLostKeyEvents() {
for ( int i = 0; i < virt_key_down_buffer.length; i++ ) {
if ( isKeyPressed(virt_key_down_buffer[i]) && !isKeyPressed(GetAsyncKeyState(i)) )
if ( isKeyPressed(virt_key_down_buffer[i]) && !isKeyPressedAsync(GetAsyncKeyState(i)) )
handleKey(i, 0, false, (byte)0, System.currentTimeMillis(), false);
}
}