From f0c1b0c5ac63cc7611f4afa21699f1240fed7a9f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Feb 2017 11:06:28 +0100 Subject: gui, logic: allow for two keybindings for each function Also, remove "disable reltrans while held" cause it's too specific. --- gui/main-window.cpp | 15 +- gui/options-dialog.cpp | 36 +++- gui/options-dialog.ui | 473 +++++++++++++++++++++++++++++++++++++++--------- logic/main-settings.hpp | 41 +++-- logic/work.cpp | 20 +- 5 files changed, 470 insertions(+), 115 deletions(-) diff --git a/gui/main-window.cpp b/gui/main-window.cpp index 046c6a44..d48e0b44 100644 --- a/gui/main-window.cpp +++ b/gui/main-window.cpp @@ -233,10 +233,17 @@ void MainWindow::register_shortcuts() t_keys keys { - t_key(s.key_start_tracking, [&](bool) -> void { emit_start_tracker(); }, true), - t_key(s.key_stop_tracking, [&](bool) -> void { emit_stop_tracker(); }, true), - t_key(s.key_toggle_tracking, [&](bool) -> void { emit_toggle_tracker(); }, true), - t_key(s.key_restart_tracking, [&](bool) -> void { emit_restart_tracker(); }, true), + t_key(s.key_start_tracking1, [&](bool) -> void { emit_start_tracker(); }, true), + t_key(s.key_start_tracking2, [&](bool) -> void { emit_start_tracker(); }, true), + + t_key(s.key_stop_tracking1, [&](bool) -> void { emit_stop_tracker(); }, true), + t_key(s.key_stop_tracking2, [&](bool) -> void { emit_stop_tracker(); }, true), + + t_key(s.key_toggle_tracking1, [&](bool) -> void { emit_toggle_tracker(); }, true), + t_key(s.key_toggle_tracking2, [&](bool) -> void { emit_toggle_tracker(); }, true), + + t_key(s.key_restart_tracking1, [&](bool) -> void { emit_restart_tracker(); }, true), + t_key(s.key_restart_tracking2, [&](bool) -> void { emit_restart_tracker(); }, true), }; global_shortcuts.reload(keys); diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index 51cfbcc7..cedb1e52 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -103,16 +103,32 @@ OptionsDialog::OptionsDialog(std::function pause_keybindings) : QPushButton* button; } tuples[] = { - { main.key_center, ui.center_text, ui.bind_center }, - { main.key_toggle, ui.toggle_text, ui.bind_toggle }, - { main.key_toggle_press, ui.toggle_held_text, ui.bind_toggle_held }, - { main.key_zero, ui.zero_text, ui.bind_zero }, - { main.key_zero_press, ui.zero_held_text, ui.bind_zero_held }, - { main.key_start_tracking, ui.start_tracking_text, ui.bind_start }, - { main.key_stop_tracking, ui.stop_tracking_text , ui.bind_stop}, - { main.key_toggle_tracking, ui.toggle_tracking_text, ui.bind_toggle_tracking }, - { main.key_restart_tracking, ui.restart_tracking_text, ui.bind_restart_tracking }, - { main.key_disable_tcomp_press, ui.tcomp_off_held_text, ui.bind_tcomp_off_held }, + { main.key_center1, ui.center_text, ui.bind_center }, + { main.key_center2, ui.center_text_2, ui.bind_center_2 }, + + { main.key_toggle1, ui.toggle_text, ui.bind_toggle }, + { main.key_toggle2, ui.toggle_text_2, ui.bind_toggle_2 }, + + { main.key_toggle_press1, ui.toggle_held_text, ui.bind_toggle_held }, + { main.key_toggle_press2, ui.toggle_held_text_2, ui.bind_toggle_held_2 }, + + { main.key_zero1, ui.zero_text, ui.bind_zero }, + { main.key_zero2, ui.zero_text_2, ui.bind_zero_2 }, + + { main.key_zero_press1, ui.zero_held_text, ui.bind_zero_held }, + { main.key_zero_press2, ui.zero_held_text_2, ui.bind_zero_held_2 }, + + { main.key_start_tracking1, ui.start_tracking_text, ui.bind_start }, + { main.key_start_tracking2, ui.start_tracking_text_2, ui.bind_start_2 }, + + { main.key_stop_tracking1, ui.stop_tracking_text , ui.bind_stop }, + { main.key_stop_tracking2, ui.stop_tracking_text_2 , ui.bind_stop_2 }, + + { main.key_toggle_tracking1, ui.toggle_tracking_text, ui.bind_toggle_tracking }, + { main.key_toggle_tracking2, ui.toggle_tracking_text_2, ui.bind_toggle_tracking_2 }, + + { main.key_restart_tracking1, ui.restart_tracking_text, ui.bind_restart_tracking }, + { main.key_restart_tracking2, ui.restart_tracking_text_2, ui.bind_restart_tracking_2 }, }; for (const tmp& val_ : tuples) diff --git a/gui/options-dialog.ui b/gui/options-dialog.ui index 2226480b..3dea2f4e 100644 --- a/gui/options-dialog.ui +++ b/gui/options-dialog.ui @@ -7,7 +7,7 @@ 0 0 607 - 596 + 575 @@ -49,6 +49,9 @@ Global shortcuts + + 0 + @@ -72,66 +75,224 @@ - 4 + 9 - 0 + 2 20 - - + + + + + 0 + 0 + + - - + + - Bind + Start tracking + + + false - - + + + + + 0 + 0 + + Bind - - + + + + + 0 + 0 + + - Restart tracking + + + + + + + + Stop tracking + + + false + + + + + + + Center + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + Zero + + + false + + + + + + + + 0 + 0 + + + + + + + + + + + Zero while held + + + + + + + Toggle false + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + + - - + + + + + 0 + 0 + + - + Bind - - + + + + Restart tracking + + + false + + + + + + + + 0 + 0 + + Bind + + + + + 0 + 0 + + + + + + + @@ -139,8 +300,14 @@ - - + + + + + 0 + 0 + + Bind @@ -156,8 +323,27 @@ + + + + + 0 + 0 + + + + Bind + + + + + + 0 + 0 + + Bind @@ -165,159 +351,285 @@ + + + 0 + 0 + + Bind + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + + - - + + + + + 0 + 0 + + - - - - Start tracking + + + + + 0 + 0 + - - false + + Bind - - + + + + + 0 + 0 + + - - + + + + + 0 + 0 + + Bind - - + + - - 3 + + 0 0 - + Bind - - - - Stop tracking + + + + + 0 + 0 + - - false + + Bind - - + + - 7 + 0 0 - Center - - - false + - - + + + + + 0 + 0 + + - - - - Zero + + + + + 0 + 0 + - - false + + Bind - - + + + + + 0 + 0 + + - - + + + + + 0 + 0 + + - Zero while held + Bind - - + + + + + 0 + 0 + + - Bind + - - + + + + + 0 + 0 + + - Toggle + Bind - - false + + + + + + + 0 + 0 + + + + - - + + + + + 0 + 0 + + Bind - - + + + + + 0 + 0 + + - Relative translation off while held + - - + + + + + 0 + 0 + + + + Bind + + + + + + + + 0 + 0 + + - - + + + + + 0 + 0 + + Bind @@ -1746,7 +2058,6 @@ bind_stop bind_toggle_tracking bind_restart_tracking - bind_tcomp_off_held trayp tray_start use_center_as_translation_camera_offset diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp index 203f531a..f66bff7d 100644 --- a/logic/main-settings.hpp +++ b/logic/main-settings.hpp @@ -102,10 +102,15 @@ struct main_settings value center_method; value neck_y, neck_z; value neck_enable; - key_opts key_start_tracking, key_stop_tracking, key_toggle_tracking, key_restart_tracking; - key_opts key_center, key_toggle, key_zero; - key_opts key_toggle_press, key_zero_press; - key_opts key_disable_tcomp_press; + key_opts key_start_tracking1, key_start_tracking2; + key_opts key_stop_tracking1, key_stop_tracking2; + key_opts key_toggle_tracking1, key_toggle_tracking2; + key_opts key_restart_tracking1, key_restart_tracking2; + key_opts key_center1, key_center2; + key_opts key_toggle1, key_toggle2; + key_opts key_zero1, key_zero2; + key_opts key_toggle_press1, key_toggle_press2; + key_opts key_zero_press1, key_zero_press2; value tracklogging_enabled; value tracklogging_filename; main_settings() : @@ -135,16 +140,24 @@ struct main_settings neck_y(b, "neck-height", 0), neck_z(b, "neck-depth", 0), neck_enable(b, "neck-enable", false), - key_start_tracking(b, "start-tracking"), - key_stop_tracking(b, "stop-tracking"), - key_toggle_tracking(b, "toggle-tracking"), - key_restart_tracking(b, "restart-tracking"), - key_center(b, "center"), - key_toggle(b, "toggle"), - key_zero(b, "zero"), - key_toggle_press(b, "toggle-press"), - key_zero_press(b, "zero-press"), - key_disable_tcomp_press(b, "disable-translation-compensation-while-held"), + key_start_tracking1(b, "start-tracking"), + key_start_tracking2(b, "start-tracking-alt"), + key_stop_tracking1(b, "stop-tracking"), + key_stop_tracking2(b, "stop-tracking-alt"), + key_toggle_tracking1(b, "toggle-tracking"), + key_toggle_tracking2(b, "toggle-tracking-alt"), + key_restart_tracking1(b, "restart-tracking"), + key_restart_tracking2(b, "restart-tracking-alt"), + key_center1(b, "center"), + key_center2(b, "center-alt"), + key_toggle1(b, "toggle"), + key_toggle2(b, "toggle-alt"), + key_zero1(b, "zero"), + key_zero2(b, "zero-alt"), + key_toggle_press1(b, "toggle-press"), + key_toggle_press2(b, "toggle-press-alt"), + key_zero_press1(b, "zero-press"), + key_zero_press2(b, "zero-press-alt"), tracklogging_enabled(b, "tracklogging-enabled", false), tracklogging_filename(b, "tracklogging-filename", QString()) { diff --git a/logic/work.cpp b/logic/work.cpp index d2a16139..ebac4c39 100644 --- a/logic/work.cpp +++ b/logic/work.cpp @@ -67,12 +67,20 @@ Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) : sc(std::make_shared()), handle(handle), keys { - key_tuple(s.key_center, [&](bool) -> void { tracker->center(); }, true), - key_tuple(s.key_toggle, [&](bool) -> void { tracker->toggle_enabled(); }, true), - key_tuple(s.key_zero, [&](bool) -> void { tracker->zero(); }, true), - key_tuple(s.key_toggle_press, [&](bool x) -> void { tracker->set_toggle(!x); }, false), - key_tuple(s.key_zero_press, [&](bool x) -> void { tracker->set_zero(x); }, false), - key_tuple(s.key_disable_tcomp_press, [&](bool x) { tracker->set_tcomp_disabled(x); }, false), + key_tuple(s.key_center1, [&](bool) -> void { tracker->center(); }, true), + key_tuple(s.key_center2, [&](bool) -> void { tracker->center(); }, true), + + key_tuple(s.key_toggle1, [&](bool) -> void { tracker->toggle_enabled(); }, true), + key_tuple(s.key_toggle2, [&](bool) -> void { tracker->toggle_enabled(); }, true), + + key_tuple(s.key_zero1, [&](bool) -> void { tracker->zero(); }, true), + key_tuple(s.key_zero2, [&](bool) -> void { tracker->zero(); }, true), + + key_tuple(s.key_toggle_press1, [&](bool x) -> void { tracker->set_toggle(!x); }, false), + key_tuple(s.key_toggle_press2, [&](bool x) -> void { tracker->set_toggle(!x); }, false), + + key_tuple(s.key_zero_press1, [&](bool x) -> void { tracker->set_zero(x); }, false), + key_tuple(s.key_zero_press2, [&](bool x) -> void { tracker->set_zero(x); }, false), } { reload_shortcuts(); -- cgit v1.2.3