Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/cpp/extras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ target_link_libraries(extras
GLESv2
GLESv3
adrenotools)

add_library(evshim SHARED evshim.c)
target_link_libraries(evshim log dl)
15 changes: 12 additions & 3 deletions app/src/main/cpp/extras/evshim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/winlator/core/DXVKHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/winlator/core/WineUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ 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 = "";
if (!currentDrives.contains("D:")) {
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);
Expand All @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/winlator/winhandler/WinHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">GameNative</string>
<string name="app_name">GameNative Genshin</string>
<string name="login_user">User Login</string>
<string name="login_2fa">Two Factor</string>
<string name="home">Home</string>
Expand Down