mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
KT: Make USBMS work
This commit is contained in:
parent
04ef2d132c
commit
5a716d2561
4 changed files with 53 additions and 20 deletions
44
functions.h
44
functions.h
|
@ -353,18 +353,32 @@ namespace {
|
|||
return 0;
|
||||
}
|
||||
void get_battery_level() {
|
||||
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||
if(batt_level_file.exists()) {
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
QString batteryLevelFileQstr;
|
||||
if(global::deviceID == "kt\n") {
|
||||
QFile batt_level_file("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity");
|
||||
if(batt_level_file.exists()) {
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
}
|
||||
}
|
||||
else {
|
||||
batt_level_int = 100;
|
||||
batt_level = "100%";
|
||||
QFile batt_level_file("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity");
|
||||
if(batt_level_file.exists()) {
|
||||
batt_level_file.open(QIODevice::ReadOnly);
|
||||
batt_level = batt_level_file.readAll();
|
||||
batt_level = batt_level.trimmed();
|
||||
batt_level_int = batt_level.toInt();
|
||||
batt_level = batt_level.append("%");
|
||||
batt_level_file.close();
|
||||
}
|
||||
else {
|
||||
batt_level_int = 100;
|
||||
batt_level = "100%";
|
||||
}
|
||||
}
|
||||
}
|
||||
void writeconfig(std::string file, std::string config) {
|
||||
|
@ -767,7 +781,15 @@ namespace {
|
|||
return checkconfig("/external_root/run/encfs_mounted");
|
||||
}
|
||||
bool isUsbPluggedIn() {
|
||||
if(global::deviceID != "kt\n") {
|
||||
if(global::deviceID == "kt\n") {
|
||||
if(readFile("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_status") == "1\n") {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Thanks to https://github.com/koreader/KoboUSBMS/blob/2efdf9d920c68752b2933f21c664dc1afb28fc2e/usbms.c#L148-L158
|
||||
int ntxfd;
|
||||
if((ntxfd = open("/dev/ntx_io", O_RDWR)) == -1) {
|
||||
|
|
|
@ -119,7 +119,7 @@ void koboxSettings::on_spinBox_valueChanged(int arg1)
|
|||
|
||||
void koboxSettings::on_pushButton_clicked()
|
||||
{
|
||||
// Export Extensions disk image over USB with g_mass_storage
|
||||
// Export Extensions disk image over USB with g_mass_storage/g_file_storage
|
||||
global::usbms::usbmsDialog = false;
|
||||
global::usbms::launchUsbms = true;
|
||||
global::usbms::koboxExportExtensions = true;
|
||||
|
|
|
@ -86,19 +86,29 @@ void usbms_splash::usbms_launch()
|
|||
QThread::msleep(1000);
|
||||
|
||||
if(global::deviceID == "n306\n" or global::deviceID == "n873\n") {
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/modules/fs/configfs/configfs.ko");
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/modules/drivers/usb/gadget/libcomposite.ko");
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/fs/configfs/configfs.ko");
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/libcomposite.ko");
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
||||
}
|
||||
else if(global::deviceID == "kt\n") {
|
||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/arcotg_udc.ko");
|
||||
}
|
||||
|
||||
QString prog_1 ("insmod");
|
||||
QStringList args_1;
|
||||
|
||||
if(global::usbms::koboxExportExtensions == true) {
|
||||
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/X11/extensions-user.img" << "removable=y" << "stall=0";
|
||||
if(global::deviceID == "kt\n") {
|
||||
massStorageModule = "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/g_file_storage.ko";
|
||||
}
|
||||
else {
|
||||
args_1 << "/external_root/modules/g_mass_storage.ko" << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
|
||||
massStorageModule = "/external_root/lib/modules/g_mass_storage.ko";
|
||||
}
|
||||
|
||||
if(global::usbms::koboxExportExtensions == true) {
|
||||
args_1 << massStorageModule << "file=/external_root/opt/storage/X11/extensions-user.img" << "removable=y" << "stall=0";
|
||||
}
|
||||
else {
|
||||
args_1 << massStorageModule << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
|
||||
}
|
||||
|
||||
QProcess *proc_1 = new QProcess();
|
||||
|
@ -111,7 +121,7 @@ void usbms_splash::usbms_launch()
|
|||
usbms_t->setInterval(1000);
|
||||
connect(usbms_t, &QTimer::timeout, [&]() {
|
||||
if(exitUsbMsDone == false) {
|
||||
if(isUsbPluggedIn() == false) {
|
||||
if(isUsbPluggedIn() == 0) {
|
||||
if(global::usbms::koboxExportExtensions == true) {
|
||||
reboot(false);
|
||||
qApp->quit();
|
||||
|
@ -138,7 +148,7 @@ void usbms_splash::usbms_launch()
|
|||
|
||||
QString prog("rmmod");
|
||||
QStringList args;
|
||||
args << "g_mass_storage";
|
||||
args << massStorageModule;
|
||||
QProcess * proc = new QProcess();
|
||||
proc->start(prog, args);
|
||||
proc->waitForFinished();
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
~usbms_splash();
|
||||
float sW;
|
||||
float sH;
|
||||
QString massStorageModule;
|
||||
|
||||
void usbms_launch();
|
||||
|
||||
|
|
Loading…
Reference in a new issue