mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 22:31:35 +00:00
add virtual controller configuration screen
This commit is contained in:
@@ -70,6 +70,12 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.limelight.Connection" />
|
||||
</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
|
||||
android:name=".discovery.DiscoveryService"
|
||||
android:label="mDNS PC Auto-Discovery Service" />
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.limelight.utils.UiHelper;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
+76
-4
@@ -20,7 +20,7 @@ import com.limelight.nvstream.input.ControllerPacket;
|
||||
*/
|
||||
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)
|
||||
{
|
||||
@@ -74,6 +74,8 @@ public class VirtualController
|
||||
private AnalogStick stick = null;
|
||||
private AnalogStick stick2 = null;
|
||||
|
||||
private boolean configuration = false;
|
||||
|
||||
NvConnection connection = null;
|
||||
|
||||
private int getPercentageV(int percent)
|
||||
@@ -401,13 +403,81 @@ public class VirtualController
|
||||
});
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
_DBG("INPUT_MAP + " + inputMap);
|
||||
_DBG("LEFT_TRIGGER " + leftTrigger);
|
||||
_DBG("RIGHT_TRIGGER " + rightTrigger);
|
||||
@@ -415,10 +485,12 @@ public class VirtualController
|
||||
_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);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
+47
@@ -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;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
@@ -8,6 +9,8 @@ import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
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;
|
||||
|
||||
public class StreamSettings extends Activity {
|
||||
@@ -49,6 +52,19 @@ public class StreamSettings extends Activity {
|
||||
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:defaultValue="auto" />
|
||||
</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>
|
||||
Reference in New Issue
Block a user