mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-23 08:46:40 +00:00
@@ -78,6 +78,8 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
@@ -597,6 +599,35 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMetaKeyCaptureState(boolean enabled) {
|
||||||
|
// This uses custom APIs present on some Samsung devices to allow capture of
|
||||||
|
// meta key events while streaming.
|
||||||
|
try {
|
||||||
|
Class<?> semWindowManager = Class.forName("com.samsung.android.view.SemWindowManager");
|
||||||
|
Method getInstanceMethod = semWindowManager.getMethod("getInstance");
|
||||||
|
Object manager = getInstanceMethod.invoke(null);
|
||||||
|
|
||||||
|
if (manager != null) {
|
||||||
|
Class<?>[] parameterTypes = new Class<?>[2];
|
||||||
|
parameterTypes[0] = String.class;
|
||||||
|
parameterTypes[1] = boolean.class;
|
||||||
|
Method requestMetaKeyEventMethod = semWindowManager.getDeclaredMethod("requestMetaKeyEvent", parameterTypes);
|
||||||
|
requestMetaKeyEventMethod.invoke(manager, this.getComponentName(), enabled);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LimeLog.warning("SemWindowManager.getInstance() returned null");
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserLeaveHint() {
|
public void onUserLeaveHint() {
|
||||||
super.onUserLeaveHint();
|
super.onUserLeaveHint();
|
||||||
@@ -1696,6 +1727,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// Enable cursor visibility again
|
// Enable cursor visibility again
|
||||||
inputCaptureProvider.disableCapture();
|
inputCaptureProvider.disableCapture();
|
||||||
|
|
||||||
|
// Disable meta key capture
|
||||||
|
setMetaKeyCaptureState(false);
|
||||||
|
|
||||||
if (!displayedFailureDialog) {
|
if (!displayedFailureDialog) {
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
LimeLog.severe("Connection terminated: " + errorCode);
|
LimeLog.severe("Connection terminated: " + errorCode);
|
||||||
@@ -1807,6 +1841,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// Keep the display on
|
// Keep the display on
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
|
// Enable meta key capture
|
||||||
|
setMetaKeyCaptureState(true);
|
||||||
|
|
||||||
// Update GameManager state to indicate we're in game
|
// Update GameManager state to indicate we're in game
|
||||||
UiHelper.notifyStreamConnected(Game.this);
|
UiHelper.notifyStreamConnected(Game.this);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user