feat: added Files app USB medium detection
This commit is contained in:
@@ -160,6 +160,7 @@ namespace Montauk {
|
||||
static constexpr uint64_t SYS_INPUT_WAIT = 123;
|
||||
static constexpr uint64_t SYS_DRIVELABEL = 124;
|
||||
static constexpr uint64_t SYS_NETSTATUS = 125;
|
||||
static constexpr uint64_t SYS_DRIVEKIND = 127;
|
||||
|
||||
static constexpr uint32_t CLIPBOARD_MAX_TEXT_BYTES = 256 * 1024;
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ struct DesktopState {
|
||||
SvgIcon icon_exec_lg;
|
||||
SvgIcon icon_drive;
|
||||
SvgIcon icon_drive_lg;
|
||||
SvgIcon icon_drive_usb;
|
||||
SvgIcon icon_drive_usb_lg;
|
||||
SvgIcon icon_delete;
|
||||
SvgIcon icon_copy;
|
||||
SvgIcon icon_cut;
|
||||
|
||||
@@ -164,6 +164,11 @@ namespace montauk {
|
||||
inline int drivelabel(int drive, char* outLabel, int maxLen) {
|
||||
return (int)syscall3(Montauk::SYS_DRIVELABEL, (uint64_t)drive, (uint64_t)outLabel, (uint64_t)maxLen);
|
||||
}
|
||||
// Returns the kernel BlockDeviceKind backing the drive: 0=unknown/ramdisk,
|
||||
// 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC.
|
||||
inline int drivekind(int drive) {
|
||||
return (int)syscall1(Montauk::SYS_DRIVEKIND, (uint64_t)drive);
|
||||
}
|
||||
|
||||
// Memory
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Montauk::SYS_ALLOC, size); }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -72,6 +72,8 @@ void ensure_filemanager_icons_loaded(DesktopState* ds) {
|
||||
Color defColor = colors::ICON_COLOR;
|
||||
ds->icon_drive = svg_load("0:/icons/drive-harddisk.svg", 16, 16, defColor);
|
||||
ds->icon_drive_lg = svg_load("0:/icons/drive-harddisk.svg", 48, 48, defColor);
|
||||
ds->icon_drive_usb = svg_load("0:/icons/drive-harddisk-usb.svg", 16, 16, defColor);
|
||||
ds->icon_drive_usb_lg = svg_load("0:/icons/drive-harddisk-usb.svg", 48, 48, defColor);
|
||||
ds->icon_home_folder = svg_load("0:/icons/folder-blue-home.svg", 16, 16, defColor);
|
||||
ds->icon_home_folder_lg = svg_load("0:/icons/folder-blue-home.svg", 48, 48, defColor);
|
||||
ds->icon_apps = svg_load("0:/icons/folder-blue-development.svg", 16, 16, defColor);
|
||||
|
||||
@@ -68,6 +68,7 @@ struct FileManagerState {
|
||||
DesktopState* desktop;
|
||||
bool grid_view;
|
||||
int drive_indices[64]; // drive number or special-folder index for Computer view entries
|
||||
int drive_kinds[64]; // kernel BlockDeviceKind for FM_ENTRY_DRIVE entries (4 = USB MSC)
|
||||
|
||||
// Clipboard
|
||||
char clipboard_path[256];
|
||||
|
||||
@@ -39,6 +39,10 @@ static void filemanager_add_root_entry(FileManagerState* fm,
|
||||
fm->entry_sizes[idx] = 0;
|
||||
fm->is_dir[idx] = true;
|
||||
fm->drive_indices[idx] = drive_index;
|
||||
fm->drive_kinds[idx] = 0;
|
||||
if (type == FM_ENTRY_DRIVE && drive_index >= 0) {
|
||||
fm->drive_kinds[idx] = montauk::drivekind(drive_index);
|
||||
}
|
||||
}
|
||||
|
||||
static int filemanager_add_virtual_entry(FileManagerState* fm,
|
||||
|
||||
@@ -333,7 +333,10 @@ void filemanager_on_draw(Window* win, Framebuffer& fb) {
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_HOME && ds->icon_home_folder_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_home_folder_lg);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DRIVE && ds->icon_drive_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_drive_lg);
|
||||
// Kind 4 = USB MSC (kernel BlockDeviceKind enum)
|
||||
const SvgIcon& di = (fm->drive_kinds[i] == 4 && ds->icon_drive_usb_lg.pixels)
|
||||
? ds->icon_drive_usb_lg : ds->icon_drive_lg;
|
||||
c.icon(icon_x, icon_y, di);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DIR && ds->icon_folder_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_folder_lg);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_EXEC && ds->icon_exec_lg.pixels) {
|
||||
@@ -464,7 +467,9 @@ void filemanager_on_draw(Window* win, Framebuffer& fb) {
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_HOME && ds->icon_home_folder.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_home_folder);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DRIVE && ds->icon_drive.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_drive);
|
||||
const SvgIcon& di = (fm->drive_kinds[i] == 4 && ds->icon_drive_usb.pixels)
|
||||
? ds->icon_drive_usb : ds->icon_drive;
|
||||
c.icon(ico_x, ico_y, di);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DIR && ds->icon_folder.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_folder);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_EXEC && ds->icon_exec.pixels) {
|
||||
|
||||
Reference in New Issue
Block a user