From 93637862da46fcbf5ea0620ee98719b011cbdc9c Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 16 Dec 2010 00:54:33 +0000 Subject: [PATCH] add trackball-use-alt-keys --- panda/src/tform/config_tform.cxx | 7 +++++++ panda/src/tform/config_tform.h | 3 +++ panda/src/tform/trackball.cxx | 21 +++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/panda/src/tform/config_tform.cxx b/panda/src/tform/config_tform.cxx index cdac11b7f0..289f152291 100644 --- a/panda/src/tform/config_tform.cxx +++ b/panda/src/tform/config_tform.cxx @@ -54,6 +54,13 @@ ConfigVariableDouble drive_horizontal_ramp_down_time ConfigVariableDouble inactivity_timeout ("inactivity-timeout", 0.0); +ConfigVariableBool trackball_use_alt_keys +("trackball-use-alt-keys", true, + PRC_DESC("Set this true to use the command and option/control keys in " + "conjunction with the first mouse button to simulate the behavior of " + "the second and third mouse buttons in trackball mode. Particularly " + "useful for Macs, or laptops with limited mouse buttons.")); + ConfigureFn(config_tform) { DriveInterface::init_type(); ButtonThrower::init_type(); diff --git a/panda/src/tform/config_tform.h b/panda/src/tform/config_tform.h index 2792d2267a..77c90c9aa4 100644 --- a/panda/src/tform/config_tform.h +++ b/panda/src/tform/config_tform.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" #include "configVariableDouble.h" +#include "configVariableBool.h" NotifyCategoryDecl(tform, EXPCL_PANDA_TFORM, EXPTP_PANDA_TFORM); @@ -36,4 +37,6 @@ extern EXPCL_PANDA_TFORM ConfigVariableDouble drive_horizontal_ramp_down_time; extern EXPCL_PANDA_TFORM ConfigVariableDouble inactivity_timeout; +extern EXPCL_PANDA_TFORM ConfigVariableBool trackball_use_alt_keys; + #endif diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index 9fb1ce170d..ace49e91ad 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -63,12 +63,13 @@ Trackball(const string &name) : watch_button(MouseButton::two()); watch_button(MouseButton::three()); -#ifdef IS_OSX - // In OSX mode, we need to use the command and option key in - // conjunction with the (one) mouse button. - watch_button(KeyboardButton::meta()); - watch_button(KeyboardButton::alt()); -#endif + if (trackball_use_alt_keys) { + // In OSX mode, we need to use the command and option key in + // conjunction with the (one) mouse button. + watch_button(KeyboardButton::control()); + watch_button(KeyboardButton::meta()); + watch_button(KeyboardButton::alt()); + } } //////////////////////////////////////////////////////////////////// @@ -554,15 +555,14 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, int this_button = 0; if (is_down(MouseButton::one())) { -#ifdef IS_OSX if (is_down(KeyboardButton::alt())) { // B1 + alt (option) = B2. this_button |= B2_MASK; - if (is_down(KeyboardButton::meta())) { + if (is_down(KeyboardButton::meta()) || is_down(KeyboardButton::control())) { this_button |= B3_MASK; } - } else if (is_down(KeyboardButton::meta())) { + } else if (is_down(KeyboardButton::meta()) || is_down(KeyboardButton::control())) { // B1 + meta (command) = B3. this_button |= B3_MASK; @@ -570,9 +570,6 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, // Without a special key, B1 is B1. this_button |= B1_MASK; } -#else // IS_OSX - this_button |= B1_MASK; -#endif // IS_OSX } if (is_down(MouseButton::two())) { this_button |= B2_MASK;