Are you using the onTouch event to get the touch coordinates or the mouseButton/Motion events?
The mouseEventsInvert methods are only applied to the case where the touch events are converted into simulated mouse events which using the onMouseButtonEvent and onMouseMotionEvents in inputManager. The onTouch event uses the following to generate the position:
I was using touch events, but this is only part of the problem. The issue also applies to clicking on NiftyGui elements - and I do not handle those events in my code at all (nifty does). These are still inverted.
So what is the right course or action here? I’d prefer not to be using an outdated android lib…
If mouseEventsEnabled is set true (default), then jME’s Android input system will take a touch event from Android and convert it into a mouse button event. The x and y value for the mouse button event are modified based the mouseEventInvertX and mouseEventInvertY settings. When mouseEventsEnabled is true, Nifty uses the simulated mouse event and the modified x and y values instead of the raw onTouch event with the original x and y values.
When I print the x and y values of the onTouch event, the bottom-left corner of the screen is 0,0 just like the mouse event on the PC.
When I print the x and y values of the mouse button event with the settings above at the defaults (all set true), the onTouch event x and y values are still 0,0 at the bottom-left corner, but the onMouseButton event x and y values are 0,0 at the top-right corner. However, changing the mouseEventInvertX and mouseEventInvertY to false, the onMouseButton event changes to be 0,0 at the bottom-left corner.
Since Nifty’s origin is the top-left corner, jME internally inverts the y value before sending it to Nifty. This is done for the mouseButton event for PC as well as the simulated mouseButton event and touch event for Android.
I really need a test case with a Nifty screen to check further, but the code that sends the x and y values to Nifty looks like it is sending the correct x and y values.
If you can’t send a test case that shows the problem, try setting mouseEventsEnabled = false in MainActivity.java to see if it changes anything.