mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-05-05 17:56:59 +00:00
fix 2
cvbi fixed fixed modify rom fixed setup activity adding required bios and keyboard&mouse params adding harddisk 'if type'
This commit is contained in:
parent
e93c1b361e
commit
ffc104cac2
12 changed files with 191 additions and 38 deletions
|
|
@ -674,16 +674,40 @@ public class MainSettingsManager extends AppCompatActivity
|
|||
return prefs.getBoolean("customMemory", false);
|
||||
}
|
||||
|
||||
public static void setVirtio(Activity activity, Boolean virtio) {
|
||||
public static void setIfType(Activity activity, String type) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putBoolean("virtio", virtio);
|
||||
edit.putString("ifType", type);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static boolean getVirtio(Activity activity) {
|
||||
public static String getIfType(Activity activity) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
return prefs.getBoolean("virtio", false);
|
||||
return prefs.getString("ifType", "ide");
|
||||
}
|
||||
|
||||
public static void setMouse(Activity activity, String type) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putString("mouse", type);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static String getMouse(Activity activity) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
return prefs.getString("mouse", "usb-mouse");
|
||||
}
|
||||
|
||||
public static void setKeyboard(Activity activity, String type) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putString("keyboard", type);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static String getKeyboard(Activity activity) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
return prefs.getString("keyboard", "usb-kbd");
|
||||
}
|
||||
|
||||
public static void setAvx(Activity activity, boolean AVX) {
|
||||
|
|
|
|||
|
|
@ -287,6 +287,12 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
addRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
File isoFile = new File(cdrom.getText().toString());
|
||||
if (isoFile.exists() && !qemu.getText().toString().contains("-drive index=1,media=cdrom,file=")) {
|
||||
isoFile.delete();
|
||||
}
|
||||
|
||||
if (modify) {
|
||||
|
||||
int position = getIntent().getIntExtra("POS", 0);
|
||||
|
|
@ -295,8 +301,9 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
current.itemExtra = qemu.getText().toString();
|
||||
try {
|
||||
JSONObject jObj = MainActivity.jArray.getJSONObject(position);
|
||||
jObj.put("imgDrv1", drive.getText().toString());
|
||||
|
||||
jObj.put("imgName", title.getText().toString());
|
||||
jObj.put("imgIcon", icon.getText().toString());
|
||||
jObj.put("imgPath", drive.getText().toString());
|
||||
jObj.put("imgExtra", qemu.getText().toString());
|
||||
|
||||
MainActivity.jArray.put(position, jObj);
|
||||
|
|
@ -499,7 +506,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
} finally {
|
||||
try {
|
||||
try {
|
||||
SaveImage(selectedImage, new File(AppConfig.maindirpath + "icons"), selectedFilePath.getName());
|
||||
SaveImage(selectedImage, new File(AppConfig.maindirpath + "icons"), title.getText().toString() + "-" + selectedFilePath.getName());
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -162,7 +162,6 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
ZipEntrySource[] addedEntries = new ZipEntrySource[]{
|
||||
new FileSource("/" + new File(current.itemPath).getName(), new File(current.itemPath)),
|
||||
new FileSource("/" + new File(current.itemIcon).getName(), new File(current.itemIcon)),
|
||||
new FileSource("/" + new File(current.itemDrv1).getName(), new File(current.itemDrv1)),
|
||||
new FileSource("/" + new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json").getName(), new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json"))
|
||||
};
|
||||
ZipUtil.pack(addedEntries, new File(AppConfig.datadirpath(MainActivity.activity) + "/cvbi/" + current.itemName + ".cvbi"));
|
||||
|
|
@ -181,7 +180,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.}
|
||||
UIUtils.UIAlert(MainActivity.activity, AppConfig.datadirpath(MainActivity.activity) + "/cvbi/" + current.itemName + ".cvbi", "DONE!");
|
||||
UIUtils.UIAlert(MainActivity.activity, "DONE!", AppConfig.datadirpath(MainActivity.activity) + "/cvbi/" + current.itemName + ".cvbi");
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
|
|
|
|||
|
|
@ -179,14 +179,17 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
if (exitValue != 0) {
|
||||
// If exit value is not zero, display a toast message
|
||||
String toastMessage = "Command failed with exit code: " + exitValue;
|
||||
activity.runOnUiThread(() -> Toast.makeText(activity, toastMessage, Toast.LENGTH_LONG).show());
|
||||
inBtn.setVisibility(View.VISIBLE);
|
||||
activity.runOnUiThread(() -> {
|
||||
appendTextAndScroll("Error: " + toastMessage + "\n");
|
||||
Toast.makeText(activity, toastMessage, Toast.LENGTH_LONG).show();
|
||||
inBtn.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
// Handle exceptions by printing the stack trace in the terminal output
|
||||
final String errorMessage = e.getMessage();
|
||||
activity.runOnUiThread(() -> {
|
||||
appendTextAndScroll("Error: " + errorMessage + "n");
|
||||
appendTextAndScroll("Error: " + errorMessage + "\n");
|
||||
Toast.makeText(activity, "Error executing command: " + errorMessage, Toast.LENGTH_LONG).show();
|
||||
inBtn.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -95,6 +95,11 @@ public class SplashActivity extends AppCompatActivity implements Runnable {
|
|||
distroDir.mkdirs();
|
||||
}
|
||||
|
||||
File cvbiDir = new File(AppConfig.datadirpath(MainActivity.activity) + "/cvbi");
|
||||
if (!cvbiDir.exists()) {
|
||||
cvbiDir.mkdirs();
|
||||
}
|
||||
|
||||
File jsonFile = new File(AppConfig.maindirpath
|
||||
+ "roms-data.json");
|
||||
if (!jsonFile.exists())
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package com.vectras.vm;
|
|||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.vectras.qemu.*;
|
||||
import com.vectras.qemu.Config;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.qemu.utils.RamInfo;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -20,6 +21,8 @@ public class StartVM {
|
|||
|
||||
ArrayList<String> params = new ArrayList<>(Arrays.asList(qemu));
|
||||
|
||||
String ifType = MainSettingsManager.getIfType(activity);
|
||||
|
||||
String cdrom;
|
||||
String hdd1;
|
||||
String hdd2;
|
||||
|
|
@ -27,7 +30,8 @@ public class StartVM {
|
|||
String hdd0 = "-drive";
|
||||
hdd0 += " index=0";
|
||||
hdd0 += ",media=disk";
|
||||
hdd0 += ",file=" + img;
|
||||
hdd0 += ",if=" + ifType;
|
||||
hdd0 += ",file='" + img + "'";
|
||||
|
||||
params.add(hdd0);
|
||||
|
||||
|
|
@ -37,7 +41,7 @@ public class StartVM {
|
|||
cdrom = "-drive";
|
||||
cdrom += " index=1";
|
||||
cdrom += ",media=cdrom";
|
||||
cdrom += ",file=" + cdromFile.getPath();
|
||||
cdrom += ",file='" + cdromFile.getPath() + "'";
|
||||
params.add(cdrom);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +51,8 @@ public class StartVM {
|
|||
hdd1 = "-drive";
|
||||
hdd1 += " index=2";
|
||||
hdd1 += ",media=disk";
|
||||
hdd1 += ",file=" + hdd1File.getPath();
|
||||
hdd1 += ",if=" + ifType;
|
||||
hdd1 += ",file='" + hdd1File.getPath() + "'";
|
||||
params.add(hdd1);
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +62,8 @@ public class StartVM {
|
|||
hdd2 = "-drive";
|
||||
hdd2 += " index=3";
|
||||
hdd2 += ",media=disk";
|
||||
hdd2 += ",file=" + hdd2File.getPath();
|
||||
hdd2 += ",if=" + ifType;
|
||||
hdd2 += ",file='" + hdd2File.getPath() + "'";
|
||||
params.add(hdd2);
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +100,19 @@ public class StartVM {
|
|||
String bios = "-bios ";
|
||||
bios += AppConfig.basefiledir + "/bios-vectras.bin";
|
||||
|
||||
String machine = "-M ";
|
||||
machine += "pc";
|
||||
|
||||
params.add(machine);
|
||||
|
||||
params.add("-overcommit");
|
||||
params.add("mem-lock=off");
|
||||
|
||||
params.add("-rtc");
|
||||
params.add("base=localtime");
|
||||
|
||||
params.add("-nodefaults");
|
||||
|
||||
params.add(bios);
|
||||
|
||||
params.add(boot);
|
||||
|
|
@ -112,15 +131,40 @@ public class StartVM {
|
|||
String vncStr = "-vnc ";
|
||||
params.add(vncStr);
|
||||
// Allow connections only from localhost using localsocket without a password
|
||||
//paramsList.add(Config.defaultVNCHost+":" + Config.defaultVNCPort);
|
||||
//params.add(Config.defaultVNCHost+":" + Config.defaultVNCPort);
|
||||
String qmpParams = "unix:";
|
||||
qmpParams += Config.getLocalVNCSocketPath();
|
||||
params.add(qmpParams);
|
||||
params.add("-monitor");
|
||||
params.add("vc");
|
||||
} else if (MainSettingsManager.getVmUi(activity).equals("SPICE"))
|
||||
params.add(spiceStr);
|
||||
|
||||
params.add("-monitor");
|
||||
params.add("vc");
|
||||
//XXX: monitor, serial, and parallel display crashes cause SDL doesn't support more than 1 window
|
||||
params.add("-monitor");
|
||||
params.add("none");
|
||||
|
||||
params.add("-serial");
|
||||
params.add("none");
|
||||
|
||||
params.add("-parallel");
|
||||
params.add("none");
|
||||
|
||||
params.add("-k");
|
||||
params.add("en-us");
|
||||
|
||||
params.add("-usb");
|
||||
|
||||
if (!MainSettingsManager.getMouse(activity).equals("ps2-mouse")) {
|
||||
params.add("-device");
|
||||
params.add(MainSettingsManager.getMouse(activity));
|
||||
}
|
||||
|
||||
if (!MainSettingsManager.getKeyboard(activity).equals("ps2-kbd")) {
|
||||
params.add("-device");
|
||||
params.add(MainSettingsManager.getKeyboard(activity));
|
||||
}
|
||||
|
||||
params.add(extras);
|
||||
|
||||
params.add(MainSettingsManager.getCustomParams(activity));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue