mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
low level support for mouselook in osx
This commit is contained in:
parent
f6e37779e4
commit
e75d2ef706
@ -1286,9 +1286,18 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
|
|||||||
{
|
{
|
||||||
GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
|
GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
|
||||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
|
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
|
||||||
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
if(_properties.get_mouse_mode()==WindowProperties::MOUSE_relative)
|
||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
MouseData currMouse=get_pointer(0);
|
||||||
|
qdGlobalPoint.h+=currMouse.get_x();
|
||||||
|
qdGlobalPoint.v+=currMouse.get_y();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
|
}
|
||||||
ButtonHandle button_h = MouseButton::one();
|
ButtonHandle button_h = MouseButton::one();
|
||||||
if(kEventMouseButtonSecondary == button)
|
if(kEventMouseButtonSecondary == button)
|
||||||
button_h = MouseButton::two();
|
button_h = MouseButton::two();
|
||||||
@ -1304,9 +1313,18 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
|
|||||||
{
|
{
|
||||||
GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
|
GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
|
||||||
// GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later
|
// GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later
|
||||||
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
if(_properties.get_mouse_mode()==WindowProperties::MOUSE_relative)
|
||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
MouseData currMouse=get_pointer(0);
|
||||||
|
qdGlobalPoint.h+=currMouse.get_x();
|
||||||
|
qdGlobalPoint.v+=currMouse.get_y();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
|
}
|
||||||
ButtonHandle button_h = MouseButton::one();
|
ButtonHandle button_h = MouseButton::one();
|
||||||
if(kEventMouseButtonSecondary == button)
|
if(kEventMouseButtonSecondary == button)
|
||||||
button_h = MouseButton::two();
|
button_h = MouseButton::two();
|
||||||
@ -1319,9 +1337,19 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground)
|
|||||||
break;
|
break;
|
||||||
case kEventMouseMoved:
|
case kEventMouseMoved:
|
||||||
case kEventMouseDragged:
|
case kEventMouseDragged:
|
||||||
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
if(_properties.get_mouse_mode()==WindowProperties::MOUSE_relative)
|
||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
|
||||||
|
MouseData currMouse=get_pointer(0);
|
||||||
|
qdGlobalPoint.h+=currMouse.get_x();
|
||||||
|
qdGlobalPoint.v+=currMouse.get_y();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
|
}
|
||||||
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
||||||
result = noErr;
|
result = noErr;
|
||||||
|
|
||||||
@ -1524,12 +1552,16 @@ if (osxdisplay_cat.is_debug())
|
|||||||
pt.h = x;
|
pt.h = x;
|
||||||
pt.v = y;
|
pt.v = y;
|
||||||
_input_devices[0].set_pointer_in_window(x, y);
|
_input_devices[0].set_pointer_in_window(x, y);
|
||||||
LocalPointToSystemPoint(pt);
|
|
||||||
CGPoint newCursorPosition = {0, 0};
|
if(_properties.get_mouse_mode()==WindowProperties::MOUSE_absolute)
|
||||||
newCursorPosition.x = pt.h;
|
{
|
||||||
newCursorPosition.y = pt.v;
|
LocalPointToSystemPoint(pt);
|
||||||
CGWarpMouseCursorPosition(newCursorPosition);
|
CGPoint newCursorPosition = {0, 0};
|
||||||
|
newCursorPosition.x = pt.h;
|
||||||
|
newCursorPosition.y = pt.v;
|
||||||
|
CGWarpMouseCursorPosition(newCursorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1725,3 +1757,27 @@ void osxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: OSXGraphicsWindow::mouse_mode_relative
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: detaches mouse. Only mouse delta from now on.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void osxGraphicsWindow::
|
||||||
|
mouse_mode_relative() {
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: OSXGraphicsWindow::mouse_mode_absolute
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: reattaches mouse to location
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void osxGraphicsWindow::
|
||||||
|
mouse_mode_absolute() {
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(true);
|
||||||
|
}
|
||||||
|
@ -58,6 +58,9 @@ public:
|
|||||||
|
|
||||||
virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
|
virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
|
||||||
int x_size, int y_size);
|
int x_size, int y_size);
|
||||||
|
|
||||||
|
virtual void mouse_mode_absolute();
|
||||||
|
virtual void mouse_mode_relative();
|
||||||
|
|
||||||
virtual void set_properties_now(WindowProperties &properties);
|
virtual void set_properties_now(WindowProperties &properties);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user