Touch Events

Touch Event is not getting triggered in Windows 8

Iam using the following code:

package test;

import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.input.RawInputListener;
import com.jme3.input.TouchInput;
import com.jme3.input.controls.TouchListener;
import com.jme3.input.controls.TouchTrigger;
import com.jme3.input.event.JoyAxisEvent;
import com.jme3.input.event.JoyButtonEvent;
import com.jme3.input.event.KeyInputEvent;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.input.event.TouchEvent;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;

public class Main extends SimpleApplication implements TouchListener,RawInputListener
{

private Vector3f walkDirection = new Vector3f();

float posX=0, posY=0;
BitmapText helloText;

public static void main(String[] args) {
Main app = new Main();
AppSettings settings = new AppSettings(true);

app.setSettings(settings);
app.start();

}

@Override
public void simpleInitApp() {
System.out.println(“simpleInitApp”);
flyCam.setDragToRotate(true);
// TouchscreenListener tcl = new TouchscreenListener();
// inputManager.addRawInputListener(this);
//inputManager.addMapping(“Touch”, new TouchTrigger(TouchInput.ALL));

//inputManager.addListener(this, new String[]{“Touch”});

//flyCam.setEnabled(false);
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry(“Box”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Blue);
geom.setMaterial(mat);

rootNode.attachChild(geom);
guiNode.detachAllChildren();
guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);
helloText = new BitmapText(guiFont, false);
helloText.setSize(guiFont.getCharSet().getRenderedSize());
helloText.setText(“Touch on Display”);
helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
guiNode.attachChild(helloText);
String[] mappings={

“Main_Touch_All”

};
inputManager.addMapping(“Main_Touch_All”, new TouchTrigger(TouchInput.ALL));
//inputManager.addMapping(“Main_Touch_All”, new TouchTrigger(TouchInput.ALL));

    inputManager.addListener(this, mappings);
    inputManager.addRawInputListener(this);

}
@Override
public void simpleUpdate(float tpf) {

guiNode.detachAllChildren();
helloText.setText( posX + " , " + posY);
guiNode.attachChild(helloText);
}

public void test()
{

System.out.println(“TOUCh”);
}

@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
@Override
public void onTouch(String name, TouchEvent event, float tpf) {
System.out.println(“TOUCh***”);
posX = event.getX();

// throw new UnsupportedOperationException(“Not supported yet.”);
}

public void beginInput() {
    //throw new UnsupportedOperationException("Not supported yet.");
}

public void endInput() {
    //throw new UnsupportedOperationException("Not supported yet.");
}

public void onJoyAxisEvent(JoyAxisEvent evt) {
    //throw new UnsupportedOperationException("Not supported yet.");
}

public void onJoyButtonEvent(JoyButtonEvent evt) {
    //throw new UnsupportedOperationException("Not supported yet.");
}

public void onTouchEvent(TouchEvent evt) {
// throw new UnsupportedOperationException(“Not supported yet.”);

    System.out.println("Touch*********************");
}
public void onMouseMotionEvent(MouseMotionEvent evt) {
    //throw new UnsupportedOperationException("Not supported yet.");com.
  

     System.out.println("mouse***********");
    // walkDirection.addLocal(evt.getX(),evt.getY(),evt.getX());
}

public void onMouseButtonEvent(MouseButtonEvent evt) {
    //throw new UnsupportedOperationException("Not supported yet.");
}

public void onKeyEvent(KeyInputEvent evt) {
    //throw new UnsupportedOperationException("Not supported yet.");
     System.out.println("key***********");
}

}

OnTouch/OnTouchEvent method is not getting triggered.

I think that touch events are supported only on Android.

In case of Windows 8, I don’t think there is even any java API which could be used to get this data. We are talking about ugly windows-specific JNI for that.

Thanks for the reply.

Are you sure, touch events are supported only in Android? Did anyone triggered touch events in Windows 8?