Feat: Allow disabling off hand swap

This commit is contained in:
Mathias-Boulay 2023-03-05 19:04:33 +01:00
parent ac3dcba776
commit a84cf5a67d
5 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package net.kdt.pojavlaunch;
import static net.kdt.pojavlaunch.MainActivity.touchCharInput;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_DISABLE_SWAP_HAND;
import static net.kdt.pojavlaunch.utils.MCOptionUtils.getMcScale;
import static org.lwjgl.glfw.CallbackBridge.sendKeyPress;
import static org.lwjgl.glfw.CallbackBridge.sendMouseButton;
@ -291,7 +292,7 @@ public class MinecraftGLSurface extends View implements GrabListener{
boolean isTouchInHotbar = hudKeyHandled != -1;
if (isTouchInHotbar) {
sendKeyPress(hudKeyHandled);
if(hasDoubleTapped && hudKeyHandled == mLastHotbarKey){
if(hasDoubleTapped && hudKeyHandled == mLastHotbarKey && !PREF_DISABLE_SWAP_HAND){
//Prevent double tapping Event on two different slots
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_F);
}

View File

@ -10,10 +10,6 @@ import android.content.*;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.WindowInsets;
import android.view.WindowMetrics;
import androidx.core.view.WindowInsetsCompat;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
@ -40,6 +36,7 @@ public class LauncherPreferences {
public static String PREF_VERSION_REPOS = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json";
public static boolean PREF_CHECK_LIBRARY_SHA = true;
public static boolean PREF_DISABLE_GESTURES = false;
public static boolean PREF_DISABLE_SWAP_HAND = false;
public static float PREF_MOUSESPEED = 1f;
public static int PREF_RAM_ALLOCATION;
public static String PREF_DEFAULT_RUNTIME;
@ -81,6 +78,7 @@ public class LauncherPreferences {
PREF_FORCE_ENGLISH = DEFAULT_PREF.getBoolean("force_english", false);
PREF_CHECK_LIBRARY_SHA = DEFAULT_PREF.getBoolean("checkLibraries",true);
PREF_DISABLE_GESTURES = DEFAULT_PREF.getBoolean("disableGestures",false);
PREF_DISABLE_SWAP_HAND = DEFAULT_PREF.getBoolean("disableDoubleTap", false);
PREF_RAM_ALLOCATION = DEFAULT_PREF.getInt("allocation", findBestRAMAllocation(ctx));
PREF_CUSTOM_JAVA_ARGS = DEFAULT_PREF.getString("javaArgs", "");
PREF_SUSTAINED_PERFORMANCE = DEFAULT_PREF.getBoolean("sustainedPerformance", false);

View File

@ -7,7 +7,6 @@ import android.hardware.SensorManager;
import android.os.Bundle;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.prefs.CustomSeekBarPreference;

View File

@ -231,6 +231,8 @@
<string name="dl_library_sha_pass">Library %s is fine and usable</string>
<string name="mcl_disable_gestures">Disable gestures</string>
<string name="mcl_disable_gestures_subtitle">Disables gestures, such as hold to break block, and tap to place a block.</string>
<string name="mcl_disable_swap_hand">Disable double tap to swap hands</string>
<string name="mcl_disable_swap_hand_subtitle">Disables double tap on an hotbar item to swap it in the second hand</string>
<string name="mcl_setting_title_mousespeed">Mouse Speed</string>
<string name="mcl_setting_subtitle_mousespeed">Changes the speed of the software mouse</string>
<string name="customctrl_passthru">Mouse pass-thru</string>

View File

@ -23,6 +23,12 @@
android:summary="@string/mcl_disable_gestures_subtitle"
android:title="@string/mcl_disable_gestures" />
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="disableDoubleTap"
android:summary="@string/mcl_disable_swap_hand_subtitle"
android:title="@string/mcl_disable_swap_hand" />
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
android:key="timeLongPressTrigger"
android:summary="@string/mcl_setting_subtitle_longpresstrigger"