mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Try to disambiguate right clicks from back presses
This commit is contained in:
parent
2f02939638
commit
64de13ab50
@ -105,6 +105,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
private boolean grabbedInput = true;
|
||||
private boolean grabComboDown = false;
|
||||
private StreamView streamView;
|
||||
private boolean gotBackPointerEvent = false;
|
||||
private boolean syntheticBackDown = false;
|
||||
|
||||
private ShortcutHelper shortcutHelper;
|
||||
|
||||
@ -839,7 +841,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
if ((event.getSource() == InputDevice.SOURCE_MOUSE ||
|
||||
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
||||
event.getKeyCode() == KeyEvent.KEYCODE_BACK &&
|
||||
event.getRepeatCount() == 0) {
|
||||
event.getRepeatCount() == 0 &&
|
||||
!gotBackPointerEvent) {
|
||||
syntheticBackDown = true;
|
||||
conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_RIGHT);
|
||||
return true;
|
||||
}
|
||||
@ -891,7 +895,12 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
// create as a result of a right-click.
|
||||
if ((event.getSource() == InputDevice.SOURCE_MOUSE ||
|
||||
event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) &&
|
||||
event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||
event.getKeyCode() == KeyEvent.KEYCODE_BACK &&
|
||||
(!gotBackPointerEvent || syntheticBackDown)) {
|
||||
// We need to raise the button if gotBackPointerEvent is true
|
||||
// in the case where it transitioned to true after we already
|
||||
// sent the right click down event.
|
||||
syntheticBackDown = false;
|
||||
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_RIGHT);
|
||||
return true;
|
||||
}
|
||||
@ -999,6 +1008,11 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
else {
|
||||
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
// Don't use the KEYCODE_BACK hack (which interferes with mice
|
||||
// with actual back buttons) since we're getting right clicks
|
||||
// using this callback.
|
||||
gotBackPointerEvent = true;
|
||||
}
|
||||
|
||||
if ((changedButtons & MotionEvent.BUTTON_TERTIARY) != 0) {
|
||||
@ -1017,6 +1031,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
else {
|
||||
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_X1);
|
||||
}
|
||||
|
||||
// Don't use the KEYCODE_BACK hack. That will cause this
|
||||
// button press to trigger a right-click.
|
||||
gotBackPointerEvent = true;
|
||||
}
|
||||
|
||||
if ((changedButtons & MotionEvent.BUTTON_FORWARD) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user