mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-10-21 15:56:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8853bf0670 | ||
|
|
71fa3a824b | ||
|
|
56fd50834c | ||
|
|
48ba812cf6 | ||
|
|
019dc6d45f | ||
|
|
cbcb784a79 | ||
|
|
39fa0258ad | ||
|
|
d0dd5bfa8c | ||
|
|
b948c47618 | ||
|
|
18cae8ac53 | ||
|
|
0576231dfc | ||
|
|
6ad35a83dd | ||
|
|
33d4dfc745 | ||
|
|
f3bf63a668 | ||
|
|
2dbb7395a4 | ||
|
|
7c1eb80d62 | ||
|
|
f2bf093691 | ||
|
|
2f002bfa4a | ||
|
|
4a19038d54 | ||
|
|
15fb3dd92c | ||
|
|
e0982d3961 | ||
|
|
7fb2f15f54 | ||
|
|
f93dbb4116 | ||
|
|
bc34fe3a9f | ||
|
|
bbe49491c1 | ||
|
|
d5ccb80f26 | ||
|
|
50fd15379a | ||
|
|
ed479f1155 | ||
|
|
04db9ba714 | ||
|
|
6a973e3248 | ||
|
|
96d9e4977b | ||
|
|
5a3897f22a | ||
|
|
ceef00b79a | ||
|
|
94ee24ea11 | ||
|
|
1a201f2e94 | ||
|
|
e0c6d41d4b | ||
|
|
44a0ae86d2 | ||
|
|
06822ad385 | ||
|
|
3be52280ba | ||
|
|
5142f978cf | ||
|
|
667ffd4dfd | ||
|
|
17626f1853 | ||
|
|
5c79567a2c | ||
|
|
0f5fd9af62 | ||
|
|
99643537d1 | ||
|
|
47650386e0 | ||
|
|
aa3fc34646 | ||
|
|
92f5f1ac71 | ||
|
|
eb739f73c7 | ||
|
|
20a646106b |
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "app/src/main/jni/jnienet/enet"]
|
||||||
|
path = app/src/main/jni/jnienet/enet
|
||||||
|
url = https://github.com/cgutman/enet.git
|
||||||
+14
-3
@@ -5,14 +5,14 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
buildToolsVersion "23.0.2"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
|
|
||||||
versionName "4.5.2"
|
versionName "4.5.8"
|
||||||
versionCode = 86
|
versionCode = 99
|
||||||
}
|
}
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
@@ -25,6 +25,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
disable 'MissingTranslation'
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
@@ -32,6 +36,13 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These lines are required to avoid dexing issues with the BouncyCastle library
|
||||||
|
// bundled with limelight-common.jar
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'META-INF/BCKEY.SF'
|
||||||
|
exclude 'META-INF/BCKEY.DSA'
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets.main.jni.srcDirs = []
|
sourceSets.main.jni.srcDirs = []
|
||||||
|
|
||||||
//noinspection GroovyAssignabilityCheck,GroovyAssignabilityCheck
|
//noinspection GroovyAssignabilityCheck,GroovyAssignabilityCheck
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -37,7 +37,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".AppView"
|
android:name=".AppView"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection" >
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.limelight.PcView" />
|
android:value="com.limelight.PcView" />
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
private String lastRawApplist;
|
private String lastRawApplist;
|
||||||
private int lastRunningAppId;
|
private int lastRunningAppId;
|
||||||
private boolean suspendGridUpdates;
|
private boolean suspendGridUpdates;
|
||||||
|
private boolean inForeground;
|
||||||
|
|
||||||
private final static int START_OR_RESUME_ID = 1;
|
private final static int START_OR_RESUME_ID = 1;
|
||||||
private final static int QUIT_ID = 2;
|
private final static int QUIT_ID = 2;
|
||||||
@@ -95,9 +96,25 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
// Load the app grid with cached data (if possible)
|
// Load the app grid with cached data (if possible)
|
||||||
populateAppGridWithCache();
|
populateAppGridWithCache();
|
||||||
|
|
||||||
getFragmentManager().beginTransaction()
|
runOnUiThread(new Runnable() {
|
||||||
.replace(R.id.appFragmentContainer, new AdapterFragment())
|
@Override
|
||||||
.commitAllowingStateLoss();
|
public void run() {
|
||||||
|
if (isFinishing() || isChangingConfigurations()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Despite my best efforts to catch all conditions that could
|
||||||
|
// cause the activity to be destroyed when we try to commit
|
||||||
|
// I haven't been able to, so we have this try-catch block.
|
||||||
|
try {
|
||||||
|
getFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.appFragmentContainer, new AdapterFragment())
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
@@ -108,7 +125,8 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void startComputerUpdates() {
|
private void startComputerUpdates() {
|
||||||
if (managerBinder == null) {
|
// Don't start polling if we're not bound or in the foreground
|
||||||
|
if (managerBinder == null || !inForeground) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +270,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
inForeground = true;
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +278,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
inForeground = false;
|
||||||
stopComputerUpdates();
|
stopComputerUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.limelight.nvstream.input.KeyboardPacket;
|
|||||||
import com.limelight.nvstream.input.MouseButtonPacket;
|
import com.limelight.nvstream.input.MouseButtonPacket;
|
||||||
import com.limelight.preferences.PreferenceConfiguration;
|
import com.limelight.preferences.PreferenceConfiguration;
|
||||||
import com.limelight.ui.GameGestures;
|
import com.limelight.ui.GameGestures;
|
||||||
|
import com.limelight.ui.StreamView;
|
||||||
import com.limelight.utils.Dialog;
|
import com.limelight.utils.Dialog;
|
||||||
import com.limelight.utils.SpinnerDialog;
|
import com.limelight.utils.SpinnerDialog;
|
||||||
|
|
||||||
@@ -74,8 +75,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
private final TouchContext[] touchContextMap = new TouchContext[2];
|
private final TouchContext[] touchContextMap = new TouchContext[2];
|
||||||
private long threeFingerDownTime = 0;
|
private long threeFingerDownTime = 0;
|
||||||
|
|
||||||
private static final double REFERENCE_HORIZ_RES = 1280;
|
private static final int REFERENCE_HORIZ_RES = 1280;
|
||||||
private static final double REFERENCE_VERT_RES = 720;
|
private static final int REFERENCE_VERT_RES = 720;
|
||||||
|
|
||||||
private static final int THREE_FINGER_TAP_THRESHOLD = 300;
|
private static final int THREE_FINGER_TAP_THRESHOLD = 300;
|
||||||
|
|
||||||
@@ -84,19 +85,18 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
private KeyboardTranslator keybTranslator;
|
private KeyboardTranslator keybTranslator;
|
||||||
|
|
||||||
private PreferenceConfiguration prefConfig;
|
private PreferenceConfiguration prefConfig;
|
||||||
private final Point screenSize = new Point(0, 0);
|
|
||||||
|
|
||||||
private NvConnection conn;
|
private NvConnection conn;
|
||||||
private SpinnerDialog spinner;
|
private SpinnerDialog spinner;
|
||||||
private boolean displayedFailureDialog = false;
|
private boolean displayedFailureDialog = false;
|
||||||
private boolean connecting = false;
|
private boolean connecting = false;
|
||||||
private boolean connected = false;
|
private boolean connected = false;
|
||||||
private boolean deferredSurfaceResize = false;
|
|
||||||
|
|
||||||
private EvdevHandler evdevHandler;
|
private EvdevHandler evdevHandler;
|
||||||
private int modifierFlags = 0;
|
private int modifierFlags = 0;
|
||||||
private boolean grabbedInput = true;
|
private boolean grabbedInput = true;
|
||||||
private boolean grabComboDown = false;
|
private boolean grabComboDown = false;
|
||||||
|
private StreamView streamView;
|
||||||
|
|
||||||
private EnhancedDecoderRenderer decoderRenderer;
|
private EnhancedDecoderRenderer decoderRenderer;
|
||||||
|
|
||||||
@@ -175,13 +175,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
drFlags |= VideoDecoderRenderer.FLAG_FILL_SCREEN;
|
drFlags |= VideoDecoderRenderer.FLAG_FILL_SCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display display = getWindowManager().getDefaultDisplay();
|
|
||||||
display.getSize(screenSize);
|
|
||||||
|
|
||||||
// Listen for events on the game surface
|
// Listen for events on the game surface
|
||||||
SurfaceView sv = (SurfaceView) findViewById(R.id.surfaceView);
|
streamView = (StreamView) findViewById(R.id.surfaceView);
|
||||||
sv.setOnGenericMotionListener(this);
|
streamView.setOnGenericMotionListener(this);
|
||||||
sv.setOnTouchListener(this);
|
streamView.setOnTouchListener(this);
|
||||||
|
|
||||||
// Warn the user if they're on a metered connection
|
// Warn the user if they're on a metered connection
|
||||||
checkDataConnection();
|
checkDataConnection();
|
||||||
@@ -258,6 +255,10 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// >= 4K screens have exactly 4K screens, so we'll be able to hit this good path
|
// >= 4K screens have exactly 4K screens, so we'll be able to hit this good path
|
||||||
// on these devices. On Marshmallow, we can start changing to 4K manually but no
|
// on these devices. On Marshmallow, we can start changing to 4K manually but no
|
||||||
// 4K devices run 6.0 at the moment.
|
// 4K devices run 6.0 at the moment.
|
||||||
|
Display display = getWindowManager().getDefaultDisplay();
|
||||||
|
Point screenSize = new Point(0, 0);
|
||||||
|
display.getSize(screenSize);
|
||||||
|
|
||||||
double screenAspectRatio = ((double)screenSize.y) / screenSize.x;
|
double screenAspectRatio = ((double)screenSize.y) / screenSize.x;
|
||||||
double streamAspectRatio = ((double)prefConfig.height) / prefConfig.width;
|
double streamAspectRatio = ((double)prefConfig.height) / prefConfig.width;
|
||||||
if (Math.abs(screenAspectRatio - streamAspectRatio) < 0.001) {
|
if (Math.abs(screenAspectRatio - streamAspectRatio) < 0.001) {
|
||||||
@@ -266,20 +267,21 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceHolder sh = sv.getHolder();
|
SurfaceHolder sh = streamView.getHolder();
|
||||||
if (prefConfig.stretchVideo || aspectRatioMatch) {
|
if (prefConfig.stretchVideo || aspectRatioMatch) {
|
||||||
// Set the surface to the size of the video
|
// Set the surface to the size of the video
|
||||||
sh.setFixedSize(prefConfig.width, prefConfig.height);
|
sh.setFixedSize(prefConfig.width, prefConfig.height);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deferredSurfaceResize = true;
|
// Set the surface to scale based on the aspect ratio of the stream
|
||||||
|
streamView.setDesiredAspectRatio((double)prefConfig.width / (double)prefConfig.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize touch contexts
|
// Initialize touch contexts
|
||||||
for (int i = 0; i < touchContextMap.length; i++) {
|
for (int i = 0; i < touchContextMap.length; i++) {
|
||||||
touchContextMap[i] = new TouchContext(conn, i,
|
touchContextMap[i] = new TouchContext(conn, i,
|
||||||
(REFERENCE_HORIZ_RES / (double)screenSize.x),
|
REFERENCE_HORIZ_RES, REFERENCE_VERT_RES,
|
||||||
(REFERENCE_VERT_RES / (double)screenSize.y));
|
streamView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LimelightBuildProps.ROOT_BUILD) {
|
if (LimelightBuildProps.ROOT_BUILD) {
|
||||||
@@ -306,26 +308,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
sh.addCallback(this);
|
sh.addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resizeSurfaceWithAspectRatio(SurfaceView sv, double vidWidth, double vidHeight)
|
|
||||||
{
|
|
||||||
// Get the visible width of the activity
|
|
||||||
double visibleWidth = getWindow().getDecorView().getWidth();
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams lp = sv.getLayoutParams();
|
|
||||||
|
|
||||||
// Calculate the new size of the SurfaceView
|
|
||||||
lp.width = (int) visibleWidth;
|
|
||||||
lp.height = (int) ((vidHeight / vidWidth) * visibleWidth);
|
|
||||||
|
|
||||||
// Apply the size change
|
|
||||||
sv.setLayoutParams(lp);
|
|
||||||
|
|
||||||
// refresh virtual controller layout
|
|
||||||
if (virtualController != null) {
|
|
||||||
virtualController.refreshLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkDataConnection()
|
private void checkDataConnection()
|
||||||
{
|
{
|
||||||
ConnectivityManager mgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager mgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
@@ -802,8 +784,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Scale the deltas if the device resolution is different
|
// Scale the deltas if the device resolution is different
|
||||||
// than the stream resolution
|
// than the stream resolution
|
||||||
deltaX = (int)Math.round((double)deltaX * (REFERENCE_HORIZ_RES / (double)screenSize.x));
|
deltaX = (int)Math.round((double)deltaX * (REFERENCE_HORIZ_RES / (double)streamView.getWidth()));
|
||||||
deltaY = (int)Math.round((double)deltaY * (REFERENCE_VERT_RES / (double)screenSize.y));
|
deltaY = (int)Math.round((double)deltaY * (REFERENCE_VERT_RES / (double)streamView.getHeight()));
|
||||||
|
|
||||||
conn.sendMouseMove((short)deltaX, (short)deltaY);
|
conn.sendMouseMove((short)deltaX, (short)deltaY);
|
||||||
}
|
}
|
||||||
@@ -932,13 +914,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
if (!connected && !connecting) {
|
if (!connected && !connecting) {
|
||||||
connecting = true;
|
connecting = true;
|
||||||
|
|
||||||
// Resize the surface to match the aspect ratio of the video
|
|
||||||
// This must be done after the surface is created.
|
|
||||||
if (deferredSurfaceResize) {
|
|
||||||
resizeSurfaceWithAspectRatio((SurfaceView) findViewById(R.id.surfaceView),
|
|
||||||
prefConfig.width, prefConfig.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.start(PlatformBinding.getDeviceName(), holder, drFlags,
|
conn.start(PlatformBinding.getDeviceName(), holder, drFlags,
|
||||||
PlatformBinding.getAudioRenderer(), decoderRenderer);
|
PlatformBinding.getAudioRenderer(), decoderRenderer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
private RelativeLayout noPcFoundLayout;
|
private RelativeLayout noPcFoundLayout;
|
||||||
private PcGridAdapter pcGridAdapter;
|
private PcGridAdapter pcGridAdapter;
|
||||||
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
private ComputerManagerService.ComputerManagerBinder managerBinder;
|
||||||
private boolean freezeUpdates, runningPolling, hasResumed;
|
private boolean freezeUpdates, runningPolling, inForeground;
|
||||||
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName className, IBinder binder) {
|
public void onServiceConnected(ComponentName className, IBinder binder) {
|
||||||
final ComputerManagerService.ComputerManagerBinder localBinder =
|
final ComputerManagerService.ComputerManagerBinder localBinder =
|
||||||
@@ -161,11 +161,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startComputerUpdates() {
|
private void startComputerUpdates() {
|
||||||
if (managerBinder != null) {
|
// Only allow polling to start if we're bound to CMS, polling is not already running,
|
||||||
if (runningPolling) {
|
// and our activity is in the foreground.
|
||||||
return;
|
if (managerBinder != null && !runningPolling && inForeground) {
|
||||||
}
|
|
||||||
|
|
||||||
freezeUpdates = false;
|
freezeUpdates = false;
|
||||||
managerBinder.startPolling(new ComputerManagerListener() {
|
managerBinder.startPolling(new ComputerManagerListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -215,7 +213,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
hasResumed = true;
|
inForeground = true;
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +221,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
hasResumed = false;
|
inForeground = false;
|
||||||
stopComputerUpdates(false);
|
stopComputerUpdates(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,10 +269,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
@Override
|
@Override
|
||||||
public void onContextMenuClosed(Menu menu) {
|
public void onContextMenuClosed(Menu menu) {
|
||||||
// For some reason, this gets called again _after_ onPause() is called on this activity.
|
// For some reason, this gets called again _after_ onPause() is called on this activity.
|
||||||
// We don't want to start computer updates again, so we need to keep track of whether we're paused.
|
// startComputerUpdates() manages this and won't actual start polling until the activity
|
||||||
if (hasResumed) {
|
// returns to the foreground.
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doPair(final ComputerDetails computer) {
|
private void doPair(final ComputerDetails computer) {
|
||||||
@@ -330,7 +327,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
Dialog.displayDialog(PcView.this, getResources().getString(R.string.pair_pairing_title),
|
Dialog.displayDialog(PcView.this, getResources().getString(R.string.pair_pairing_title),
|
||||||
getResources().getString(R.string.pair_pairing_msg)+" "+pinStr, false);
|
getResources().getString(R.string.pair_pairing_msg)+" "+pinStr, false);
|
||||||
|
|
||||||
PairingManager.PairState pairState = httpConn.pair(pinStr);
|
PairingManager.PairState pairState = httpConn.pair(httpConn.getServerInfo(), pinStr);
|
||||||
if (pairState == PairingManager.PairState.PIN_WRONG) {
|
if (pairState == PairingManager.PairState.PIN_WRONG) {
|
||||||
message = getResources().getString(R.string.pair_incorrect_pin);
|
message = getResources().getString(R.string.pair_incorrect_pin);
|
||||||
}
|
}
|
||||||
@@ -368,14 +365,15 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (toastSuccess) {
|
if (toastSuccess) {
|
||||||
// Open the app list after a successful pairing attemp
|
// Open the app list after a successful pairing attempt
|
||||||
doAppList(computer);
|
doAppList(computer);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Start polling again if we're still in the foreground
|
||||||
|
startComputerUpdates();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start polling again
|
|
||||||
startComputerUpdates();
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
defaultContext.leftTriggerAxis = MotionEvent.AXIS_BRAKE;
|
defaultContext.leftTriggerAxis = MotionEvent.AXIS_BRAKE;
|
||||||
defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS;
|
defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS;
|
||||||
defaultContext.controllerNumber = (short) 0;
|
defaultContext.controllerNumber = (short) 0;
|
||||||
|
defaultContext.assignedControllerNumber = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputDevice.MotionRange getMotionRangeForJoystickAxis(InputDevice dev, int axis) {
|
private static InputDevice.MotionRange getMotionRangeForJoystickAxis(InputDevice dev, int axis) {
|
||||||
@@ -146,8 +147,9 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
InputDeviceContext devContext = (InputDeviceContext) context;
|
InputDeviceContext devContext = (InputDeviceContext) context;
|
||||||
|
|
||||||
LimeLog.info(devContext.name+" ("+context.id+") needs a controller number assigned");
|
LimeLog.info(devContext.name+" ("+context.id+") needs a controller number assigned");
|
||||||
if (devContext.name != null && devContext.name.contains("gpio-keys")) {
|
if (devContext.name != null &&
|
||||||
// This is the back button on Shield portable consoles
|
(devContext.name.contains("gpio-keys") || // This is the back button on Shield portable consoles
|
||||||
|
devContext.name.contains("joy_key"))) { // These are the gamepad buttons on the Archos Gamepad 2
|
||||||
LimeLog.info("Built-in buttons hardcoded as controller 0");
|
LimeLog.info("Built-in buttons hardcoded as controller 0");
|
||||||
context.controllerNumber = 0;
|
context.controllerNumber = 0;
|
||||||
}
|
}
|
||||||
@@ -398,12 +400,82 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendControllerInputPacket(GenericControllerContext context) {
|
private byte maxByMagnitude(byte a, byte b) {
|
||||||
assignControllerNumberIfNeeded(context);
|
int absA = Math.abs(a);
|
||||||
conn.sendControllerInput(context.controllerNumber, context.inputMap,
|
int absB = Math.abs(b);
|
||||||
context.leftTrigger, context.rightTrigger,
|
if (absA > absB) {
|
||||||
context.leftStickX, context.leftStickY,
|
return a;
|
||||||
context.rightStickX, context.rightStickY);
|
}
|
||||||
|
else {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private short maxByMagnitude(short a, short b) {
|
||||||
|
int absA = Math.abs(a);
|
||||||
|
int absB = Math.abs(b);
|
||||||
|
if (absA > absB) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendControllerInputPacket(GenericControllerContext originalContext) {
|
||||||
|
assignControllerNumberIfNeeded(originalContext);
|
||||||
|
|
||||||
|
// Take the context's controller number and fuse all inputs with the same number
|
||||||
|
short controllerNumber = originalContext.controllerNumber;
|
||||||
|
short inputMap = 0;
|
||||||
|
byte leftTrigger = 0;
|
||||||
|
byte rightTrigger = 0;
|
||||||
|
short leftStickX = 0;
|
||||||
|
short leftStickY = 0;
|
||||||
|
short rightStickX = 0;
|
||||||
|
short rightStickY = 0;
|
||||||
|
|
||||||
|
// In order to properly handle controllers that are split into multiple devices,
|
||||||
|
// we must aggregate all controllers with the same controller number into a single
|
||||||
|
// device before we send it.
|
||||||
|
for (int i = 0; i < inputDeviceContexts.size(); i++) {
|
||||||
|
GenericControllerContext context = inputDeviceContexts.valueAt(i);
|
||||||
|
if (context.assignedControllerNumber && context.controllerNumber == controllerNumber) {
|
||||||
|
inputMap |= context.inputMap;
|
||||||
|
leftTrigger |= maxByMagnitude(leftTrigger, context.leftTrigger);
|
||||||
|
rightTrigger |= maxByMagnitude(rightTrigger, context.rightTrigger);
|
||||||
|
leftStickX |= maxByMagnitude(leftStickX, context.leftStickX);
|
||||||
|
leftStickY |= maxByMagnitude(leftStickY, context.leftStickY);
|
||||||
|
rightStickX |= maxByMagnitude(rightStickX, context.rightStickX);
|
||||||
|
rightStickY |= maxByMagnitude(rightStickY, context.rightStickY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < usbDeviceContexts.size(); i++) {
|
||||||
|
GenericControllerContext context = usbDeviceContexts.valueAt(i);
|
||||||
|
if (context.assignedControllerNumber && context.controllerNumber == controllerNumber) {
|
||||||
|
inputMap |= context.inputMap;
|
||||||
|
leftTrigger |= maxByMagnitude(leftTrigger, context.leftTrigger);
|
||||||
|
rightTrigger |= maxByMagnitude(rightTrigger, context.rightTrigger);
|
||||||
|
leftStickX |= maxByMagnitude(leftStickX, context.leftStickX);
|
||||||
|
leftStickY |= maxByMagnitude(leftStickY, context.leftStickY);
|
||||||
|
rightStickX |= maxByMagnitude(rightStickX, context.rightStickX);
|
||||||
|
rightStickY |= maxByMagnitude(rightStickY, context.rightStickY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defaultContext.controllerNumber == controllerNumber) {
|
||||||
|
inputMap |= defaultContext.inputMap;
|
||||||
|
leftTrigger |= maxByMagnitude(leftTrigger, defaultContext.leftTrigger);
|
||||||
|
rightTrigger |= maxByMagnitude(rightTrigger, defaultContext.rightTrigger);
|
||||||
|
leftStickX |= maxByMagnitude(leftStickX, defaultContext.leftStickX);
|
||||||
|
leftStickY |= maxByMagnitude(leftStickY, defaultContext.leftStickY);
|
||||||
|
rightStickX |= maxByMagnitude(rightStickX, defaultContext.rightStickX);
|
||||||
|
rightStickY |= maxByMagnitude(rightStickY, defaultContext.rightStickY);
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.sendControllerInput(controllerNumber, inputMap,
|
||||||
|
leftTrigger, rightTrigger,
|
||||||
|
leftStickX, leftStickY,
|
||||||
|
rightStickX, rightStickY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a valid keycode, 0 to consume, or -1 to not consume the event
|
// Return a valid keycode, 0 to consume, or -1 to not consume the event
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.limelight.binding.input;
|
package com.limelight.binding.input;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.limelight.nvstream.NvConnection;
|
import com.limelight.nvstream.NvConnection;
|
||||||
import com.limelight.nvstream.input.MouseButtonPacket;
|
import com.limelight.nvstream.input.MouseButtonPacket;
|
||||||
|
|
||||||
@@ -17,23 +19,27 @@ public class TouchContext {
|
|||||||
private boolean confirmedDrag;
|
private boolean confirmedDrag;
|
||||||
private Timer dragTimer;
|
private Timer dragTimer;
|
||||||
private double distanceMoved;
|
private double distanceMoved;
|
||||||
|
private double xFactor, yFactor;
|
||||||
|
|
||||||
private final NvConnection conn;
|
private final NvConnection conn;
|
||||||
private final int actionIndex;
|
private final int actionIndex;
|
||||||
private final double xFactor;
|
private final int referenceWidth;
|
||||||
private final double yFactor;
|
private final int referenceHeight;
|
||||||
|
private final View targetView;
|
||||||
|
|
||||||
private static final int TAP_MOVEMENT_THRESHOLD = 20;
|
private static final int TAP_MOVEMENT_THRESHOLD = 20;
|
||||||
private static final int TAP_DISTANCE_THRESHOLD = 25;
|
private static final int TAP_DISTANCE_THRESHOLD = 25;
|
||||||
private static final int TAP_TIME_THRESHOLD = 250;
|
private static final int TAP_TIME_THRESHOLD = 250;
|
||||||
private static final int DRAG_TIME_THRESHOLD = 650;
|
private static final int DRAG_TIME_THRESHOLD = 650;
|
||||||
|
|
||||||
public TouchContext(NvConnection conn, int actionIndex, double xFactor, double yFactor)
|
public TouchContext(NvConnection conn, int actionIndex,
|
||||||
|
int referenceWidth, int referenceHeight, View view)
|
||||||
{
|
{
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
this.actionIndex = actionIndex;
|
this.actionIndex = actionIndex;
|
||||||
this.xFactor = xFactor;
|
this.referenceWidth = referenceWidth;
|
||||||
this.yFactor = yFactor;
|
this.referenceHeight = referenceHeight;
|
||||||
|
this.targetView = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActionIndex()
|
public int getActionIndex()
|
||||||
@@ -68,6 +74,10 @@ public class TouchContext {
|
|||||||
|
|
||||||
public boolean touchDownEvent(int eventX, int eventY)
|
public boolean touchDownEvent(int eventX, int eventY)
|
||||||
{
|
{
|
||||||
|
// Get the view dimensions to scale inputs on this touch
|
||||||
|
xFactor = referenceWidth / (double)targetView.getWidth();
|
||||||
|
yFactor = referenceHeight / (double)targetView.getHeight();
|
||||||
|
|
||||||
originalTouchX = lastTouchX = eventX;
|
originalTouchX = lastTouchX = eventX;
|
||||||
originalTouchY = lastTouchY = eventY;
|
originalTouchY = lastTouchY = eventY;
|
||||||
originalTouchTime = System.currentTimeMillis();
|
originalTouchTime = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.limelight.binding.input.evdev;
|
package com.limelight.binding.input.evdev;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.app.Activity;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.limelight.LimeLog;
|
import com.limelight.LimeLog;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ public class EvdevHandler {
|
|||||||
private Process su;
|
private Process su;
|
||||||
private ServerSocket servSock;
|
private ServerSocket servSock;
|
||||||
private Socket evdevSock;
|
private Socket evdevSock;
|
||||||
|
private Activity activity;
|
||||||
|
|
||||||
private static final byte UNGRAB_REQUEST = 1;
|
private static final byte UNGRAB_REQUEST = 1;
|
||||||
private static final byte REGRAB_REQUEST = 2;
|
private static final byte REGRAB_REQUEST = 2;
|
||||||
@@ -49,6 +51,12 @@ public class EvdevHandler {
|
|||||||
try {
|
try {
|
||||||
su = builder.start();
|
su = builder.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(activity, "This device is not rooted - Mouse capture is unavailable", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -155,9 +163,10 @@ public class EvdevHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public EvdevHandler(Context context, EvdevListener listener) {
|
public EvdevHandler(Activity activity, EvdevListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.libraryPath = context.getApplicationInfo().nativeLibraryDir;
|
this.activity = activity;
|
||||||
|
this.libraryPath = activity.getApplicationInfo().nativeLibraryDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void regrabAll() {
|
public void regrabAll() {
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ public class MediaCodecHelper {
|
|||||||
// Software decoders that don't support H264 high profile
|
// Software decoders that don't support H264 high profile
|
||||||
blacklistedDecoderPrefixes.add("omx.google");
|
blacklistedDecoderPrefixes.add("omx.google");
|
||||||
blacklistedDecoderPrefixes.add("AVCDecoder");
|
blacklistedDecoderPrefixes.add("AVCDecoder");
|
||||||
|
|
||||||
|
// Without bitstream fixups, we perform horribly on NVIDIA's HEVC
|
||||||
|
// decoder. While not strictly necessary, I'm going to fully blacklist this
|
||||||
|
// one to avoid users getting inaccurate impressions of Tegra X1/Moonlight performance.
|
||||||
|
blacklistedDecoderPrefixes.add("OMX.Nvidia.h265.decode");
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class PreferenceConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use small mode on anything smaller than a 7" tablet
|
// Use small mode on anything smaller than a 7" tablet
|
||||||
return context.getResources().getConfiguration().smallestScreenWidthDp < 600;
|
return context.getResources().getConfiguration().screenWidthDp < 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDefaultBitrate(Context context) {
|
public static int getDefaultBitrate(Context context) {
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.limelight.ui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
|
||||||
|
public class StreamView extends SurfaceView {
|
||||||
|
private double desiredAspectRatio;
|
||||||
|
|
||||||
|
public void setDesiredAspectRatio(double aspectRatio) {
|
||||||
|
this.desiredAspectRatio = aspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(21)
|
||||||
|
public StreamView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
// If no fixed aspect ratio has been provided, simply use the default onMeasure() behavior
|
||||||
|
if (desiredAspectRatio == 0) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Based on code from: https://www.buzzingandroid.com/2012/11/easy-measuring-of-custom-views-with-specific-aspect-ratio/
|
||||||
|
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||||
|
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||||
|
|
||||||
|
int measuredHeight, measuredWidth;
|
||||||
|
if (widthSize > heightSize * desiredAspectRatio) {
|
||||||
|
measuredHeight = heightSize;
|
||||||
|
measuredWidth = (int)(measuredHeight * desiredAspectRatio);
|
||||||
|
} else {
|
||||||
|
measuredWidth = widthSize;
|
||||||
|
measuredHeight = (int)(measuredWidth / desiredAspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
setMeasuredDimension(measuredWidth, measuredHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Android.mk for Moonlight's ENet JNI binding
|
||||||
|
MY_LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(call all-subdir-makefiles)
|
||||||
|
|
||||||
|
LOCAL_PATH := $(MY_LOCAL_PATH)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := jnienet
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := jnienet.c \
|
||||||
|
enet/callbacks.c \
|
||||||
|
enet/compress.c \
|
||||||
|
enet/host.c \
|
||||||
|
enet/list.c \
|
||||||
|
enet/packet.c \
|
||||||
|
enet/peer.c \
|
||||||
|
enet/protocol.c \
|
||||||
|
enet/unix.c \
|
||||||
|
enet/win32.c \
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := -DHAS_SOCKLEN_T=1
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/enet/include
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
Submodule
+1
Submodule app/src/main/jni/jnienet/enet added at 8b24595dbd.
@@ -0,0 +1,148 @@
|
|||||||
|
#include "enet/enet.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#define CLIENT_TO_LONG(x) ((intptr_t)(x))
|
||||||
|
#define LONG_TO_CLIENT(x) ((ENetHost*)(intptr_t)(x))
|
||||||
|
|
||||||
|
#define PEER_TO_LONG(x) ((intptr_t)(x))
|
||||||
|
#define LONG_TO_PEER(x) ((ENetPeer*)(intptr_t)(x))
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_initializeEnet(JNIEnv *env, jobject class) {
|
||||||
|
return enet_initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_createClient(JNIEnv *env, jobject class, jstring address) {
|
||||||
|
ENetAddress enetAddress;
|
||||||
|
const char *addrStr;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
// Perform a lookup on the address to determine the address family
|
||||||
|
addrStr = (*env)->GetStringUTFChars(env, address, 0);
|
||||||
|
err = enet_address_set_host(&enetAddress, addrStr);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, address, addrStr);
|
||||||
|
if (err < 0) {
|
||||||
|
return CLIENT_TO_LONG(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a client that can use 1 outgoing connection and 1 channel
|
||||||
|
return CLIENT_TO_LONG(enet_host_create(enetAddress.address.ss_family, NULL, 1, 1, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_connectToPeer(JNIEnv *env, jobject class, jlong client, jstring address, jint port, jint timeout) {
|
||||||
|
ENetPeer* peer;
|
||||||
|
ENetAddress enetAddress;
|
||||||
|
ENetEvent event;
|
||||||
|
const char *addrStr;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
// Initialize the ENet address
|
||||||
|
addrStr = (*env)->GetStringUTFChars(env, address, 0);
|
||||||
|
err = enet_address_set_host(&enetAddress, addrStr);
|
||||||
|
enet_address_set_port(&enetAddress, port);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, address, addrStr);
|
||||||
|
if (err < 0) {
|
||||||
|
return PEER_TO_LONG(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the connection
|
||||||
|
peer = enet_host_connect(LONG_TO_CLIENT(client), &enetAddress, 1, 0);
|
||||||
|
if (peer == NULL) {
|
||||||
|
return PEER_TO_LONG(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for the connect to complete
|
||||||
|
if (enet_host_service(LONG_TO_CLIENT(client), &event, timeout) <= 0 || event.type != ENET_EVENT_TYPE_CONNECT) {
|
||||||
|
enet_peer_reset(peer);
|
||||||
|
return PEER_TO_LONG(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the connect verify ACK is sent immediately
|
||||||
|
enet_host_flush(LONG_TO_CLIENT(client));
|
||||||
|
|
||||||
|
// Set the max peer timeout to 10 seconds
|
||||||
|
enet_peer_timeout(peer, ENET_PEER_TIMEOUT_LIMIT, ENET_PEER_TIMEOUT_MINIMUM, 10000);
|
||||||
|
|
||||||
|
return PEER_TO_LONG(peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_readPacket(JNIEnv *env, jobject class, jlong client, jbyteArray data, jint length, jint timeout) {
|
||||||
|
jint err;
|
||||||
|
jbyte* dataPtr;
|
||||||
|
ENetEvent event;
|
||||||
|
|
||||||
|
// Wait for a receive event, timeout, or disconnect
|
||||||
|
err = enet_host_service(LONG_TO_CLIENT(client), &event, timeout);
|
||||||
|
if (err <= 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
else if (event.type != ENET_EVENT_TYPE_RECEIVE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the packet isn't too large
|
||||||
|
if (event.packet->dataLength > length) {
|
||||||
|
enet_packet_destroy(event.packet);
|
||||||
|
return event.packet->dataLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the packet data into the caller's buffer
|
||||||
|
dataPtr = (*env)->GetByteArrayElements(env, data, 0);
|
||||||
|
memcpy(dataPtr, event.packet->data, event.packet->dataLength);
|
||||||
|
err = event.packet->dataLength;
|
||||||
|
(*env)->ReleaseByteArrayElements(env, data, dataPtr, 0);
|
||||||
|
|
||||||
|
// Free the packet
|
||||||
|
enet_packet_destroy(event.packet);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_writePacket(JNIEnv *env, jobject class, jlong client, jlong peer, jbyteArray data, jint length, jint packetFlags) {
|
||||||
|
ENetPacket* packet;
|
||||||
|
jboolean ret;
|
||||||
|
jbyte* dataPtr;
|
||||||
|
|
||||||
|
dataPtr = (*env)->GetByteArrayElements(env, data, 0);
|
||||||
|
|
||||||
|
// Create the reliable packet that describes our outgoing message
|
||||||
|
packet = enet_packet_create(dataPtr, length, packetFlags);
|
||||||
|
if (packet != NULL) {
|
||||||
|
// Send the message to the peer
|
||||||
|
if (enet_peer_send(LONG_TO_PEER(peer), 0, packet) < 0) {
|
||||||
|
// This can fail if the peer has been disconnected
|
||||||
|
enet_packet_destroy(packet);
|
||||||
|
ret = JNI_FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Force the client to send the packet now
|
||||||
|
enet_host_flush(LONG_TO_CLIENT(client));
|
||||||
|
ret = JNI_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*env)->ReleaseByteArrayElements(env, data, dataPtr, JNI_ABORT);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_destroyClient(JNIEnv *env, jobject class, jlong client) {
|
||||||
|
enet_host_destroy(LONG_TO_CLIENT(client));
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_limelight_nvstream_enet_EnetConnection_disconnectPeer(JNIEnv *env, jobject class, jlong peer) {
|
||||||
|
enet_peer_disconnect_now(LONG_TO_PEER(peer), 0);
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".Game" >
|
tools:context=".Game" >
|
||||||
|
|
||||||
<SurfaceView
|
<com.limelight.ui.StreamView
|
||||||
android:id="@+id/surfaceView"
|
android:id="@+id/surfaceView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#Sun Dec 07 22:52:07 PST 2014
|
#Sat Feb 06 16:21:20 EST 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
Reference in new issue
Block a user