From 74912c63c873eba303ed3c3e6c707c0bccdcbe0e Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 2 Nov 2005 00:01:26 +0000 Subject: [PATCH] Updates to work with refactored JME input handling. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3743 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- lib/LIBS | 1 + src/java/com/threerings/jme/JmeApp.java | 31 +++-------- src/java/com/threerings/jme/JmeCanvasApp.java | 4 +- .../threerings/jme/input/GodViewHandler.java | 46 ++++------------ .../threerings/jme/input/HardwareMouse.java | 52 ------------------- 5 files changed, 21 insertions(+), 113 deletions(-) delete mode 100644 src/java/com/threerings/jme/input/HardwareMouse.java diff --git a/lib/LIBS b/lib/LIBS index c5574564d..2c3223e94 100644 --- a/lib/LIBS +++ b/lib/LIBS @@ -8,6 +8,7 @@ commons-logging.jar jme-bui.jar jme.jar jme-model.jar +jme-awt.jar junit-3.7.jar lwjgl.jar lwjgl_util.jar diff --git a/src/java/com/threerings/jme/JmeApp.java b/src/java/com/threerings/jme/JmeApp.java index 46004130b..ad4e8a483 100644 --- a/src/java/com/threerings/jme/JmeApp.java +++ b/src/java/com/threerings/jme/JmeApp.java @@ -40,11 +40,12 @@ import com.jme.system.JmeException; import com.jme.system.PropertiesIO; import com.jme.system.lwjgl.LWJGLPropertiesDialog; +import com.jme.input.InputHandler; +import com.jme.input.KeyInput; +import com.jme.input.Mouse; +import com.jme.input.MouseInput; import com.jmex.bui.BRootNode; import com.jmex.bui.PolledRootNode; -import com.jme.input.InputHandler; -import com.jme.input.InputSystem; -import com.jme.input.Mouse; import com.jme.light.PointLight; import com.jme.math.Vector3f; @@ -271,9 +272,7 @@ public class JmeApp */ protected void initInput () { - InputSystem.createInputSystem(_properties.getRenderer()); _input = createInputHandler(_camera, _properties.getRenderer()); - _input.setMouse(createMouse()); } /** @@ -285,17 +284,6 @@ public class JmeApp return new GodViewHandler(camera, api); } - /** - * Creates the type of mouse handler we'll use to manage the mouse - * position. - */ - protected Mouse createMouse () - { - HardwareMouse mouse = new HardwareMouse("Mouse"); - mouse.setMouseInput(InputSystem.getMouseInput()); - return mouse; - } - /** * Creates our root node and sets up the basic rendering system. */ @@ -343,7 +331,7 @@ public class JmeApp _rnode = new PolledRootNode(_timer, _input); _iface.attachChild(_rnode); // we don't hide the cursor - InputSystem.getMouseInput().setCursorVisible(true); + MouseInput.get().setCursorVisible(true); } /** @@ -441,13 +429,8 @@ public class JmeApp protected void cleanup () { _display.reset(); - - if (InputSystem.getKeyInput() != null) { - InputSystem.getKeyInput().destroy(); - } - if (InputSystem.getMouseInput() != null) { - InputSystem.getMouseInput().destroy(); - } + KeyInput.destroyIfInitalized(); + MouseInput.destroyIfInitalized(); } /** diff --git a/src/java/com/threerings/jme/JmeCanvasApp.java b/src/java/com/threerings/jme/JmeCanvasApp.java index eb12861fb..35575bde3 100644 --- a/src/java/com/threerings/jme/JmeCanvasApp.java +++ b/src/java/com/threerings/jme/JmeCanvasApp.java @@ -30,8 +30,8 @@ import com.jme.renderer.Renderer; import com.jme.renderer.lwjgl.LWJGLRenderer; import com.jme.scene.Node; import com.jme.system.DisplaySystem; -import com.jme.util.awt.JMECanvas; -import com.jme.util.awt.JMECanvasImplementor; +import com.jmex.awt.JMECanvas; +import com.jmex.awt.JMECanvasImplementor; import com.jmex.bui.CanvasRootNode; diff --git a/src/java/com/threerings/jme/input/GodViewHandler.java b/src/java/com/threerings/jme/input/GodViewHandler.java index 2d4f210e4..744e0c6a1 100644 --- a/src/java/com/threerings/jme/input/GodViewHandler.java +++ b/src/java/com/threerings/jme/input/GodViewHandler.java @@ -9,7 +9,6 @@ import com.jme.math.Vector3f; import com.jme.renderer.Camera; import com.jme.input.InputHandler; -import com.jme.input.InputSystem; import com.jme.input.KeyBindingManager; import com.jme.input.KeyInput; import com.jme.input.RelativeMouse; @@ -139,9 +138,6 @@ public class GodViewHandler extends InputHandler protected void setKeyBindings (String api) { KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager(); - InputSystem.createInputSystem(api); - - keyboard.setKeyInput(InputSystem.getKeyInput()); // the key bindings for the pan actions keyboard.set("forward", KeyInput.KEY_W); @@ -162,15 +158,11 @@ public class GodViewHandler extends InputHandler keyboard.set("rollBack", KeyInput.KEY_END); keyboard.set("screenshot", KeyInput.KEY_F12); - - setKeyBindingManager(keyboard); } protected void addActions (Camera cam) { - KeyScreenShotAction screen = new KeyScreenShotAction(); - screen.setKey("screenshot"); - addAction(screen); + addAction(new KeyScreenShotAction(), "screenshot", false); addPanActions(cam); addZoomActions(cam); @@ -191,8 +183,7 @@ public class GodViewHandler extends InputHandler _camera.update(); } }; - forward.setKey("forward"); - addAction(forward); + addAction(forward, "forward", true); CameraAction backward = new CameraAction(cam, 0.5f) { public void performAction (InputActionEvent evt) { @@ -202,8 +193,7 @@ public class GodViewHandler extends InputHandler _camera.update(); } }; - backward.setKey("backward"); - addAction(backward); + addAction(backward, "backward", true); CameraAction left = new CameraAction(cam, 0.5f) { public void performAction (InputActionEvent evt) { @@ -213,8 +203,7 @@ public class GodViewHandler extends InputHandler _camera.update(); } }; - left.setKey("left"); - addAction(left); + addAction(left, "left", true); CameraAction right = new CameraAction(cam, 0.5f) { public void performAction (InputActionEvent evt) { @@ -224,8 +213,7 @@ public class GodViewHandler extends InputHandler _camera.update(); } }; - right.setKey("right"); - addAction(right); + addAction(right, "right", true); } /** @@ -244,8 +232,7 @@ public class GodViewHandler extends InputHandler } } }; - zoomIn.setKey("zoomIn"); - addAction(zoomIn); + addAction(zoomIn, "zoomIn", true); CameraAction zoomOut = new CameraAction(cam, 0.5f) { public void performAction (InputActionEvent evt) { @@ -258,8 +245,7 @@ public class GodViewHandler extends InputHandler } } }; - zoomOut.setKey("zoomOut"); - addAction(zoomOut); + addAction(zoomOut, "zoomOut", true); } /** @@ -267,13 +253,8 @@ public class GodViewHandler extends InputHandler */ protected void addOrbitActions (Camera cam) { - OrbitAction orbitRight = new OrbitAction(-FastMath.PI / 2); - orbitRight.setKey("turnRight"); - addAction(orbitRight); - - OrbitAction orbitLeft = new OrbitAction(FastMath.PI / 2); - orbitLeft.setKey("turnLeft"); - addAction(orbitLeft); + addAction(new OrbitAction(-FastMath.PI / 2), "turnRight", true); + addAction(new OrbitAction(FastMath.PI / 2), "turnLeft", true); } /** @@ -281,13 +262,8 @@ public class GodViewHandler extends InputHandler */ protected void addRollActions (Camera cam) { - RollAction rollForward = new RollAction(-FastMath.PI / 2); - rollForward.setKey("rollForward"); - addAction(rollForward); - - RollAction rollBack = new RollAction(FastMath.PI / 2); - rollBack.setKey("rollBack"); - addAction(rollBack); + addAction(new RollAction(-FastMath.PI / 2), "rollForward", true); + addAction(new RollAction(FastMath.PI / 2), "rollBack", true); } /** diff --git a/src/java/com/threerings/jme/input/HardwareMouse.java b/src/java/com/threerings/jme/input/HardwareMouse.java deleted file mode 100644 index 2a1e85f49..000000000 --- a/src/java/com/threerings/jme/input/HardwareMouse.java +++ /dev/null @@ -1,52 +0,0 @@ -// -// $Id$ -// -// Narya library - tools for developing networked games -// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved -// http://www.threerings.net/code/narya/ -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package com.threerings.jme.input; - -import com.jme.input.Mouse; -import com.jme.math.Vector3f; - -/** - * Implements the {@link Mouse} methods by simply querying the position of - * the hardware mouse under the assumption that it will not be turned off. - */ -public class HardwareMouse extends Mouse -{ - public HardwareMouse (String name) - { - super(name); - } - - public void update () - { - update(true); - } - - public void update (boolean updateState) - { - } - - public Vector3f getHotSpotPosition() { - hotSpotLocation.x = mouse.getXAbsolute(); - hotSpotLocation.y = mouse.getYAbsolute(); - return hotSpotLocation; - } -}