mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Attempt to use raw mouse for camera movement on OSX, hopefully this doesn't break it
This commit is contained in:
parent
fd3fac3b0e
commit
ec2cbdb873
44
src/Window.c
44
src/Window.c
@ -48,6 +48,7 @@ static void Window_RegrabMouse(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Window_DefaultEnableRawMouse(void) {
|
static void Window_DefaultEnableRawMouse(void) {
|
||||||
|
win_rawMouse = true;
|
||||||
Window_RegrabMouse();
|
Window_RegrabMouse();
|
||||||
Cursor_SetVisible(false);
|
Cursor_SetVisible(false);
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@ static void Window_DefaultUpdateRawMouse(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Window_DefaultDisableRawMouse(void) {
|
static void Window_DefaultDisableRawMouse(void) {
|
||||||
|
win_rawMouse = false;
|
||||||
Window_RegrabMouse();
|
Window_RegrabMouse();
|
||||||
Cursor_SetVisible(true);
|
Cursor_SetVisible(true);
|
||||||
}
|
}
|
||||||
@ -658,9 +660,7 @@ void Window_OpenKeyboard(void) { }
|
|||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
|
|
||||||
void Window_EnableRawMouse(void) {
|
void Window_EnableRawMouse(void) {
|
||||||
win_rawMouse = true;
|
|
||||||
Window_DefaultEnableRawMouse();
|
Window_DefaultEnableRawMouse();
|
||||||
|
|
||||||
if (!rawMouseInited) Window_InitRawMouse();
|
if (!rawMouseInited) Window_InitRawMouse();
|
||||||
rawMouseInited = true;
|
rawMouseInited = true;
|
||||||
}
|
}
|
||||||
@ -674,10 +674,7 @@ void Window_UpdateRawMouse(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) { Window_DefaultDisableRawMouse(); }
|
||||||
win_rawMouse = false;
|
|
||||||
Window_DefaultDisableRawMouse();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -1625,7 +1622,7 @@ static OSStatus Window_ProcessWindowEvent(EventRef inEvent) {
|
|||||||
|
|
||||||
static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
||||||
int mouseX, mouseY;
|
int mouseX, mouseY;
|
||||||
HIPoint pt;
|
HIPoint pt, raw;
|
||||||
UInt32 kind;
|
UInt32 kind;
|
||||||
bool down;
|
bool down;
|
||||||
EventMouseButton button;
|
EventMouseButton button;
|
||||||
@ -1639,6 +1636,12 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
|||||||
Logger_Abort2(res, "Getting mouse position");
|
Logger_Abort2(res, "Getting mouse position");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (win_rawMouse) {
|
||||||
|
raw.x = 0; raw.y = 0;
|
||||||
|
GetEventParameter(inEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &raw);
|
||||||
|
Event_RaiseMouseMove(&MouseEvents.RawMoved, (int)raw.x, (int)raw.y);
|
||||||
|
}
|
||||||
|
|
||||||
mouseX = (int)pt.x; mouseY = (int)pt.y;
|
mouseX = (int)pt.x; mouseY = (int)pt.y;
|
||||||
/* kEventParamMouseLocation is in screen coordinates */
|
/* kEventParamMouseLocation is in screen coordinates */
|
||||||
if (!win_fullscreen) { mouseX -= windowX; mouseY -= windowY; }
|
if (!win_fullscreen) { mouseX -= windowX; mouseY -= windowY; }
|
||||||
@ -1969,10 +1972,7 @@ void Cursor_SetPosition(int x, int y) {
|
|||||||
CGPoint point;
|
CGPoint point;
|
||||||
point.x = x + windowX;
|
point.x = x + windowX;
|
||||||
point.y = y + windowY;
|
point.y = y + windowY;
|
||||||
|
|
||||||
CGAssociateMouseAndMouseCursorPosition(0);
|
|
||||||
CGDisplayMoveCursorToPoint(CGMainDisplayID(), point);
|
CGDisplayMoveCursorToPoint(CGMainDisplayID(), point);
|
||||||
CGAssociateMouseAndMouseCursorPosition(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cursor_SetVisible(bool visible) {
|
void Cursor_SetVisible(bool visible) {
|
||||||
@ -2048,9 +2048,17 @@ void Window_FreeFramebuffer(Bitmap* bmp) {
|
|||||||
|
|
||||||
void Window_OpenKeyboard(void) { }
|
void Window_OpenKeyboard(void) { }
|
||||||
void Window_CloseKeyboard(void) { }
|
void Window_CloseKeyboard(void) { }
|
||||||
void Window_EnableRawMouse(void) { Window_DefaultEnableRawMouse(); }
|
|
||||||
void Window_UpdateRawMouse(void) { Window_DefaultUpdateRawMouse(); }
|
void Window_EnableRawMouse(void) {
|
||||||
void Window_DisableRawMouse(void) { Window_DefaultDisableRawMouse(); }
|
Window_DefaultEnableRawMouse();
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window_UpdateRawMouse(void) { Window_CentreMousePosition(); }
|
||||||
|
void Window_DisableRawMouse(void) {
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(1);
|
||||||
|
Window_DefaultDisableRawMouse();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -3105,15 +3113,9 @@ void Window_CloseKeyboard(void) {
|
|||||||
JavaCallVoid(env, "closeKeyboard", "()V", NULL);
|
JavaCallVoid(env, "closeKeyboard", "()V", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_EnableRawMouse(void) {
|
void Window_EnableRawMouse(void) { Window_DefaultEnableRawMouse(); }
|
||||||
Window_DefaultEnableRawMouse();
|
|
||||||
win_rawMouse = true;
|
|
||||||
}
|
|
||||||
void Window_UpdateRawMouse(void) { }
|
void Window_UpdateRawMouse(void) { }
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) { Window_DefaultDisableRawMouse(); }
|
||||||
Window_DefaultDisableRawMouse();
|
|
||||||
win_rawMouse = false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user