Merge pull request #1064 from FennelFetish/jme3-vr_mouse-fix
Adds option to disable VR mouse cursor
This commit is contained in:
commit
1a1348983b
@ -9,7 +9,6 @@ import com.jme3.input.MouseInput;
|
|||||||
import com.jme3.input.lwjgl.GlfwMouseInputVR;
|
import com.jme3.input.lwjgl.GlfwMouseInputVR;
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.system.lwjgl.LwjglWindow;
|
import com.jme3.system.lwjgl.LwjglWindow;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
@ -27,8 +26,8 @@ public abstract class AbstractVRMouseManager implements VRMouseManager {
|
|||||||
|
|
||||||
private VREnvironment environment = null;
|
private VREnvironment environment = null;
|
||||||
|
|
||||||
|
private boolean vrMouseEnabled = true;
|
||||||
|
private boolean mouseAttached = false;
|
||||||
private Picture mouseImage;
|
private Picture mouseImage;
|
||||||
private int recentCenterCount = 0;
|
private int recentCenterCount = 0;
|
||||||
|
|
||||||
@ -70,6 +69,11 @@ public abstract class AbstractVRMouseManager implements VRMouseManager {
|
|||||||
public VREnvironment getVREnvironment() {
|
public VREnvironment getVREnvironment() {
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVRMouseEnabled(boolean enabled) {
|
||||||
|
vrMouseEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setThumbstickMode(boolean set) {
|
public void setThumbstickMode(boolean set) {
|
||||||
@ -185,10 +189,9 @@ public abstract class AbstractVRMouseManager implements VRMouseManager {
|
|||||||
@Override
|
@Override
|
||||||
public void update(float tpf) {
|
public void update(float tpf) {
|
||||||
// if we are showing the cursor, add our picture as it
|
// if we are showing the cursor, add our picture as it
|
||||||
|
if( vrMouseEnabled && environment.getApplication().getInputManager().isCursorVisible() ) {
|
||||||
if( environment.getApplication().getInputManager().isCursorVisible() ) {
|
if(!mouseAttached) {
|
||||||
if( mouseImage.getParent() == null ) {
|
mouseAttached = true;
|
||||||
|
|
||||||
environment.getApplication().getGuiViewPort().attachScene(mouseImage);
|
environment.getApplication().getGuiViewPort().attachScene(mouseImage);
|
||||||
centerMouse();
|
centerMouse();
|
||||||
// the "real" mouse pointer should stay hidden
|
// the "real" mouse pointer should stay hidden
|
||||||
@ -216,13 +219,13 @@ public abstract class AbstractVRMouseManager implements VRMouseManager {
|
|||||||
|
|
||||||
mouseImage.updateGeometricState();
|
mouseImage.updateGeometricState();
|
||||||
|
|
||||||
} else if( mouseImage.getParent() != null ) {
|
} else if(mouseAttached) {
|
||||||
Node n = mouseImage.getParent();
|
mouseAttached = false;
|
||||||
mouseImage.removeFromParent();
|
environment.getApplication().getGuiViewPort().detachScene(mouseImage);
|
||||||
|
|
||||||
if (n != null){
|
// Use the setCursorVisible implementation to show the cursor again, depending on the state of cursorVisible
|
||||||
n.updateGeometricState();
|
boolean cursorVisible = environment.getApplication().getInputManager().isCursorVisible();
|
||||||
}
|
environment.getApplication().getContext().getMouseInput().setCursorVisible(cursorVisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,12 @@ public interface VRMouseManager {
|
|||||||
* @return the {@link VREnvironment VR Environment} to which this manager is attached.
|
* @return the {@link VREnvironment VR Environment} to which this manager is attached.
|
||||||
*/
|
*/
|
||||||
public VREnvironment getVREnvironment();
|
public VREnvironment getVREnvironment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the mouse cursor should be used in the VR view.
|
||||||
|
* @param enabled <code>true</code> if the mouse cursor should be displayed in VR and <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setVRMouseEnabled(boolean enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the VR device controller is used within thumb stick mode.
|
* Set if the VR device controller is used within thumb stick mode.
|
||||||
@ -29,7 +35,7 @@ public interface VRMouseManager {
|
|||||||
public void setThumbstickMode(boolean set);
|
public void setThumbstickMode(boolean set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if the VR device controller is used within thumb stick mode.
|
* Get if the VR device controller is used within thumb stick mode.
|
||||||
* @return <code>true</code> if the VR device controller is used within thumb stick mode and <code>false</code> otherwise.
|
* @return <code>true</code> if the VR device controller is used within thumb stick mode and <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean isThumbstickMode();
|
public boolean isThumbstickMode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user