mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-12 14:16:58 -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.Mathias-Boulay:ExtendedView:1.0.0'
|
||||
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'
|
||||
|
@ -12,6 +12,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||
import net.kdt.pojavlaunch.customcontrols.EditorExitable;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||
@ -43,7 +44,7 @@ public class CustomControlsActivity extends BaseActivity implements EditorExitab
|
||||
switch(position) {
|
||||
case 0: mControlLayout.addControlButton(new ControlData("New")); 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 4: mControlLayout.openSaveDialog(this); 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)
|
||||
for(ControlData joystick : mLayout.mJoystickDataList){
|
||||
for(ControlJoystickData joystick : mLayout.mJoystickDataList){
|
||||
addJoystickView(joystick);
|
||||
}
|
||||
|
||||
@ -196,12 +196,12 @@ public class ControlLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
// JOYSTICK BUTTON
|
||||
public void addJoystickButton(ControlData data){
|
||||
public void addJoystickButton(ControlJoystickData data){
|
||||
mLayout.mJoystickDataList.add(data);
|
||||
addJoystickView(data);
|
||||
}
|
||||
|
||||
private void addJoystickView(ControlData data){
|
||||
private void addJoystickView(ControlJoystickData data){
|
||||
addView(new ControlJoystick(this, data));
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,14 @@ public class CustomControls {
|
||||
public float scaledAt;
|
||||
public List<ControlData> mControlDataList;
|
||||
public List<ControlDrawerData> mDrawerDataList;
|
||||
public List<ControlData> mJoystickDataList;
|
||||
public List<ControlJoystickData> mJoystickDataList;
|
||||
public CustomControls() {
|
||||
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.mDrawerDataList = mDrawerDataList;
|
||||
this.mJoystickDataList = mJoystickDataList;
|
||||
|
@ -16,6 +16,7 @@ import android.view.View;
|
||||
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
|
||||
import net.kdt.pojavlaunch.Tools;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick;
|
||||
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[] mDirectionBackward = new int[]{LwjglGlfwKeycode.GLFW_KEY_S};
|
||||
private final int[] mDirectionLeft = new int[]{LwjglGlfwKeycode.GLFW_KEY_A};
|
||||
private ControlData mControlData;
|
||||
private ControlJoystickData mControlData;
|
||||
private int mLastDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
||||
private int mCurrentDirectionInt = GamepadJoystick.DIRECTION_NONE;
|
||||
public ControlJoystick(ControlLayout parent, ControlData data) {
|
||||
public ControlJoystick(ControlLayout parent, ControlJoystickData data) {
|
||||
super(parent.getContext());
|
||||
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;
|
||||
setProperties(preProcessProperties(data, layout));
|
||||
setDeadzone(35);
|
||||
setFixedCenter(false);
|
||||
setAutoReCenterButton(true);
|
||||
postDelayed(() -> setForwardLockDistance((int) Tools.dpToPx(35)), 10);
|
||||
|
||||
injectBehaviors();
|
||||
|
||||
@ -88,8 +88,9 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
||||
|
||||
@Override
|
||||
public void setProperties(ControlData properties, boolean changePos) {
|
||||
mControlData = properties;
|
||||
mControlData = (ControlJoystickData) properties;
|
||||
ControlInterface.super.setProperties(properties, changePos);
|
||||
postDelayed(() -> setForwardLockDistance(mControlData.forwardLock ? (int) Tools.dpToPx(60) : 0), 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,8 +101,8 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
|
||||
|
||||
@Override
|
||||
public void cloneButton() {
|
||||
ControlData data = new ControlData(getProperties());
|
||||
getControlLayoutParent().addJoystickButton(data);
|
||||
ControlData data = new ControlJoystickData(getProperties());
|
||||
getControlLayoutParent().addJoystickButton((ControlJoystickData) data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import android.view.animation.Interpolator;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
@ -35,6 +36,7 @@ import net.kdt.pojavlaunch.R;
|
||||
import net.kdt.pojavlaunch.colorselector.ColorSelector;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||
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.ControlInterface;
|
||||
|
||||
@ -73,7 +75,7 @@ public class EditControlPopup {
|
||||
};
|
||||
protected EditText mNameEditText, mWidthEditText, mHeightEditText;
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
||||
protected Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch;
|
||||
protected Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch, mForwardLockSwitch;
|
||||
protected Spinner mOrientationSpinner;
|
||||
protected TextView[] mKeycodeTextviews = new TextView[4];
|
||||
protected SeekBar mStrokeWidthSeekbar, mCornerRadiusSeekbar, mAlphaSeekbar;
|
||||
@ -266,6 +268,7 @@ public class EditControlPopup {
|
||||
setDefaultVisibilitySetting();
|
||||
mOrientationTextView.setVisibility(GONE);
|
||||
mOrientationSpinner.setVisibility(GONE);
|
||||
mForwardLockSwitch.setVisibility(GONE);
|
||||
|
||||
mNameEditText.setText(data.name);
|
||||
mWidthEditText.setText(String.valueOf(data.getWidth()));
|
||||
@ -321,7 +324,7 @@ public class EditControlPopup {
|
||||
/**
|
||||
* Load values for the joystick
|
||||
*/
|
||||
public void loadJoystickValues(ControlData data) {
|
||||
public void loadJoystickValues(ControlJoystickData data) {
|
||||
loadValues(data);
|
||||
|
||||
mMappingTextView.setVisibility(GONE);
|
||||
@ -340,6 +343,9 @@ public class EditControlPopup {
|
||||
mSwipeableSwitch.setVisibility(View.GONE);
|
||||
mPassthroughSwitch.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);
|
||||
mPassthroughSwitch = mScrollView.findViewById(R.id.checkboxPassThrough);
|
||||
mSwipeableSwitch = mScrollView.findViewById(R.id.checkboxSwipeable);
|
||||
mForwardLockSwitch = mScrollView.findViewById(R.id.checkboxForwardLock);
|
||||
mKeycodeSpinners[0] = mScrollView.findViewById(R.id.editMapping_spinner_1);
|
||||
mKeycodeSpinners[1] = mScrollView.findViewById(R.id.editMapping_spinner_2);
|
||||
mKeycodeSpinners[2] = mScrollView.findViewById(R.id.editMapping_spinner_3);
|
||||
@ -478,6 +485,12 @@ public class EditControlPopup {
|
||||
if (internalChanges) return;
|
||||
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() {
|
||||
@Override
|
||||
|
@ -317,6 +317,17 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
|
||||
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 -->
|
||||
<fr.spse.extended_view.ExtendedTextView
|
||||
android:id="@+id/editBackgroundColor_textView"
|
||||
@ -333,7 +344,7 @@
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/checkboxSwipeable" />
|
||||
app:layout_constraintTop_toBottomOf="@id/checkboxForwardLock" />
|
||||
|
||||
|
||||
<!-- STROKE WIDTH -->
|
||||
|
@ -239,6 +239,7 @@
|
||||
<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_swipeable">Swipeable</string>
|
||||
<string name="customctrl_forward_lock">Forward lock</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="mcl_memory_allocation">Memory allocation</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user