mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-22 04:22:45 +00:00
Android Studio auto-reformat of new virtual controller code
This commit is contained in:
parent
b6bd48584f
commit
2736bd9165
@ -18,13 +18,21 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class AnalogStick extends VirtualControllerElement {
|
public class AnalogStick extends VirtualControllerElement {
|
||||||
|
|
||||||
/** outer radius size in percent of the ui element */
|
/**
|
||||||
|
* outer radius size in percent of the ui element
|
||||||
|
*/
|
||||||
public static final int SIZE_RADIUS_COMPLETE = 90;
|
public static final int SIZE_RADIUS_COMPLETE = 90;
|
||||||
/** analog stick size in percent of the ui element */
|
/**
|
||||||
|
* analog stick size in percent of the ui element
|
||||||
|
*/
|
||||||
public static final int SIZE_RADIUS_ANALOG_STICK = 90;
|
public static final int SIZE_RADIUS_ANALOG_STICK = 90;
|
||||||
/** dead zone size in percent of the ui element */
|
/**
|
||||||
|
* dead zone size in percent of the ui element
|
||||||
|
*/
|
||||||
public static final int SIZE_RADIUS_DEADZONE = 90;
|
public static final int SIZE_RADIUS_DEADZONE = 90;
|
||||||
/** time frame for a double click */
|
/**
|
||||||
|
* time frame for a double click
|
||||||
|
*/
|
||||||
public final static long timeoutDoubleClick = 250;
|
public final static long timeoutDoubleClick = 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +42,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* onMovement event will be fired on real analog stick movement (outside of the deadzone).
|
* onMovement event will be fired on real analog stick movement (outside of the deadzone).
|
||||||
|
*
|
||||||
* @param x horizontal position, value from -1.0 ... 0 .. 1.0
|
* @param x horizontal position, value from -1.0 ... 0 .. 1.0
|
||||||
* @param y vertical position, value from -1.0 ... 0 .. 1.0
|
* @param y vertical position, value from -1.0 ... 0 .. 1.0
|
||||||
*/
|
*/
|
||||||
@ -73,19 +82,31 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
DOUBLE
|
DOUBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/** configuration if the analog stick should be displayed as circle or square*/
|
/**
|
||||||
|
* configuration if the analog stick should be displayed as circle or square
|
||||||
|
*/
|
||||||
private boolean circle_stick = true; // TODO: implement square sick for simulations
|
private boolean circle_stick = true; // TODO: implement square sick for simulations
|
||||||
|
|
||||||
/** outer radius, this size will be automatically updated on resize */
|
/**
|
||||||
|
* outer radius, this size will be automatically updated on resize
|
||||||
|
*/
|
||||||
private float radius_complete = 0;
|
private float radius_complete = 0;
|
||||||
/** analog stick radius, this size will be automatically updated on resize */
|
/**
|
||||||
|
* analog stick radius, this size will be automatically updated on resize
|
||||||
|
*/
|
||||||
private float radius_analog_stick = 0;
|
private float radius_analog_stick = 0;
|
||||||
/** dead zone radius, this size will be automatically updated on resize */
|
/**
|
||||||
|
* dead zone radius, this size will be automatically updated on resize
|
||||||
|
*/
|
||||||
private float radius_dead_zone = 0;
|
private float radius_dead_zone = 0;
|
||||||
|
|
||||||
/** horizontal position in relation to the center of the element */
|
/**
|
||||||
|
* horizontal position in relation to the center of the element
|
||||||
|
*/
|
||||||
private float relative_x = 0;
|
private float relative_x = 0;
|
||||||
/** vertical position in relation to the center of the element */
|
/**
|
||||||
|
* vertical position in relation to the center of the element
|
||||||
|
*/
|
||||||
private float relative_y = 0;
|
private float relative_y = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ public class DigitalButton extends VirtualControllerElement {
|
|||||||
|
|
||||||
private void checkMovementForAllButtons(float x, float y) {
|
private void checkMovementForAllButtons(float x, float y) {
|
||||||
for (VirtualControllerElement element : virtualController.getElements()) {
|
for (VirtualControllerElement element : virtualController.getElements()) {
|
||||||
if (element != this && element instanceof DigitalButton){
|
if (element != this && element instanceof DigitalButton) {
|
||||||
((DigitalButton)element).checkMovement(x, y, this);
|
((DigitalButton) element).checkMovement(x, y, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,20 @@ public class LeftTrigger extends DigitalButton {
|
|||||||
public void onClick() {
|
public void onClick() {
|
||||||
VirtualController.ControllerInputContext inputContext =
|
VirtualController.ControllerInputContext inputContext =
|
||||||
controller.getControllerInputContext();
|
controller.getControllerInputContext();
|
||||||
inputContext.leftTrigger = (byte)0xFF;
|
inputContext.leftTrigger = (byte) 0xFF;
|
||||||
|
|
||||||
controller.sendControllerInputContext();
|
controller.sendControllerInputContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLongClick() {}
|
public void onLongClick() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRelease() {
|
public void onRelease() {
|
||||||
VirtualController.ControllerInputContext inputContext =
|
VirtualController.ControllerInputContext inputContext =
|
||||||
controller.getControllerInputContext();
|
controller.getControllerInputContext();
|
||||||
inputContext.leftTrigger = (byte)0x00;
|
inputContext.leftTrigger = (byte) 0x00;
|
||||||
|
|
||||||
controller.sendControllerInputContext();
|
controller.sendControllerInputContext();
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,20 @@ public class RightTrigger extends DigitalButton {
|
|||||||
public void onClick() {
|
public void onClick() {
|
||||||
VirtualController.ControllerInputContext inputContext =
|
VirtualController.ControllerInputContext inputContext =
|
||||||
controller.getControllerInputContext();
|
controller.getControllerInputContext();
|
||||||
inputContext.rightTrigger = (byte)0xFF;
|
inputContext.rightTrigger = (byte) 0xFF;
|
||||||
|
|
||||||
controller.sendControllerInputContext();
|
controller.sendControllerInputContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLongClick() {}
|
public void onLongClick() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRelease() {
|
public void onRelease() {
|
||||||
VirtualController.ControllerInputContext inputContext =
|
VirtualController.ControllerInputContext inputContext =
|
||||||
controller.getControllerInputContext();
|
controller.getControllerInputContext();
|
||||||
inputContext.rightTrigger = (byte)0x00;
|
inputContext.rightTrigger = (byte) 0x00;
|
||||||
|
|
||||||
controller.sendControllerInputContext();
|
controller.sendControllerInputContext();
|
||||||
}
|
}
|
||||||
|
@ -110,11 +110,11 @@ public class VirtualController {
|
|||||||
VirtualControllerConfigurationLoader.createDefaultLayout(this, context);
|
VirtualControllerConfigurationLoader.createDefaultLayout(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerMode getControllerMode () {
|
public ControllerMode getControllerMode() {
|
||||||
return currentMode;
|
return currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerInputContext getControllerInputContext () {
|
public ControllerInputContext getControllerInputContext() {
|
||||||
return inputContext;
|
return inputContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class VirtualControllerConfigurationLoader {
|
public class VirtualControllerConfigurationLoader {
|
||||||
private static final String PROFILE_PATH = "profiles";
|
private static final String PROFILE_PATH = "profiles";
|
||||||
|
|
||||||
private static int getPercent(
|
private static int getPercent(
|
||||||
int percent,
|
int percent,
|
||||||
int total) {
|
int total) {
|
||||||
|
@ -46,8 +46,8 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void moveElement(int pressed_x, int pressed_y, int x, int y) {
|
protected void moveElement(int pressed_x, int pressed_y, int x, int y) {
|
||||||
int newPos_x = (int)getX() + x - pressed_x;
|
int newPos_x = (int) getX() + x - pressed_x;
|
||||||
int newPos_y = (int)getY() + y - pressed_y;
|
int newPos_y = (int) getY() + y - pressed_y;
|
||||||
|
|
||||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
AlertDialog alert = alertBuilder.create();
|
AlertDialog alert = alertBuilder.create();
|
||||||
// show menu
|
// show menu
|
||||||
alert.show();
|
alert.show();
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,6 +245,7 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void onElementDraw(Canvas canvas);
|
abstract protected void onElementDraw(Canvas canvas);
|
||||||
|
|
||||||
abstract public boolean onElementTouchEvent(MotionEvent event);
|
abstract public boolean onElementTouchEvent(MotionEvent event);
|
||||||
|
|
||||||
protected static final void _DBG(String text) {
|
protected static final void _DBG(String text) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user