mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-09 12:43:36 -04:00
feat[TouchController]: add TouchController mod detection
This commit is contained in:
parent
cd0f40f377
commit
8f1aede432
@ -104,13 +104,14 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (LauncherPreferences.PREF_ENABLE_TOUCHCONTROLLER) {
|
||||
minecraftProfile = LauncherProfiles.getCurrentProfile();
|
||||
|
||||
String gameDirPath = Tools.getGameDirPath(minecraftProfile).getAbsolutePath();
|
||||
MCOptionUtils.load(gameDirPath);
|
||||
if (Tools.hasTouchController(new File(gameDirPath)) || LauncherPreferences.PREF_FORCE_ENABLE_TOUCHCONTROLLER) {
|
||||
TouchControllerUtils.initialize(this);
|
||||
}
|
||||
|
||||
minecraftProfile = LauncherProfiles.getCurrentProfile();
|
||||
MCOptionUtils.load(Tools.getGameDirPath(minecraftProfile).getAbsolutePath());
|
||||
|
||||
Intent gameServiceIntent = new Intent(this, GameService.class);
|
||||
// Start the service a bit early
|
||||
ContextCompat.startForegroundService(this, gameServiceIntent);
|
||||
|
@ -227,6 +227,27 @@ public final class Tools {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for TouchController mod to automatically enable TouchController mod support.
|
||||
*
|
||||
* @param gameDir current game directory
|
||||
* @return whether TouchController is found
|
||||
*/
|
||||
public static boolean hasTouchController(File gameDir) {
|
||||
File modsDir = new File(gameDir, "mods");
|
||||
File[] mods = modsDir.listFiles(file -> file.isFile() && file.getName().endsWith(".jar"));
|
||||
if (mods == null) {
|
||||
return false;
|
||||
}
|
||||
for (File file : mods) {
|
||||
String name = file.getName().toLowerCase(Locale.ROOT);
|
||||
if (name.contains("touchcontroller")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize OpenGL and do checks to see if the GPU of the device is affected by the render
|
||||
* distance issue.
|
||||
|
@ -70,7 +70,7 @@ public class LauncherPreferences {
|
||||
public static String PREF_DOWNLOAD_SOURCE = "default";
|
||||
public static boolean PREF_SKIP_NOTIFICATION_PERMISSION_CHECK = false;
|
||||
public static boolean PREF_VSYNC_IN_ZINK = true;
|
||||
public static boolean PREF_ENABLE_TOUCHCONTROLLER = false;
|
||||
public static boolean PREF_FORCE_ENABLE_TOUCHCONTROLLER = false;
|
||||
public static int PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = 100;
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ public class LauncherPreferences {
|
||||
PREF_VERIFY_MANIFEST = DEFAULT_PREF.getBoolean("verifyManifest", true);
|
||||
PREF_SKIP_NOTIFICATION_PERMISSION_CHECK = DEFAULT_PREF.getBoolean(PREF_KEY_SKIP_NOTIFICATION_CHECK, false);
|
||||
PREF_VSYNC_IN_ZINK = DEFAULT_PREF.getBoolean("vsync_in_zink", true);
|
||||
PREF_ENABLE_TOUCHCONTROLLER = DEFAULT_PREF.getBoolean("enableTouchController", false);
|
||||
PREF_FORCE_ENABLE_TOUCHCONTROLLER = DEFAULT_PREF.getBoolean("forceEnableTouchController", false);
|
||||
PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = DEFAULT_PREF.getInt("touchControllerVibrateLength", 100);
|
||||
|
||||
String argLwjglLibname = "-Dorg.lwjgl.opengl.libname=";
|
||||
|
@ -401,8 +401,8 @@
|
||||
<string name="mg_renderer_title_errorSetting">OpenGL 报错设置</string>
|
||||
|
||||
<string name="preference_category_touchcontroller_settings">TouchController 设置</string>
|
||||
<string name="preference_enable_touchcontroller_title">启用 TouchController</string>
|
||||
<string name="preference_enable_touchcontroller_description">启用 TouchController 集成。</string>
|
||||
<string name="preference_force_enable_touchcontroller_title">强制启用 TouchController</string>
|
||||
<string name="preference_force_enable_touchcontroller_description">启用 TouchController 集成,即使没有找到模组文件。</string>
|
||||
<string name="preference_touchcontroller_vibrate_length_title">TouchController 震动长度</string>
|
||||
<string name="preference_touchcontroller_vibrate_length_description">设置使用 TouchController 时的震动长度。</string>
|
||||
</resources>
|
||||
|
@ -458,8 +458,8 @@
|
||||
<string name="neoforge_dl_no_installer">Sorry, but this version of NeoForge does not have an installer, which is not yet supported.</string>
|
||||
|
||||
<string name="preference_category_touchcontroller_settings">TouchController Settings</string>
|
||||
<string name="preference_enable_touchcontroller_title">Enable TouchController</string>
|
||||
<string name="preference_enable_touchcontroller_description">Enable TouchController integration.</string>
|
||||
<string name="preference_force_enable_touchcontroller_title">Force enable TouchController</string>
|
||||
<string name="preference_force_enable_touchcontroller_description">Force enable TouchController integration, even if mod file is not found.</string>
|
||||
<string name="preference_touchcontroller_vibrate_length_title">TouchController vibrate length</string>
|
||||
<string name="preference_touchcontroller_vibrate_length_description">Set the length of the vibration when using TouchController.</string>
|
||||
</resources>
|
||||
|
@ -167,9 +167,9 @@
|
||||
<PreferenceCategory
|
||||
android:title="@string/preference_category_touchcontroller_settings">
|
||||
<SwitchPreference
|
||||
android:key="enableTouchController"
|
||||
android:title="@string/preference_enable_touchcontroller_title"
|
||||
android:summary="@string/preference_enable_touchcontroller_description"/>
|
||||
android:key="forceEnableTouchController"
|
||||
android:title="@string/preference_force_enable_touchcontroller_title"
|
||||
android:summary="@string/preference_force_enable_touchcontroller_description"/>
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="touchControllerVibrateLength"
|
||||
android:title="@string/preference_touchcontroller_vibrate_length_title"
|
||||
|
Loading…
x
Reference in New Issue
Block a user