Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.
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
16 changes: 14 additions & 2 deletions RomM/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,14 @@ def fetch_platforms(self) -> None:
for platform in platforms:
if platform["rom_count"] > 0:
platform_slug = platform["slug"].lower()
if self.file_system.is_muos:
if (
platform_maps._env_maps
and platform_slug in platform_maps._env_platforms
and platform_slug not in self._exclude_platforms
):
# A custom map from the .env was found, no need to check defaults
pass
elif self.file_system.is_muos:
if (
platform_slug not in platform_maps.MUOS_SUPPORTED_PLATFORMS
or platform_slug in self._exclude_platforms
Expand Down Expand Up @@ -452,7 +459,12 @@ def fetch_roms(self) -> None:
_roms = []
for rom in roms:
platform_slug = rom["platform_slug"].lower()
if self.file_system.is_muos:
if (
platform_maps._env_maps
and platform_slug in platform_maps._env_platforms
):
pass
elif self.file_system.is_muos:
if platform_slug not in platform_maps.MUOS_SUPPORTED_PLATFORMS:
continue
elif self.file_system.is_spruceos:
Expand Down
5 changes: 5 additions & 0 deletions RomM/env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ COLLECTION_TYPE=collection

# Do not display collections with these names (comma separated)
# EXCLUDE_COLLECTIONS=""

# Map RomM slugs to filesystem directories
# For example, if your PlayStation directory is called "psx":
# CUSTOM_MAPS='{"ps": "psx"}'
# CUSTOM_MAPS=''
3 changes: 3 additions & 0 deletions RomM/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def _get_platform_storage_dir_from_mapping(self, platform: str) -> str:
platform, platform_dir
)

if platform_maps._env_maps and platform in platform_maps._env_platforms:
platform_dir = platform_maps._env_maps.get(platform, platform_dir)

return platform_dir

def _get_sd1_platforms_storage_path(self, platform: str) -> str:
Expand Down
5 changes: 5 additions & 0 deletions RomM/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import sys
import zipfile

import platform_maps

# Add dependencies to path
base_path = os.path.dirname(os.path.abspath(__file__))
libs_path = os.path.join(base_path, "deps")
Expand Down Expand Up @@ -48,6 +50,9 @@ def apply_pending_update():
os.makedirs(os.path.dirname(log_file), exist_ok=True)
sys.stdout = open(log_file, "w", buffering=1)

# Read any custom maps
platform_maps.init_env_maps()


def cleanup(romm: RomM, exit_code: int):
romm.ui.cleanup()
Expand Down
30 changes: 30 additions & 0 deletions RomM/platform_maps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
import os

# Manual mapping of RomM slugs to device folder names and platform icons for es systems
# This is sometimes needed to match custom system folders with defaults, for example ES-DE uses roms/gc and some Batocera forks use roms/gamecube
# https://gitlab.com/es-de/emulationstation-de/-/blob/master/resources/systems/unix/es_systems.xml
Expand Down Expand Up @@ -192,3 +195,30 @@
SPRUCEOS_SUPPORTED_PLATFORMS_FS = frozenset(
SPRUCEOS_SUPPORTED_PLATFORMS_FS_MAP.values()
)

_env_maps = None
_env_platforms = None


def _load_env_maps() -> dict[str, str]:
raw = os.getenv("CUSTOM_MAPS")
if not raw:
return {}
try:
loaded = json.loads(raw)
return loaded
except json.JSONDecodeError as e:
print(f"Error: CUSTOM_MAPS is an invalid JSON format: {e}")
return {}
except Exception as e:
print(f"Error: Unexpected error: {e}")
return {}


def init_env_maps():
global _env_maps
global _env_platforms
if _env_maps is None:
_env_maps = _load_env_maps()
if _env_platforms is None:
_env_platforms = frozenset(_env_maps.keys())