File tree Expand file tree Collapse file tree
app_pojavlauncher/src/main Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,13 +104,14 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
104104 public void onCreate (Bundle savedInstanceState ) {
105105 super .onCreate (savedInstanceState );
106106
107- if (LauncherPreferences .PREF_ENABLE_TOUCHCONTROLLER ) {
107+ minecraftProfile = LauncherProfiles .getCurrentProfile ();
108+
109+ String gameDirPath = Tools .getGameDirPath (minecraftProfile ).getAbsolutePath ();
110+ MCOptionUtils .load (gameDirPath );
111+ if (Tools .hasTouchController (new File (gameDirPath )) || LauncherPreferences .PREF_FORCE_ENABLE_TOUCHCONTROLLER ) {
108112 TouchControllerUtils .initialize (this );
109113 }
110114
111- minecraftProfile = LauncherProfiles .getCurrentProfile ();
112- MCOptionUtils .load (Tools .getGameDirPath (minecraftProfile ).getAbsolutePath ());
113-
114115 Intent gameServiceIntent = new Intent (this , GameService .class );
115116 // Start the service a bit early
116117 ContextCompat .startForegroundService (this , gameServiceIntent );
Original file line number Diff line number Diff line change @@ -227,6 +227,27 @@ private static boolean hasSodium(File gameDir) {
227227 return false ;
228228 }
229229
230+ /**
231+ * Search for TouchController mod to automatically enable TouchController mod support.
232+ *
233+ * @param gameDir current game directory
234+ * @return whether TouchController is found
235+ */
236+ public static boolean hasTouchController (File gameDir ) {
237+ File modsDir = new File (gameDir , "mods" );
238+ File [] mods = modsDir .listFiles (file -> file .isFile () && file .getName ().endsWith (".jar" ));
239+ if (mods == null ) {
240+ return false ;
241+ }
242+ for (File file : mods ) {
243+ String name = file .getName ().toLowerCase (Locale .ROOT );
244+ if (name .contains ("touchcontroller" )) {
245+ return true ;
246+ }
247+ }
248+ return false ;
249+ }
250+
230251 /**
231252 * Initialize OpenGL and do checks to see if the GPU of the device is affected by the render
232253 * distance issue.
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public class LauncherPreferences {
7070 public static String PREF_DOWNLOAD_SOURCE = "default" ;
7171 public static boolean PREF_SKIP_NOTIFICATION_PERMISSION_CHECK = false ;
7272 public static boolean PREF_VSYNC_IN_ZINK = true ;
73- public static boolean PREF_ENABLE_TOUCHCONTROLLER = false ;
73+ public static boolean PREF_FORCE_ENABLE_TOUCHCONTROLLER = false ;
7474 public static int PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = 100 ;
7575
7676
@@ -114,7 +114,7 @@ public static void loadPreferences(Context ctx) {
114114 PREF_VERIFY_MANIFEST = DEFAULT_PREF .getBoolean ("verifyManifest" , true );
115115 PREF_SKIP_NOTIFICATION_PERMISSION_CHECK = DEFAULT_PREF .getBoolean (PREF_KEY_SKIP_NOTIFICATION_CHECK , false );
116116 PREF_VSYNC_IN_ZINK = DEFAULT_PREF .getBoolean ("vsync_in_zink" , true );
117- PREF_ENABLE_TOUCHCONTROLLER = DEFAULT_PREF .getBoolean ("enableTouchController " , false );
117+ PREF_FORCE_ENABLE_TOUCHCONTROLLER = DEFAULT_PREF .getBoolean ("forceEnableTouchController " , false );
118118 PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = DEFAULT_PREF .getInt ("touchControllerVibrateLength" , 100 );
119119
120120 String argLwjglLibname = "-Dorg.lwjgl.opengl.libname=" ;
Original file line number Diff line number Diff line change 401401 <string name =" mg_renderer_title_errorSetting" >OpenGL 报错设置</string >
402402
403403 <string name =" preference_category_touchcontroller_settings" >TouchController 设置</string >
404- <string name =" preference_enable_touchcontroller_title " >启用 TouchController</string >
405- <string name =" preference_enable_touchcontroller_description " >启用 TouchController 集成。</string >
404+ <string name =" preference_force_enable_touchcontroller_title " >强制启用 TouchController</string >
405+ <string name =" preference_force_enable_touchcontroller_description " >启用 TouchController 集成,即使没有找到模组文件 。</string >
406406 <string name =" preference_touchcontroller_vibrate_length_title" >TouchController 震动长度</string >
407407 <string name =" preference_touchcontroller_vibrate_length_description" >设置使用 TouchController 时的震动长度。</string >
408408</resources >
Original file line number Diff line number Diff line change 458458 <string name =" neoforge_dl_no_installer" >Sorry, but this version of NeoForge does not have an installer, which is not yet supported.</string >
459459
460460 <string name =" preference_category_touchcontroller_settings" >TouchController Settings</string >
461- <string name =" preference_enable_touchcontroller_title " >Enable TouchController</string >
462- <string name =" preference_enable_touchcontroller_description " >Enable TouchController integration.</string >
461+ <string name =" preference_force_enable_touchcontroller_title " >Force enable TouchController</string >
462+ <string name =" preference_force_enable_touchcontroller_description " >Force enable TouchController integration, even if mod file is not found .</string >
463463 <string name =" preference_touchcontroller_vibrate_length_title" >TouchController vibrate length</string >
464464 <string name =" preference_touchcontroller_vibrate_length_description" >Set the length of the vibration when using TouchController.</string >
465465</resources >
Original file line number Diff line number Diff line change 167167 <PreferenceCategory
168168 android : title =" @string/preference_category_touchcontroller_settings" >
169169 <SwitchPreference
170- android : key =" enableTouchController "
171- android : title =" @string/preference_enable_touchcontroller_title "
172- android : summary =" @string/preference_enable_touchcontroller_description " />
170+ android : key =" forceEnableTouchController "
171+ android : title =" @string/preference_force_enable_touchcontroller_title "
172+ android : summary =" @string/preference_force_enable_touchcontroller_description " />
173173 <net .kdt.pojavlaunch.prefs.CustomSeekBarPreference
174174 android : key =" touchControllerVibrateLength"
175175 android : title =" @string/preference_touchcontroller_vibrate_length_title"
You can’t perform that action at this time.
0 commit comments