mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix mac mouse wheel processing
This commit is contained in:
parent
278f5ca58d
commit
155604428e
@ -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
|
||||
|
@ -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__ */
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user