# HG changeset patch # User Michael Pavone # Date 1540519960 25200 # Node ID 7bbe0bfedb58dcf1145531bc796519c03924e04d # Parent 18a946ec74c89009846ab3251992fb9137c5200b Handle looking up dpad config in binding UI. Fix left/right stick config display in binding UI diff -r 18a946ec74c8 -r 7bbe0bfedb58 nuklear_ui/blastem_nuklear.c --- a/nuklear_ui/blastem_nuklear.c Wed Oct 24 21:10:12 2018 -0700 +++ b/nuklear_ui/blastem_nuklear.c Thu Oct 25 19:12:40 2018 -0700 @@ -611,7 +611,7 @@ char *tmp = malloc(period-key + 1); memcpy(tmp, key, period-key); tmp[period-key] = 0; - axis = render_lookup_axis(key); + axis = render_lookup_axis(tmp); free(tmp); is_negative = strcmp(period+1, "negative") == 0; } else { @@ -644,6 +644,13 @@ if (pad) { tern_foreach(tern_find_node(pad, "buttons"), button_iter, bindings); tern_foreach(tern_find_node(pad, "axes"), axis_iter, bindings); + tern_node *dpad = tern_find_path(pad, "dpads\0" "0\0", TVAL_NODE).ptrval; + const char *dir_keys[] = {"up", "down", "right", "left"}; + const int button_idx[] = {SDL_CONTROLLER_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_LEFT}; + for (int i = 0; i < NUM_AXIS_DIRS; i++) + { + bindings->button_binds[button_idx[i]] = tern_find_ptr(dpad, dir_keys[i]); + } } }