From 82dc0ffef414e9478c66279f9b9ee91d634ffb28 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 Feb 2011 16:25:32 +0000 Subject: [PATCH] Send lshift/rshift, lalt/ralt and lcontrol/rcontrol instead of just shift/alt/control (untested) --- panda/src/osxdisplay/osxGraphicsWindow.I | 13 ------ panda/src/osxdisplay/osxGraphicsWindow.h | 2 +- panda/src/osxdisplay/osxGraphicsWindow.mm | 51 +++++++++++++++++++---- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/panda/src/osxdisplay/osxGraphicsWindow.I b/panda/src/osxdisplay/osxGraphicsWindow.I index 4abeb89bd2..0c2ca7f328 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.I +++ b/panda/src/osxdisplay/osxGraphicsWindow.I @@ -13,16 +13,3 @@ //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::send_key_event -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -inline void osxGraphicsWindow:: -send_key_event(ButtonHandle key, bool down) { - if (down) { - _input_devices[0].button_down(key); - } else { - _input_devices[0].button_up(key); - } -} diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index a6d66031ca..ec30d3318d 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -59,7 +59,7 @@ public: private: void release_system_resources(bool destructing); - inline void send_key_event(ButtonHandle key, bool down); + void send_key_event(ButtonHandle key, bool down); protected: virtual void close_window(); diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index bd3ca3100a..956d550f87 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -615,6 +615,29 @@ release_system_resources(bool destructing) { _osx_window = NULL; } +//////////////////////////////////////////////////////////////////// +// Function: osxGraphicsWindow::send_key_event +// Access: Private +// Description: +//////////////////////////////////////////////////////////////////// +inline void osxGraphicsWindow:: +send_key_event(ButtonHandle key, bool down) { + if (key == KeyboardButton::lcontrol() || key == KeyboardButton::rcontrol()) { + send_key_event (KeyboardButton::control(), down); + } + if (key == KeyboardButton::lshift() || key == KeyboardButton::rshift()) { + send_key_event (KeyboardButton::shift(), down); + } + if (key == KeyboardButton::lalt() || key == KeyboardButton::ralt()) { + send_key_event (KeyboardButton::alt(), down); + } + + if (down) { + _input_devices[0].button_down(key); + } else { + _input_devices[0].button_up(key); + } +} static int id_seed = 100; @@ -1730,24 +1753,36 @@ void osxGraphicsWindow:: handle_modifier_delta(UInt32 new_modifiers) { UInt32 changed = _last_key_modifiers ^ new_modifiers; - if ((changed & (shiftKey | rightShiftKey)) != 0) { - send_key_event(KeyboardButton::shift(),(new_modifiers & (shiftKey | rightShiftKey)) != 0) ; + if ((changed & shiftKey) != 0) { + send_key_event(KeyboardButton::lshift(), (new_modifiers & shiftKey) != 0); } - if ((changed & (optionKey | rightOptionKey)) != 0) { - send_key_event(KeyboardButton::alt(),(new_modifiers & (optionKey | rightOptionKey)) != 0); + if ((changed & rightShiftKey) != 0) { + send_key_event(KeyboardButton::rshift(), (new_modifiers & rightShiftKey) != 0); } - if ((changed & (controlKey | rightControlKey)) != 0) { - send_key_event(KeyboardButton::control(),(new_modifiers & (controlKey | rightControlKey)) != 0); + if ((changed & optionKey) != 0) { + send_key_event(KeyboardButton::lalt(), (new_modifiers & optionKey) != 0); + } + + if ((changed & rightOptionKey) != 0) { + send_key_event(KeyboardButton::ralt(), (new_modifiers & rightOptionKey) != 0); + } + + if ((changed & controlKey) != 0) { + send_key_event(KeyboardButton::lcontrol(), (new_modifiers & controlKey) != 0); + } + + if ((changed & rightControlKey) != 0) { + send_key_event(KeyboardButton::rcontrol(), (new_modifiers & rightControlKey) != 0); } if ((changed & cmdKey) != 0) { - send_key_event(KeyboardButton::meta(),(new_modifiers & cmdKey) != 0); + send_key_event(KeyboardButton::meta(), (new_modifiers & cmdKey) != 0); } if ((changed & alphaLock) != 0) { - send_key_event(KeyboardButton::caps_lock(),(new_modifiers & alphaLock) != 0); + send_key_event(KeyboardButton::caps_lock(), (new_modifiers & alphaLock) != 0); } // save current state