# HG changeset patch # User Michael Pavone # Date 1680243612 25200 # Node ID 59fd8aa352e25c1316b031dc9ff63eee79a00289 # Parent ef5dc4d02d2797e8fe24a23cd28aeedf52455c54 Apply binding changes after a config change in UI diff -r ef5dc4d02d27 -r 59fd8aa352e2 bindings.c --- a/bindings.c Thu Mar 30 20:20:25 2023 -0700 +++ b/bindings.c Thu Mar 30 23:20:12 2023 -0700 @@ -1177,8 +1177,10 @@ tern_foreach(mice, process_mouse, buttonmaps); } tern_node * speed_nodes = tern_find_path(config, "clocks\0speeds\0", TVAL_NODE).ptrval; + free(speeds); speeds = malloc(sizeof(uint32_t)); speeds[0] = 100; + num_speeds = 1; process_speeds(speed_nodes, NULL); for (int i = 0; i < num_speeds; i++) { @@ -1189,6 +1191,17 @@ } } +void update_pad_bindings(void) +{ + for (int i = 0; i < MAX_JOYSTICKS; i++) + { + if (joysticks[i].num_buttons || joysticks[i].num_axes || joysticks[i].num_dpads) { + reset_joystick_bindings(i); + handle_joy_added(i); + } + } +} + void bindings_set_mouse_mode(uint8_t mode) { mouse_mode = mode; diff -r ef5dc4d02d27 -r 59fd8aa352e2 bindings.h --- a/bindings.h Thu Mar 30 20:20:25 2023 -0700 +++ b/bindings.h Thu Mar 30 23:20:12 2023 -0700 @@ -10,6 +10,7 @@ } mouse_modes; void set_bindings(void); +void update_pad_bindings(void); void bindings_set_mouse_mode(uint8_t mode); tern_node *get_binding_node_for_pad(int padnum); void handle_keydown(int keycode, uint8_t scancode); diff -r ef5dc4d02d27 -r 59fd8aa352e2 blastem.c --- a/blastem.c Thu Mar 30 20:20:25 2023 -0700 +++ b/blastem.c Thu Mar 30 23:20:12 2023 -0700 @@ -381,6 +381,8 @@ void apply_updated_config(void) { render_config_updated(); + set_bindings(); + update_pad_bindings(); if (current_system && current_system->config_updated) { current_system->config_updated(current_system); }