|
| 1 | +"""Declarative key-binding tables for the interactive viewer. |
| 2 | +
|
| 3 | +Three dispatch tables map key events to method names on InteractiveViewer: |
| 4 | +
|
| 5 | +- ``SHIFT_BINDINGS``: Checked first. Maps uppercase ``raw_key`` (Shift |
| 6 | + held) to a method name. E.g. ``'O'`` → ``'_action_shift_o'``. |
| 7 | +- ``KEY_BINDINGS``: Checked second. Maps lowercase ``key`` to a method |
| 8 | + name. E.g. ``'t'`` → ``'_action_toggle_shadows'``. |
| 9 | +- ``SPECIAL_BINDINGS``: Checked last. Maps ``(raw_key, key)`` tuples |
| 10 | + for keys that need both values (e.g. ``r`` vs ``R``). |
| 11 | +
|
| 12 | +Movement keys (WASD, arrows, IJKL, Q/E, PageUp/Down) are tracked in |
| 13 | +``MOVEMENT_KEYS`` and handled separately by adding to ``_held_keys``. |
| 14 | +
|
| 15 | +Observer slots 1-8 are handled separately in ``_handle_key_press``. |
| 16 | +""" |
| 17 | + |
| 18 | +# Keys that get added to _held_keys for continuous movement/look |
| 19 | +MOVEMENT_KEYS = frozenset({ |
| 20 | + 'w', 's', 'a', 'd', |
| 21 | + 'up', 'down', 'left', 'right', |
| 22 | + 'q', 'e', 'pageup', 'pagedown', |
| 23 | + 'i', 'j', 'k', 'l', |
| 24 | +}) |
| 25 | + |
| 26 | +# Shift+<key> bindings — checked first (raw_key is uppercase) |
| 27 | +SHIFT_BINDINGS = { |
| 28 | + 'O': '_action_shift_o', # Cycle drone mode |
| 29 | + 'V': '_action_shift_v', # Snap to observer |
| 30 | + 'K': '_action_clear_observers', # Kill all observers |
| 31 | + 'F': '_action_toggle_firms', # FIRMS fire layer |
| 32 | + 'W': '_action_toggle_wind', # Wind particles |
| 33 | + 'E': '_action_toggle_terrain_vis', # Toggle terrain visibility |
| 34 | + 'B': '_action_toggle_gtfs_rt', # GTFS-RT vehicles |
| 35 | + 'C': '_action_cycle_pc_colors', # Point cloud color mode |
| 36 | + 'D': '_action_toggle_denoiser', # Denoiser |
| 37 | + 'G': '_action_cycle_gi', # GI bounces |
| 38 | + 'H': '_action_prev_help_page', # Previous help page |
| 39 | + 'L': '_action_toggle_drone_glow', # Drone glow |
| 40 | + 'T': '_action_cycle_time', # Time-of-day |
| 41 | +} |
| 42 | + |
| 43 | +# Lowercase key bindings — checked after shift bindings |
| 44 | +KEY_BINDINGS = { |
| 45 | + 't': '_action_toggle_shadows', |
| 46 | + 'c': '_action_cycle_colormap', |
| 47 | + 'g': '_cycle_terrain_layer', |
| 48 | + 'n': '_cycle_geometry_layer', |
| 49 | + 'p': '_action_jump_prev_geom', |
| 50 | + 'h': '_action_next_help_page', |
| 51 | + 'm': '_action_toggle_minimap', |
| 52 | + 'o': '_action_place_observer', |
| 53 | + 'v': '_toggle_viewshed', |
| 54 | + '[': '_action_observer_elev_down', |
| 55 | + ']': '_action_observer_elev_up', |
| 56 | + 'f': '_save_screenshot', |
| 57 | + 'y': '_action_cycle_color_stretch', |
| 58 | + 'b': '_action_cycle_mesh_type', |
| 59 | + 'u': '_action_cycle_basemap_fwd', |
| 60 | + ',': '_action_overlay_alpha_down', |
| 61 | + '.': '_action_overlay_alpha_up', |
| 62 | + '0': '_action_toggle_ao', |
| 63 | + '9': '_action_toggle_dof', |
| 64 | + ';': '_action_dof_aperture_down', |
| 65 | + "'": '_action_dof_aperture_up', |
| 66 | + 'escape': '_action_exit', |
| 67 | + 'x': '_action_exit', |
| 68 | +} |
| 69 | + |
| 70 | +# Keys that need both raw_key and key for dispatch |
| 71 | +# (raw_key, key) → method name |
| 72 | +SPECIAL_BINDINGS = { |
| 73 | + # Speed |
| 74 | + ('+', '+'): '_action_speed_up', |
| 75 | + ('=', '='): '_action_speed_up', |
| 76 | + ('-', '-'): '_action_speed_down', |
| 77 | + # Resolution: r = coarser, R = finer |
| 78 | + ('r', 'r'): '_action_resolution_coarser', |
| 79 | + ('R', 'r'): '_action_resolution_finer', |
| 80 | + # Vertical exaggeration: z = decrease, Z = increase |
| 81 | + ('z', 'z'): '_action_ve_down', |
| 82 | + ('Z', 'z'): '_action_ve_up', |
| 83 | + # Basemap: U = reverse |
| 84 | + ('U', 'u'): '_action_cycle_basemap_rev', |
| 85 | + # DOF focal distance: : = decrease, " = increase |
| 86 | + (':', ':'): '_action_dof_focal_down', |
| 87 | + ('"', '"'): '_action_dof_focal_up', |
| 88 | +} |
0 commit comments