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
This commit is contained in:
@@ -8,6 +8,7 @@ commons-logging.jar
|
|||||||
jme-bui.jar
|
jme-bui.jar
|
||||||
jme.jar
|
jme.jar
|
||||||
jme-model.jar
|
jme-model.jar
|
||||||
|
jme-awt.jar
|
||||||
junit-3.7.jar
|
junit-3.7.jar
|
||||||
lwjgl.jar
|
lwjgl.jar
|
||||||
lwjgl_util.jar
|
lwjgl_util.jar
|
||||||
|
|||||||
@@ -40,11 +40,12 @@ import com.jme.system.JmeException;
|
|||||||
import com.jme.system.PropertiesIO;
|
import com.jme.system.PropertiesIO;
|
||||||
import com.jme.system.lwjgl.LWJGLPropertiesDialog;
|
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.BRootNode;
|
||||||
import com.jmex.bui.PolledRootNode;
|
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.light.PointLight;
|
||||||
import com.jme.math.Vector3f;
|
import com.jme.math.Vector3f;
|
||||||
@@ -271,9 +272,7 @@ public class JmeApp
|
|||||||
*/
|
*/
|
||||||
protected void initInput ()
|
protected void initInput ()
|
||||||
{
|
{
|
||||||
InputSystem.createInputSystem(_properties.getRenderer());
|
|
||||||
_input = createInputHandler(_camera, _properties.getRenderer());
|
_input = createInputHandler(_camera, _properties.getRenderer());
|
||||||
_input.setMouse(createMouse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,17 +284,6 @@ public class JmeApp
|
|||||||
return new GodViewHandler(camera, api);
|
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.
|
* Creates our root node and sets up the basic rendering system.
|
||||||
*/
|
*/
|
||||||
@@ -343,7 +331,7 @@ public class JmeApp
|
|||||||
_rnode = new PolledRootNode(_timer, _input);
|
_rnode = new PolledRootNode(_timer, _input);
|
||||||
_iface.attachChild(_rnode);
|
_iface.attachChild(_rnode);
|
||||||
// we don't hide the cursor
|
// we don't hide the cursor
|
||||||
InputSystem.getMouseInput().setCursorVisible(true);
|
MouseInput.get().setCursorVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,13 +429,8 @@ public class JmeApp
|
|||||||
protected void cleanup ()
|
protected void cleanup ()
|
||||||
{
|
{
|
||||||
_display.reset();
|
_display.reset();
|
||||||
|
KeyInput.destroyIfInitalized();
|
||||||
if (InputSystem.getKeyInput() != null) {
|
MouseInput.destroyIfInitalized();
|
||||||
InputSystem.getKeyInput().destroy();
|
|
||||||
}
|
|
||||||
if (InputSystem.getMouseInput() != null) {
|
|
||||||
InputSystem.getMouseInput().destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import com.jme.renderer.Renderer;
|
|||||||
import com.jme.renderer.lwjgl.LWJGLRenderer;
|
import com.jme.renderer.lwjgl.LWJGLRenderer;
|
||||||
import com.jme.scene.Node;
|
import com.jme.scene.Node;
|
||||||
import com.jme.system.DisplaySystem;
|
import com.jme.system.DisplaySystem;
|
||||||
import com.jme.util.awt.JMECanvas;
|
import com.jmex.awt.JMECanvas;
|
||||||
import com.jme.util.awt.JMECanvasImplementor;
|
import com.jmex.awt.JMECanvasImplementor;
|
||||||
|
|
||||||
import com.jmex.bui.CanvasRootNode;
|
import com.jmex.bui.CanvasRootNode;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.jme.math.Vector3f;
|
|||||||
import com.jme.renderer.Camera;
|
import com.jme.renderer.Camera;
|
||||||
|
|
||||||
import com.jme.input.InputHandler;
|
import com.jme.input.InputHandler;
|
||||||
import com.jme.input.InputSystem;
|
|
||||||
import com.jme.input.KeyBindingManager;
|
import com.jme.input.KeyBindingManager;
|
||||||
import com.jme.input.KeyInput;
|
import com.jme.input.KeyInput;
|
||||||
import com.jme.input.RelativeMouse;
|
import com.jme.input.RelativeMouse;
|
||||||
@@ -139,9 +138,6 @@ public class GodViewHandler extends InputHandler
|
|||||||
protected void setKeyBindings (String api)
|
protected void setKeyBindings (String api)
|
||||||
{
|
{
|
||||||
KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();
|
KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();
|
||||||
InputSystem.createInputSystem(api);
|
|
||||||
|
|
||||||
keyboard.setKeyInput(InputSystem.getKeyInput());
|
|
||||||
|
|
||||||
// the key bindings for the pan actions
|
// the key bindings for the pan actions
|
||||||
keyboard.set("forward", KeyInput.KEY_W);
|
keyboard.set("forward", KeyInput.KEY_W);
|
||||||
@@ -162,15 +158,11 @@ public class GodViewHandler extends InputHandler
|
|||||||
keyboard.set("rollBack", KeyInput.KEY_END);
|
keyboard.set("rollBack", KeyInput.KEY_END);
|
||||||
|
|
||||||
keyboard.set("screenshot", KeyInput.KEY_F12);
|
keyboard.set("screenshot", KeyInput.KEY_F12);
|
||||||
|
|
||||||
setKeyBindingManager(keyboard);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addActions (Camera cam)
|
protected void addActions (Camera cam)
|
||||||
{
|
{
|
||||||
KeyScreenShotAction screen = new KeyScreenShotAction();
|
addAction(new KeyScreenShotAction(), "screenshot", false);
|
||||||
screen.setKey("screenshot");
|
|
||||||
addAction(screen);
|
|
||||||
|
|
||||||
addPanActions(cam);
|
addPanActions(cam);
|
||||||
addZoomActions(cam);
|
addZoomActions(cam);
|
||||||
@@ -191,8 +183,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
_camera.update();
|
_camera.update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
forward.setKey("forward");
|
addAction(forward, "forward", true);
|
||||||
addAction(forward);
|
|
||||||
|
|
||||||
CameraAction backward = new CameraAction(cam, 0.5f) {
|
CameraAction backward = new CameraAction(cam, 0.5f) {
|
||||||
public void performAction (InputActionEvent evt) {
|
public void performAction (InputActionEvent evt) {
|
||||||
@@ -202,8 +193,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
_camera.update();
|
_camera.update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
backward.setKey("backward");
|
addAction(backward, "backward", true);
|
||||||
addAction(backward);
|
|
||||||
|
|
||||||
CameraAction left = new CameraAction(cam, 0.5f) {
|
CameraAction left = new CameraAction(cam, 0.5f) {
|
||||||
public void performAction (InputActionEvent evt) {
|
public void performAction (InputActionEvent evt) {
|
||||||
@@ -213,8 +203,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
_camera.update();
|
_camera.update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
left.setKey("left");
|
addAction(left, "left", true);
|
||||||
addAction(left);
|
|
||||||
|
|
||||||
CameraAction right = new CameraAction(cam, 0.5f) {
|
CameraAction right = new CameraAction(cam, 0.5f) {
|
||||||
public void performAction (InputActionEvent evt) {
|
public void performAction (InputActionEvent evt) {
|
||||||
@@ -224,8 +213,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
_camera.update();
|
_camera.update();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
right.setKey("right");
|
addAction(right, "right", true);
|
||||||
addAction(right);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,8 +232,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
zoomIn.setKey("zoomIn");
|
addAction(zoomIn, "zoomIn", true);
|
||||||
addAction(zoomIn);
|
|
||||||
|
|
||||||
CameraAction zoomOut = new CameraAction(cam, 0.5f) {
|
CameraAction zoomOut = new CameraAction(cam, 0.5f) {
|
||||||
public void performAction (InputActionEvent evt) {
|
public void performAction (InputActionEvent evt) {
|
||||||
@@ -258,8 +245,7 @@ public class GodViewHandler extends InputHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
zoomOut.setKey("zoomOut");
|
addAction(zoomOut, "zoomOut", true);
|
||||||
addAction(zoomOut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,13 +253,8 @@ public class GodViewHandler extends InputHandler
|
|||||||
*/
|
*/
|
||||||
protected void addOrbitActions (Camera cam)
|
protected void addOrbitActions (Camera cam)
|
||||||
{
|
{
|
||||||
OrbitAction orbitRight = new OrbitAction(-FastMath.PI / 2);
|
addAction(new OrbitAction(-FastMath.PI / 2), "turnRight", true);
|
||||||
orbitRight.setKey("turnRight");
|
addAction(new OrbitAction(FastMath.PI / 2), "turnLeft", true);
|
||||||
addAction(orbitRight);
|
|
||||||
|
|
||||||
OrbitAction orbitLeft = new OrbitAction(FastMath.PI / 2);
|
|
||||||
orbitLeft.setKey("turnLeft");
|
|
||||||
addAction(orbitLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -281,13 +262,8 @@ public class GodViewHandler extends InputHandler
|
|||||||
*/
|
*/
|
||||||
protected void addRollActions (Camera cam)
|
protected void addRollActions (Camera cam)
|
||||||
{
|
{
|
||||||
RollAction rollForward = new RollAction(-FastMath.PI / 2);
|
addAction(new RollAction(-FastMath.PI / 2), "rollForward", true);
|
||||||
rollForward.setKey("rollForward");
|
addAction(new RollAction(FastMath.PI / 2), "rollBack", true);
|
||||||
addAction(rollForward);
|
|
||||||
|
|
||||||
RollAction rollBack = new RollAction(FastMath.PI / 2);
|
|
||||||
rollBack.setKey("rollBack");
|
|
||||||
addAction(rollBack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user