mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-19 15:00:22 +00:00
add virtual controller configuration screen
This commit is contained in:
@@ -70,6 +70,12 @@
|
|||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.limelight.Connection" />
|
android:value="com.limelight.Connection" />
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".binding.input.virtual_controller.VirtualControllerConfiguration"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
|
android:theme="@style/StreamTheme"
|
||||||
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection" >
|
||||||
|
</activity>
|
||||||
<service
|
<service
|
||||||
android:name=".discovery.DiscoveryService"
|
android:name=".discovery.DiscoveryService"
|
||||||
android:label="mDNS PC Auto-Discovery Service" />
|
android:label="mDNS PC Auto-Discovery Service" />
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.limelight.utils.UiHelper;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -54,8 +55,8 @@ public class AppView extends Activity {
|
|||||||
setContentView(R.layout.activity_app_view);
|
setContentView(R.layout.activity_app_view);
|
||||||
|
|
||||||
UiHelper.notifyNewRootView(this);
|
UiHelper.notifyNewRootView(this);
|
||||||
|
|
||||||
byte[] address = getIntent().getByteArrayExtra(ADDRESS_EXTRA);
|
byte[] address = getIntent().getByteArrayExtra(ADDRESS_EXTRA);
|
||||||
uniqueId = getIntent().getStringExtra(UNIQUEID_EXTRA);
|
uniqueId = getIntent().getStringExtra(UNIQUEID_EXTRA);
|
||||||
remote = getIntent().getBooleanExtra(REMOTE_EXTRA, false);
|
remote = getIntent().getBooleanExtra(REMOTE_EXTRA, false);
|
||||||
if (address == null || uniqueId == null) {
|
if (address == null || uniqueId == null) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.limelight.nvstream.input.ControllerPacket;
|
|||||||
*/
|
*/
|
||||||
public class VirtualController
|
public class VirtualController
|
||||||
{
|
{
|
||||||
private static final boolean _PRINT_DEBUG_INFORMATION = false;
|
private static final boolean _PRINT_DEBUG_INFORMATION = true;
|
||||||
|
|
||||||
private static final void _DBG(String text)
|
private static final void _DBG(String text)
|
||||||
{
|
{
|
||||||
@@ -30,25 +30,25 @@ public class VirtualController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private short inputMap = 0x0000;
|
private short inputMap = 0x0000;
|
||||||
private byte leftTrigger = 0x00;
|
private byte leftTrigger = 0x00;
|
||||||
private byte rightTrigger = 0x00;
|
private byte rightTrigger = 0x00;
|
||||||
private short rightStickX = 0x0000;
|
private short rightStickX = 0x0000;
|
||||||
private short rightStickY = 0x0000;
|
private short rightStickY = 0x0000;
|
||||||
private short leftStickX = 0x0000;
|
private short leftStickX = 0x0000;
|
||||||
private short leftStickY = 0x0000;
|
private short leftStickY = 0x0000;
|
||||||
|
|
||||||
private FrameLayout frame_layout = null;
|
private FrameLayout frame_layout = null;
|
||||||
private RelativeLayout relative_layout = null;
|
private RelativeLayout relative_layout = null;
|
||||||
|
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonDPadLeft = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonDPadLeft = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonDPadRight = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonDPadRight = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonDPadUp = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonDPadUp = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonDPadDown = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonDPadDown = null;
|
||||||
|
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonA = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonA = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonB = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonB = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonX = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonX = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonY = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonY = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonR1 = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonR1 = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonR2 = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonR2 = null;
|
||||||
|
|
||||||
@@ -56,13 +56,13 @@ public class VirtualController
|
|||||||
private RelativeLayout.LayoutParams layoutParamsParamsStick2 = null;
|
private RelativeLayout.LayoutParams layoutParamsParamsStick2 = null;
|
||||||
|
|
||||||
private Button buttonStart = null;
|
private Button buttonStart = null;
|
||||||
private Button buttonSelect = null;
|
private Button buttonSelect = null;
|
||||||
private Button buttonESC = null;
|
private Button buttonESC = null;
|
||||||
|
|
||||||
private Button buttonDPadLeft = null;
|
private Button buttonDPadLeft = null;
|
||||||
private Button buttonDPadRight = null;
|
private Button buttonDPadRight = null;
|
||||||
private Button buttonDPadUp = null;
|
private Button buttonDPadUp = null;
|
||||||
private Button buttonDPadDown = null;
|
private Button buttonDPadDown = null;
|
||||||
|
|
||||||
private Button buttonA = null;
|
private Button buttonA = null;
|
||||||
private Button buttonB = null;
|
private Button buttonB = null;
|
||||||
@@ -71,9 +71,11 @@ public class VirtualController
|
|||||||
private Button buttonR1 = null;
|
private Button buttonR1 = null;
|
||||||
private Button buttonR2 = null;
|
private Button buttonR2 = null;
|
||||||
|
|
||||||
private AnalogStick stick = null;
|
private AnalogStick stick = null;
|
||||||
private AnalogStick stick2 = null;
|
private AnalogStick stick2 = null;
|
||||||
|
|
||||||
|
private boolean configuration = false;
|
||||||
|
|
||||||
NvConnection connection = null;
|
NvConnection connection = null;
|
||||||
|
|
||||||
private int getPercentageV(int percent)
|
private int getPercentageV(int percent)
|
||||||
@@ -141,21 +143,21 @@ public class VirtualController
|
|||||||
layoutParamsButtonB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
layoutParamsButtonX = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonX = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
layoutParamsButtonY = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonY = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
layoutParamsButtonR1 = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonR1 = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
layoutParamsButtonR2 = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonR2 = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsButtonDPadLeft, 5, 45);
|
setPercentilePosition(layoutParamsButtonDPadLeft, 5, 45);
|
||||||
setPercentilePosition(layoutParamsButtonDPadRight, 15, 45);
|
setPercentilePosition(layoutParamsButtonDPadRight, 15, 45);
|
||||||
setPercentilePosition(layoutParamsButtonDPadUp, 10, 35);
|
setPercentilePosition(layoutParamsButtonDPadUp, 10, 35);
|
||||||
setPercentilePosition(layoutParamsButtonDPadDown, 10, 55);
|
setPercentilePosition(layoutParamsButtonDPadDown, 10, 55);
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsParamsStick, 22, 78);
|
setPercentilePosition(layoutParamsParamsStick, 22, 78);
|
||||||
setPercentilePosition(layoutParamsParamsStick2, 78, 78);
|
setPercentilePosition(layoutParamsParamsStick2, 78, 78);
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsButtonA, 85, 52);
|
setPercentilePosition(layoutParamsButtonA, 85, 52);
|
||||||
setPercentilePosition(layoutParamsButtonB, 92, 47);
|
setPercentilePosition(layoutParamsButtonB, 92, 47);
|
||||||
setPercentilePosition(layoutParamsButtonX, 85, 40);
|
setPercentilePosition(layoutParamsButtonX, 85, 40);
|
||||||
setPercentilePosition(layoutParamsButtonY, 92, 35);
|
setPercentilePosition(layoutParamsButtonY, 92, 35);
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsButtonR1, 95, 68);
|
setPercentilePosition(layoutParamsButtonR1, 95, 68);
|
||||||
setPercentilePosition(layoutParamsButtonR2, 95, 80);
|
setPercentilePosition(layoutParamsButtonR2, 95, 80);
|
||||||
@@ -404,24 +406,94 @@ public class VirtualController
|
|||||||
refreshLayout();
|
refreshLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VirtualController(FrameLayout layout, Context context, WindowManager window_manager)
|
||||||
|
{
|
||||||
|
this.connection = null;
|
||||||
|
frame_layout = layout;
|
||||||
|
|
||||||
|
relative_layout = new RelativeLayout(context);
|
||||||
|
|
||||||
|
relative_layout.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
|
||||||
|
{
|
||||||
|
refreshLayout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
frame_layout.addView(relative_layout);
|
||||||
|
|
||||||
|
buttonDPadLeft = new Button(context);
|
||||||
|
buttonDPadLeft.setText("LF");
|
||||||
|
|
||||||
|
buttonDPadRight = new Button(context);
|
||||||
|
buttonDPadRight.setText("RI");
|
||||||
|
|
||||||
|
buttonDPadUp = new Button(context);
|
||||||
|
buttonDPadUp.setText("UP");
|
||||||
|
|
||||||
|
buttonDPadDown = new Button(context);
|
||||||
|
buttonDPadDown.setText("DW");
|
||||||
|
|
||||||
|
buttonX = new Button(context);
|
||||||
|
buttonX.setText("X");
|
||||||
|
|
||||||
|
buttonY = new Button(context);
|
||||||
|
buttonY.setText("Y");
|
||||||
|
|
||||||
|
buttonA = new Button(context);
|
||||||
|
buttonA.setText("A");
|
||||||
|
|
||||||
|
buttonB = new Button(context);
|
||||||
|
buttonB.setText("B");
|
||||||
|
|
||||||
|
buttonR1 = new Button(context);
|
||||||
|
buttonR1.setText("LT");
|
||||||
|
|
||||||
|
buttonR2 = new Button(context);
|
||||||
|
buttonR2.setText("RT");
|
||||||
|
|
||||||
|
stick = new AnalogStick(context);
|
||||||
|
stick2 = new AnalogStick(context);
|
||||||
|
|
||||||
|
configuration = true;
|
||||||
|
|
||||||
|
|
||||||
|
// receive touch events
|
||||||
|
frame_layout.setOnTouchListener(new View.OnTouchListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event)
|
||||||
|
{
|
||||||
|
_DBG("touch event");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
refreshLayout();
|
||||||
|
}
|
||||||
|
|
||||||
private void sendControllerInputPacket()
|
private void sendControllerInputPacket()
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
_DBG("INPUT_MAP + " + inputMap);
|
||||||
_DBG("INPUT_MAP + " + inputMap);
|
_DBG("LEFT_TRIGGER " + leftTrigger);
|
||||||
_DBG("LEFT_TRIGGER " + leftTrigger);
|
_DBG("RIGHT_TRIGGER " + rightTrigger);
|
||||||
_DBG("RIGHT_TRIGGER " + rightTrigger);
|
_DBG("LEFT STICK X: " + leftStickX + " Y: " + leftStickY);
|
||||||
_DBG("LEFT STICK X: " + leftStickX + " Y: " + leftStickY);
|
_DBG("RIGHT STICK X: " + rightStickX + " Y: " + rightStickY);
|
||||||
_DBG("RIGHT STICK X: " + rightStickX + " Y: " + rightStickY);
|
_DBG("RIGHT STICK X: " + rightStickX + " Y: " + rightStickY);
|
||||||
_DBG("RIGHT STICK X: " + rightStickX + " Y: " + rightStickY);
|
|
||||||
|
|
||||||
|
if (connection != null)
|
||||||
connection.sendControllerInput(inputMap, leftTrigger, rightTrigger,
|
{
|
||||||
leftStickX, leftStickY, rightStickX, rightStickY);
|
connection.sendControllerInput(inputMap, leftTrigger, rightTrigger,
|
||||||
}
|
leftStickX, leftStickY, rightStickX, rightStickY);
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
}
|
||||||
e.printStackTrace();
|
catch (Exception e)
|
||||||
}
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.limelight.binding.input.virtual_controller;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.limelight.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Karim Mreisi on 22.01.2015.
|
||||||
|
*/
|
||||||
|
public class VirtualControllerConfiguration extends Activity
|
||||||
|
{
|
||||||
|
VirtualController virtualController;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// We don't want a title bar
|
||||||
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
|
// Full-screen and don't let the display go off
|
||||||
|
getWindow().addFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
||||||
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
|
// Inflate the content
|
||||||
|
setContentView(R.layout.activity_configure_virtual_controller);
|
||||||
|
|
||||||
|
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.configure_virtual_controller_frameLayout);
|
||||||
|
|
||||||
|
// start with configuration constructor
|
||||||
|
virtualController = new VirtualController(frameLayout, getApplicationContext(), getWindowManager());
|
||||||
|
|
||||||
|
Toast toast = new Toast(this);
|
||||||
|
toast.setText("Not implemented yet!");
|
||||||
|
toast.setDuration(Toast.LENGTH_SHORT);
|
||||||
|
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.limelight.preferences;
|
package com.limelight.preferences;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -8,6 +9,8 @@ import android.preference.PreferenceFragment;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.limelight.R;
|
import com.limelight.R;
|
||||||
|
import com.limelight.binding.input.virtual_controller.VirtualController;
|
||||||
|
import com.limelight.binding.input.virtual_controller.VirtualControllerConfiguration;
|
||||||
import com.limelight.utils.UiHelper;
|
import com.limelight.utils.UiHelper;
|
||||||
|
|
||||||
public class StreamSettings extends Activity {
|
public class StreamSettings extends Activity {
|
||||||
@@ -49,6 +52,19 @@ public class StreamSettings extends Activity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Preference siteVirtualControllerButton = (Preference)findPreference("button_open_virtual_controller_configuration");
|
||||||
|
siteVirtualControllerButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference arg0)
|
||||||
|
{
|
||||||
|
Intent virtualControllerConfiguration = new Intent(getActivity(), VirtualControllerConfiguration.class);
|
||||||
|
startActivity(virtualControllerConfiguration);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/configure_virtual_controller_frameLayout"
|
||||||
|
>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -55,5 +55,15 @@
|
|||||||
android:summary="@string/summary_decoder_list"
|
android:summary="@string/summary_decoder_list"
|
||||||
android:defaultValue="auto" />
|
android:defaultValue="auto" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory android:title="Virtual Controller">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="virtual_controller_checkbox_enable"
|
||||||
|
android:title="Enable virtual controller"
|
||||||
|
android:summary="Show virtual controller overlay on game screen"
|
||||||
|
android:defaultValue="true"/>
|
||||||
|
<Preference android:title="Site virtual controller items"
|
||||||
|
android:key="button_open_virtual_controller_configuration"
|
||||||
|
android:summary="tbd"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
Reference in New Issue
Block a user