mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-26 06:22:45 +00:00
Revert "Use a global set of modifier flags rather than per-device flags"
This reverts commit 1d3e42f92edd5e3431fb8df7d227c69cad625dce.
This commit is contained in:
parent
b1f9fd459e
commit
7f24f47978
@ -598,10 +598,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
|
||||||
// We can't guarantee the state of modifiers keys which may have
|
|
||||||
// lifted while focus was not on us. Clear the modifier state.
|
|
||||||
this.modifierFlags = 0;
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
// Capture is lost when focus is lost, so it must be requested again
|
// Capture is lost when focus is lost, so it must be requested again
|
||||||
// when focus is regained.
|
// when focus is regained.
|
||||||
@ -1000,6 +996,20 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte getModifierState(KeyEvent event) {
|
||||||
|
byte modifier = 0;
|
||||||
|
if (event.isShiftPressed()) {
|
||||||
|
modifier |= KeyboardPacket.MODIFIER_SHIFT;
|
||||||
|
}
|
||||||
|
if (event.isCtrlPressed()) {
|
||||||
|
modifier |= KeyboardPacket.MODIFIER_CTRL;
|
||||||
|
}
|
||||||
|
if (event.isAltPressed()) {
|
||||||
|
modifier |= KeyboardPacket.MODIFIER_ALT;
|
||||||
|
}
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
|
||||||
private byte getModifierState() {
|
private byte getModifierState() {
|
||||||
return (byte) modifierFlags;
|
return (byte) modifierFlags;
|
||||||
}
|
}
|
||||||
@ -1065,7 +1075,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte modifiers = getModifierState();
|
byte modifiers = getModifierState(event);
|
||||||
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
||||||
modifiers |= KeyboardPacket.MODIFIER_SHIFT;
|
modifiers |= KeyboardPacket.MODIFIER_SHIFT;
|
||||||
conn.sendKeyboardInput((short) 0x8010, KeyboardPacket.KEY_DOWN, modifiers);
|
conn.sendKeyboardInput((short) 0x8010, KeyboardPacket.KEY_DOWN, modifiers);
|
||||||
@ -1129,13 +1139,13 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte modifiers = getModifierState();
|
byte modifiers = getModifierState(event);
|
||||||
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
||||||
modifiers |= KeyboardPacket.MODIFIER_SHIFT;
|
modifiers |= KeyboardPacket.MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
conn.sendKeyboardInput(translated, KeyboardPacket.KEY_UP, modifiers);
|
conn.sendKeyboardInput(translated, KeyboardPacket.KEY_UP, modifiers);
|
||||||
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
if (KeyboardTranslator.needsShift(event.getKeyCode())) {
|
||||||
conn.sendKeyboardInput((short) 0x8010, KeyboardPacket.KEY_UP, getModifierState());
|
conn.sendKeyboardInput((short) 0x8010, KeyboardPacket.KEY_UP, getModifierState(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user