diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 4574334dd7..22bcc62617 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -48,6 +48,11 @@ ConfigVariableBool osx_disable_event_loop "the window event loop is already handled by another part of the " "app.")); +ConfigVariableInt osx_mouse_wheel_scale +("osx-mouse-wheel-scale", 5, + PRC_DESC("Specify the number of units to spin the Mac mouse wheel to " + "represent a single wheel_up or wheel_down message.")); + //////////////////////////////////////////////////////////////////// // Function: init_libosxdisplay // Description: Initializes the library. This must be called at diff --git a/panda/src/osxdisplay/config_osxdisplay.h b/panda/src/osxdisplay/config_osxdisplay.h index 9337dee0ee..212416b37e 100644 --- a/panda/src/osxdisplay/config_osxdisplay.h +++ b/panda/src/osxdisplay/config_osxdisplay.h @@ -18,8 +18,8 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" -#include "configVariableString.h" #include "configVariableBool.h" +#include "configVariableInt.h" NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL); @@ -27,5 +27,6 @@ extern EXPCL_PANDAGL void init_libosxdisplay(); extern ConfigVariableBool show_resize_box; extern ConfigVariableBool osx_disable_event_loop; +extern ConfigVariableInt osx_mouse_wheel_scale; #endif /* __CONFIG_OSXDISPLAY_H__ */ diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index 4cb43f9311..288723e61f 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -127,6 +127,8 @@ private: // True if the cursor is actually hidden right now via system calls. bool _display_hide_cursor; + + SInt32 _wheel_delta; public: static TypeHandle get_class_type() { diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index e6cd4af539..b917849d07 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -541,6 +541,7 @@ osxGraphicsWindow::osxGraphicsWindow(GraphicsPipe *pipe, _cursor_hidden = false; _display_hide_cursor = false; + _wheel_delta = 0; if (osxdisplay_cat.is_debug()) osxdisplay_cat.debug() << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n"; @@ -1325,7 +1326,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) Point qdGlobalPoint = {0, 0}; UInt32 modifiers = 0; Rect rectPort; - SInt32 wheelDelta; + SInt32 this_wheel_delta; EventMouseWheelAxis wheelAxis; // cerr <<" Start Mouse Event " << _ID << "\n"; @@ -1405,7 +1406,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) break; case kEventMouseWheelMoved: - GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(wheelDelta), NULL, &wheelDelta); + GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(this_wheel_delta), NULL, &this_wheel_delta); GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis ); GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); SystemPointToLocalPoint(qdGlobalPoint); @@ -1413,17 +1414,20 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) if (wheelAxis == kEventMouseWheelAxisY) { set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); - if (wheelDelta > 0) - { - _input_devices[0].button_down(MouseButton::wheel_up()); - result = noErr; + _wheel_delta += this_wheel_delta; + SInt32 wheel_scale = osx_mouse_wheel_scale; + while (_wheel_delta > wheel_scale) { + _input_devices[0].button_down(MouseButton::wheel_up()); + _input_devices[0].button_up(MouseButton::wheel_up()); + _wheel_delta -= wheel_scale; } - else if (wheelDelta < 0) - { - _input_devices[0].button_down(MouseButton::wheel_down()); + while (_wheel_delta < -wheel_scale) { + _input_devices[0].button_down(MouseButton::wheel_down()); + _input_devices[0].button_up(MouseButton::wheel_down()); + _wheel_delta += wheel_scale; } } - result = noErr; + result = noErr; break; } // result = noErr;