mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
fix digital button/pad mouse movement, add selct & start button
This commit is contained in:
parent
1c9458d056
commit
1d6b7e1b2e
@ -104,7 +104,7 @@ public class DigitalButton extends View
|
|||||||
|
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawText(text,
|
canvas.drawText(text,
|
||||||
getPercent(getWidth(), 50), getPercent(getHeight(), 75),
|
getPercent(getWidth(), 50), getPercent(getHeight(), 73),
|
||||||
paint);
|
paint);
|
||||||
|
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
@ -173,6 +173,6 @@ public class DigitalButton extends View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onTouchEvent(event);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class DigitalPad extends View
|
|||||||
paint.setColor((direction & DIGITAL_PAD_DIRECTION_LEFT) > 0 ? pressedColor : normalColor);
|
paint.setColor((direction & DIGITAL_PAD_DIRECTION_LEFT) > 0 ? pressedColor : normalColor);
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawText("LF",
|
canvas.drawText("LF",
|
||||||
getPercent(getWidth(), 16.5f), getPercent(getHeight(), 58),
|
getPercent(getWidth(), 16.5f), getPercent(getHeight(), 56),
|
||||||
paint);
|
paint);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
@ -131,7 +131,7 @@ public class DigitalPad extends View
|
|||||||
paint.setColor((direction & DIGITAL_PAD_DIRECTION_UP) > 0 ? pressedColor : normalColor);
|
paint.setColor((direction & DIGITAL_PAD_DIRECTION_UP) > 0 ? pressedColor : normalColor);
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawText("UP",
|
canvas.drawText("UP",
|
||||||
getPercent(getWidth(), 49.5f), getPercent(getHeight(), 25),
|
getPercent(getWidth(), 49.5f), getPercent(getHeight(), 23),
|
||||||
paint);
|
paint);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
@ -157,7 +157,7 @@ public class DigitalPad extends View
|
|||||||
paint.setColor((direction & DIGITAL_PAD_DIRECTION_RIGHT) > 0 ? pressedColor : normalColor);
|
paint.setColor((direction & DIGITAL_PAD_DIRECTION_RIGHT) > 0 ? pressedColor : normalColor);
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawText("RI",
|
canvas.drawText("RI",
|
||||||
getPercent(getWidth(), 82.5f), getPercent(getHeight(), 58),
|
getPercent(getWidth(), 82.5f), getPercent(getHeight(), 56),
|
||||||
paint);
|
paint);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
@ -183,7 +183,7 @@ public class DigitalPad extends View
|
|||||||
paint.setColor((direction & DIGITAL_PAD_DIRECTION_DOWN) > 0 ? pressedColor : normalColor);
|
paint.setColor((direction & DIGITAL_PAD_DIRECTION_DOWN) > 0 ? pressedColor : normalColor);
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawText("DW",
|
canvas.drawText("DW",
|
||||||
getPercent(getWidth(), 49.5f), getPercent(getHeight(), 91),
|
getPercent(getWidth(), 49.5f), getPercent(getHeight(), 89),
|
||||||
paint);
|
paint);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
@ -280,6 +280,6 @@ public class DigitalPad extends View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onTouchEvent(event);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.limelight.binding.input.virtual_controller;
|
package com.limelight.binding.input.virtual_controller;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
@ -16,7 +14,7 @@ import com.limelight.nvstream.input.ControllerPacket;
|
|||||||
*/
|
*/
|
||||||
public class VirtualController
|
public class VirtualController
|
||||||
{
|
{
|
||||||
private static final boolean _PRINT_DEBUG_INFORMATION = true;
|
private static final boolean _PRINT_DEBUG_INFORMATION = false;
|
||||||
|
|
||||||
private static final void _DBG(String text)
|
private static final void _DBG(String text)
|
||||||
{
|
{
|
||||||
@ -37,6 +35,10 @@ public class VirtualController
|
|||||||
private FrameLayout frame_layout = null;
|
private FrameLayout frame_layout = null;
|
||||||
private RelativeLayout relative_layout = null;
|
private RelativeLayout relative_layout = null;
|
||||||
|
|
||||||
|
private RelativeLayout.LayoutParams layoutParamsButtonStart = null;
|
||||||
|
private RelativeLayout.LayoutParams layoutParamsButtonSelect = null;
|
||||||
|
// private RelativeLayout.LayoutParams layoutParamsButtonEscape = null;
|
||||||
|
|
||||||
private RelativeLayout.LayoutParams layoutParamsDPad = null;
|
private RelativeLayout.LayoutParams layoutParamsDPad = null;
|
||||||
|
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonA = null;
|
private RelativeLayout.LayoutParams layoutParamsButtonA = null;
|
||||||
@ -51,13 +53,9 @@ public class VirtualController
|
|||||||
private RelativeLayout.LayoutParams layoutParamsParamsStick = null;
|
private RelativeLayout.LayoutParams layoutParamsParamsStick = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsParamsStick2 = null;
|
private RelativeLayout.LayoutParams layoutParamsParamsStick2 = null;
|
||||||
|
|
||||||
// configuration
|
private DigitalButton buttonStart = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonOpenColorPickerNormal = null;
|
private DigitalButton buttonSelect = null;
|
||||||
private RelativeLayout.LayoutParams layoutParamsButtonOpenColorPickerPressed = null;
|
// private DigitalButton buttonEscape = null;
|
||||||
|
|
||||||
private Button buttonStart = null;
|
|
||||||
private Button buttonSelect = null;
|
|
||||||
private Button buttonESC = null;
|
|
||||||
|
|
||||||
private DigitalPad digitalPad = null;
|
private DigitalPad digitalPad = null;
|
||||||
|
|
||||||
@ -73,8 +71,6 @@ public class VirtualController
|
|||||||
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)
|
||||||
@ -87,11 +83,11 @@ public class VirtualController
|
|||||||
return (int)(((float)frame_layout.getWidth() / (float)100) * (float)percent);
|
return (int)(((float)frame_layout.getWidth() / (float)100) * (float)percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPercentilePosition(RelativeLayout.LayoutParams parm, int pos_x, int pos_y)
|
private void setPercentilePosition(RelativeLayout.LayoutParams parm, float pos_x, float pos_y)
|
||||||
{
|
{
|
||||||
parm.setMargins(
|
parm.setMargins(
|
||||||
(int)(((float)frame_layout.getWidth() / (float)100 * (float)pos_x) - ((float)parm.width / (float)2)),
|
(int)(((float)frame_layout.getWidth() / (float)100 * pos_x) - ((float)parm.width / (float)2)),
|
||||||
(int)(((float)frame_layout.getHeight() / (float)100 * (float)pos_y) - ((float)parm.height / (float)2)),
|
(int)(((float)frame_layout.getHeight() / (float)100 * pos_y) - ((float)parm.height / (float)2)),
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
@ -116,6 +112,9 @@ public class VirtualController
|
|||||||
layoutParamsButtonLB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonLB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
layoutParamsButtonRB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
layoutParamsButtonRB = new RelativeLayout.LayoutParams(getPercentageV(10), getPercentageV(10));
|
||||||
|
|
||||||
|
layoutParamsButtonStart = new RelativeLayout.LayoutParams(getPercentageH(12), getPercentageV(8));
|
||||||
|
layoutParamsButtonSelect = new RelativeLayout.LayoutParams(getPercentageH(12), getPercentageV(8));
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsDPad, 10, 35);
|
setPercentilePosition(layoutParamsDPad, 10, 35);
|
||||||
|
|
||||||
setPercentilePosition(layoutParamsParamsStick, 22, 78);
|
setPercentilePosition(layoutParamsParamsStick, 22, 78);
|
||||||
@ -132,6 +131,10 @@ public class VirtualController
|
|||||||
setPercentilePosition(layoutParamsButtonLB, 85, 28);
|
setPercentilePosition(layoutParamsButtonLB, 85, 28);
|
||||||
setPercentilePosition(layoutParamsButtonRB, 92, 23);
|
setPercentilePosition(layoutParamsButtonRB, 92, 23);
|
||||||
|
|
||||||
|
setPercentilePosition(layoutParamsButtonSelect, 43, 94);
|
||||||
|
setPercentilePosition(layoutParamsButtonStart, 57, 94);
|
||||||
|
|
||||||
|
|
||||||
relative_layout.addView(digitalPad, layoutParamsDPad);
|
relative_layout.addView(digitalPad, layoutParamsDPad);
|
||||||
|
|
||||||
relative_layout.addView(stick, layoutParamsParamsStick);
|
relative_layout.addView(stick, layoutParamsParamsStick);
|
||||||
@ -145,6 +148,9 @@ public class VirtualController
|
|||||||
relative_layout.addView(buttonRT, layoutParamsButtonRT);
|
relative_layout.addView(buttonRT, layoutParamsButtonRT);
|
||||||
relative_layout.addView(buttonLB, layoutParamsButtonLB);
|
relative_layout.addView(buttonLB, layoutParamsButtonLB);
|
||||||
relative_layout.addView(buttonRB, layoutParamsButtonRB);
|
relative_layout.addView(buttonRB, layoutParamsButtonRB);
|
||||||
|
|
||||||
|
relative_layout.addView(buttonSelect, layoutParamsButtonSelect);
|
||||||
|
relative_layout.addView(buttonStart, layoutParamsButtonStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DigitalButton createDigitalButton(String text, final int key, Context context)
|
private DigitalButton createDigitalButton(String text, final int key, Context context)
|
||||||
@ -309,70 +315,8 @@ public class VirtualController
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
refreshLayout();
|
buttonStart = createDigitalButton("START", ControllerPacket.PLAY_FLAG, context);
|
||||||
}
|
buttonSelect = createDigitalButton("SELECT", ControllerPacket.SPECIAL_BUTTON_FLAG, context);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
digitalPad = new DigitalPad(context);
|
|
||||||
|
|
||||||
buttonX = new DigitalButton(context);
|
|
||||||
buttonX.setText("X");
|
|
||||||
|
|
||||||
buttonY = new DigitalButton(context);
|
|
||||||
buttonY.setText("Y");
|
|
||||||
|
|
||||||
buttonA = new DigitalButton(context);
|
|
||||||
buttonA.setText("A");
|
|
||||||
|
|
||||||
buttonB = new DigitalButton(context);
|
|
||||||
buttonB.setText("B");
|
|
||||||
|
|
||||||
buttonLT = new DigitalButton(context);
|
|
||||||
buttonLT.setText("LT");
|
|
||||||
|
|
||||||
buttonRT = new DigitalButton(context);
|
|
||||||
buttonRT.setText("RT");
|
|
||||||
|
|
||||||
buttonLB = new DigitalButton(context);
|
|
||||||
buttonLB.setText("LB");
|
|
||||||
|
|
||||||
buttonRB = new DigitalButton(context);
|
|
||||||
buttonRB.setText("RB");
|
|
||||||
|
|
||||||
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();
|
refreshLayout();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.limelight.binding.input.virtual_controller;
|
package com.limelight.binding.input.virtual_controller;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@ -36,7 +37,7 @@ public class VirtualControllerConfiguration extends Activity
|
|||||||
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.configure_virtual_controller_frameLayout);
|
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.configure_virtual_controller_frameLayout);
|
||||||
|
|
||||||
// start with configuration constructor
|
// start with configuration constructor
|
||||||
virtualController = new VirtualController(frameLayout, getApplicationContext(), getWindowManager());
|
virtualController = new VirtualController(null, frameLayout, this, getWindowManager());
|
||||||
|
|
||||||
Toast.makeText(getApplicationContext(), "Not implemented yet!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Not implemented yet!", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user