From 46098ef5b694494dd0ae41ecc2a260bc4cd8f1b4 Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Thu, 15 Feb 2024 08:38:53 -0800 Subject: [PATCH 1/7] Basic functionality within ludo --- core/core.go | 1 + scanner/scanner.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/core/core.go b/core/core.go index e3aea607..79f04b39 100644 --- a/core/core.go +++ b/core/core.go @@ -111,6 +111,7 @@ func unarchiveGame(filename string) (string, int64, error) { extPrefered := make(map[string]int) extPrefered[".cue"] = 1 extPrefered[".m3u"] = 2 + extPrefered[".pbp"] = 3 err = archiver.Walk(filename, func(f archiver.File) error { fname := f.Name() diff --git a/scanner/scanner.go b/scanner/scanner.go index 4c70bbf3..bbebc391 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -135,6 +135,10 @@ func Scan(dir string, roms []string, games chan (dat.Game), n *ntf.Notification) // Look for a matching game entry in the database state.DB.FindByROMName(f, filepath.Base(f), 0, games) n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) + case ".pbp": + // Look for a matching game entry in the database + state.DB.FindByROMName(f, filepath.Base(f), 0, games) + n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) case ".32x", "a52", ".a78", ".col", ".crt", ".d64", ".pce", ".fds", ".gb", ".gba", ".gbc", ".gen", ".gg", ".ipf", ".j64", ".jag", ".lnx", ".md", ".n64", ".nes", ".ngc", ".nds", ".rom", ".sfc", ".sg", ".smc", ".smd", ".sms", ".ws", ".wsc": bytes, err := ioutil.ReadFile(f) if err != nil { From 5ce1b2dc26fa640d208ad3db19288f243c39e04c Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Thu, 15 Feb 2024 11:13:33 -0800 Subject: [PATCH 2/7] cleaned up the pbp file check --- scanner/scanner.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scanner/scanner.go b/scanner/scanner.go index bbebc391..a3b57c1a 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -131,14 +131,10 @@ func Scan(dir string, roms []string, games chan (dat.Game), n *ntf.Notification) } } z.Close() - case ".cue": + case ".cue", ".pbp": // Look for a matching game entry in the database state.DB.FindByROMName(f, filepath.Base(f), 0, games) - n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) - case ".pbp": - // Look for a matching game entry in the database - state.DB.FindByROMName(f, filepath.Base(f), 0, games) - n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) + n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) case ".32x", "a52", ".a78", ".col", ".crt", ".d64", ".pce", ".fds", ".gb", ".gba", ".gbc", ".gen", ".gg", ".ipf", ".j64", ".jag", ".lnx", ".md", ".n64", ".nes", ".ngc", ".nds", ".rom", ".sfc", ".sg", ".smc", ".smd", ".sms", ".ws", ".wsc": bytes, err := ioutil.ReadFile(f) if err != nil { From aa7043c6c751be43b5f569736e94cf6d4a891700 Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Thu, 15 Feb 2024 12:18:43 -0800 Subject: [PATCH 3/7] cleaned up trailing whitespace --- scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scanner/scanner.go b/scanner/scanner.go index a3b57c1a..f3e0b440 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -134,7 +134,7 @@ func Scan(dir string, roms []string, games chan (dat.Game), n *ntf.Notification) case ".cue", ".pbp": // Look for a matching game entry in the database state.DB.FindByROMName(f, filepath.Base(f), 0, games) - n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) + n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) case ".32x", "a52", ".a78", ".col", ".crt", ".d64", ".pce", ".fds", ".gb", ".gba", ".gbc", ".gen", ".gg", ".ipf", ".j64", ".jag", ".lnx", ".md", ".n64", ".nes", ".ngc", ".nds", ".rom", ".sfc", ".sg", ".smc", ".smd", ".sms", ".ws", ".wsc": bytes, err := ioutil.ReadFile(f) if err != nil { From 5c56421faa3a5288c6d2ee843e550f248a4febef Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Thu, 15 Feb 2024 15:13:09 -0800 Subject: [PATCH 4/7] Added m3u support and improved multi disc playlist support. --- dat/dat.go | 11 +++++++---- menu/scene_playlist.go | 5 +++++ scanner/scanner.go | 3 +-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dat/dat.go b/dat/dat.go index 210641ea..5d0b5cc0 100644 --- a/dat/dat.go +++ b/dat/dat.go @@ -101,10 +101,13 @@ func (db *DB) FindByROMName(romPath string, romName string, crc uint32, games ch continue } // If the checksums match - if romName == game.ROMs[0].Name { - game.Path = romPath - game.System = system - games <- game + for _, ROM := range game.ROMs { + if romName == ROM.Name { + game.Path = romPath + game.System = system + games <- game + } + // element is the element from someSlice for where we are } } wg.Done() diff --git a/menu/scene_playlist.go b/menu/scene_playlist.go index 705cf18a..c140f192 100644 --- a/menu/scene_playlist.go +++ b/menu/scene_playlist.go @@ -26,6 +26,11 @@ func buildPlaylist(path string) Scene { for _, game := range playlists.Playlists[path] { game := game // needed for callbackOK strippedName, tags := extractTags(game.Name) + if strings.Contains(game.Name, "Disc") { + re := regexp.MustCompile(`\((Disc [1-9]?)\)`) + match := re.FindStringSubmatch(game.Name) + strippedName = strippedName + " (" + match[1] + ")" + } list.children = append(list.children, entry{ label: strippedName, gameName: game.Name, diff --git a/scanner/scanner.go b/scanner/scanner.go index f3e0b440..6953749d 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -11,7 +11,6 @@ import ( "path/filepath" "strconv" "strings" - "github.com/libretro/ludo/dat" ntf "github.com/libretro/ludo/notifications" "github.com/libretro/ludo/playlists" @@ -131,7 +130,7 @@ func Scan(dir string, roms []string, games chan (dat.Game), n *ntf.Notification) } } z.Close() - case ".cue", ".pbp": + case ".cue", ".pbp", ".m3u": // Look for a matching game entry in the database state.DB.FindByROMName(f, filepath.Base(f), 0, games) n.Update(ntf.Info, strconv.Itoa(i)+"/"+strconv.Itoa(len(roms))+" "+f) From 55c9427d62700258526ad98c0e44db485642ba18 Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Sat, 17 Feb 2024 20:15:33 -0800 Subject: [PATCH 5/7] configurable starting path added. --- menu/scene_tabs.go | 7 ++++--- settings/defaults.go | 1 + settings/settings.go | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/menu/scene_tabs.go b/menu/scene_tabs.go index 630d4a1a..b46401e1 100644 --- a/menu/scene_tabs.go +++ b/menu/scene_tabs.go @@ -3,7 +3,7 @@ package menu import ( "fmt" "os" - "os/user" + //"os/user" "sort" "github.com/libretro/ludo/audio" @@ -15,6 +15,7 @@ import ( "github.com/libretro/ludo/state" "github.com/libretro/ludo/utils" "github.com/libretro/ludo/video" + "github.com/libretro/ludo/settings" colorful "github.com/lucasb-eyer/go-colorful" "github.com/tanema/gween" @@ -63,8 +64,8 @@ func buildTabs() Scene { subLabel: "Scan your collection", icon: "add", callbackOK: func() { - usr, _ := user.Current() - menu.Push(buildExplorer(usr.HomeDir, nil, + //usr, _ := user.Current() + menu.Push(buildExplorer(settings.Current.FileDirectory, nil, func(path string) { scanner.ScanDir(path, refreshTabs) }, diff --git a/settings/defaults.go b/settings/defaults.go index 072615ec..47914d50 100644 --- a/settings/defaults.go +++ b/settings/defaults.go @@ -58,6 +58,7 @@ func defaultSettings() Settings { "SNK - Neo Geo Pocket": "mednafen_ngp_libretro", "Sony - PlayStation": playstationCore, }, + FileDirectory: xdg.DataHome, CoresDirectory: "./cores", AssetsDirectory: "./assets", DatabaseDirectory: "./database", diff --git a/settings/settings.go b/settings/settings.go index b3d6fb87..b03db8ac 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -36,6 +36,7 @@ type Settings struct { CoreForPlaylist map[string]string `hide:"always" toml:"core_for_playlist"` + FileDirectory string `hide:"ludos" toml:"files_dir" label:"Files Directory" fmt:"%s" widget:"dir"` CoresDirectory string `hide:"ludos" toml:"cores_dir" label:"Cores Directory" fmt:"%s" widget:"dir"` AssetsDirectory string `hide:"ludos" toml:"assets_dir" label:"Assets Directory" fmt:"%s" widget:"dir"` DatabaseDirectory string `hide:"ludos" toml:"database_dir" label:"Database Directory" fmt:"%s" widget:"dir"` From 553f635cebc4f7add4ef58f96558243d1d3e66ac Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Mon, 19 Feb 2024 11:46:18 -0800 Subject: [PATCH 6/7] Setting now exists, and functions correctly when changed in settings.toml, but crashes when changed in GUI. --- menu/input.go | 46 +++++++++++++++++++++------------ menu/scene.go | 11 ++++++-- menu/scene_core_disk_control.go | 11 ++++++-- menu/scene_core_options.go | 9 +++++-- menu/scene_dialog.go | 17 ++++++++++-- menu/scene_history.go | 11 ++++++-- menu/scene_keyboard.go | 29 +++++++++++++++------ menu/scene_playlist.go | 10 +++++-- menu/scene_savestates.go | 22 +++++++++++++--- menu/scene_settings.go | 15 +++++++++-- menu/scene_tabs.go | 20 +++++++++++--- menu/scene_wifi.go | 14 ++++++++-- settings/defaults.go | 1 + settings/settings.go | 1 + 14 files changed, 168 insertions(+), 49 deletions(-) diff --git a/menu/input.go b/menu/input.go index 28b8c648..b518b737 100644 --- a/menu/input.go +++ b/menu/input.go @@ -85,22 +85,6 @@ func genericInput(list *entry, dt float32) { genericAnimate(list) }) - // OK - if input.Released[0][libretro.DeviceIDJoypadA] == 1 { - if list.children[list.ptr].callbackOK != nil { - audio.PlayEffect(audio.Effects["ok"]) - list.children[list.ptr].callbackOK() - } - } - - // X - if input.Released[0][libretro.DeviceIDJoypadX] == 1 { - if list.children[list.ptr].callbackX != nil { - audio.PlayEffect(audio.Effects["ok"]) - list.children[list.ptr].callbackX() - } - } - // Right if input.Released[0][libretro.DeviceIDJoypadRight] == 1 { if list.children[list.ptr].incr != nil { @@ -117,8 +101,28 @@ func genericInput(list *entry, dt float32) { } } + var confirmKey uint32 + var cancelKey uint32 + + confirmKey = libretro.DeviceIDJoypadA + cancelKey = libretro.DeviceIDJoypadB + + // Optionally swap confirm and cancel + if settings.Current.SwapConfirm { + confirmKey = libretro.DeviceIDJoypadB + cancelKey = libretro.DeviceIDJoypadA + } + + // OK + if input.Released[0][confirmKey] == 1 { + if list.children[list.ptr].callbackOK != nil { + audio.PlayEffect(audio.Effects["ok"]) + list.children[list.ptr].callbackOK() + } + } + // Cancel - if input.Released[0][libretro.DeviceIDJoypadB] == 1 { + if input.Released[0][cancelKey] == 1 { if len(menu.stack) > 1 { audio.PlayEffect(audio.Effects["cancel"]) menu.stack[len(menu.stack)-2].segueBack() @@ -126,6 +130,14 @@ func genericInput(list *entry, dt float32) { } } + // X + if input.Released[0][libretro.DeviceIDJoypadX] == 1 { + if list.children[list.ptr].callbackX != nil { + audio.PlayEffect(audio.Effects["ok"]) + list.children[list.ptr].callbackX() + } + } + // Jump to next letter if input.Released[0][libretro.DeviceIDJoypadR] == 1 && len(list.indexes) > 0 { list.ptr = indexed(list, +1) diff --git a/menu/scene.go b/menu/scene.go index f3020a6b..761842f4 100644 --- a/menu/scene.go +++ b/menu/scene.go @@ -2,6 +2,7 @@ package menu import ( "github.com/libretro/ludo/state" + "github.com/libretro/ludo/settings" "github.com/tanema/gween" "github.com/tanema/gween/ease" ) @@ -273,6 +274,12 @@ func genericDrawHintBar() { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) - stackHint(&stack, a, "OK", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, b, "OK", h) + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, a, "OPEN", h) + stackHint(&stack, b, "OK", h) + } } diff --git a/menu/scene_core_disk_control.go b/menu/scene_core_disk_control.go index ef3dfd13..d5aa362a 100644 --- a/menu/scene_core_disk_control.go +++ b/menu/scene_core_disk_control.go @@ -5,6 +5,7 @@ import ( ntf "github.com/libretro/ludo/notifications" "github.com/libretro/ludo/state" + "github.com/libretro/ludo/settings" ) type sceneCoreDiskControl struct { @@ -79,13 +80,19 @@ func (s *sceneCoreDiskControl) drawHintBar() { w, h := menu.GetFramebufferSize() menu.DrawRect(0, float32(h)-70*menu.ratio, float32(w), 70*menu.ratio, 0, lightGrey) - _, upDown, leftRight, _, b, _, _, _, _, guide := hintIcons() + _, upDown, leftRight, a, b, _, _, _, _, guide := hintIcons() var stack float32 if state.CoreRunning { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, b, "BACK", h) + } + stackHint(&stack, leftRight, "SET", h) } diff --git a/menu/scene_core_options.go b/menu/scene_core_options.go index e347d7dd..aeea7db7 100644 --- a/menu/scene_core_options.go +++ b/menu/scene_core_options.go @@ -6,6 +6,7 @@ import ( "github.com/libretro/ludo/core" ntf "github.com/libretro/ludo/notifications" "github.com/libretro/ludo/state" + "github.com/libretro/ludo/settings" ) type sceneCoreOptions struct { @@ -83,13 +84,17 @@ func (s *sceneCoreOptions) drawHintBar() { w, h := menu.GetFramebufferSize() menu.DrawRect(0, float32(h)-70*menu.ratio, float32(w), 70*menu.ratio, 0, lightGrey) - _, upDown, leftRight, _, b, _, _, _, _, guide := hintIcons() + _, upDown, leftRight, a, b, _, _, _, _, guide := hintIcons() var stack float32 if state.CoreRunning { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) + if settings.Current.SwapConfirm { + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, b, "BACK", h) + } stackHint(&stack, leftRight, "SET", h) } diff --git a/menu/scene_dialog.go b/menu/scene_dialog.go index 7da8c35e..b10a78a2 100644 --- a/menu/scene_dialog.go +++ b/menu/scene_dialog.go @@ -4,6 +4,7 @@ import ( "github.com/libretro/ludo/audio" "github.com/libretro/ludo/input" "github.com/libretro/ludo/libretro" + "github.com/libretro/ludo/settings" ) type sceneDialog struct { @@ -36,8 +37,20 @@ func (s *sceneDialog) segueBack() { } func (s *sceneDialog) update(dt float32) { + var confirmKey uint32 + var cancelKey uint32 + + confirmKey = libretro.DeviceIDJoypadA + cancelKey = libretro.DeviceIDJoypadB + + // Optionally swap confirm and cancel + if settings.Current.SwapConfirm { + confirmKey = libretro.DeviceIDJoypadB + cancelKey = libretro.DeviceIDJoypadA + } + // OK - if input.Released[0][libretro.DeviceIDJoypadA] == 1 { + if input.Released[0][confirmKey] == 1 { audio.PlayEffect(audio.Effects["ok"]) menu.stack[len(menu.stack)-2].segueBack() menu.stack = menu.stack[:len(menu.stack)-1] @@ -45,7 +58,7 @@ func (s *sceneDialog) update(dt float32) { } // Cancel - if input.Released[0][libretro.DeviceIDJoypadB] == 1 { + if input.Released[0][cancelKey] == 1 { audio.PlayEffect(audio.Effects["cancel"]) menu.stack[len(menu.stack)-2].segueBack() menu.stack = menu.stack[:len(menu.stack)-1] diff --git a/menu/scene_history.go b/menu/scene_history.go index c52b4ccd..2bbdd3a7 100644 --- a/menu/scene_history.go +++ b/menu/scene_history.go @@ -8,6 +8,7 @@ import ( "github.com/libretro/ludo/history" ntf "github.com/libretro/ludo/notifications" "github.com/libretro/ludo/state" + "github.com/libretro/ludo/settings" ) type sceneHistory struct { @@ -242,8 +243,14 @@ func (s *sceneHistory) drawHintBar() { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) - stackHint(&stack, a, "RUN", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, b, "RUN", h) + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, a, "RUN", h) + stackHint(&stack, b, "BACK", h) + } list := menu.stack[len(menu.stack)-1].Entry() if list.children[list.ptr].callbackX != nil { diff --git a/menu/scene_keyboard.go b/menu/scene_keyboard.go index 96765b23..bb35b33f 100644 --- a/menu/scene_keyboard.go +++ b/menu/scene_keyboard.go @@ -5,6 +5,7 @@ import ( "github.com/libretro/ludo/input" "github.com/libretro/ludo/libretro" "github.com/libretro/ludo/video" + "github.com/libretro/ludo/settings" "github.com/tanema/gween" "github.com/tanema/gween/ease" ) @@ -109,12 +110,31 @@ func (s *sceneKeyboard) update(dt float32) { } }) + var confirmKey uint32 + var cancelKey uint32 + + confirmKey = libretro.DeviceIDJoypadA + cancelKey = libretro.DeviceIDJoypadB + + // Optionally swap confirm and cancel + if settings.Current.SwapConfirm { + confirmKey = libretro.DeviceIDJoypadB + cancelKey = libretro.DeviceIDJoypadA + } + // OK - if input.Released[0][libretro.DeviceIDJoypadA] == 1 { + if input.Released[0][confirmKey] == 1 { audio.PlayEffect(audio.Effects["ok"]) s.value += layouts[s.layout][s.index] } + // Cancel + if input.Released[0][cancelKey] == 1 && len(menu.stack) > 1 { + audio.PlayEffect(audio.Effects["cancel"]) + menu.stack[len(menu.stack)-2].segueBack() + menu.stack = menu.stack[:len(menu.stack)-1] + } + // Switch layout if input.Released[0][libretro.DeviceIDJoypadX] == 1 { audio.PlayEffect(audio.Effects["ok"]) @@ -132,13 +152,6 @@ func (s *sceneKeyboard) update(dt float32) { } }) - // Cancel - if input.Released[0][libretro.DeviceIDJoypadB] == 1 && len(menu.stack) > 1 { - audio.PlayEffect(audio.Effects["cancel"]) - menu.stack[len(menu.stack)-2].segueBack() - menu.stack = menu.stack[:len(menu.stack)-1] - } - // Done if input.Released[0][libretro.DeviceIDJoypadStart] == 1 && s.value != "" { audio.PlayEffect(audio.Effects["notice"]) diff --git a/menu/scene_playlist.go b/menu/scene_playlist.go index c140f192..ff42b4ae 100644 --- a/menu/scene_playlist.go +++ b/menu/scene_playlist.go @@ -275,8 +275,14 @@ func (s *scenePlaylist) drawHintBar() { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) - stackHint(&stack, a, "RUN", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, b, "RUN", h) + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, a, "RUN", h) + stackHint(&stack, b, "BACK", h) + } list := menu.stack[len(menu.stack)-1].Entry() if list.children[list.ptr].callbackX != nil { diff --git a/menu/scene_savestates.go b/menu/scene_savestates.go index 950888f6..38333c1a 100644 --- a/menu/scene_savestates.go +++ b/menu/scene_savestates.go @@ -175,11 +175,25 @@ func (s *sceneSavestates) drawHintBar() { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) - if ptr == 0 { - stackHint(&stack, a, "SAVE", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, b, "BACK", h) + } + + if settings.Current.SwapConfirm { + if ptr == 0 { + stackHint(&stack, b, "SAVE", h) + } else { + stackHint(&stack, b, "LOAD", h) + } } else { - stackHint(&stack, a, "LOAD", h) + if ptr == 0 { + stackHint(&stack, a, "SAVE", h) + } else { + stackHint(&stack, a, "LOAD", h) + } } list := menu.stack[len(menu.stack)-1].Entry() diff --git a/menu/scene_settings.go b/menu/scene_settings.go index c5e93bf1..b7be85d5 100644 --- a/menu/scene_settings.go +++ b/menu/scene_settings.go @@ -284,9 +284,20 @@ func (s *sceneSettings) drawHintBar() { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, b, "BACK", h) + } + + if list.children[list.ptr].callbackOK != nil { - stackHint(&stack, a, "SET", h) + if settings.Current.SwapConfirm { + stackHint(&stack, b, "SET", h) + } else { + stackHint(&stack, a, "SET", h) + } } else { stackHint(&stack, leftRight, "SET", h) } diff --git a/menu/scene_tabs.go b/menu/scene_tabs.go index b46401e1..4ad44c4d 100644 --- a/menu/scene_tabs.go +++ b/menu/scene_tabs.go @@ -263,8 +263,17 @@ func (tabs *sceneTabs) update(dt float32) { tabs.animate() }) + var confirmKey uint32 + + confirmKey = libretro.DeviceIDJoypadA + + // Optionally swap confirm and cancel + if settings.Current.SwapConfirm { + confirmKey = libretro.DeviceIDJoypadB + } + // OK - if input.Released[0][libretro.DeviceIDJoypadA] == 1 { + if input.Released[0][confirmKey] == 1 { if tabs.children[tabs.ptr].callbackOK != nil { audio.PlayEffect(audio.Effects["ok"]) tabs.segueNext() @@ -315,15 +324,18 @@ func (tabs sceneTabs) drawHintBar() { w, h := menu.GetFramebufferSize() menu.DrawRect(0, float32(h)-70*menu.ratio, float32(w), 70*menu.ratio, 0, lightGrey) - _, _, leftRight, a, _, x, _, _, _, guide := hintIcons() + _, _, leftRight, a, b, x, _, _, _, guide := hintIcons() var stack float32 if state.CoreRunning { stackHint(&stack, guide, "RESUME", h) } stackHint(&stack, leftRight, "NAVIGATE", h) - stackHint(&stack, a, "OPEN", h) - + if settings.Current.SwapConfirm { + stackHint(&stack, b, "OPEN", h) + } else { + stackHint(&stack, a, "OPEN", h) + } list := menu.stack[0].Entry() if list.children[list.ptr].callbackX != nil { stackHint(&stack, x, "DELETE", h) diff --git a/menu/scene_wifi.go b/menu/scene_wifi.go index 0af9d257..83716eb0 100644 --- a/menu/scene_wifi.go +++ b/menu/scene_wifi.go @@ -2,6 +2,7 @@ package menu import ( "github.com/libretro/ludo/ludos" + "github.com/libretro/ludo/settings" ntf "github.com/libretro/ludo/notifications" ) @@ -92,8 +93,17 @@ func (s *sceneWiFi) drawHintBar() { var stack float32 stackHint(&stack, upDown, "NAVIGATE", h) - stackHint(&stack, b, "BACK", h) + + if settings.Current.SwapConfirm { + stackHint(&stack, a, "BACK", h) + } else { + stackHint(&stack, b, "BACK", h) + } if s.children[0].callbackOK != nil { - stackHint(&stack, a, "CONNECT", h) + if settings.Current.SwapConfirm { + stackHint(&stack, b, "CONNECT", h) + } else { + stackHint(&stack, a, "CONNECT", h) + } } } diff --git a/settings/defaults.go b/settings/defaults.go index 47914d50..0afd836b 100644 --- a/settings/defaults.go +++ b/settings/defaults.go @@ -12,6 +12,7 @@ func defaultSettings() Settings { VideoMonitorIndex: 0, VideoFilter: "Pixel Perfect", MapAxisToDPad: false, + SwapConfirm: false, AudioVolume: 0.5, MenuAudioVolume: 0.25, ShowHiddenFiles: false, diff --git a/settings/settings.go b/settings/settings.go index b03db8ac..c2338e91 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -33,6 +33,7 @@ type Settings struct { ShowHiddenFiles bool `toml:"menu_showhiddenfiles" label:"Show Hidden Files" fmt:"%t" widget:"switch"` MapAxisToDPad bool `toml:"input_map_axis_to_dpad" label:"Map Sticks To DPad" fmt:"%t" widget:"switch"` + SwapConfirm bool `toml:"input_swap_confirm" label:"Swap Confirm and Cancel" fmt:"%t" widget:"switch"` CoreForPlaylist map[string]string `hide:"always" toml:"core_for_playlist"` From 33cc4ab8dc615f60748c71f692839ad3f8bd3356 Mon Sep 17 00:00:00 2001 From: Stephen Ancona Date: Mon, 19 Feb 2024 11:53:26 -0800 Subject: [PATCH 7/7] Fixed the crash. I had forgotten to make a settings callback for the new option. --- menu/scene_settings.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menu/scene_settings.go b/menu/scene_settings.go index b7be85d5..ac3bf17c 100644 --- a/menu/scene_settings.go +++ b/menu/scene_settings.go @@ -209,6 +209,12 @@ var incrCallbacks = map[string]callbackIncrement{ f.Set(v) settings.Save() }, + "SwapConfirm": func(f *structs.Field, direction int) { + v := f.Value().(bool) + v = !v + f.Set(v) + settings.Save() + }, "AudioVolume": func(f *structs.Field, direction int) { v := f.Value().(float32) v += 0.1 * float32(direction)