mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-18 18:42:46 +00:00
Fix mouse back button closing the app with mouseNavButtons enabled
This commit is contained in:
parent
b6e8389544
commit
2f4f53b048
@ -1002,11 +1002,19 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// Handle a synthetic back button event that some Android OS versions
|
// Handle a synthetic back button event that some Android OS versions
|
||||||
// create as a result of a right-click. This event WILL repeat if
|
// create as a result of a right-click. This event WILL repeat if
|
||||||
// the right mouse button is held down, so we ignore those.
|
// the right mouse button is held down, so we ignore those.
|
||||||
if (!prefConfig.mouseNavButtons &&
|
if ((event.getSource() == InputDevice.SOURCE_MOUSE ||
|
||||||
(event.getSource() == InputDevice.SOURCE_MOUSE ||
|
|
||||||
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
||||||
event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||||
|
|
||||||
|
// Send the right mouse button event if mouse back and forward
|
||||||
|
// are disabled. If they are enabled, handleMotionEvent() will take
|
||||||
|
// care of this.
|
||||||
|
if (!prefConfig.mouseNavButtons) {
|
||||||
conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_RIGHT);
|
conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always return true, otherwise the back press will be propagated
|
||||||
|
// up to the parent and finish the activity.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1065,11 +1073,19 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Handle a synthetic back button event that some Android OS versions
|
// Handle a synthetic back button event that some Android OS versions
|
||||||
// create as a result of a right-click.
|
// create as a result of a right-click.
|
||||||
if (!prefConfig.mouseNavButtons &&
|
if ((event.getSource() == InputDevice.SOURCE_MOUSE ||
|
||||||
(event.getSource() == InputDevice.SOURCE_MOUSE ||
|
|
||||||
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
||||||
event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||||
|
|
||||||
|
// Send the right mouse button event if mouse back and forward
|
||||||
|
// are disabled. If they are enabled, handleMotionEvent() will take
|
||||||
|
// care of this.
|
||||||
|
if (!prefConfig.mouseNavButtons) {
|
||||||
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_RIGHT);
|
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always return true, otherwise the back press will be propagated
|
||||||
|
// up to the parent and finish the activity.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1167,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Ignore mouse input if we're not capturing from our input source
|
// Ignore mouse input if we're not capturing from our input source
|
||||||
if (!inputCaptureProvider.isCapturingActive()) {
|
if (!inputCaptureProvider.isCapturingActive()) {
|
||||||
return false;
|
// We return true here because otherwise the events may end up causing
|
||||||
|
// Android to synthesize d-pad events.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getActionMasked() == MotionEvent.ACTION_SCROLL) {
|
if (event.getActionMasked() == MotionEvent.ACTION_SCROLL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user