Skip to content

Commit 6b2be6f

Browse files
committed
peripheral fingerprinting will now consider meta information in the filename
eg. (PADDLE) indicates that a paddle is to be used
1 parent e94ac81 commit 6b2be6f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

hardware/peripherals/fingerprint.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package peripherals
1717

1818
import (
1919
"fmt"
20+
"strings"
2021

2122
"github.com/jetsetilly/gopher2600/cartridgeloader"
2223
"github.com/jetsetilly/gopher2600/hardware/peripherals/atarivox"
@@ -43,6 +44,12 @@ func Fingerprint(port plugging.PortID, loader cartridgeloader.Loader) ports.NewP
4344
panic(fmt.Sprintf("cannot fingerprint for port %v", port))
4445
}
4546

47+
// scan filename for any mention of a controller. this takes priority over everything else
48+
p := fingerprintFilename(loader.Filename)
49+
if p != nil {
50+
return p
51+
}
52+
4653
// atarivox and savekey are the most specific peripheral. because atarivox
4754
// includes the functionality of savekey we need to check atarivox first
4855
if fingerprintAtariVox(port, loader) {
@@ -73,6 +80,23 @@ func Fingerprint(port plugging.PortID, loader cartridgeloader.Loader) ports.NewP
7380
return controllers.NewStick
7481
}
7582

83+
func fingerprintFilename(name string) ports.NewPeripheral {
84+
name = strings.ToUpper(name)
85+
if strings.Contains(name, "(PADDLE)") {
86+
return controllers.NewPaddles
87+
}
88+
if strings.Contains(name, "(GAMEPAD)") {
89+
return controllers.NewGamepad
90+
}
91+
if strings.Contains(name, "(KEYPAD)") {
92+
return controllers.NewKeypad
93+
}
94+
if strings.Contains(name, "(JOYSTICK)") {
95+
return controllers.NewStick
96+
}
97+
return nil
98+
}
99+
76100
// fingerprinting beyond the first 64k or so of cartridge data can result in
77101
// very slow fingerprinting, particular if looking at a large file that is not a
78102
// cartridge file at all

0 commit comments

Comments
 (0)