diff bindings.c @ 2181:0c723b8b637c

Add bindup and binddown debugger commands
author Michael Pavone <pavone@retrodev.com>
date Sat, 13 Aug 2022 20:04:02 -0700
parents 1270fe86eb89
children 0d1d5dccdd28
line wrap: on
line diff
--- a/bindings.c	Sat Aug 13 19:39:42 2022 -0700
+++ b/bindings.c	Sat Aug 13 20:04:02 2022 -0700
@@ -586,7 +586,7 @@
 	}
 }
 
-int parse_binding_target(int device_num, char * target, tern_node * padbuttons, tern_node *mousebuttons, uint8_t * subtype_a, uint8_t * subtype_b)
+int parse_binding_target(int device_num, const char * target, tern_node * padbuttons, tern_node *mousebuttons, uint8_t * subtype_a, uint8_t * subtype_b)
 {
 	const int gpadslen = strlen("gamepads.");
 	const int mouselen = strlen("mouse.");
@@ -953,6 +953,29 @@
 	return mousebuttons;
 }
 
+uint8_t bind_up(const char *target)
+{
+	keybinding bind;
+	bind.bind_type = parse_binding_target(0, target, get_pad_buttons(), get_mouse_buttons(), &bind.subtype_a, &bind.subtype_b);
+	if (!bind.bind_type) {
+		return 0;
+	}
+	handle_binding_up(&bind);
+	return 1;
+}
+
+uint8_t bind_down(const char *target)
+{
+	keybinding bind;
+	bind.bind_type = parse_binding_target(0, target, get_pad_buttons(), get_mouse_buttons(), &bind.subtype_a, &bind.subtype_b);
+	if (!bind.bind_type) {
+		return 0;
+	}
+	handle_binding_down(&bind);
+	return 1;
+}
+
+
 tern_node *get_binding_node_for_pad(int padnum)
 {
 	if (padnum > MAX_JOYSTICKS) {