Added a method to unregister from the input manager.

Untested and incomplete because some things can't
be undone.  Better than nothing.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9160 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 13 years ago
parent 4c18bfaecb
commit f9ab14b751
  1. 60
      engine/src/core/com/jme3/input/FlyByCamera.java

@ -53,6 +53,25 @@ import com.jme3.renderer.Camera;
*/
public class FlyByCamera implements AnalogListener, ActionListener {
private static String[] mappings = new String[]{
"FLYCAM_Left",
"FLYCAM_Right",
"FLYCAM_Up",
"FLYCAM_Down",
"FLYCAM_StrafeLeft",
"FLYCAM_StrafeRight",
"FLYCAM_Forward",
"FLYCAM_Backward",
"FLYCAM_ZoomIn",
"FLYCAM_ZoomOut",
"FLYCAM_RotateDrag",
"FLYCAM_Rise",
"FLYCAM_Lower"
};
protected Camera cam;
protected Vector3f initialUpVec;
protected float rotationSpeed = 1f;
@ -153,25 +172,6 @@ public class FlyByCamera implements AnalogListener, ActionListener {
public void registerWithInput(InputManager inputManager){
this.inputManager = inputManager;
String[] mappings = new String[]{
"FLYCAM_Left",
"FLYCAM_Right",
"FLYCAM_Up",
"FLYCAM_Down",
"FLYCAM_StrafeLeft",
"FLYCAM_StrafeRight",
"FLYCAM_Forward",
"FLYCAM_Backward",
"FLYCAM_ZoomIn",
"FLYCAM_ZoomOut",
"FLYCAM_RotateDrag",
"FLYCAM_Rise",
"FLYCAM_Lower"
};
// both mouse and button - rotation of cam
inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true),
new KeyTrigger(KeyInput.KEY_LEFT));
@ -211,6 +211,28 @@ public class FlyByCamera implements AnalogListener, ActionListener {
}
}
/**
* Registers the FlyByCamera to receive input events from the provided
* Dispatcher.
* @param inputManager
*/
public void unregisterInput(){
for (String s : mappings) {
inputManager.deleteMapping( s );
}
inputManager.removeListener(this);
inputManager.setCursorVisible(!dragToRotate);
Joystick[] joysticks = inputManager.getJoysticks();
if (joysticks != null && joysticks.length > 0){
Joystick joystick = joysticks[0];
// No way to unassing axis
}
}
protected void rotateCamera(float value, Vector3f axis){
if (dragToRotate){
if (canRotate){

Loading…
Cancel
Save