-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from nickd3000/develop
Develop
- Loading branch information
Showing
9 changed files
with
187 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.physmo.garnet.input; | ||
|
||
import com.physmo.garnet.Garnet; | ||
|
||
public class Keyboard { | ||
|
||
public boolean printKeyCodes = false; | ||
Garnet garnet; | ||
int maxKeys = 512; | ||
private final boolean[] keyboardState = new boolean[maxKeys]; | ||
private final boolean[] keyboardStatePrev = new boolean[maxKeys]; | ||
|
||
public Keyboard(Garnet garnet) { | ||
this.garnet = garnet; | ||
} | ||
|
||
public void init() { | ||
garnet.addKeyboardCallback((key, scancode, action, mods) -> { | ||
|
||
if (printKeyCodes) { | ||
System.out.println("keyboard handler - key:" + key + " scancode:" + scancode + " action:" + action); | ||
} | ||
|
||
if (action == 1) { | ||
keyboardState[key] = true; | ||
} else if (action == 0) { | ||
keyboardState[key] = false; | ||
} | ||
}); | ||
} | ||
|
||
public void update() { | ||
System.arraycopy(keyboardState, 0, keyboardStatePrev, 0, keyboardState.length); | ||
} | ||
|
||
public boolean[] getKeyboardState() { | ||
return keyboardState; | ||
} | ||
|
||
public boolean[] getKeyboardStatePrev() { | ||
return keyboardStatePrev; | ||
} | ||
|
||
public void setPrintKeyCodes(boolean printKeyCodes) { | ||
this.printKeyCodes = printKeyCodes; | ||
} | ||
} |
Oops, something went wrong.