Touch: Added keycode to touchtrigger, 0 for all events

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7623 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
kim..ng 14 years ago
parent 97e4a03ceb
commit 8955f719b7
  1. 2
      engine/src/core/com/jme3/input/InputManager.java
  2. 34
      engine/src/core/com/jme3/input/TouchInput.java
  3. 32
      engine/src/core/com/jme3/input/controls/TouchTrigger.java
  4. 6
      engine/src/core/com/jme3/input/event/TouchEvent.java

@ -846,7 +846,7 @@ public class InputManager implements RawInputListener {
* @param evt The touch event to be dispatched to all onTouch listeners * @param evt The touch event to be dispatched to all onTouch listeners
*/ */
public void onTouchEventQueued(TouchEvent evt) { public void onTouchEventQueued(TouchEvent evt) {
ArrayList<Mapping> maps = bindings.get(TouchTrigger.touchHash()); ArrayList<Mapping> maps = bindings.get(TouchTrigger.touchHash(evt.getKeyCode()));
if (maps == null) { if (maps == null) {
return; return;
} }

@ -37,17 +37,47 @@ package com.jme3.input;
*/ */
public interface TouchInput extends Input { public interface TouchInput extends Input {
/**
* No filter, get all events
*/
public static final int ALL = 0x00;
/**
* Home key
*/
public static final int KEYCODE_HOME = 0x03;
/**
* Escape key.
*/
public static final int KEYCODE_BACK = 0x04;
/**
* Context Menu key.
*/
public static final int KEYCODE_MENU = 0x52;
/**
* Search key.
*/
public static final int KEYCODE_SEARCH = 0x54;
/**
* Volume up key.
*/
public static final int KEYCODE_VOLUME_UP = 0x18;
/**
* Volume down key.
*/
public static final int KEYCODE_VOLUME_DOWN = 0x19;
/** /**
* Set whether mouse events should be generated * Set whether mouse events should be generated
* *
* @param simulate Whether mouse events should be generated * @param simulate if mouse events should be generated
*/ */
public void setSimulateMouse(boolean simulate); public void setSimulateMouse(boolean simulate);
/** /**
* Set whether keyboard events should be generated * Set whether keyboard events should be generated
* *
* @param simulate Whether keyboard events should be generated * @param simulate if keyboard events should be generated
*/ */
public void setSimulateKeyboard(boolean simulate); public void setSimulateKeyboard(boolean simulate);

@ -32,22 +32,42 @@
package com.jme3.input.controls; package com.jme3.input.controls;
/**
* Class to trigger TouchEvents, keycode can be TouchInput.ALL(=0) or TouchInput.KEYCODE_*
* @author larynx
*
*/
public class TouchTrigger implements Trigger { public class TouchTrigger implements Trigger {
public TouchTrigger() { private final int keyCode;
/**
* Constructor
* @param keyCode can be zero to get all events or TouchInput.KEYCODE_*
*/
public TouchTrigger(int keyCode) {
super(); super();
this.keyCode = keyCode;
} }
@Override @Override
public String getName() { public String getName() {
return "TouchInput"; if (keyCode != 0)
return "TouchInput";
else
return "TouchInput KeyCode " + keyCode;
} }
public static int touchHash(){ public static int touchHash(int keyCode){
return 0xfedcba98; assert keyCode >= 0 && keyCode <= 255;
return 0xfedcba98 + keyCode;
} }
public int triggerHashCode() { public int triggerHashCode() {
return touchHash(); return touchHash(keyCode);
}
public int getKeyCode(){
return keyCode;
} }
} }

@ -124,6 +124,12 @@ public class TouchEvent extends InputEvent {
this.posY = y; this.posY = y;
this.deltaX = deltax; this.deltaX = deltax;
this.deltaY = deltay; this.deltaY = deltay;
pointerId = 0;
pressure = 0;
keyCode = 0;
scaleFactor = 0;
scaleSpan = 0;
characters = "";
consumed = false; consumed = false;
} }

Loading…
Cancel
Save