-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat(CFW): added AmberELEC support with RG351V and Rg351P devices #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
XargonWan
wants to merge
5
commits into
rommapp:main
Choose a base branch
from
XargonWan:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
44719a9
feat(CFW): added AmberELEC support with RG351V device
XargonWan 84d7dc9
feat(cfw): created a dedicated platform for AmberELEC
XargonWan dc69a9e
docs(AmberELEC): updated installation instructions
XargonWan 57e44d7
fix(docs): fixed ports location folder
XargonWan b17d0a3
feat(amberelec): added support for RG351P
XargonWan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| package amberelec | ||
|
|
||
| import ( | ||
| "embed" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "grout/cfw/rocknix" | ||
| ) | ||
|
|
||
| //go:embed input_mappings/*.json | ||
| var embeddedInputMappings embed.FS | ||
|
|
||
| type Device string | ||
|
|
||
| const ( | ||
| DeviceGeneric Device = "generic" | ||
| DeviceRG351V Device = "rg351v" | ||
| ) | ||
|
|
||
| var Platforms = buildPlatforms() | ||
|
|
||
| func DetectDevice() Device { | ||
| arch, err := os.ReadFile("/storage/.config/.OS_ARCH") | ||
| if err != nil { | ||
| return DeviceGeneric | ||
| } | ||
|
|
||
| switch strings.ToUpper(strings.TrimSpace(string(arch))) { | ||
| case "RG351V": | ||
| return DeviceRG351V | ||
| default: | ||
| return DeviceGeneric | ||
| } | ||
| } | ||
|
|
||
| func GetInputMappingBytes() ([]byte, error) { | ||
| var filename string | ||
| switch DetectDevice() { | ||
| case DeviceRG351V: | ||
| filename = "input_mappings/rg351v.json" | ||
| default: | ||
| return nil, nil | ||
| } | ||
|
|
||
| overridePath := filepath.Join("overrides", "cfw", "amberelec", filename) | ||
| data, err := os.ReadFile(overridePath) | ||
| if err != nil { | ||
| data, err = embeddedInputMappings.ReadFile(filename) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to read embedded input mapping %s: %w", filename, err) | ||
| } | ||
| } | ||
|
|
||
| return data, nil | ||
| } | ||
|
|
||
| func GetBasePath() string { | ||
| if basePath := os.Getenv("BASE_PATH"); basePath != "" { | ||
| return basePath | ||
| } | ||
| return "/storage" | ||
| } | ||
|
|
||
| func GetRomDirectory() string { | ||
| return filepath.Join(GetBasePath(), "roms") | ||
| } | ||
|
|
||
| func GetBIOSDirectory() string { | ||
| return filepath.Join(GetRomDirectory(), "bios") | ||
| } | ||
|
|
||
| func GetBaseSavePath() string { | ||
| return GetRomDirectory() | ||
| } | ||
|
|
||
| func GetArtDirectory(romDir string) string { | ||
| return filepath.Join(romDir, "images") | ||
| } | ||
|
|
||
| func GetGroutGamelist() string { | ||
| return filepath.Join(GetRomDirectory(), "ports", "gamelist.xml") | ||
| } | ||
|
|
||
| func GetVideoDirectory(romDir string) string { | ||
| return filepath.Join(romDir, "videos") | ||
| } | ||
|
|
||
| func GetManualDirectory(romDir string) string { | ||
| return filepath.Join(romDir, "manuals") | ||
| } | ||
|
|
||
| func GetBezelDirectory(romDir string) string { | ||
| return filepath.Join(romDir, "bezels") | ||
| } | ||
|
|
||
| func buildPlatforms() map[string][]string { | ||
| platforms := clonePlatformMap(rocknix.Platforms) | ||
|
|
||
| setFolders(platforms, "gamegear", "gamegear", "gamegearh") | ||
| setFolders(platforms, "gb", "gb", "gbh") | ||
| setFolders(platforms, "gba", "gba", "gbah") | ||
| setFolders(platforms, "gbc", "gbc", "gbch") | ||
| setFolders(platforms, "genesis", "genesis", "megadrive", "genh", "megadrive-japan") | ||
| setFolders(platforms, "nes", "nes", "nesh") | ||
| setFolders(platforms, "sfam", "sfc", "snes") | ||
| setFolders(platforms, "snes", "snes", "sfc", "snesh", "snesmsu1") | ||
|
|
||
| setFolders(platforms, "gamegearh", "gamegearh") | ||
| setFolders(platforms, "gbh", "gbh") | ||
| setFolders(platforms, "gbah", "gbah") | ||
| setFolders(platforms, "gbch", "gbch") | ||
| setFolders(platforms, "genh", "genh") | ||
| setFolders(platforms, "megadrive-japan", "megadrive-japan") | ||
| setFolders(platforms, "nesh", "nesh") | ||
| setFolders(platforms, "sfc", "sfc") | ||
| setFolders(platforms, "snesh", "snesh") | ||
| setFolders(platforms, "snesmsu1", "snesmsu1") | ||
| setFolders(platforms, "vic-20", "vic20") | ||
|
|
||
| // AmberELEC wiki systems that are not currently exposed as RomM fs_slugs. | ||
| // Uncomment or adjust these when RomM adds the corresponding platform keys. | ||
| // setFolders(platforms, "atomiswave", "atomiswave") | ||
| // setFolders(platforms, "laserdisc", "laserdisc") | ||
| // setFolders(platforms, "naomi", "naomi") | ||
| // setFolders(platforms, "advision", "advision") | ||
| // setFolders(platforms, "gamepocketcomputer", "gamepocketcomputer") | ||
| // setFolders(platforms, "gamate", "gamate") | ||
| // setFolders(platforms, "gamemaster", "gamemaster") | ||
| // setFolders(platforms, "gamecom", "gamecom") | ||
| // setFolders(platforms, "gameking", "gameking") | ||
| // setFolders(platforms, "gameking3", "gameking3") | ||
| // setFolders(platforms, "pspminis", "pspminis") | ||
| // setFolders(platforms, "pv1000", "pv1000") | ||
| // setFolders(platforms, "satellaview", "satellaview") | ||
| // setFolders(platforms, "scv", "scv") | ||
| // setFolders(platforms, "sufami", "sufami") | ||
| // setFolders(platforms, "vsmile", "vsmile") | ||
| // setFolders(platforms, "chip-8", "chip-8") | ||
| // setFolders(platforms, "lowresnx", "lowresnx") | ||
| // setFolders(platforms, "piece", "piece") | ||
| // setFolders(platforms, "vircon32", "vircon32") | ||
| // setFolders(platforms, "wasm4", "wasm4") | ||
| // setFolders(platforms, "build", "build") | ||
| // setFolders(platforms, "doom", "doom") | ||
| // setFolders(platforms, "easyrpg", "easyrpg") | ||
| // setFolders(platforms, "ecwolf", "ecwolf") | ||
| // setFolders(platforms, "scummvm", "scummvm") | ||
| // setFolders(platforms, "solarus", "solarus") | ||
| // setFolders(platforms, "zmachine", "zmachine") | ||
| // setFolders(platforms, "ep64-128", "ep64-128") | ||
| // setFolders(platforms, "sc-3000", "sc-3000") | ||
| // setFolders(platforms, "thomson", "thomson") | ||
| // setFolders(platforms, "tvc", "tvc") | ||
|
|
||
| return platforms | ||
| } | ||
|
|
||
| func clonePlatformMap(platforms map[string][]string) map[string][]string { | ||
| cloned := make(map[string][]string, len(platforms)) | ||
| for slug, folders := range platforms { | ||
| cloned[slug] = append([]string(nil), folders...) | ||
| } | ||
| return cloned | ||
| } | ||
|
|
||
| func setFolders(platforms map[string][]string, slug string, folders ...string) { | ||
| platforms[slug] = append([]string(nil), folders...) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "keyboard_map": { | ||
| "59": 15 | ||
| }, | ||
| "controller_button_map": { | ||
| "0": 5, | ||
| "1": 6, | ||
| "2": 7, | ||
| "3": 8, | ||
| "4": 14, | ||
| "5": 15, | ||
| "6": 13, | ||
| "9": 9, | ||
| "10": 11, | ||
| "11": 1, | ||
| "12": 2, | ||
| "13": 3, | ||
| "14": 4 | ||
| }, | ||
| "controller_hat_map": {}, | ||
| "joystick_axis_map": { | ||
| "4": { | ||
| "positive_button": 10, | ||
| "negative_button": 0, | ||
| "threshold": 16000 | ||
| }, | ||
| "5": { | ||
| "positive_button": 12, | ||
| "negative_button": 0, | ||
| "threshold": 16000 | ||
| } | ||
| }, | ||
| "joystick_button_map": { | ||
| "4": 9 | ||
| }, | ||
| "joystick_hat_map": {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.