use of com.jme3.input.event.KeyInputEvent in project jmonkeyengine by jMonkeyEngine.
the class AwtKeyInput method keyPressed.
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);
}
}
}
use of com.jme3.input.event.KeyInputEvent in project jmonkeyengine by jMonkeyEngine.
the class NewtKeyInput method keyPressed.
public void keyPressed(KeyEvent evt) {
int code = convertNewtKey(evt.getKeySymbol());
KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, evt.isAutoRepeat());
keyEvent.setTime(evt.getWhen());
synchronized (eventQueue) {
eventQueue.add(keyEvent);
}
}
use of com.jme3.input.event.KeyInputEvent in project jmonkeyengine by jMonkeyEngine.
the class GlfwKeyInput method initialize.
public void initialize() {
if (!context.isRenderable()) {
return;
}
glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() {
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
if (key < 0 || key > GLFW_KEY_LAST) {
return;
}
int jmeKey = GlfwKeyMap.toJmeKeyCode(key);
final KeyInputEvent event = new KeyInputEvent(jmeKey, '\0', GLFW_PRESS == action, GLFW_REPEAT == action);
event.setTime(getInputTimeNanos());
keyInputEvents.add(event);
}
@Override
public void close() {
super.close();
}
@Override
public void callback(long args) {
super.callback(args);
}
});
glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() {
@Override
public void invoke(long window, int codepoint) {
final char keyChar = (char) codepoint;
final KeyInputEvent pressed = new KeyInputEvent(KeyInput.KEY_UNKNOWN, keyChar, true, false);
pressed.setTime(getInputTimeNanos());
keyInputEvents.add(pressed);
final KeyInputEvent released = new KeyInputEvent(KeyInput.KEY_UNKNOWN, keyChar, false, false);
released.setTime(getInputTimeNanos());
keyInputEvents.add(released);
}
@Override
public void close() {
super.close();
}
@Override
public void callback(long args) {
super.callback(args);
}
});
initialized = true;
logger.fine("Keyboard created.");
}
Aggregations