mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -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 "
|
"the window event loop is already handled by another part of the "
|
||||||
"app."));
|
"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
|
// Function: init_libosxdisplay
|
||||||
// Description: Initializes the library. This must be called at
|
// Description: Initializes the library. This must be called at
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
#include "notifyCategoryProxy.h"
|
#include "notifyCategoryProxy.h"
|
||||||
#include "configVariableString.h"
|
|
||||||
#include "configVariableBool.h"
|
#include "configVariableBool.h"
|
||||||
|
#include "configVariableInt.h"
|
||||||
|
|
||||||
NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL);
|
NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL);
|
||||||
|
|
||||||
@ -27,5 +27,6 @@ extern EXPCL_PANDAGL void init_libosxdisplay();
|
|||||||
|
|
||||||
extern ConfigVariableBool show_resize_box;
|
extern ConfigVariableBool show_resize_box;
|
||||||
extern ConfigVariableBool osx_disable_event_loop;
|
extern ConfigVariableBool osx_disable_event_loop;
|
||||||
|
extern ConfigVariableInt osx_mouse_wheel_scale;
|
||||||
|
|
||||||
#endif /* __CONFIG_OSXDISPLAY_H__ */
|
#endif /* __CONFIG_OSXDISPLAY_H__ */
|
||||||
|
@ -128,6 +128,8 @@ private:
|
|||||||
// True if the cursor is actually hidden right now via system calls.
|
// True if the cursor is actually hidden right now via system calls.
|
||||||
bool _display_hide_cursor;
|
bool _display_hide_cursor;
|
||||||
|
|
||||||
|
SInt32 _wheel_delta;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -541,6 +541,7 @@ osxGraphicsWindow::osxGraphicsWindow(GraphicsPipe *pipe,
|
|||||||
|
|
||||||
_cursor_hidden = false;
|
_cursor_hidden = false;
|
||||||
_display_hide_cursor = false;
|
_display_hide_cursor = false;
|
||||||
|
_wheel_delta = 0;
|
||||||
|
|
||||||
if (osxdisplay_cat.is_debug())
|
if (osxdisplay_cat.is_debug())
|
||||||
osxdisplay_cat.debug() << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n";
|
osxdisplay_cat.debug() << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n";
|
||||||
@ -1325,7 +1326,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
Point qdGlobalPoint = {0, 0};
|
Point qdGlobalPoint = {0, 0};
|
||||||
UInt32 modifiers = 0;
|
UInt32 modifiers = 0;
|
||||||
Rect rectPort;
|
Rect rectPort;
|
||||||
SInt32 wheelDelta;
|
SInt32 this_wheel_delta;
|
||||||
EventMouseWheelAxis wheelAxis;
|
EventMouseWheelAxis wheelAxis;
|
||||||
|
|
||||||
// cerr <<" Start Mouse Event " << _ID << "\n";
|
// cerr <<" Start Mouse Event " << _ID << "\n";
|
||||||
@ -1405,7 +1406,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kEventMouseWheelMoved:
|
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, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis );
|
||||||
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
@ -1413,17 +1414,20 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
if (wheelAxis == kEventMouseWheelAxisY)
|
if (wheelAxis == kEventMouseWheelAxisY)
|
||||||
{
|
{
|
||||||
set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
||||||
if (wheelDelta > 0)
|
_wheel_delta += this_wheel_delta;
|
||||||
{
|
SInt32 wheel_scale = osx_mouse_wheel_scale;
|
||||||
_input_devices[0].button_down(MouseButton::wheel_up());
|
while (_wheel_delta > wheel_scale) {
|
||||||
result = noErr;
|
_input_devices[0].button_down(MouseButton::wheel_up());
|
||||||
|
_input_devices[0].button_up(MouseButton::wheel_up());
|
||||||
|
_wheel_delta -= wheel_scale;
|
||||||
}
|
}
|
||||||
else if (wheelDelta < 0)
|
while (_wheel_delta < -wheel_scale) {
|
||||||
{
|
_input_devices[0].button_down(MouseButton::wheel_down());
|
||||||
_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;
|
break;
|
||||||
}
|
}
|
||||||
// result = noErr;
|
// result = noErr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user