mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-12 22:26:56 -04:00
Feat[joystick]: kdefault to disable forward lock, better lock display
This commit is contained in:
parent
3729230c42
commit
85f35cc5ee
@ -187,7 +187,7 @@ dependencies {
|
|||||||
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
|
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
|
||||||
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
|
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
|
||||||
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:eb92e3a5bb'
|
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:eb92e3a5bb'
|
||||||
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:231334e191'
|
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:cb7bf45ba5'
|
||||||
|
|
||||||
|
|
||||||
// implementation 'com.intuit.sdp:sdp-android:1.0.5'
|
// implementation 'com.intuit.sdp:sdp-android:1.0.5'
|
||||||
|
@ -12,6 +12,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||||||
|
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
|
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
|
||||||
|
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||||
import net.kdt.pojavlaunch.customcontrols.EditorExitable;
|
import net.kdt.pojavlaunch.customcontrols.EditorExitable;
|
||||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||||
@ -43,7 +44,7 @@ public class CustomControlsActivity extends BaseActivity implements EditorExitab
|
|||||||
switch(position) {
|
switch(position) {
|
||||||
case 0: mControlLayout.addControlButton(new ControlData("New")); break;
|
case 0: mControlLayout.addControlButton(new ControlData("New")); break;
|
||||||
case 1: mControlLayout.addDrawer(new ControlDrawerData()); break;
|
case 1: mControlLayout.addDrawer(new ControlDrawerData()); break;
|
||||||
case 2: mControlLayout.addJoystickButton(new ControlData()); break;
|
case 2: mControlLayout.addJoystickButton(new ControlJoystickData()); break;
|
||||||
case 3: mControlLayout.openLoadDialog(); break;
|
case 3: mControlLayout.openLoadDialog(); break;
|
||||||
case 4: mControlLayout.openSaveDialog(this); break;
|
case 4: mControlLayout.openSaveDialog(this); break;
|
||||||
case 5: mControlLayout.openSetDefaultDialog(); break;
|
case 5: mControlLayout.openSetDefaultDialog(); break;
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package net.kdt.pojavlaunch.customcontrols;
|
||||||
|
|
||||||
|
public class ControlJoystickData extends ControlData {
|
||||||
|
|
||||||
|
/* Whether the joystick can stay forward */
|
||||||
|
public boolean forwardLock = false;
|
||||||
|
|
||||||
|
public ControlJoystickData(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControlJoystickData(ControlData properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
}
|
@ -110,7 +110,7 @@ public class ControlLayout extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Joystick(s)
|
// Joystick(s)
|
||||||
for(ControlData joystick : mLayout.mJoystickDataList){
|
for(ControlJoystickData joystick : mLayout.mJoystickDataList){
|
||||||
addJoystickView(joystick);
|
addJoystickView(joystick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +196,12 @@ public class ControlLayout extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JOYSTICK BUTTON
|
// JOYSTICK BUTTON
|
||||||
public void addJoystickButton(ControlData data){
|
public void addJoystickButton(ControlJoystickData data){
|
||||||
mLayout.mJoystickDataList.add(data);
|
mLayout.mJoystickDataList.add(data);
|
||||||
addJoystickView(data);
|
addJoystickView(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addJoystickView(ControlData data){
|
private void addJoystickView(ControlJoystickData data){
|
||||||
addView(new ControlJoystick(this, data));
|
addView(new ControlJoystick(this, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,14 +13,14 @@ public class CustomControls {
|
|||||||
public float scaledAt;
|
public float scaledAt;
|
||||||
public List<ControlData> mControlDataList;
|
public List<ControlData> mControlDataList;
|
||||||
public List<ControlDrawerData> mDrawerDataList;
|
public List<ControlDrawerData> mDrawerDataList;
|
||||||
public List<ControlData> mJoystickDataList;
|
public List<ControlJoystickData> mJoystickDataList;
|
||||||
public CustomControls() {
|
public CustomControls() {
|
||||||
this(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
this(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CustomControls(List<ControlData> mControlDataList, List<ControlDrawerData> mDrawerDataList, List<ControlData> mJoystickDataList) {
|
public CustomControls(List<ControlData> mControlDataList, List<ControlDrawerData> mDrawerDataList, List<ControlJoystickData> mJoystickDataList) {
|
||||||
this.mControlDataList = mControlDataList;
|
this.mControlDataList = mControlDataList;
|
||||||
this.mDrawerDataList = mDrawerDataList;
|
this.mDrawerDataList = mDrawerDataList;
|
||||||
this.mJoystickDataList = mJoystickDataList;
|
this.mJoystickDataList = mJoystickDataList;
|
||||||
|
@ -16,6 +16,7 @@ import android.view.View;
|
|||||||
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
|
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
|
||||||
import net.kdt.pojavlaunch.Tools;
|
import net.kdt.pojavlaunch.Tools;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
|
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||||
import net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick;
|
import net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick;
|
||||||
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
|
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
|
||||||
@ -33,10 +34,10 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
|||||||
private final int[] mDirectionRight = new int[]{LwjglGlfwKeycode.GLFW_KEY_D};
|
private final int[] mDirectionRight = new int[]{LwjglGlfwKeycode.GLFW_KEY_D};
|
||||||
private final int[] mDirectionBackward = new int[]{LwjglGlfwKeycode.GLFW_KEY_S};
|
private final int[] mDirectionBackward = new int[]{LwjglGlfwKeycode.GLFW_KEY_S};
|
||||||
private final int[] mDirectionLeft = new int[]{LwjglGlfwKeycode.GLFW_KEY_A};
|
private final int[] mDirectionLeft = new int[]{LwjglGlfwKeycode.GLFW_KEY_A};
|
||||||
private ControlData mControlData;
|
private ControlJoystickData mControlData;
|
||||||
private int mLastDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
private int mLastDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
||||||
private int mCurrentDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
private int mCurrentDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
||||||
public ControlJoystick(ControlLayout parent, ControlData data) {
|
public ControlJoystick(ControlLayout parent, ControlJoystickData data) {
|
||||||
super(parent.getContext());
|
super(parent.getContext());
|
||||||
init(data, parent);
|
init(data, parent);
|
||||||
}
|
}
|
||||||
@ -47,13 +48,12 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(ControlData data, ControlLayout layout) {
|
private void init(ControlJoystickData data, ControlLayout layout) {
|
||||||
mControlData = data;
|
mControlData = data;
|
||||||
setProperties(preProcessProperties(data, layout));
|
setProperties(preProcessProperties(data, layout));
|
||||||
setDeadzone(35);
|
setDeadzone(35);
|
||||||
setFixedCenter(false);
|
setFixedCenter(false);
|
||||||
setAutoReCenterButton(true);
|
setAutoReCenterButton(true);
|
||||||
postDelayed(() -> setForwardLockDistance((int) Tools.dpToPx(35)), 10);
|
|
||||||
|
|
||||||
injectBehaviors();
|
injectBehaviors();
|
||||||
|
|
||||||
@ -88,8 +88,9 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProperties(ControlData properties, boolean changePos) {
|
public void setProperties(ControlData properties, boolean changePos) {
|
||||||
mControlData = properties;
|
mControlData = (ControlJoystickData) properties;
|
||||||
ControlInterface.super.setProperties(properties, changePos);
|
ControlInterface.super.setProperties(properties, changePos);
|
||||||
|
postDelayed(() -> setForwardLockDistance(mControlData.forwardLock ? (int) Tools.dpToPx(60) : 0), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,8 +101,8 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneButton() {
|
public void cloneButton() {
|
||||||
ControlData data = new ControlData(getProperties());
|
ControlData data = new ControlJoystickData(getProperties());
|
||||||
getControlLayoutParent().addJoystickButton(data);
|
getControlLayoutParent().addJoystickButton((ControlJoystickData) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,7 @@ import android.view.animation.Interpolator;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
@ -35,6 +36,7 @@ import net.kdt.pojavlaunch.R;
|
|||||||
import net.kdt.pojavlaunch.colorselector.ColorSelector;
|
import net.kdt.pojavlaunch.colorselector.ColorSelector;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
|
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
|
||||||
|
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
|
||||||
import net.kdt.pojavlaunch.customcontrols.buttons.ControlDrawer;
|
import net.kdt.pojavlaunch.customcontrols.buttons.ControlDrawer;
|
||||||
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
|
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ public class EditControlPopup {
|
|||||||
};
|
};
|
||||||
protected EditText mNameEditText, mWidthEditText, mHeightEditText;
|
protected EditText mNameEditText, mWidthEditText, mHeightEditText;
|
||||||
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
||||||
protected Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch;
|
protected Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch, mForwardLockSwitch;
|
||||||
protected Spinner mOrientationSpinner;
|
protected Spinner mOrientationSpinner;
|
||||||
protected TextView[] mKeycodeTextviews = new TextView[4];
|
protected TextView[] mKeycodeTextviews = new TextView[4];
|
||||||
protected SeekBar mStrokeWidthSeekbar, mCornerRadiusSeekbar, mAlphaSeekbar;
|
protected SeekBar mStrokeWidthSeekbar, mCornerRadiusSeekbar, mAlphaSeekbar;
|
||||||
@ -266,6 +268,7 @@ public class EditControlPopup {
|
|||||||
setDefaultVisibilitySetting();
|
setDefaultVisibilitySetting();
|
||||||
mOrientationTextView.setVisibility(GONE);
|
mOrientationTextView.setVisibility(GONE);
|
||||||
mOrientationSpinner.setVisibility(GONE);
|
mOrientationSpinner.setVisibility(GONE);
|
||||||
|
mForwardLockSwitch.setVisibility(GONE);
|
||||||
|
|
||||||
mNameEditText.setText(data.name);
|
mNameEditText.setText(data.name);
|
||||||
mWidthEditText.setText(String.valueOf(data.getWidth()));
|
mWidthEditText.setText(String.valueOf(data.getWidth()));
|
||||||
@ -321,7 +324,7 @@ public class EditControlPopup {
|
|||||||
/**
|
/**
|
||||||
* Load values for the joystick
|
* Load values for the joystick
|
||||||
*/
|
*/
|
||||||
public void loadJoystickValues(ControlData data) {
|
public void loadJoystickValues(ControlJoystickData data) {
|
||||||
loadValues(data);
|
loadValues(data);
|
||||||
|
|
||||||
mMappingTextView.setVisibility(GONE);
|
mMappingTextView.setVisibility(GONE);
|
||||||
@ -340,6 +343,9 @@ public class EditControlPopup {
|
|||||||
mSwipeableSwitch.setVisibility(View.GONE);
|
mSwipeableSwitch.setVisibility(View.GONE);
|
||||||
mPassthroughSwitch.setVisibility(View.GONE);
|
mPassthroughSwitch.setVisibility(View.GONE);
|
||||||
mToggleSwitch.setVisibility(View.GONE);
|
mToggleSwitch.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
mForwardLockSwitch.setVisibility(VISIBLE);
|
||||||
|
mForwardLockSwitch.setChecked(data.forwardLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,6 +375,7 @@ public class EditControlPopup {
|
|||||||
mToggleSwitch = mScrollView.findViewById(R.id.checkboxToggle);
|
mToggleSwitch = mScrollView.findViewById(R.id.checkboxToggle);
|
||||||
mPassthroughSwitch = mScrollView.findViewById(R.id.checkboxPassThrough);
|
mPassthroughSwitch = mScrollView.findViewById(R.id.checkboxPassThrough);
|
||||||
mSwipeableSwitch = mScrollView.findViewById(R.id.checkboxSwipeable);
|
mSwipeableSwitch = mScrollView.findViewById(R.id.checkboxSwipeable);
|
||||||
|
mForwardLockSwitch = mScrollView.findViewById(R.id.checkboxForwardLock);
|
||||||
mKeycodeSpinners[0] = mScrollView.findViewById(R.id.editMapping_spinner_1);
|
mKeycodeSpinners[0] = mScrollView.findViewById(R.id.editMapping_spinner_1);
|
||||||
mKeycodeSpinners[1] = mScrollView.findViewById(R.id.editMapping_spinner_2);
|
mKeycodeSpinners[1] = mScrollView.findViewById(R.id.editMapping_spinner_2);
|
||||||
mKeycodeSpinners[2] = mScrollView.findViewById(R.id.editMapping_spinner_3);
|
mKeycodeSpinners[2] = mScrollView.findViewById(R.id.editMapping_spinner_3);
|
||||||
@ -478,6 +485,12 @@ public class EditControlPopup {
|
|||||||
if (internalChanges) return;
|
if (internalChanges) return;
|
||||||
mCurrentlyEditedButton.getProperties().passThruEnabled = isChecked;
|
mCurrentlyEditedButton.getProperties().passThruEnabled = isChecked;
|
||||||
});
|
});
|
||||||
|
mForwardLockSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
if (internalChanges) return;
|
||||||
|
if(mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData){
|
||||||
|
((ControlJoystickData) mCurrentlyEditedButton.getProperties()).forwardLock = isChecked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mAlphaSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
mAlphaSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -317,6 +317,17 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
|
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
|
||||||
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
||||||
|
|
||||||
|
<!-- FORWARD LOCK SECTION -->
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/checkboxForwardLock"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/_36sdp"
|
||||||
|
android:text="@string/customctrl_forward_lock"
|
||||||
|
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/checkboxSwipeable"
|
||||||
|
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
||||||
|
|
||||||
<!-- BACKGROUND COLOR SECTION -->
|
<!-- BACKGROUND COLOR SECTION -->
|
||||||
<fr.spse.extended_view.ExtendedTextView
|
<fr.spse.extended_view.ExtendedTextView
|
||||||
android:id="@+id/editBackgroundColor_textView"
|
android:id="@+id/editBackgroundColor_textView"
|
||||||
@ -333,7 +344,7 @@
|
|||||||
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/checkboxSwipeable" />
|
app:layout_constraintTop_toBottomOf="@id/checkboxForwardLock" />
|
||||||
|
|
||||||
|
|
||||||
<!-- STROKE WIDTH -->
|
<!-- STROKE WIDTH -->
|
||||||
|
@ -239,6 +239,7 @@
|
|||||||
<string name="mcl_setting_subtitle_mousespeed">Changes the speed of the software mouse</string>
|
<string name="mcl_setting_subtitle_mousespeed">Changes the speed of the software mouse</string>
|
||||||
<string name="customctrl_passthru">Mouse pass-thru</string>
|
<string name="customctrl_passthru">Mouse pass-thru</string>
|
||||||
<string name="customctrl_swipeable">Swipeable</string>
|
<string name="customctrl_swipeable">Swipeable</string>
|
||||||
|
<string name="customctrl_forward_lock">Forward lock</string>
|
||||||
<string name="customctrl_rounded">Rounded</string>
|
<string name="customctrl_rounded">Rounded</string>
|
||||||
<string name="memory_warning_msg">The current amount of free RAM (%d) is lower than allocated RAM (%d), which may lead to crashes. Change the allocation if the game crashes.</string>
|
<string name="memory_warning_msg">The current amount of free RAM (%d) is lower than allocated RAM (%d), which may lead to crashes. Change the allocation if the game crashes.</string>
|
||||||
<string name="mcl_memory_allocation">Memory allocation</string>
|
<string name="mcl_memory_allocation">Memory allocation</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user