home · contact · privacy
Made keybindings array into linked list; on the way rewrote / improved great parts...
[plomrogue] / src / control.c
index e73f5a16e4695d916965fd1f17f3df49807d1d4b..842b7106ea301e43a2d7d4c8803cc9572d03825f 100644 (file)
@@ -5,8 +5,8 @@
 #include "windows.h" /* for cycle_active_win(), shift_active_win(), struct Win,
                       *  struct WinMeta
                       */
-#include "keybindings.h" /* for get_action_key(), save_keybindings(),
-                          * keyswin_move_selection(), keyswin_mod_key()
+#include "keybindings.h" /* for get_keycode_to_action(), save_keybindings(),
+                          * move_keys_mod_selection(), keyswin_mod_key()
                           */
 #include "map.h" /* for map_scroll(), map_center_player(), dir enum */
 #include "main.h" /* for World struct */
@@ -49,23 +49,23 @@ extern void record_control(int action, struct World * world)
 
 extern uint8_t player_control(int key, struct World * world)
 {
-    if      (key == get_action_key(world->keybindings, "player_u"))
+    if      (key == get_keycode_to_action(world->keybindings, "player_u"))
     {
         move_player(world, NORTH);
     }
-    else if (key == get_action_key(world->keybindings, "player_r"))
+    else if (key == get_keycode_to_action(world->keybindings, "player_r"))
     {
         move_player(world, EAST);
     }
-    else if (key == get_action_key(world->keybindings, "player_d"))
+    else if (key == get_keycode_to_action(world->keybindings, "player_d"))
     {
         move_player(world, SOUTH);
     }
-    else if (key == get_action_key(world->keybindings, "player_l"))
+    else if (key == get_keycode_to_action(world->keybindings, "player_l"))
     {
         move_player(world, WEST);
     }
-    else if (key == get_action_key(world->keybindings, "wait"))
+    else if (key == get_keycode_to_action(world->keybindings, "wait"))
     {
         player_wait(world);
     }
@@ -89,119 +89,119 @@ extern uint8_t meta_control(int key, struct World * world)
     char * err_shift  = "Trouble with shift_active_win() in meta_keys().";
     char * err_resize = "Trouble with growshrink_active_window() in "
                         "meta_keys().";
-    if (key == get_action_key(world->keybindings, "quit"))
+    if (key == get_keycode_to_action(world->keybindings, "quit"))
     {
         return 1;
     }
-    else if (key == get_action_key(world->keybindings, "scrl_r"))
+    else if (key == get_keycode_to_action(world->keybindings, "scrl_r"))
     {
         scroll_pad(win_meta, '+');
     }
-    else if (key == get_action_key(world->keybindings, "scrl_l"))
+    else if (key == get_keycode_to_action(world->keybindings, "scrl_l"))
     {
         scroll_pad(win_meta, '-');
     }
-    else if (key == get_action_key(world->keybindings, "to_keywin"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_keywin"))
     {
         exit_err(toggle_window(win_meta, win_keys), world, err_toggle);
     }
-    else if (key == get_action_key(world->keybindings, "to_mapwin"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_mapwin"))
     {
         exit_err(toggle_window(win_meta, win_map), world, err_toggle);
     }
-    else if (key == get_action_key(world->keybindings, "to_infowin"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_infowin"))
     {
         exit_err(toggle_window(win_meta, win_info), world, err_toggle);
     }
-    else if (key == get_action_key(world->keybindings, "to_logwin"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_logwin"))
     {
         exit_err(toggle_window(win_meta, win_log), world, err_toggle);
     }
-    else if (key == get_action_key(world->keybindings, "cyc_win_f"))
+    else if (key == get_keycode_to_action(world->keybindings, "cyc_win_f"))
     {
         cycle_active_win(win_meta, 'f');
     }
-    else if (key == get_action_key(world->keybindings, "cyc_win_b"))
+    else if (key == get_keycode_to_action(world->keybindings, "cyc_win_b"))
     {
         cycle_active_win(win_meta, 'b');
     }
-    else if (key == get_action_key(world->keybindings, "shift_f"))
+    else if (key == get_keycode_to_action(world->keybindings, "shift_f"))
     {
         exit_err(shift_active_win(win_meta, 'f'), world, err_shift);
     }
-    else if (key == get_action_key(world->keybindings, "shift_b"))
+    else if (key == get_keycode_to_action(world->keybindings, "shift_b"))
     {
         exit_err(shift_active_win(win_meta, 'b'), world, err_shift);
     }
-    else if (key == get_action_key(world->keybindings, "grow_h"))
+    else if (key == get_keycode_to_action(world->keybindings, "grow_h"))
     {
         exit_err(growshrink_active_window(world, '*'), world, err_resize);
     }
-    else if (key == get_action_key(world->keybindings, "shri_h"))
+    else if (key == get_keycode_to_action(world->keybindings, "shri_h"))
     {
         exit_err(growshrink_active_window(world, '_'), world, err_resize);
     }
-    else if (key == get_action_key(world->keybindings, "grow_v"))
+    else if (key == get_keycode_to_action(world->keybindings, "grow_v"))
     {
         exit_err(growshrink_active_window(world, '+'), world, err_resize);
     }
-    else if (key == get_action_key(world->keybindings, "shri_v"))
+    else if (key == get_keycode_to_action(world->keybindings, "shri_v"))
     {
         exit_err(growshrink_active_window(world, '-'), world, err_resize);
     }
-    else if (key == get_action_key(world->keybindings, "save_keys"))
+    else if (key == get_keycode_to_action(world->keybindings, "save_keys"))
     {
         save_keybindings(world);
     }
-    else if (key == get_action_key(world->keybindings, "keys_u"))
+    else if (key == get_keycode_to_action(world->keybindings, "keys_u"))
     {
-        keyswin_move_selection(world, 'u');
+        move_keys_mod_selection(world, 'u');
     }
-    else if (key == get_action_key(world->keybindings, "keys_d"))
+    else if (key == get_keycode_to_action(world->keybindings, "keys_d"))
     {
-        keyswin_move_selection(world, 'd');
+        move_keys_mod_selection(world, 'd');
     }
-    else if (key == get_action_key(world->keybindings, "keys_m"))
+    else if (key == get_keycode_to_action(world->keybindings, "keys_m"))
     {
         keyswin_mod_key(world, win_meta);
     }
-    else if (key == get_action_key(world->keybindings, "map_u"))
+    else if (key == get_keycode_to_action(world->keybindings, "map_u"))
     {
         map_scroll(world->map, NORTH, win_map->frame.size);
      }
-    else if (key == get_action_key(world->keybindings, "map_d"))
+    else if (key == get_keycode_to_action(world->keybindings, "map_d"))
     {
         map_scroll(world->map, SOUTH, win_map->frame.size);
     }
-    else if (key == get_action_key(world->keybindings, "map_r"))
+    else if (key == get_keycode_to_action(world->keybindings, "map_r"))
     {
         map_scroll(world->map, EAST, win_map->frame.size);
     }
-    else if (key == get_action_key(world->keybindings, "map_l"))
+    else if (key == get_keycode_to_action(world->keybindings, "map_l"))
     {
         map_scroll(world->map, WEST, win_map->frame.size);
     }
-    else if (key == get_action_key(world->keybindings, "map_c"))
+    else if (key == get_keycode_to_action(world->keybindings, "map_c"))
     {
         map_center_player(world->map, world->player, win_map->frame.size);
     }
-    else if (key == get_action_key(world->keybindings, "reload_wins"))
+    else if (key == get_keycode_to_action(world->keybindings, "reload_wins"))
     {
         reload_win_config(world);
     }
-    else if (key == get_action_key(world->keybindings, "winconf"))
+    else if (key == get_keycode_to_action(world->keybindings, "winconf"))
     {
         toggle_winconfig(world, world->wmeta->active);
     }
-    else if (key == get_action_key(world->keybindings, "to_height_t"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_height_t"))
     {
         toggle_win_height_type(world, world->wmeta->active);
     }
-    else if (key == get_action_key(world->keybindings, "to_width_t"))
+    else if (key == get_keycode_to_action(world->keybindings, "to_width_t"))
     {
         toggle_win_width_type(world, world->wmeta->active);
     }
-    else if (key == get_action_key(world->keybindings, "save_winconf"))
+    else if (key == get_keycode_to_action(world->keybindings, "save_winconf"))
     {
         save_win_configs(world);
     }