How to reverse controls on android?

Hi,

I’m using jMonkey on android and I have found the gestures to be non-intuitive. Basically its opposite of what usually applications have as its translating android events to mouse events. Can I disable mouse events and enable flick to move camera in the opposite order? In not how should i code myself with the flick to move camera so that it has momentum effect. I’m sure there should be some library to use and I want to avoid reinventing the wheel.

PS: My personal opinion is that jMonkey doesn’t have a nice helloAndroid tutorial, i would like to write one when I get some experience and will get major things done myself.

Part 1 is probably something to do with: http://hub.jmonkeyengine.org/javadoc/com/jme3/input/InputManager.html#setSimulateMouse(boolean)
…then just check for the touch events you want I guess.

Great, you have given nice clue. There are these functions that can manipulate emulated mouse, however they are not working. I have tried multiple times
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:appsettings

[java]setEmulateMouse(true) Enable or disable mouse emulation for touchscreen-based devices. Setting this to true converts taps on the touchscreen to clicks, and finger swiping gestures over the touchscreen into mouse axis events. false
setEmulateMouseFlipAxis(true,true) Flips the X or Y (or both) axes for the emulated mouse. Set the first parameter to true to flip the x axis, and the second to flip the y axis.[/java]

Does anyone know how to make them work??

You are setting them to true or false? True is the opposite of what you want… so maybe posting the actual code is in order.

In setEmulateFlipMouseFlipAxis,
I tried one true and one false, yet no effect. I dont know why this library is not working

setEmulateMouse(false) also doesnt work…

The flip is what I want if it starts working. I guess its a bug.

Did you try:

[java]
public class JmeActivity extends AndroidHarness {

@Override
public void onCreate(Bundle savedInstanceState) {
	...
	mouseEventsInvertX = true;
	mouseEventsInvertY = true;

	super.onCreate(savedInstanceState);
}

}
[/java]

@simar.i3r said: In setEmulateFlipMouseFlipAxis, I tried one true and one false, yet no effect. I dont know why this library is not working

setEmulateMouse(false) also doesnt work…

The flip is what I want if it starts working. I guess its a bug.

Ok, well the code you’ve posted looks fine. :wink: I can’t comment on whether or not you are doing it right without seeing the code, really. For example, one of a thousand things that could be wrong is setting the AppSettings up inside of main()… but I can’t make that assumption or any other assumption.

Maybe someone with more android experience has had this same problem and can reduce it down to a handful of potential issues instead and guess right.

This is what I did in vain

[java] public static void main(String[] args) {
Main app = new Main();
AppSettings settings = new AppSettings (true);
settings.setEmulateMouseFlipAxis(false, true);
app.setSettings(settings);
app.start();
}
[/java]

I tried making a new class as suggested above

[java]public class JmeActivity extends AndroidHarness {

@Override
public void onCreate(Bundle savedInstanceState) {
    …
    mouseEventsInvertX = true;
    mouseEventsInvertY = true;

    super.onCreate(savedInstanceState);
}

}[/java]

However it complains that there isn’t any class. Neither I could find AndroidHarness in jME libraries.
Do we have a nice class diagram for the jMonkey project, which could be of great use while hacking the source.

99.9999% sure that the main method is not run at all for android apps. Only for desktop.

@simar.i3r said: Do we have a nice class diagram for the jMonkey project, which could be of great use while hacking the source.

…well, there is the javadoc which even lists the classes alphabetically.

http://hub.jmonkeyengine.org/javadoc/com/jme3/app/AndroidHarness.html

I did not know that thanks :). However I tried this, no use

[java]public void simpleInitApp() {
initCrossHairs(); // a “+” in the middle of the screen to help aiming
initKeys(); // load custom key mappings
initMark(); // a red sphere to mark the hit
setUpLight();
setUpCamera();
setUpButtons();
setUpSky();

//SHOP scene
//sceneModel = assetManager.loadModel("Scenes/Scene.j3o");
//sceneModel.setLocalScale(3f);
//sceneModel.setLocalTranslation(0f,-5f,-3f);

mall = assetManager.loadModel("Models/mall-final/mall-final.j3o");
mall.setLocalScale(5);
//mall.setLocalTranslation(0f,-5f,-3f);
settings.setEmulateMouseFlipAxis(true, false);
//settings.setEmulateMouse(false);

allAttached = new Node("AllAttached");

…[/java]

If main does not run then whats the flow of control for android. Do you know some good reference where I can learn all this.

Have you tried setting that boolean on InputManager in your simpleInitApp() method?

Settings only take affect if you start/restart the application. I don’t know exactly how android is initialized… something about an activity or something. Someone else will have to help with that but I’m pretty sure that setting eventually effects InputManager or the app context or both. I haven’t looked at the code but it’s available online.

Yes, that boolean deactivates the emulated mouse very well. However not the settings.

And I dont have com.jme3.app.AndroidHarness in my library. The SDK complains of this import and I have checked com.jme3.app as well…

I’ve had a look at the code again and I’m afraid it looks like you’ll have to use the AndroidHarness which basically is the “public static void main(…)” for the Android app.
I am not using the SDK so I can’t give you any directions their. Someone has written a nice guide how to build your Android app using Eclipse: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:eclipse_jme3_android_jnindk?s[]=android&s[]=eclipse#android_project
This gives you more control on the Android side.

So, hopefully someone can give you some advice how to achieve the same in the JMonkey SDK.

Ah nice!!
I wanted something similar. Thanks a lot. However I will prefer it in jMonkey SDK.

We need a nice helloAndroid tutorial, which I’m very interested to write once I get enough experience myself.

I found this in ImportantFiles folder that carry the android project. Despite the variables being true they still don’t flip the X and Y mouse movements…

[java]public class MainActivity extends AndroidHarness{
public MainActivity(){
// Set the application class to run
appClass = “mygame.Main”;
// Try ConfigType.FASTEST; or ConfigType.LEGACY if you have problems
eglConfigType = ConfigType.BEST;
// Exit Dialog title & message
exitDialogTitle = “Exit?”;
exitDialogMessage = “Press Yes”;
// Enable verbose logging
eglConfigVerboseLogging = false;
// Choose screen orientation
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
// Invert the MouseEvents X (default = true)
mouseEventsInvertX = true;
// Invert the MouseEvents Y (default = true)
mouseEventsInvertY = true;
}

}[/java]

I’m still a little confused on what the problem actually is. At some point while ago, we switched the x and y values so that the default coordinates matched what the PC version uses. This should be the default setting.

Is the problem that the mouse coordinates reported via android don’t match the mouse coordinates you get when you run the app on desktop?

What are you trying to do that isn’t working? (don’t say your trying to flip the coordinates, I got that. I was wondering what doesn’t work that makes you think you need to flip the coordinates)

Are you using a nightly build of the sdk, standard RC3, or a nightly build of the engine?