changeset 493:36c080ece4ed

Add support for UI bindings on gamepad buttons and dpads
author Mike Pavone <pavone@retrodev.com>
date Fri, 04 Oct 2013 20:16:18 -0700
parents db5880d8ea03
children 8ac0eb05642c
files io.c
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/io.c	Thu Oct 03 21:22:05 2013 -0700
+++ b/io.c	Fri Oct 04 20:16:18 2013 -0700
@@ -147,6 +147,16 @@
 	bind_key(keycode, BIND_UI, action, 0, param);
 }
 
+void bind_button_ui(int joystick, int joybutton, ui_action action, uint8_t param)
+{
+	bind_button(joystick, joybutton, BIND_UI, action, 0, param);
+}
+
+void bind_dpad_ui(int joystick, int dpad, uint8_t direction, ui_action action, uint8_t param)
+{
+	bind_dpad(joystick, dpad, direction, BIND_UI, action, 0, param);
+}
+
 void handle_binding_down(keybinding * binding)
 {
 	switch(binding->bind_type)
@@ -487,8 +497,9 @@
 						int bindtype = parse_binding_target(target, padbuttons, &ui_func, &padnum, &button);
 						if (bindtype == 1) {
 							bind_dpad_gamepad(i, dpad, dirnums[dir], padnum, button);
+						} else if (bindtype == 2) {
+							bind_dpad_ui(i, dpad, dirnums[dir], ui_func, button);
 						}
-						//TODO: Handle UI bindings
 					}
 				}
 			}
@@ -508,8 +519,9 @@
 					int bindtype = parse_binding_target(target, padbuttons, &ui_func, &padnum, &button);
 					if (bindtype == 1) {
 						bind_button_gamepad(i, but, padnum, button);
+					} else if (bindtype == 2) {
+						bind_button_ui(i, but, ui_func, button);
 					}
-					//TODO: Handle UI bindings
 				}
 			}
 		}