Control camera using joystick but WITHOUT joystick behaviour


What I want in my application is to use the Android sensors to control the camera object just like you would using the mouse.
Since Android sensors (orientation) has been implemented to mimic a Joystick to control the camera object, I have been looking into how to convert the Joystick behavior into mouse like behavior where the camera will return to previous position when the device is returned to previous position; kinda like it’s tracking, like a mouse would.

Once the sensor signals to the program that an event has occured, (r9840) retrieves the current value of the axis but not the delta. I’m thinking that shoud be modified / extended to implement the following
[java] public int getDeltaX() {
return deltaX;
public int getDeltaY() {
return deltaY;
} [/java] with the constructor as
[java] public JoyAxisEvent(int x, int y, int dx, int dy, float value) {
this.x = x;
this.y = y;
this.dx = x;
this.dy = y;
this.value = value;
with no changes to (r9840).

Once the deltas can be obtained, then onJoyAxisEventQueued() of (r9987) should be modified similar to onMouseMotionEventQueued() including the removal of conditions based on axisDeadZone.

Perhaps I fail to understand how the camera is controlled but this is my newbie assessment.

Pretty sure that joysticks do not report deltas. So this would have to be tracked from one frame to the next… might as well just do the tracking yourself. I don’t see any reason for that to be added to InputManager.

I would appreciate it if someone could clarify exactly how the camera is controlled.

I understand that the user interacts with the application (mouse / key / sensor / etc.) which triggers an event (MouseMotionEvent / JoyAxisEvent / etc.) which triggers its listener (AnalogListener / ActionListener) who handles the operation via onAnalog() / onAction() which contains the name, value (between 0 & 1) and tpf of the event. I start to get lost when trying to understand how value is obtained. Where ever the following is done:

inputs such as a joystick which give analogue control though then the value will also indicate the strength of the input premultiplied by tpf.

Also, is the onAnalog() called within class?

Camera is the camera. It has no inputs at all.

Things like FlyByCamera are just mappings from input to camera motion. They listen to whatever input the want and move the camera the way they want. If you want behavior different than FlyByCamera then it isn’t difficult to write a new one of your own. It’s an extremely simple class… almost purely just input → camera movement.

I’ve created my own FlyByCamera (MyFlyByCamera) class, with my own behavior I think, as an “inner class” to Main but how do I enable it?

When SimpleApplication is extended, I’m given access to a fly-by camera (FlyByCamera) by [java] flyCam.setEnabled(true);[/java] however I want this default flyCam disabled while enabling mine.

Do I need to create my own FlyCamAppState (MyFlyCamAppState) and then access it through the SimpleApplication’s simpleUpdate() loop?

There are about 50 posts or so about removing fly cam. You need to either not pass the flycam app state on SimpleApplications constructor or remove it in simpleInit.

You can create your own app state but it’s not necessary… just good practice.