6363import net .kdt .pojavlaunch .services .GameService ;
6464import net .kdt .pojavlaunch .utils .JREUtils ;
6565import net .kdt .pojavlaunch .utils .MCOptionUtils ;
66+ import net .kdt .pojavlaunch .utils .TouchControllerInputView ;
6667import net .kdt .pojavlaunch .utils .TouchControllerUtils ;
6768import net .kdt .pojavlaunch .value .MinecraftAccount ;
6869import net .kdt .pojavlaunch .value .launcherprofiles .LauncherProfiles ;
@@ -85,6 +86,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
8586 protected static View .OnGenericMotionListener motionListener = (v , event ) -> false ;
8687
8788 public static TouchCharInput touchCharInput ;
89+ private TouchControllerInputView touchControllerInputView ;
8890 private MinecraftGLSurface minecraftGLView ;
8991 private static Touchpad touchpad ;
9092 private LoggerView loggerView ;
@@ -142,9 +144,6 @@ public void onCreate(Bundle savedInstanceState) {
142144
143145 String gameDirPath = Tools .getGameDirPath (minecraftProfile ).getAbsolutePath ();
144146 MCOptionUtils .load (gameDirPath );
145- if (Tools .hasTouchController (new File (gameDirPath )) || LauncherPreferences .PREF_FORCE_ENABLE_TOUCHCONTROLLER ) {
146- TouchControllerUtils .initialize (this );
147- }
148147
149148 Intent gameServiceIntent = new Intent (this , GameService .class );
150149 // Start the service a bit early
@@ -153,6 +152,10 @@ public void onCreate(Bundle savedInstanceState) {
153152 CallbackBridge .addGrabListener (touchpad );
154153 CallbackBridge .addGrabListener (minecraftGLView );
155154
155+ if (Tools .hasTouchController (new File (gameDirPath )) || LauncherPreferences .PREF_FORCE_ENABLE_TOUCHCONTROLLER ) {
156+ TouchControllerUtils .initialize (this , touchControllerInputView );
157+ }
158+
156159 mGyroControl = new GyroControl (this );
157160
158161 // Enabling this on TextureView results in a broken white result
@@ -206,6 +209,8 @@ protected void initLayout(int resId) {
206209 GLOBAL_CLIPBOARD = (ClipboardManager ) getSystemService (CLIPBOARD_SERVICE );
207210 touchCharInput .setCharacterSender (new LwjglCharSender ());
208211
212+ touchControllerInputView .setSize (minecraftGLView .getWidth (), minecraftGLView .getHeight ());
213+
209214 if (minecraftProfile .pojavRendererName != null ) {
210215 Log .i ("RdrDebug" ,"__P_renderer=" +minecraftProfile .pojavRendererName );
211216 Tools .LOCAL_RENDERER = minecraftProfile .pojavRendererName ;
@@ -306,6 +311,7 @@ private void bindValues(){
306311 loggerView = findViewById (R .id .mainLoggerView );
307312 mControlLayout = findViewById (R .id .main_control_layout );
308313 touchCharInput = findViewById (R .id .mainTouchCharInput );
314+ touchControllerInputView = findViewById (R .id .touch_controller_input );
309315 mDrawerPullButton = findViewById (R .id .drawer_button );
310316 mHotbarView = findViewById (R .id .hotbar_view );
311317 }
@@ -367,6 +373,7 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) {
367373 minecraftGLView .refreshSize ();
368374 Tools .updateWindowSize (this );
369375 mControlLayout .refreshControlButtonPositions ();
376+ touchControllerInputView .setSize (minecraftGLView .getWidth (), minecraftGLView .getHeight ());
370377 });
371378 }
372379
0 commit comments