Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ jobs:
GROUT_VERSION: ${{ needs.prepare.outputs.version }}

- name: Package ARM64 platforms
run: task package:next package:muos package:knulli package:rocknix package:trimui package:batocera
run: task package:next package:muos package:knulli package:rocknix package:amberelec package:trimui package:batocera

- name: Create distributions
run: |
cd dist/Grout.pak && zip -r ../Grout.pak.zip . && cd ../..
cd dist/muOS && zip -r Grout.muxapp Grout && mv Grout.muxapp ../Grout.muxapp && cd ../..
cd dist/Knulli && zip -r ../Grout-Knulli.zip Grout && cd ../..
cd dist/ROCKNIX && zip -r ../Grout-ROCKNIX.zip Grout.sh Grout && cd ../..
cd dist/AmberELEC && zip -r ../Grout-AmberELEC.zip Grout.sh Grout && cd ../..
cd dist/Trimui && zip -r ../Grout-Trimui.zip Grout && cd ../..
cd dist/Batocera-arm64 && zip -r ../Grout-Batocera-arm64.zip Grout.sh Grout && cd ../..

Expand All @@ -113,6 +114,7 @@ jobs:
dist/Grout.muxapp
dist/Grout-Knulli.zip
dist/Grout-ROCKNIX.zip
dist/Grout-AmberELEC.zip
dist/Grout-Trimui.zip
dist/Grout-Batocera-arm64.zip
build64/grout
Expand Down Expand Up @@ -301,6 +303,7 @@ jobs:
**/Grout-Koriki.zip
**/Grout-Knulli.zip
**/Grout-ROCKNIX.zip
**/Grout-AmberELEC.zip
**/Grout-Trimui.zip
**/Grout-MinUI.zip
**/Grout-Batocera-arm64.zip
Expand Down Expand Up @@ -375,6 +378,7 @@ jobs:
"Grout-Knulli.zip"
"Grout.spruce.zip"
"Grout-ROCKNIX.zip"
"Grout-AmberELEC.zip"
"Grout-Trimui.zip"
"Grout-Allium.zip"
"Grout-Onion.zip"
Expand Down
3 changes: 3 additions & 0 deletions app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"grout/cache"
"grout/cfw"
"grout/cfw/amberelec"
"grout/cfw/allium"
"grout/cfw/koriki"
"grout/cfw/minui"
Expand Down Expand Up @@ -77,6 +78,8 @@ func setupInputMapping(currentCFW cfw.CFW) {
var mappingBytes []byte
var mappingErr error
switch currentCFW {
case cfw.AmberELEC:
mappingBytes, mappingErr = amberelec.GetInputMappingBytes()
case cfw.MuOS:
mappingBytes, mappingErr = muos.GetInputMappingBytes()
case cfw.Allium:
Expand Down
171 changes: 171 additions & 0 deletions cfw/amberelec/amberelec.go
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)
Comment thread
XargonWan marked this conversation as resolved.
Outdated

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...)
}
37 changes: 37 additions & 0 deletions cfw/amberelec/input_mappings/rg351v.json
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": {}
}
7 changes: 4 additions & 3 deletions cfw/cfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type CFW string

const (
AmberELEC CFW = "AMBERELEC"
NextUI CFW = "NEXTUI"
MuOS CFW = "MUOS"
Knulli CFW = "KNULLI"
Expand All @@ -27,18 +28,18 @@ func GetCFW() CFW {
cfw := CFW(cfwEnv)

switch cfw {
case MuOS, NextUI, Knulli, Spruce, ROCKNIX, Trimui, Allium, Onion, Koriki, Batocera, MinUI:
case AmberELEC, MuOS, NextUI, Knulli, Spruce, ROCKNIX, Trimui, Allium, Onion, Koriki, Batocera, MinUI:
return cfw
default:
log.SetOutput(os.Stderr)
log.Fatalf("Unsupported CFW: '%s'. Valid options: NextUI, muOS, Knulli, Spruce, ROCKNIX, Trimui, Allium, Onion, Koriki, Batocera, MinUI", cfwEnv)
log.Fatalf("Unsupported CFW: '%s'. Valid options: AmberELEC, NextUI, muOS, Knulli, Spruce, ROCKNIX, Trimui, Allium, Onion, Koriki, Batocera, MinUI", cfwEnv)
return ""
}
}

func (c CFW) IsBasedOnEmulationStation() bool {
switch c {
case Knulli, ROCKNIX, Batocera:
case AmberELEC, Knulli, ROCKNIX, Batocera:
return true
default:
return false
Expand Down
Loading