You've already forked Shipwright-Android
mirror of
https://github.com/izzy2lost/Shipwright-Android.git
synced 2026-03-26 16:51:07 -07:00
Touch Controls
This commit is contained in:
+2
-2
@@ -17,7 +17,7 @@ android {
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 31
|
||||
versionCode 6
|
||||
versionName "1.2.2"
|
||||
versionName "1.3.0"
|
||||
externalNativeBuild {
|
||||
//ndkBuild {
|
||||
// arguments "APP_PLATFORM=android-23"
|
||||
@@ -75,7 +75,7 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.core:core:1.7.0' // Use the latest version
|
||||
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
|
||||
+1
-1
Submodule app/jni/src/libultraship updated: 43adc0d5a0...03e683e1d1
@@ -36,6 +36,24 @@ s32 Camera_UpdateWater(Camera* camera);
|
||||
|
||||
#include "z_camera_data.inc"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "jni.h"
|
||||
|
||||
float touchCameraYaw=0;
|
||||
float touchCameraPitch=0;
|
||||
|
||||
extern void JNICALL Java_com_dishii_soh_MainActivity_setCameraState(JNIEnv *env, jobject jobj, jint axis, jfloat value) {
|
||||
switch(axis){
|
||||
case 0:
|
||||
touchCameraYaw=value;
|
||||
break;
|
||||
case 1:
|
||||
touchCameraPitch=value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===============================================================*/
|
||||
|
||||
/**
|
||||
@@ -1422,6 +1440,11 @@ s32 SetCameraManual(Camera* camera) {
|
||||
f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f;
|
||||
f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
newCamX += -touchCameraYaw*10.0f;
|
||||
newCamY += touchCameraPitch*10.0f;
|
||||
#endif
|
||||
|
||||
if ((fabsf(newCamX) >= 15.0f || fabsf(newCamY) >= 15.0f) && camera->play->manualCamera == false) {
|
||||
camera->play->manualCamera = true;
|
||||
|
||||
@@ -1489,6 +1512,11 @@ s32 Camera_Free(Camera* camera) {
|
||||
f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVarGetFloat("gThirdPersonCameraSensitivityY", 1.0f));
|
||||
bool invertXAxis = (CVarGetInteger("gInvertXAxis", 0) && !CVarGetInteger("gMirroredWorld", 0)) || (!CVarGetInteger("gInvertXAxis", 0) && CVarGetInteger("gMirroredWorld", 0));
|
||||
|
||||
#ifdef __ANDROID__
|
||||
newCamX += -touchCameraYaw*10.0f;
|
||||
newCamY += touchCameraPitch*10.0f;
|
||||
#endif
|
||||
|
||||
camera->play->camX += newCamX * (invertXAxis ? -1 : 1);
|
||||
camera->play->camY += newCamY * (CVarGetInteger("gInvertYAxis", 1) ? 1 : -1);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dishii.soh"
|
||||
android:versionCode="6"
|
||||
android:versionName="1.2.2"
|
||||
android:versionName="1.3.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- OpenGL ES 3.0 -->
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.dishii.soh;
|
||||
|
||||
public class ControllerButtons {
|
||||
// Xbox Buttons
|
||||
public static final int BUTTON_A = 0;
|
||||
public static final int BUTTON_B = 1;
|
||||
public static final int BUTTON_X = 2;
|
||||
public static final int BUTTON_Y = 3;
|
||||
public static final int BUTTON_LB = 9; // Left Bumper
|
||||
public static final int BUTTON_RB = -5; // Right Bumper
|
||||
public static final int BUTTON_BACK = 4;
|
||||
public static final int BUTTON_START = 6;
|
||||
public static final int BUTTON_DPAD_UP = 11;
|
||||
public static final int BUTTON_DPAD_DOWN = 12;
|
||||
public static final int BUTTON_DPAD_LEFT = 13;
|
||||
public static final int BUTTON_DPAD_RIGHT = 14;
|
||||
|
||||
// Xbox Axis (Joysticks and Triggers)
|
||||
public static final int AXIS_LX = 0; // Left stick X
|
||||
public static final int AXIS_LY = 1; // Left stick Y
|
||||
public static final int AXIS_RX = 2; // Right stick X
|
||||
public static final int AXIS_RY = 3; // Right stick Y
|
||||
public static final int AXIS_LT = -2; // Left Trigger (negative axis)
|
||||
public static final int AXIS_RT = -4; // Right Trigger (negative axis)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@ import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.util.Log;
|
||||
|
||||
//This class is the main SDLActivity and just sets up a bunch of default files
|
||||
@@ -25,10 +32,15 @@ public class MainActivity extends SDLActivity{
|
||||
|
||||
private static final int STORAGE_PERMISSION_REQUEST_CODE = 1;
|
||||
|
||||
SharedPreferences preferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
preferences = getSharedPreferences("com.dishii.soh.prefs",Context.MODE_PRIVATE);
|
||||
|
||||
setupControllerOverlay();
|
||||
// Check if storage permissions are granted
|
||||
if (hasStoragePermission()) {
|
||||
doVersionCheck();
|
||||
@@ -36,10 +48,10 @@ public class MainActivity extends SDLActivity{
|
||||
} else {
|
||||
requestStoragePermission();
|
||||
}
|
||||
attachController();
|
||||
}
|
||||
|
||||
private void doVersionCheck(){
|
||||
SharedPreferences preferences = getSharedPreferences("com.dishii.soh.prefs",Context.MODE_PRIVATE);
|
||||
int currentVersion = BuildConfig.VERSION_CODE; // Use your app's version code
|
||||
int storedVersion = preferences.getInt("appVersion", 1);
|
||||
|
||||
@@ -186,4 +198,285 @@ public class MainActivity extends SDLActivity{
|
||||
return Environment.MEDIA_MOUNTED.equals(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public native void attachController();
|
||||
public native void detachController();
|
||||
// Native method for setting button state
|
||||
public native void setButton(int button, boolean value);
|
||||
public native void setCameraState(int axis, float value);
|
||||
|
||||
// Native method for setting joystick axis value
|
||||
public native void setAxis(int axis, short value);
|
||||
|
||||
private Button button1, button2, button3, button4;
|
||||
private Button buttonA, buttonB, buttonX, buttonY;
|
||||
private Button buttonDpadUp, buttonDpadDown, buttonDpadLeft, buttonDpadRight;
|
||||
private Button buttonLB, buttonRB, buttonZ, buttonStart, buttonBack;
|
||||
private Button buttonToggle;
|
||||
private FrameLayout leftJoystick;
|
||||
private ImageView leftJoystickKnob;
|
||||
private View overlayView;
|
||||
|
||||
// Function to set up the controller overlay (inflate layout and initialize buttons)
|
||||
private void setupControllerOverlay() {
|
||||
// Inflate the touchcontrol_overlay layout
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
overlayView = inflater.inflate(R.layout.touchcontrol_overlay, null);
|
||||
|
||||
// Set layout params for overlayView to control positioning and sizing
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
overlayView.setLayoutParams(layoutParams);
|
||||
// Add overlay view to the main layout (you may need to add it to a container like FrameLayout)
|
||||
ViewGroup view = (ViewGroup) getContentView();
|
||||
view.addView(overlayView);
|
||||
|
||||
final ViewGroup buttonGroup = overlayView.findViewById(R.id.button_group);
|
||||
|
||||
buttonA = overlayView.findViewById(R.id.buttonA);
|
||||
buttonB = overlayView.findViewById(R.id.buttonB);
|
||||
buttonX = overlayView.findViewById(R.id.buttonX);
|
||||
buttonY = overlayView.findViewById(R.id.buttonY);
|
||||
|
||||
buttonDpadUp = overlayView.findViewById(R.id.buttonDpadUp);
|
||||
buttonDpadDown = overlayView.findViewById(R.id.buttonDpadDown);
|
||||
buttonDpadLeft = overlayView.findViewById(R.id.buttonDpadLeft);
|
||||
buttonDpadRight = overlayView.findViewById(R.id.buttonDpadRight);
|
||||
|
||||
buttonLB = overlayView.findViewById(R.id.buttonLB);
|
||||
buttonRB = overlayView.findViewById(R.id.buttonRB);
|
||||
buttonZ = overlayView.findViewById(R.id.buttonZ);
|
||||
|
||||
buttonStart = overlayView.findViewById(R.id.buttonStart);
|
||||
buttonBack = overlayView.findViewById(R.id.buttonBack);
|
||||
|
||||
buttonToggle = overlayView.findViewById(R.id.buttonToggle);
|
||||
|
||||
// Initialize joysticks and joystick knobs from the inflated layout
|
||||
leftJoystick = overlayView.findViewById(R.id.left_joystick);
|
||||
leftJoystickKnob = overlayView.findViewById(R.id.left_joystick_knob);
|
||||
|
||||
FrameLayout rightScreenArea = overlayView.findViewById(R.id.right_screen_area);
|
||||
|
||||
// Set OnTouchListeners for the Xbox controller buttons
|
||||
addTouchListener(buttonA, ControllerButtons.BUTTON_A); // SDL Button 0 (A)
|
||||
addTouchListener(buttonB, ControllerButtons.BUTTON_B); // SDL Button 1 (B)
|
||||
addTouchListener(buttonX, ControllerButtons.BUTTON_X); // SDL Button 2 (X)
|
||||
addTouchListener(buttonY, ControllerButtons.BUTTON_Y); // SDL Button 3 (Y)
|
||||
|
||||
setupCButtons(buttonDpadUp, ControllerButtons.AXIS_RY, 1); // SDL Button 10 (D-Pad Up)
|
||||
setupCButtons(buttonDpadDown, ControllerButtons.AXIS_RY , -1); // SDL Button 11 (D-Pad Down)
|
||||
setupCButtons(buttonDpadLeft, ControllerButtons.AXIS_RX, 1); // SDL Button 12 (D-Pad Left)
|
||||
setupCButtons(buttonDpadRight, ControllerButtons.AXIS_RX, -1); // SDL Button 13 (D-Pad Right)
|
||||
|
||||
addTouchListener(buttonLB, ControllerButtons.BUTTON_LB); // SDL Button 4 (LB)
|
||||
addTouchListener(buttonRB, ControllerButtons.BUTTON_RB); // SDL Button 5 (RB)
|
||||
addTouchListener(buttonZ, ControllerButtons.AXIS_RT); // SDL Button 5 (Z)
|
||||
|
||||
addTouchListener(buttonStart, ControllerButtons.BUTTON_START); // SDL Button 7 (Start)
|
||||
addTouchListener(buttonBack, ControllerButtons.BUTTON_BACK); // SDL Button 6 (Back)
|
||||
|
||||
|
||||
// Setup joystick movement
|
||||
setupJoystick(leftJoystick, leftJoystickKnob, true); // Left joystick
|
||||
|
||||
setupLookAround(rightScreenArea);
|
||||
|
||||
setupToggleButton(buttonToggle,buttonGroup);
|
||||
|
||||
}
|
||||
|
||||
private void setupToggleButton(Button button, ViewGroup uiGroup){
|
||||
boolean isHidden = preferences.getBoolean("controlsVisible", false); // Default to 'false' (visible)
|
||||
uiGroup.setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE); // Set the initial visibility based on the saved state
|
||||
/*if(isHidden){
|
||||
detachController();
|
||||
}*/
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
boolean isHidden = false;
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isHidden) {
|
||||
uiGroup.setVisibility(View.VISIBLE); // Show UI elements
|
||||
//attachController();
|
||||
} else {
|
||||
uiGroup.setVisibility(View.INVISIBLE); // Hide UI elements
|
||||
//detachController();
|
||||
}
|
||||
preferences.edit().putBoolean("controlsVisible", !isHidden).apply();
|
||||
isHidden = !isHidden; // Toggle state
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to set a touch listener for each button
|
||||
private void addTouchListener(Button button, int buttonNum) {
|
||||
button.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
setButton(buttonNum, true);
|
||||
button.setPressed(true);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
setButton(buttonNum, false);
|
||||
button.setPressed(false);
|
||||
return true;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
setButton(buttonNum, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupCButtons(Button button, int buttonNum, int direction) {
|
||||
button.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
setAxis(buttonNum, direction<0 ? Short.MAX_VALUE : Short.MIN_VALUE);
|
||||
button.setPressed(true);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
setAxis(buttonNum, (short) 0);
|
||||
button.setPressed(false);
|
||||
return true;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
setAxis(buttonNum, (short) 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean TouchAreaEnabled = true;
|
||||
|
||||
void DisableTouchArea(){
|
||||
TouchAreaEnabled = false;
|
||||
}
|
||||
void EnableTouchArea(){
|
||||
TouchAreaEnabled = true;
|
||||
}
|
||||
|
||||
private void setupLookAround(FrameLayout rightScreenArea) {
|
||||
rightScreenArea.setOnTouchListener(new View.OnTouchListener() {
|
||||
private float lastX = 0;
|
||||
private float lastY = 0;
|
||||
private boolean isTouching = false;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// Start tracking the finger's position
|
||||
lastX = event.getX();
|
||||
lastY = event.getY();
|
||||
isTouching = true;
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (isTouching) {
|
||||
// Calculate the change in position (delta)
|
||||
float deltaX = event.getX() - lastX;
|
||||
float deltaY = event.getY() - lastY;
|
||||
|
||||
// Update the last position
|
||||
lastX = event.getX();
|
||||
lastY = event.getY();
|
||||
|
||||
// Increase sensitivity by using a larger multiplier
|
||||
// Adjust these multipliers to suit your needs
|
||||
float sensitivityMultiplier = 15; // Higher value for more sensitivity
|
||||
float rx = (deltaX * sensitivityMultiplier);
|
||||
float ry = (deltaY * sensitivityMultiplier);
|
||||
|
||||
// Send the mapped values to the joystick axes
|
||||
setCameraState(0, rx); // Right stick X axis
|
||||
setCameraState(1, ry); // Right stick Y axis
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
// Stop tracking the finger's position and reset joystick input
|
||||
isTouching = false;
|
||||
setCameraState(0, 0.0f); // Reset right stick X axis
|
||||
setCameraState(1, 0.0f); // Reset right stick Y axis
|
||||
break;
|
||||
}
|
||||
return TouchAreaEnabled; // Event full handled
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Function to set joystick movement with reset to center when not touched
|
||||
private void setupJoystick(FrameLayout joystickLayout, ImageView joystickKnob, boolean isLeft) {
|
||||
joystickLayout.post(() -> {
|
||||
// Calculate the joystick center once, before any events
|
||||
final float joystickCenterX = joystickLayout.getWidth() / 2f;
|
||||
final float joystickCenterY = joystickLayout.getHeight() / 2f;
|
||||
|
||||
joystickLayout.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// Calculate the joystick movement and move the knob
|
||||
float deltaX = event.getX() - joystickCenterX;
|
||||
float deltaY = event.getY() - joystickCenterY;
|
||||
|
||||
// Clamp the joystick movement to prevent it from going outside the area
|
||||
float maxRadius = joystickLayout.getWidth() / 2f - joystickKnob.getWidth() / 2f;
|
||||
float distance = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
if (distance > maxRadius) {
|
||||
float scale = maxRadius / distance;
|
||||
deltaX *= scale;
|
||||
deltaY *= scale;
|
||||
}
|
||||
|
||||
joystickKnob.setX(joystickCenterX + deltaX - joystickKnob.getWidth() / 2f);
|
||||
joystickKnob.setY(joystickCenterY + deltaY - joystickKnob.getHeight() / 2f);
|
||||
|
||||
// Send joystick values to native C code
|
||||
short x = (short) (deltaX / maxRadius * Short.MAX_VALUE);
|
||||
short y = (short) (deltaY / maxRadius * Short.MAX_VALUE);
|
||||
|
||||
// Send X-axis and Y-axis values
|
||||
setAxis(isLeft ? ControllerButtons.AXIS_LX : ControllerButtons.AXIS_RX, x); // X-axis
|
||||
setAxis(isLeft ? ControllerButtons.AXIS_LY : ControllerButtons.AXIS_RY, y); // Y-axis
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
// Reset joystick knob to the center position (ensure it's placed correctly)
|
||||
joystickKnob.setX(joystickCenterX - joystickKnob.getWidth() / 2f);
|
||||
joystickKnob.setY(joystickCenterY - joystickKnob.getHeight() / 2f);
|
||||
|
||||
// Reset joystick values to 0 when released or canceled
|
||||
setAxis(isLeft ? ControllerButtons.AXIS_LX : ControllerButtons.AXIS_RX, (short) 0); // X-axis
|
||||
setAxis(isLeft ? ControllerButtons.AXIS_LY : ControllerButtons.AXIS_RY, (short) 0); // Y-axis
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Pressed state -->
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#10FFFFFF" /> <!-- Darker color when pressed -->
|
||||
<stroke
|
||||
android:width="2.5dp"
|
||||
android:color="#20FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<!-- Default state -->
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#20FFFFFF" />
|
||||
<stroke
|
||||
android:width="2.5dp"
|
||||
android:color="#25FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,19 @@
|
||||
<vector android:alpha="1.0" android:height="221.78dp"
|
||||
android:viewportHeight="221.78" android:viewportWidth="221.78"
|
||||
android:width="221.78dp"
|
||||
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillAlpha="1.0"
|
||||
android:fillColor="#20FFFFFF"
|
||||
android:pathData="M221.78,87.07v47.64a11.53,11.53 0,0 1,-11.5 11.5H151.62a5.42,5.42 0,0 0,-5.41 5.41v58.66a11.53,11.53 0,0 1,-11.5 11.5H87.07a11.53,11.53 0,0 1,-11.5 -11.5V151.61a5.41,5.41 0,0 0,-5.41 -5.41H11.5A11.53,11.53 0,0 1,0 134.7V87.05a11.53,11.53 0,0 1,11.5 -11.5H70.16a5.41,5.41 0,0 0,5.41 -5.41V11.5A11.53,11.53 0,0 1,87.07 0h47.64a11.53,11.53 0,0 1,11.5 11.5V70.16a5.41,5.41 0,0 0,5.41 5.41h58.66A11.53,11.53 0,0 1,221.78 87.07Z"
|
||||
android:strokeWidth="2.5"
|
||||
android:strokeColor="#25FFFFFF"
|
||||
android:strokeAlpha="1.0" />
|
||||
<path android:fillColor="#25FFFFFF" android:fillAlpha="1.0"
|
||||
android:pathData="M195.47,110.32l-16.26,-9.38a0.65,0.65 0,0 0,-1 0.56v18.78a0.66,0.66 0,0 0,1 0.57l16.26,-9.39A0.66,0.66 0,0 0,195.47 110.32Z" />
|
||||
<path android:fillColor="#25FFFFFF" android:fillAlpha="1.0"
|
||||
android:pathData="M26.31,110.32l16.26,-9.38a0.65,0.65 0,0 1,1 0.56v18.78a0.66,0.66 0,0 1,-1 0.57l-16.26,-9.39A0.66,0.66 0,0 1,26.31 110.32Z" />
|
||||
<path android:fillColor="#25FFFFFF" android:fillAlpha="1.0"
|
||||
android:pathData="M110.32,26.31l-9.38,16.26a0.65,0.65 0,0 0,0.56 1h18.78a0.66,0.66 0,0 0,0.57 -1l-9.39,-16.26A0.66,0.66 0,0 0,110.32 26.31Z" />
|
||||
<path android:fillColor="#25FFFFFF" android:fillAlpha="1.0"
|
||||
android:pathData="M110.32,195.47l-9.38,-16.26a0.65,0.65 0,0 1,0.56 -1h18.78a0.66,0.66 0,0 1,0.57 1l-9.39,16.26A0.66,0.66 0,0 1,110.32 195.47Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Pressed state -->
|
||||
<item android:state_pressed="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#10FFFFFF" /> <!-- Darker color when pressed -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
<!-- Default state -->
|
||||
<item>
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#20FFFFFF" /> <!-- Default color -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#20FFFFFF"
|
||||
android:pathData="M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#10FFFFFF" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<padding
|
||||
android:bottom="10dp"
|
||||
android:left="10dp"
|
||||
android:right="10dp"
|
||||
android:top="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#30000000" />
|
||||
<size
|
||||
android:width="30dp"
|
||||
android:height="30dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Pressed state -->
|
||||
<item android:state_pressed="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#10FFFFFF" /> <!-- Darker color when pressed -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners
|
||||
android:bottomLeftRadius="10dp"
|
||||
android:bottomRightRadius="10dp"
|
||||
android:topLeftRadius="50dp"
|
||||
android:topRightRadius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
<!-- Default state -->
|
||||
<item>
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#20FFFFFF" /> <!-- Default color -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners
|
||||
android:bottomLeftRadius="10dp"
|
||||
android:bottomRightRadius="10dp"
|
||||
android:topLeftRadius="50dp"
|
||||
android:topRightRadius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Pressed state -->
|
||||
<item android:state_pressed="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#10FFFFFF" /> <!-- Darker color when pressed -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners
|
||||
android:bottomLeftRadius="10dp"
|
||||
android:bottomRightRadius="10dp"
|
||||
android:topLeftRadius="10dp"
|
||||
android:topRightRadius="50dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
<!-- Default state -->
|
||||
<item>
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#20FFFFFF" /> <!-- Default color -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#25FFFFFF" />
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<corners
|
||||
android:bottomLeftRadius="10dp"
|
||||
android:bottomRightRadius="10dp"
|
||||
android:topLeftRadius="10dp"
|
||||
android:topRightRadius="50dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,213 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<!-- New Grouping Layout -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/button_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- Left Joystick -->
|
||||
<FrameLayout
|
||||
android:id="@+id/left_joystick"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@drawable/ic_stick"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/left_joystick_knob"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/ic_button" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_screen_area"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/left_joystick"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/ic_cross"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/buttonDpadDown"
|
||||
app:layout_constraintEnd_toEndOf="@+id/buttonDpadRight"
|
||||
app:layout_constraintStart_toStartOf="@+id/buttonDpadLeft"
|
||||
app:layout_constraintTop_toTopOf="@+id/buttonDpadUp" />
|
||||
|
||||
<!-- D-Pad -->
|
||||
<Button
|
||||
android:id="@+id/buttonDpadUp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/buttonDpadRight"
|
||||
app:layout_constraintEnd_toStartOf="@id/buttonDpadRight"
|
||||
android:background="@android:color/transparent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonDpadDown"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
app:layout_constraintStart_toEndOf="@id/buttonDpadLeft"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttonDpadLeft"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonDpadLeft"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="60dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/left_joystick"
|
||||
app:layout_constraintEnd_toEndOf="@id/left_joystick"
|
||||
app:layout_constraintStart_toStartOf="@id/left_joystick"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttonLB"
|
||||
android:background="@android:color/transparent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonDpadRight"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/buttonDpadDown"
|
||||
app:layout_constraintStart_toEndOf="@id/buttonDpadDown"
|
||||
android:background="@android:color/transparent"/>
|
||||
|
||||
<!-- Action Buttons (A, B, X, Y) -->
|
||||
<Button
|
||||
android:id="@+id/buttonB"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/ic_button"
|
||||
android:text="B"
|
||||
app:layout_constraintEnd_toStartOf="@id/buttonA"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttonA"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonA"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:background="@drawable/ic_button"
|
||||
android:text="A"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttonZ"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonY"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/ic_button"
|
||||
android:text="Y"
|
||||
app:layout_constraintBottom_toTopOf="@id/buttonB"
|
||||
app:layout_constraintEnd_toStartOf="@id/buttonB"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonX"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/ic_button"
|
||||
android:text="X"
|
||||
app:layout_constraintBottom_toTopOf="@id/buttonA"
|
||||
app:layout_constraintEnd_toStartOf="@id/buttonA"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<!-- Shoulder Buttons -->
|
||||
<Button
|
||||
android:id="@+id/buttonLB"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/ic_trigger_button_left"
|
||||
android:text="L"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonRB"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/ic_trigger_button_right"
|
||||
android:text="R"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonZ"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/ic_trigger_button_right"
|
||||
android:text="Z"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttonRB"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<!-- Start and Back Buttons -->
|
||||
<Button
|
||||
android:id="@+id/buttonBack"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="100dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/ic_rectangular_button"
|
||||
android:text="Back"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonStart"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="100dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/ic_rectangular_button"
|
||||
android:text="Start"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- Toggle Button -->
|
||||
<Button
|
||||
android:id="@+id/buttonToggle"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/ic_show"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user