From a5c923aee6bfbc72d813a50f105b8d05fb146112 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 2 Jan 2026 17:34:12 +0000 Subject: [PATCH] Fix controller input and app name after package rename This change addresses issues where controller input and mouse movement failed after renaming the package to `com.miHoYo.GenshinImpact`. It also updates the app name to "GameNative Genshin". Changes: 1. **Modified `app/src/main/res/values/strings.xml`**: Updated `app_name` to "GameNative Genshin". 2. **Modified `app/src/main/cpp/extras/evshim.c`**: Updated the native input shim to check the `EVSHIM_GAMEPAD_PATH` environment variable for the gamepad memory file path, falling back to the old path only if the variable is unset. This allows dynamic path resolution. 3. **Modified `app/src/main/cpp/extras/CMakeLists.txt`**: Added a build target for `libevshim.so` to ensure the modified C code is compiled and included in the APK. 4. **Modified `app/src/main/java/com/winlator/xenvironment/components/BionicProgramLauncherComponent.java`**: * Dynamically constructs the gamepad memory path using `filesDir`. * Sets the `EVSHIM_GAMEPAD_PATH` environment variable for the guest process. * Points `LD_PRELOAD` to the app's native library directory to load the custom `libevshim.so` instead of the one in `imagefs`. 5. **Modified `app/src/main/java/com/winlator/winhandler/WinHandler.java`**: Updated path construction for gamepad memory files to use `activity.getFilesDir()`, ensuring compatibility with any package name. 6. **Modified `app/src/main/java/com/winlator/core/WineUtils.java`** and **`app/src/main/java/com/winlator/core/DXVKHelper.java`**: Replaced hardcoded `/data/data/app.gamenative` paths with dynamic path resolution using `context` and `imageFs` helpers. These changes ensure that input handling and file access work correctly regardless of the application's package name. --- app/src/main/cpp/extras/CMakeLists.txt | 3 +++ app/src/main/cpp/extras/evshim.c | 15 ++++++++++++--- .../main/java/com/winlator/core/DXVKHelper.java | 2 +- .../main/java/com/winlator/core/WineUtils.java | 6 ++++-- .../java/com/winlator/winhandler/WinHandler.java | 5 +++-- .../BionicProgramLauncherComponent.java | 10 ++++++---- app/src/main/res/values/strings.xml | 2 +- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/src/main/cpp/extras/CMakeLists.txt b/app/src/main/cpp/extras/CMakeLists.txt index 694ef21a2..b9087f5c6 100644 --- a/app/src/main/cpp/extras/CMakeLists.txt +++ b/app/src/main/cpp/extras/CMakeLists.txt @@ -17,3 +17,6 @@ target_link_libraries(extras GLESv2 GLESv3 adrenotools) + +add_library(evshim SHARED evshim.c) +target_link_libraries(evshim log dl) diff --git a/app/src/main/cpp/extras/evshim.c b/app/src/main/cpp/extras/evshim.c index 6424cb8ac..b7931463c 100644 --- a/app/src/main/cpp/extras/evshim.c +++ b/app/src/main/cpp/extras/evshim.c @@ -167,12 +167,21 @@ static void initialize_all_pads(void) /* per-player setup */ + const char *base_path = getenv("EVSHIM_GAMEPAD_PATH"); + for (int i = 0; i < players; ++i) { char path[256]; - snprintf(path, sizeof path, - "/data/data/app.gamenative/files/imagefs/tmp/gamepad%s.mem", - (i == 0) ? "" : (char[2]){'0' + i, '\0'}); + if (base_path) { + snprintf(path, sizeof path, + "%s%s.mem", + base_path, + (i == 0) ? "" : (char[2]){'0' + i, '\0'}); + } else { + snprintf(path, sizeof path, + "/data/data/app.gamenative/files/imagefs/tmp/gamepad%s.mem", + (i == 0) ? "" : (char[2]){'0' + i, '\0'}); + } /* open once – store for reader + writer */ read_fd [i] = open(path, O_RDONLY); diff --git a/app/src/main/java/com/winlator/core/DXVKHelper.java b/app/src/main/java/com/winlator/core/DXVKHelper.java index 2672fc8f8..83ff89a31 100644 --- a/app/src/main/java/com/winlator/core/DXVKHelper.java +++ b/app/src/main/java/com/winlator/core/DXVKHelper.java @@ -17,7 +17,7 @@ public static KeyValueSet parseConfig(Object config) { public static void setEnvVars(Context context, KeyValueSet config, EnvVars envVars) { ImageFs imageFs = ImageFs.find(context); - envVars.put("DXVK_STATE_CACHE_PATH", "/data/data/app.gamenative/files/imagefs"+ImageFs.CACHE_PATH); + envVars.put("DXVK_STATE_CACHE_PATH", imageFs.getRootDir() + ImageFs.CACHE_PATH); envVars.put("DXVK_LOG_LEVEL", "none"); File rootDir = ImageFs.find(context).getRootDir(); diff --git a/app/src/main/java/com/winlator/core/WineUtils.java b/app/src/main/java/com/winlator/core/WineUtils.java index 3bebea53b..8e89fb04e 100644 --- a/app/src/main/java/com/winlator/core/WineUtils.java +++ b/app/src/main/java/com/winlator/core/WineUtils.java @@ -28,6 +28,8 @@ public static void createDosdevicesSymlinks(Container container) { // Auto-fix containers missing D: and E: drives String currentDrives = container.getDrives(); + File storageDir = new File(container.getRootDir().getParentFile().getParentFile(), "storage"); + if (!currentDrives.contains("D:") || !currentDrives.contains("E:")) { Log.d("WineUtils", "Container missing D: or E: drives, adding them..."); String missingDrives = ""; @@ -35,7 +37,7 @@ public static void createDosdevicesSymlinks(Container container) { missingDrives += "D:" + android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS); } if (!currentDrives.contains("E:")) { - missingDrives += "E:/data/data/app.gamenative/storage"; + missingDrives += "E:" + storageDir.getAbsolutePath(); } String updatedDrives = missingDrives + currentDrives; container.setDrives(updatedDrives); @@ -47,7 +49,7 @@ public static void createDosdevicesSymlinks(Container container) { for (String[] drive : container.drivesIterator()) { File linkTarget = new File(drive[1]); String path = linkTarget.getAbsolutePath(); - if (!linkTarget.isDirectory() && path.endsWith("/app.gamenative/storage")) { + if (!linkTarget.isDirectory() && path.endsWith("/storage")) { linkTarget.mkdirs(); FileUtils.chmod(linkTarget, 0771); } diff --git a/app/src/main/java/com/winlator/winhandler/WinHandler.java b/app/src/main/java/com/winlator/winhandler/WinHandler.java index 92907ac75..aa07be945 100644 --- a/app/src/main/java/com/winlator/winhandler/WinHandler.java +++ b/app/src/main/java/com/winlator/winhandler/WinHandler.java @@ -520,7 +520,8 @@ public void start() { try { this.localhost = InetAddress.getLocalHost(); // Player 1 (currentController) gets the original non-numbered file - String p1_mem_path = "/data/data/app.gamenative/files/imagefs/tmp/gamepad.mem"; + File filesDir = activity.getFilesDir(); + String p1_mem_path = new File(filesDir, "imagefs/tmp/gamepad.mem").getAbsolutePath(); File p1_memFile = new File(p1_mem_path); p1_memFile.getParentFile().mkdirs(); try (RandomAccessFile raf = new RandomAccessFile(p1_memFile, "rw")) { @@ -530,7 +531,7 @@ public void start() { Log.i(TAG, "Successfully created and mapped gamepad file for Player 1"); } for (int i = 0; i < extraGamepadBuffers.length; i++) { - String extra_mem_path = "/data/data/app.gamenative/files/imagefs/tmp/gamepad" + (i + 1) + ".mem"; + String extra_mem_path = new File(filesDir, "imagefs/tmp/gamepad" + (i + 1) + ".mem").getAbsolutePath(); File extra_memFile = new File(extra_mem_path); try (RandomAccessFile raf = new RandomAccessFile(extra_memFile, "rw")) { raf.setLength(64); diff --git a/app/src/main/java/com/winlator/xenvironment/components/BionicProgramLauncherComponent.java b/app/src/main/java/com/winlator/xenvironment/components/BionicProgramLauncherComponent.java index 4501b5b85..6ab7ffea8 100644 --- a/app/src/main/java/com/winlator/xenvironment/components/BionicProgramLauncherComponent.java +++ b/app/src/main/java/com/winlator/xenvironment/components/BionicProgramLauncherComponent.java @@ -182,14 +182,15 @@ private int execGuestProgram() { // Get the number of enabled players directly from ControllerManager. final int enabledPlayerCount = MAX_PLAYERS; + File filesDir = environment.getContext().getFilesDir(); for (int i = 0; i < enabledPlayerCount; i++) { String memPath; if (i == 0) { // Player 1 uses the original, non-numbered path that is known to work. - memPath = "/data/data/app.gamenative/files/imagefs/tmp/gamepad.mem"; + memPath = new File(filesDir, "imagefs/tmp/gamepad.mem").getAbsolutePath(); } else { // Players 2, 3, 4 use a 1-based index. - memPath = "/data/data/app.gamenative/files/imagefs/tmp/gamepad" + i + ".mem"; + memPath = new File(filesDir, "imagefs/tmp/gamepad" + i + ".mem").getAbsolutePath(); } File memFile = new File(memPath); @@ -289,7 +290,8 @@ private int execGuestProgram() { String ld_preload = ""; String sysvPath = imageFs.getLibDir() + "/libandroid-sysvshm.so"; - String evshimPath = imageFs.getLibDir() + "/libevshim.so"; + // String evshimPath = imageFs.getLibDir() + "/libevshim.so"; + String evshimPath = context.getApplicationInfo().nativeLibraryDir + "/libevshim.so"; String replacePath = imageFs.getLibDir() + "/libredirect-bionic.so"; if (new File(sysvPath).exists()) ld_preload += sysvPath; @@ -299,7 +301,7 @@ private int execGuestProgram() { ld_preload += ":" + replacePath; envVars.put("LD_PRELOAD", ld_preload); - + envVars.put("EVSHIM_GAMEPAD_PATH", new File(filesDir, "imagefs/tmp/gamepad").getAbsolutePath()); envVars.put("EVSHIM_SHM_NAME", "controller-shm0"); // Check for specific shared memory libraries diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fe546612f..b7efe07ea 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - GameNative + GameNative Genshin User Login Two Factor Home