本文整理汇总了Java中com.jme3.input.event.KeyInputEvent类的典型用法代码示例。如果您正苦于以下问题:Java KeyInputEvent类的具体用法?Java KeyInputEvent怎么用?Java KeyInputEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyInputEvent类属于com.jme3.input.event包,在下文中一共展示了KeyInputEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyEventQueued
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private void onKeyEventQueued(KeyInputEvent evt, NiftyInputConsumer nic) {
int code = evt.getKeyCode();
if (code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT) {
shiftDown = evt.isPressed();
} else if (code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL) {
ctrlDown = evt.isPressed();
}
KeyboardInputEvent keyEvt = new KeyboardInputEvent(code,
evt.getKeyChar(),
evt.isPressed(),
shiftDown,
ctrlDown);
if (nic.processKeyboardEvent(keyEvt)){
evt.setConsumed();
}
}
示例2: forwardEvents
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
public void forwardEvents(NiftyInputConsumer nic) {
int queueSize = inputQueue.size();
for (int i = 0; i < queueSize; i++){
InputEvent evt = inputQueue.get(i);
if (evt instanceof MouseMotionEvent){
onMouseMotionEventQueued( (MouseMotionEvent)evt, nic);
}else if (evt instanceof MouseButtonEvent){
onMouseButtonEventQueued( (MouseButtonEvent)evt, nic);
}else if (evt instanceof KeyInputEvent){
onKeyEventQueued( (KeyInputEvent)evt, nic);
}
}
inputQueue.clear();
}
示例3: update
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
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);
}
}
示例4: getAxisKey
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
/**
* Handle the Kie as an axis input : return a Vector3f from the kie keyCode.
*
* @param kie the KeyInputEvent to handle as an Axis
* @return UNIT_X for 'x', UNIT_Y for 'y' and UNIT_Z for 'z' kie.
*/
public static Vector3f getAxisKey(KeyInputEvent kie) {
Vector3f result = Vector3f.ZERO;
switch (kie.getKeyCode()) {
case KeyInput.KEY_X:
result = Vector3f.UNIT_X;
break;
case KeyInput.KEY_Y:
result = Vector3f.UNIT_Y;
break;
case KeyInput.KEY_Z:
result = Vector3f.UNIT_Z;
break;
}
return result;
}
示例5: dispatch
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
protected void dispatch(KeyInputEvent evt) {
if( !isEnabled() )
return;
// Intercept for key modifiers
int code = evt.getKeyCode();
if( code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT ) {
setModifier(KeyModifiers.SHIFT_DOWN, evt.isPressed());
}
if( code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL ) {
setModifier(KeyModifiers.CONTROL_DOWN, evt.isPressed());
}
if( code == KeyInput.KEY_LMENU || code == KeyInput.KEY_RMENU ) {
setModifier(KeyModifiers.ALT_DOWN, evt.isPressed());
}
ModifiedKeyInputEvent wrapper = null;
for( KeyListener l : keyListeners.getArray() ) {
// Only wrap if we will actually deliver
if( wrapper == null ) {
wrapper = new ModifiedKeyInputEvent(evt, modifiers);
}
l.onKeyEvent(wrapper);
}
}
示例6: onKeyEvent
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
public void onKeyEvent( KeyInputEvent evt ) {
ModifiedKeyInputEvent mEvt = (ModifiedKeyInputEvent)evt;
if( mEvt.isPressed() ) {
KeyAction key = mEvt.toKeyAction(); //new KeyAction(code, (control?KeyAction.CONTROL_DOWN:0), (shift?KeyAction.SHIFT_DOWN:0) );
KeyActionListener handler = actionMap.get(key);
if( handler != null ) {
handler.keyAction(TextEntryComponent.this, key);
evt.setConsumed();
return;
}
// Making sure that no matter what, certain
// characters never make it directly to the
// document
if( evt.getKeyChar() >= 32 ) {
model.insert(evt.getKeyChar());
evt.setConsumed();
//resetText(); ...should be automatic now
}
}
}
示例7: onKeyEvent
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
public void onKeyEvent(KeyInputEvent evt) {
int kc = evt.getKeyCode();
if (evt.isPressed()) {
//controlIsDown = (kc == KeyInput.KEY_LCONTROL || kc == KeyInput.KEY_RCONTROL);
shiftIsDown = (kc == KeyInput.KEY_LSHIFT || kc == KeyInput.KEY_RSHIFT);
} else {
switch (kc) {
case KeyInput.KEY_LSHIFT:
case KeyInput.KEY_RSHIFT:
shiftIsDown = false;
break;
// case KeyInput.KEY_LCONTROL:
// case KeyInput.KEY_RCONTROL:
// controlIsDown = false;
// break;
}
}
}
示例8: testDirectUsage
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Test
public void testDirectUsage() {
// 1. Define action
@SuppressWarnings("unchecked")
Observer<Float> observer = mock(Observer.class);
// 2. map InputEvents --to--> actions (setup InputMapper's mappings)
sut.mappings.clear();
sut.map(tmplKeyInputEvent(KeyInput.KEY_0), InputMapperHelpers.isPressedAsOne, observer);
//3. simulate events
sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', true, false));
sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', false, false));
//4. check
InOrder inOrder1 = inOrder(observer);
inOrder1.verify(observer, times(1)).onNext(1.0f);
inOrder1.verify(observer, times(1)).onNext(0.0f);
verify(observer, Mockito.never()).onCompleted();
}
示例9: testIndirectUsage
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Test
public void testIndirectUsage() {
// 1. Define action (a biz facade points from where 'real' action)
Subject<Float,Float> actionf0 = PublishSubject.create();
// 2. map InputEvents --to--> actions (setup InputMapper's mappings)
sut.mappings.clear();
sut.map(tmplKeyInputEvent(KeyInput.KEY_0), InputMapperHelpers.isPressedAsOne, actionf0);
// 3. map actions --to--> subscribe listener/observer
@SuppressWarnings("unchecked")
Observer<Float> observer = mock(Observer.class);
actionf0.subscribe(observer);
sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', true, false));
sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', false, false));
InOrder inOrder1 = inOrder(observer);
inOrder1.verify(observer, times(1)).onNext(1.0f);
inOrder1.verify(observer, times(1)).onNext(0.0f);
verify(observer, Mockito.never()).onCompleted();
}
示例10: checkCommandKey
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkCommandKey(KeyInputEvent kie) {
if (kie.getKeyCode() == KeyInput.KEY_D) {
if (shiftDown) {
duplicateSelected();
return true;
}
}
// X will only delete if the user isn't already transforming
if (currentState == null && kie.getKeyCode() == KeyInput.KEY_X) {
if (!ctrlDown && !shiftDown) {
deleteSelected();
return true;
}
}
return false;
}
示例11: checkStateKey
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkStateKey(KeyInputEvent kie) {
Spatial selected = toolController.getSelectedSpatial();
if (kie.getKeyCode() == KeyInput.KEY_G) {
currentState = State.translate;
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
moveManager.reset();
Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
moveManager.initiateMove(selected, rot, false);
moving = moveManager.makeUndo();
return true;
} else if (kie.getKeyCode() == KeyInput.KEY_R) {
currentState = State.rotate;
return true;
} else if (kie.getKeyCode() == KeyInput.KEY_S) {
currentState = State.scale;
return true;
}
return false;
}
示例12: checkAxisKey
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkAxisKey(KeyInputEvent kie) {
if (kie.getKeyCode() == KeyInput.KEY_X) {
currentAxis = Vector3f.UNIT_X;
checkMovePlane(MoveManager.XY, MoveManager.XZ);
return true;
} else if (kie.getKeyCode() == KeyInput.KEY_Y) {
currentAxis = Vector3f.UNIT_Y;
checkMovePlane(MoveManager.XY, MoveManager.YZ);
return true;
} else if (kie.getKeyCode() == KeyInput.KEY_Z) {
currentAxis = Vector3f.UNIT_Z;
checkMovePlane(MoveManager.XZ, MoveManager.YZ);
return true;
}
return false;
}
示例13: onKeyEvent
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
public void onKeyEvent(KeyInputEvent evt) {
if (evt.isReleased())
return;
if (evt.getKeyChar() == '\n' || evt.getKeyChar() == '\r') {
txt3.setText(str.toString());
str.setLength(0);
} else {
str.append(evt.getKeyChar());
}
}
示例14: onKeyEventQueued
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private void onKeyEventQueued(KeyInputEvent evt) {
if (evt.isRepeating()) {
return; // repeat events not used for bindings
}
int hash = KeyTrigger.keyHash(evt.getKeyCode());
invokeActions(hash, evt.isPressed());
invokeTimedActions(hash, evt.getTime(), evt.isPressed());
}
示例15: onKeyEvent
import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
/**
* Callback from RawInputListener. Do not use.
*/
public void onKeyEvent(KeyInputEvent evt) {
if (!eventsPermitted) {
throw new UnsupportedOperationException("KeyInput has raised an event at an illegal time.");
}
inputQueue.add(evt);
}