diff bindings.c @ 2528:90a40be940f7

Implement read-only SC-3000 cassette support
author Michael Pavone <pavone@retrodev.com>
date Mon, 25 Nov 2024 22:26:45 -0800
parents f8ce89498e11
children f973651b48d7
line wrap: on
line diff
--- a/bindings.c	Sat Oct 26 14:31:21 2024 -0700
+++ b/bindings.c	Mon Nov 25 22:26:45 2024 -0800
@@ -19,7 +19,8 @@
 	BIND_NONE,
 	BIND_UI,
 	BIND_GAMEPAD,
-	BIND_MOUSE
+	BIND_MOUSE,
+	BIND_CASSETTE
 };
 
 typedef enum {
@@ -314,6 +315,11 @@
 			current_system->mouse_up(current_system, binding->subtype_a, binding->subtype_b);
 		}
 		break;
+	case BIND_CASSETTE:
+		if (allow_content_binds && current_system->cassette_action) {
+			current_system->cassette_action(current_system, binding->subtype_a);
+		}
+		break;
 	case BIND_UI:
 		switch (binding->subtype_a)
 		{
@@ -649,6 +655,20 @@
 		} else {
 			warning("Gamepad mapping string '%s' refers to an invalid mouse number %c\n", target, target[mouselen]);
 		}
+	} else if (startswith(target, "cassette.")) {
+		if (!strcmp(target + 9, "play")) {
+			*subtype_a = CASSETTE_PLAY;
+		} else if (!strcmp(target + 9, "record")) {
+			*subtype_a = CASSETTE_RECORD;
+		} else if (!strcmp(target + 9, "stop")) {
+			*subtype_a = CASSETTE_STOP;
+		} else if (!strcmp(target + 9, "rewind")) {
+			*subtype_a = CASSETTE_REWIND;
+		} else {
+			warning("Cassette mapping string '%s' refers to an invalid action\n", target);
+			return BIND_NONE;
+		}
+		return BIND_CASSETTE;
 	} else if(startswith(target, "ui.")) {
 		if (!strcmp(target + 3, "vdp_debug_mode")) {
 			*subtype_a = UI_DEBUG_MODE_INC;