Touch vs Nifty vs Android

Hey, (I’m back :P)

I try to make the touch work on Android and so far, the touch event is caught by the app… the only thing is that I don’t know where to implement the action to do when the event is caught.

For now, the event seems to trigger a camera rotation depending on the touch coordinates. But I can’t find this code, it seems to pass by RawInputListener, InputManager, and some others but I’m going crazy trying to follow this path.

So does someone know where I can find this ?

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_input_system

Well, I already know this but that’s not what I’m looking for. I meant that I need to find some part of jme code (already implemented) that implement the default behavior of the touch on Android.



By default, when a touch event is caught, the app get the touch coordinates and uses it to move the camera around (without me to implement any action). And what I want is this default part of the code.

disable the flyCam

No you don’t get it, I don’t want to remove this effect, I just want to see the code.

There is no code but flyCam.setEnabled(), to use the mouse input follow the code in the tutorial I posted, its not any different on android.

The mouse events which control the flycam are created (faked) in AndroidInput.

They are dispatched over the RawInputListener interface to the listener which

was set by androidinput.setListener( the_listener ) which normally is the application class.



The whole AndroidInput needs an overhaul:

  1. make it non-allocating
  2. make it jme inputmanager compatible



    These two points are now on the top of my list, suggestions are very welcome.

Thx, I found what I wanted… “FlyByCam.java”.

Well, so I’ve made some tests and I successfully caught touch with a basic jme app using AndroidHarness. But Nifty is still reluctant… I thought that Nifty was using mouse click events and as AndroidInputs emulate a mouse, I thought that a touch could be interpreted as a mouse click but it seems that it’s not the case.

I tested it with the following code:



[java]package com.lesmobilizers.helloandroidharness.apps;

import java.util.logging.Logger;

import com.jme3.app.SimpleApplication;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.collision.shapes.BoxCollisionShape;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.input.MouseInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.MouseButtonTrigger;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.FastMath;

import com.jme3.math.Vector3f;

import com.jme3.niftygui.NiftyJmeDisplay;

import com.jme3.scene.CameraNode;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;

import com.jme3.scene.control.CameraControl.ControlDirection;

import com.jme3.scene.shape.Box;

import de.lessvoid.nifty.Nifty;



public class Test2 extends SimpleApplication {



private final static Logger logger = Logger.getLogger(Test2.class.getName());

private BulletAppState bulletAppState;

private float ratio;

private Node platformNode;

private Nifty nifty;



public Test2() {

super();

}



@Override

public void simpleInitApp() {

ratio = 0.1f;

bulletAppState = new BulletAppState();

logger.info(“CHECK: application’s physical state creation… DONE”);

stateManager.attach(bulletAppState);

logger.info(“CHECK: physical state’s binding to state manager… DONE”);

logger.info(“CHECK: physical space’s enablement… DONE”);

initPlatform();

initCamera(ratio*30);

initKeys();

initGUI();

}



public void update(float tpf){

}



private void initPlatform(){

Box platform = new Box(ratio * 10, ratio * 2, ratio * 10);

logger.info(“CHECK: platform’s box creation… DONE”);

Geometry platformGeometry = new Geometry(“platform”, platform);

logger.info(“CHECK: platform’s geometry creation… DONE”);

Material platformMaterial = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

logger.info(“CHECK: platform’s material creation… DONE”);

platformMaterial.setColor(“m_Color”, ColorRGBA.Red);

logger.info(“CHECK: platform’s color setup… DONE”);

platformGeometry.setMaterial(platformMaterial);

logger.info(“CHECK: platform’s material setup… DONE”);

// platformGeometry.setLocalTranslation(new Vector3f(0, -3f, 0));

// logger.info(“CHECK: platform’s geometry translation… DONE”);

// platformGeometry.rotate(0, 0, FastMath.PI/6);

// logger.info(“CHECK: platform’s geometry rotation… DONE”);

BoxCollisionShape platformCollisionShape = new BoxCollisionShape(new Vector3f(ratio * 10, ratio * 2, ratio * 10));

logger.info(“CHECK: platform’s collision shape creation… DONE”);

RigidBodyControl platformPhysics = new RigidBodyControl(platformCollisionShape, 0f);

logger.info(“CHECK: platform’s body controls creation… DONE”);

platformGeometry.addControl(platformPhysics);

logger.info(“CHECK: platform’s body controls adding… DONE”);

platformPhysics.setKinematic(true);

logger.info(“CHECK: platform’s kinematic mode enablement… DONE”);

bulletAppState.getPhysicsSpace().add(platformPhysics);

logger.info(“CHECK: platform adding to the physics space… DONE”);

platformNode = new Node(“platformNode”);

logger.info(“CHECK: platform’s node creation… DONE”);

platformNode.attachChild(platformGeometry);

logger.info(“CHECK: platform’s attachment to the node… DONE”);

rootNode.attachChild(platformNode);

logger.info(“CHECK: platform’s node attachment to the root node… DONE”);

}



private void initCamera(float distance) {

flyCam.setEnabled(false);

cam.setLocation(new Vector3f(0, FastMath.sin(FastMath.PI/3)*distance, FastMath.cos(FastMath.PI/3)*distance));

cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));

cam.setFrustumFar(100);

CameraNode cameraNode = new CameraNode(“CameraNode”, cam);

cameraNode.setLocalTranslation(new Vector3f(0, 2f, 2f));

platformNode.attachChild(cameraNode);

cameraNode.setControlDir(ControlDirection.CameraToSpatial);

}



private void initGUI() {

// flyCam.setDragToRotate(true);

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);

nifty = niftyDisplay.getNifty();

nifty.fromXml(“Interface/Screens/screensmanager.xml”, “homescreen”);

guiViewPort.addProcessor(niftyDisplay);

}



private void initKeys() {

this.getInputManager().clearMappings();

this.getInputManager().addMapping(“Trigger”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

this.getInputManager().addListener(actionListener, new String[] {“Trigger”});

}



private ActionListener actionListener = new ActionListener() {

public void onAction(String name, boolean keyPressed, float tpf) {

if (name.equals(“Trigger”) && !keyPressed) {

logger.info(“CHECK: Touch event caught…”);

}

}

};

}[/java]



The app runs fine, Nifty do display well but as soon as I want to touch the Nifty GUI, the app crashes with the following log error:


06-01 17:35:20.678: INFO/Test2(12926): CHECK: application's physical state creation... DONE
06-01 17:35:20.768: INFO/Test2(12926): CHECK: physical state's binding to state manager... DONE
06-01 17:35:20.768: INFO/Test2(12926): CHECK: physical space's enablement... DONE
06-01 17:35:20.768: INFO/Test2(12926): CHECK: platform's box creation... DONE
06-01 17:35:20.768: INFO/Test2(12926): CHECK: platform's geometry creation... DONE
06-01 17:35:20.768: INFO/MaterialDef(12926): Loaded material definition: {0}
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's material creation... DONE
06-01 17:35:20.808: WARN/Material(12926): Material parameter {0} uses a deprecated naming convention use {1} instead
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's color setup... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's material setup... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's collision shape creation... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's body controls creation... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's body controls adding... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's kinematic mode enablement... DONE
06-01 17:35:20.808: INFO/PhysicsSpace(12926): Adding RigidBody {0} to physics space.
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform adding to the physics space... DONE
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's node creation... DONE
06-01 17:35:20.808: INFO/com.jme3.scene.Node(12926): Child ({0}) attached to this node ({1})
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's attachment to the node... DONE
06-01 17:35:20.808: INFO/com.jme3.scene.Node(12926): Child ({0}) attached to this node ({1})
06-01 17:35:20.808: INFO/Test2(12926): CHECK: platform's node attachment to the root node... DONE
06-01 17:35:20.808: INFO/com.jme3.scene.Node(12926): Child ({0}) attached to this node ({1})
06-01 17:35:20.808: INFO/MaterialDef(12926): Loaded material definition: {0}
06-01 17:35:20.828: INFO/Screen(12926): Missing ScreenController for screen [null] using DefaultScreenController() instead but this might not be what you want.
06-01 17:35:20.828: WARN/AndroidLocator(12926): Failed to locate {0}
06-01 17:35:20.928: INFO/dalvikvm(12926): Jit: resizing JitTable from 4096 to 8192
06-01 17:35:21.178: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:21.248: WARN/AndroidLocator(12926): Failed to locate {0}
06-01 17:35:21.478: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:21.478: WARN/AndroidLocator(12926): Failed to locate {0}
06-01 17:35:21.618: WARN/WindowManager(1127): App freeze timeout expired.
06-01 17:35:21.708: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:21.738: WARN/AndroidLocator(12926): Failed to locate {0}
06-01 17:35:21.958: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:21.958: WARN/AndroidLocator(12926): Failed to locate {0}
06-01 17:35:22.008: INFO/dalvikvm-heap(12926): Grow heap (frag case) to 5.308MB for 95642-byte allocation
06-01 17:35:22.248: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:22.278: WARN/de.lessvoid.nifty.Nifty(12926): An event service by the name NiftyEventBusalready exists. Perhaps multiple threads tried to create a service about the same time?
06-01 17:35:22.278: INFO/de.lessvoid.nifty.Nifty(12926): loadFromFile [Interface/Screens/screensmanager.xml]
06-01 17:35:22.278: INFO/global(12926): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
06-01 17:35:22.278: INFO/NiftyLoader(12926): loading new nifty xml file with schemaId [nifty.nxs]
06-01 17:35:22.358: WARN/WindowManager(1127): Window freeze timeout expired.
06-01 17:35:22.358: WARN/WindowManager(1127): Force clearing orientation change: Window{46f036b8 com.lesmobilizers.helloandroidharness/com.lesmobilizers.helloandroidharness.MainActivity paused=false}
06-01 17:35:22.358: WARN/WindowManager(1127): Force clearing orientation change: Window{46f343f0 SurfaceView paused=false}
06-01 17:35:22.598: INFO/NiftyLoader(12926): loaded nifty xml file with schemaId [nifty.nxs] took [315 ms]
06-01 17:35:22.598: INFO/NiftyType(12926): debug out [0]
06-01 17:35:22.598: INFO/NiftyType(12926): resourceBundles [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerStyle [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerControlDefinition [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerEffect [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerSound [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerMusic [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerMouseCursor [0]
06-01 17:35:22.598: INFO/NiftyType(12926): registerPopup [0]
06-01 17:35:22.598: INFO/NiftyLoader(12926): internal prepare screen (homescreen) [5]
06-01 17:35:22.658: INFO/NiftyLoader(12926): internal create screen (homescreen) [59]
06-01 17:35:22.668: INFO/NiftyLoader(12926): internal prepare screen (quickgamescreen) [7]
06-01 17:35:22.698: INFO/NiftyLoader(12926): internal create screen (quickgamescreen) [27]
06-01 17:35:22.698: INFO/NiftyLoader(12926): internal prepare screen (solomodescreen) [5]
06-01 17:35:22.728: INFO/NiftyLoader(12926): internal create screen (solomodescreen) [24]
06-01 17:35:22.728: INFO/NiftyLoader(12926): internal prepare screen (settingsscreen) [5]
06-01 17:35:22.748: INFO/NiftyLoader(12926): internal create screen (settingsscreen) [21]
06-01 17:35:22.808: INFO/NiftyLoader(12926): internal prepare screen (creditsscreen) [51]
06-01 17:35:22.818: INFO/NiftyLoader(12926): internal create screen (creditsscreen) [12]
06-01 17:35:22.818: INFO/NiftyLoader(12926): internal prepare screen (hudscreen) [3]
06-01 17:35:22.838: INFO/NiftyLoader(12926): internal create screen (hudscreen) [14]
06-01 17:35:22.838: INFO/NiftyLoader(12926): internal prepare screen (pausescreen) [3]
06-01 17:35:22.858: INFO/NiftyLoader(12926): internal create screen (pausescreen) [18]
06-01 17:35:22.858: INFO/NiftyType(12926): create Screens [264]
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): Nifty Data:
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children styles
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children useStyles
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children useControls
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children registerSounds
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children registeredMusic
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children registeredEffect
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children popups
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children controlDefinitions
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children screens: 7
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (id => homescreen, controller => com.lesmobilizers.tehmoballizer.screens.HomeScreen)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children layers: 1
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (id => layer1, backgroundColor => #ccc5, childLayout => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children elements: 1
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 75%, backgroundColor => #000f, align => center, width => 35%, childLayout => vertical, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (startDelay => 0, direction => top, name => move, length => 300, inherit => true, mode => in)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (startDelay => 0, direction => top, name => move, length => 300, inherit => true, mode => out)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children elements: 9
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 27.5%, backgroundColor => #0000, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => true, height => 10%, backgroundColor => #050c, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (onClick => onClickButton(quickgamescreen))
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 5%, backgroundColor => #0000, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => true, height => 10%, backgroundColor => #005c, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (onClick => onClickButton(solomodescreen))
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 5%, backgroundColor => #0000, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => true, height => 10%, backgroundColor => #500c, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (onClick => onClickButton(settingsscreen))
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 5%, backgroundColor => #0000, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => true, height => 10%, backgroundColor => #555c, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (onClick => onClickButton(exitgame))
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 27.5%, backgroundColor => #0000, align => center, width => 75%, childLayout => center, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): no children elements
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (id => quickgamescreen, controller => com.lesmobilizers.tehmoballizer.screens.QuickGameScreen)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children layers: 1
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (id => layer1, backgroundColor => #ccc5, childLayout => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children elements: 1
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): [element] (visibleToMouse => false, height => 75%, backgroundColor => #050c, align => center, width => 35%, childLayout => vertical, valign => center)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): ()
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (startDelay => 0, direction => top, name => move, length => 300, inherit => true, mode => in)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): (startDelay => 0, direction => top, name => move, length => 300, inherit => true, mode => out)
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): children elements: 10
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): <panel
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): loadFromFile took [810]
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): gotoScreen [homescreen]
06-01 17:35:23.088: INFO/de.lessvoid.nifty.Nifty(12926): gotoScreenInternal [homescreen]
06-01 17:35:23.098: INFO/Effect(12926): starting effect [(Move[null])] with customKey [null]
06-01 17:35:23.098: INFO/EffectProcessor(12926): adding effect as active
06-01 17:35:23.138: WARN/OGLESShaderRenderer(12926): glError 1280
06-01 17:35:23.148: INFO/global(12926): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
06-01 17:35:23.148: INFO/global(12926): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
06-01 17:35:23.178: INFO/global(12926): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
06-01 17:35:23.178: INFO/global(12926): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
06-01 17:35:23.268: WARN/OGLESShaderRenderer(12926): glError 1280
06-01 17:35:23.298: WARN/OGLESShaderRenderer(12926): glError 1280
06-01 17:35:23.338: INFO/INKSPOT(1318): ContentResolver.unregisterContentObserver : android.database.AbstractCursor$SelfContentObserver@46bdca70
06-01 17:35:23.338: INFO/INKSPOT(1318): ContentResolver.unregisterContentObserver : android.database.AbstractCursor$SelfContentObserver@46c2c528
06-01 17:35:23.338: INFO/INKSPOT(1318): ContentResolver.unregisterContentObserver : android.database.AbstractCursor$SelfContentObserver@46d8f060
06-01 17:35:23.338: INFO/INKSPOT(1318): ContentResolver.unregisterContentObserver : android.database.AbstractCursor$SelfContentObserver@46e975e0
06-01 17:35:23.448: INFO/Screen(12926): onStartScreen has ended
06-01 17:35:24.068: INFO/dalvikvm(12926): Jit: resizing JitTable from 8192 to 16384
06-01 17:35:25.448: WARN/dalvikvm(12926): threadid=8: thread exiting with uncaught exception (group=0x40020ce0)
06-01 17:35:25.448: ERROR/Application(12926): Uncaught exception thrown in Thread[GLThread 10,5,main]
06-01 17:35:25.448: ERROR/Application(12926): java.lang.NoSuchMethodError: de.lessvoid.nifty.NiftyInputConsumer.processMouseEvent
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:126)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:169)
06-01 17:35:25.448: ERROR/Application(12926): at de.lessvoid.nifty.Nifty.update(Nifty.java:224)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:92)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.input.InputManager.processQueue(InputManager.java:551)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.input.InputManager.update(InputManager.java:600)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.app.Application.update(Application.java:463)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:228)
06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:313)
06-01 17:35:25.448: ERROR/Application(12926): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
06-01 17:35:25.448: ERROR/Application(12926): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)


I don't understand why. My guess is that Nifty doesn't use jme events or something like that...

Note:

The whole AndroidInput needs an overhaul:
1) make it non-allocating
2) make it jme inputmanager compatible

These two points are now on the top of my list, suggestions are very welcome.


I think the best way to do so is to create jme-like events from the android ones. This way you can retrieve events easily and use the jme "format" to insert them into the InputManager.

This one looks strange:



06-01 17:35:25.448: ERROR/Application(12926): java.lang.NoSuchMethodError: de.lessvoid.nifty.NiftyInputConsumer.processMouseEvent

06-01 17:35:25.448: ERROR/Application(12926): at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:126)

Yeah I noticed this one, that’s what made me assume that Nifty isn’t using the events created by jME. It could be too that the fake event created by jME doesn’t suits Nifty.



Anyway, does someone have an idea to fix this ?

I tried on desktop and it appears that I have the same problem:


SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NoSuchMethodError: de.lessvoid.nifty.NiftyInputConsumer.processMouseEvent(IIIIZ)Z
at com.jme3.niftygui.InputSystemJme.onMouseMotionEventQueued(InputSystemJme.java:106)
at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:169)
at de.lessvoid.nifty.Nifty.update(Nifty.java:224)
at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:94)
at com.jme3.input.InputManager.processQueue(InputManager.java:551)
at com.jme3.input.InputManager.update(InputManager.java:600)
at com.jme3.app.Application.update(Application.java:461)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:224)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:137)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:161)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:680)


Could it be a synchronization problem with jme/nifty libs when I build the SVN ?

Seems like you updated the nifty libraries but didn’t recompile jME3? It seems there’s some incompatibility between the nifty version that jME3 is using and the one you’re using

Well, I updated my whole libs organization and now I successfully display the Nifty GUI and I have no longer error when I touch the screen but nifty is not catching the touch event. I mean, in my app, I have an object (a platform) at the background and I overlay the GUI and when I touch the screen, the platform is moving (at the back) according to the touch (so the event is caught) but the GUI has no reaction. Like my touch is passing through the GUI. It’s like the “onClick” method I have in the “interact” part of my GUI panel is not triggered by the touch.



In the end I don’t know what to do to fix this… I guess it has to be fixed into the Nifty code and not in the jME one. Does someone have any guidance for me ?

Is your platform moved by mouse events (mouse motion and mouse button)? This is what nifty is listening for.

Yes it is. But shouldn’t Nifty get the event before the platform ? And if it’s not, is there a way to disable the background control while the overlay is on and make the overlay get the events instead ?

A event can be “consumed”, so no listener further back in the queue will get it. I think i will have to debug this,

but nifty getting to run in the first place is a challenge.



Maybe you could try to debug it yourself, look at InputManager.processQueue() and set a breakpoint there.

I found another topic pretty similar but it was the other way round. Nifty was consuming event before it reaches the background app…



http://hub.jmonkeyengine.org/groups/gui/forum/topic/nifty-eating-input-events/



I’mma see if I can debug it.

Btw, I didn’t think of it actually but, how can I set a breakpoint in this class ? It’s in the libs…

you need the source to debug it. In the lib path settings you can specify the source location. Then open InputManager and normally set the breakpoint.