Skip to content

Commit 8f33ef0

Browse files
committed
fix pointer grab by not handling action cancel
1 parent caa8707 commit 8f33ef0

13 files changed

Lines changed: 11 additions & 62 deletions

File tree

jme3-android/src/main/java/com/jme3/input/android/AndroidMouseInput14.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ public boolean onGenericMotion(MotionEvent event) {
234234
break;
235235

236236
case MotionEvent.ACTION_UP:
237-
case MotionEvent.ACTION_CANCEL:
238237
if((btnState & MotionEvent.BUTTON_PRIMARY) == MotionEvent.BUTTON_PRIMARY) {
239238
leftPressed = false;
240239
}
@@ -269,10 +268,6 @@ public void setCursorVisible(boolean visible) {
269268
logger.log(Level.FINE, "Cannot hide mouse till API 24");
270269
}
271270

272-
@Override
273-
public void setMouseGrab(boolean grab) {
274-
logger.log(Level.FINE, "Cannot grab mouse till API 26");
275-
}
276271

277272
@Override
278273
public int getButtonCount() {

jme3-android/src/main/java/com/jme3/input/android/AndroidMouseInput24.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public boolean onGenericMotion(MotionEvent event) {
7979
break;
8080

8181
case MotionEvent.ACTION_BUTTON_RELEASE:
82-
case MotionEvent.ACTION_CANCEL:
8382
if(btnAction == MotionEvent.BUTTON_PRIMARY) {
8483
leftPressed = false;
8584
}

jme3-android/src/main/java/com/jme3/input/android/AndroidMouseInput26.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public boolean onCapturedPointer(MotionEvent event) {
7777
break;
7878

7979
case MotionEvent.ACTION_BUTTON_RELEASE:
80-
case MotionEvent.ACTION_CANCEL:
8180
if(btnAction == MotionEvent.BUTTON_PRIMARY) {
8281
leftPressed = false;
8382
}
@@ -108,8 +107,8 @@ public boolean onCapturedPointer(MotionEvent event) {
108107
}
109108

110109
@Override
111-
public void setMouseGrab(boolean grab) {
112-
if(grab) {
110+
public void setCursorVisible(boolean visible) {
111+
if(!visible) {
113112
inputHandler.getView().requestPointerCapture();
114113
} else {
115114
inputHandler.getView().releasePointerCapture();

jme3-core/src/main/java/com/jme3/app/ChaseCameraAppState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public final void registerWithInput() {
127127
initToggleRotateInput();
128128

129129
inputManager.addListener(this, inputs);
130-
inputManager.setMouseGrab(!dragToRotate);
130+
inputManager.setCursorVisible(dragToRotate);
131131
}
132132

133133
@Override
@@ -441,7 +441,7 @@ public void setDragToRotate(boolean dragToRotate) {
441441
this.dragToRotate = dragToRotate;
442442
this.canRotate = !dragToRotate;
443443
if (inputManager != null) {
444-
inputManager.setMouseGrab(!dragToRotate);
444+
inputManager.setCursorVisible(dragToRotate);
445445
}
446446
}
447447

jme3-core/src/main/java/com/jme3/input/ChaseCamera.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ public boolean isDragToRotate() {
925925
public void setDragToRotate(boolean dragToRotate) {
926926
this.dragToRotate = dragToRotate;
927927
this.canRotate = !dragToRotate;
928-
inputManager.setMouseGrab(!dragToRotate);
928+
inputManager.setCursorVisible(dragToRotate);
929929
}
930930

931931
/**

jme3-core/src/main/java/com/jme3/input/FlyByCamera.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,8 @@ public float getZoomSpeed() {
205205
*/
206206
public void setEnabled(boolean enable) {
207207
if (enabled && !enable) {
208-
if (inputManager != null) {
209-
inputManager.setMouseGrab(!dragToRotate);
210-
inputManager.setCursorVisible(!dragToRotate || (dragToRotate && canRotate));
208+
if (inputManager != null && (!dragToRotate || (dragToRotate && canRotate))) {
209+
inputManager.setCursorVisible(true);
211210
}
212211
}
213212
enabled = enable;
@@ -247,7 +246,7 @@ public boolean isDragToRotate() {
247246
public void setDragToRotate(boolean dragToRotate) {
248247
this.dragToRotate = dragToRotate;
249248
if (inputManager != null) {
250-
inputManager.setMouseGrab(!dragToRotate);
249+
inputManager.setCursorVisible(dragToRotate);
251250
}
252251
}
253252

@@ -288,7 +287,7 @@ public void registerWithInput(InputManager inputManager) {
288287
inputManager.addMapping(CameraInput.FLYCAM_LOWER, new KeyTrigger(KeyInput.KEY_Z));
289288

290289
inputManager.addListener(this, mappings);
291-
inputManager.setMouseGrab(!dragToRotate && isEnabled());
290+
inputManager.setCursorVisible(dragToRotate || !isEnabled());
292291

293292
Joystick[] joysticks = inputManager.getJoysticks();
294293
if (joysticks != null && joysticks.length > 0) {
@@ -350,7 +349,7 @@ public void unregisterInput() {
350349
}
351350

352351
inputManager.removeListener(this);
353-
inputManager.setMouseGrab(false);
352+
inputManager.setCursorVisible(!dragToRotate);
354353

355354
// Joysticks cannot be "unassigned" in the same way, but mappings are removed with listener.
356355
// Joystick-specific mapping might persist but won't trigger this listener.

jme3-core/src/main/java/com/jme3/input/InputManager.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public class InputManager implements RawInputListener {
9696
private long frameDelta = 0;
9797
private boolean eventsPermitted = false;
9898
private boolean mouseVisible = true;
99-
private boolean mouseGrab = false;
10099
private boolean safeMode = false;
101100
private float globalAxisDeadZone = 0.05f;
102101
private final Vector2f cursorPos = new Vector2f();
@@ -701,18 +700,6 @@ public void setCursorVisible(boolean visible) {
701700
}
702701
}
703702

704-
/**
705-
* Set whether to grab the mouse or not.
706-
*
707-
* @param grab whether to grab the mouse or not.
708-
*/
709-
public void setMouseGrab(boolean grab) {
710-
if (mouseGrab != grab) {
711-
mouseGrab = grab;
712-
mouse.setMouseGrab(mouseGrab);
713-
}
714-
}
715-
716703
/**
717704
* Returns the current cursor position. The position is relative to the
718705
* bottom-left of the screen and is in pixels.

jme3-core/src/main/java/com/jme3/input/MouseInput.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ public interface MouseInput extends Input {
7575
*/
7676
public void setCursorVisible(boolean visible);
7777

78-
/**
79-
* Set whether to grab the mouse or not.
80-
*
81-
* @param grab whether to grab the mouse or not.
82-
*/
83-
public void setMouseGrab(boolean grab);
84-
8578
/**
8679
* Returns the number of buttons the mouse has. Typically 3 for most mice.
8780
*

jme3-core/src/main/java/com/jme3/input/dummy/DummyMouseInput.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ public void setCursorVisible(boolean visible) {
4848
throw new IllegalStateException("Input not initialized.");
4949
}
5050

51-
@Override
52-
public void setMouseGrab(boolean grab) {
53-
}
54-
5551
@Override
5652
public int getButtonCount() {
5753
return 0;

jme3-desktop/src/main/java/com/jme3/input/AWTMouseInput.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ private int convertButton(int i) {
183183
public void setCursorVisible(final boolean visible) {
184184
}
185185

186-
@Override
187-
public void setMouseGrab(boolean grab) {
188-
}
189-
190186
@Override
191187
public int getButtonCount() {
192188
return 3;
@@ -239,4 +235,4 @@ public void mouseExited(java.awt.event.MouseEvent e) {
239235
public void mouseWheelMoved(MouseWheelEvent e) {
240236
onWheelScroll(e.getWheelRotation() * WHEEL_SCALE, e.getWheelRotation() * WHEEL_SCALE);
241237
}
242-
}
238+
}

0 commit comments

Comments
 (0)