Java Code Examples for com.jme3.input.event.KeyInputEvent#setTime()
The following examples show how to use
com.jme3.input.event.KeyInputEvent#setTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWTKeyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void onKeyEvent(KeyEvent keyEvent, boolean pressed) { int code = convertKeyCode(keyEvent.getID()); char keyChar = keyEvent.getKeyChar(); final KeyInputEvent event = new KeyInputEvent(code, keyChar, pressed, false); event.setTime(getInputTimeNanos()); EXECUTOR.addToExecute(new Runnable() { @Override public void run() { keyInputEvents.add(event); } }); }
Example 2
Source File: LwjglKeyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void update() { if (!context.isRenderable()) return; Keyboard.poll(); while (Keyboard.next()){ int keyCode = Keyboard.getEventKey(); char keyChar = Keyboard.getEventCharacter(); boolean pressed = Keyboard.getEventKeyState(); boolean down = Keyboard.isRepeatEvent(); long time = Keyboard.getEventNanoseconds(); KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down); evt.setTime(time); listener.onKeyEvent(evt); } }
Example 3
Source File: LwjglKeyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void update() { if (!context.isRenderable()) return; Keyboard.poll(); while (Keyboard.next()){ int keyCode = Keyboard.getEventKey(); char keyChar = Keyboard.getEventCharacter(); boolean pressed = Keyboard.getEventKeyState(); boolean down = Keyboard.isRepeatEvent(); long time = Keyboard.getEventNanoseconds(); KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down); evt.setTime(time); listener.onKeyEvent(evt); } }
Example 4
Source File: AwtKeyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void keyPressed(KeyEvent evt) { int code = convertAwtKey(evt.getKeyCode()); // Check if key was already pressed if (!keyStateSet.get(code)){ keyStateSet.set(code); KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false); keyEvent.setTime(evt.getWhen()); synchronized (eventQueue){ eventQueue.add(keyEvent); } } }
Example 5
Source File: AwtKeyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void keyReleased(KeyEvent evt) { int code = convertAwtKey(evt.getKeyCode()); // Check if key was already released if (keyStateSet.get(code)) { keyStateSet.clear(code); KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false); keyEvent.setTime(evt.getWhen()); synchronized (eventQueue){ eventQueue.add(keyEvent); } } }
Example 6
Source File: AwtKeyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void keyPressed(KeyEvent evt) { int code = convertAwtKey(evt.getKeyCode()); KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false); keyEvent.setTime(evt.getWhen()); synchronized (eventQueue){ eventQueue.add(keyEvent); } }
Example 7
Source File: AwtKeyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void keyReleased(KeyEvent evt) { int code = convertAwtKey(evt.getKeyCode()); KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false); keyEvent.setTime(evt.getWhen()); synchronized (eventQueue){ eventQueue.add(keyEvent); } }