From fd8d4c66bc0b2081d36ae2b22f62d69866f3cdbf Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 15 Sep 2019 20:52:02 +1000 Subject: [PATCH] share some more code between carbon/cocoa --- src/Window.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Window.c b/src/Window.c index 34c3d3ed6..dc1d9fb12 100644 --- a/src/Window.c +++ b/src/Window.c @@ -1748,6 +1748,28 @@ void Clipboard_SetText(const String* value) { void Window_OpenKeyboard(void) { } void Window_CloseKeyboard(void) { } + + +void Window_EnableRawMouse(void) { + Window_DefaultEnableRawMouse(); + CGAssociateMouseAndMouseCursorPosition(0); +} + +void Window_UpdateRawMouse(void) { Window_CentreMousePosition(); } +void Window_DisableRawMouse(void) { + CGAssociateMouseAndMouseCursorPosition(1); + Window_DefaultDisableRawMouse(); +} + + +#ifdef CC_BUILD_GL +bool GLContext_TryRestore(void) { return true; } + +void* GLContext_GetAddress(const char* function) { + void* address = DynamicLib_GetFrom("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", function); + return GLContext_IsInvalidAddress(address) ? NULL : address; +} +#endif #endif @@ -2228,17 +2250,6 @@ void Window_FreeFramebuffer(Bitmap* bmp) { CGColorSpaceRelease(colorSpace); } -void Window_EnableRawMouse(void) { - Window_DefaultEnableRawMouse(); - CGAssociateMouseAndMouseCursorPosition(0); -} - -void Window_UpdateRawMouse(void) { Window_CentreMousePosition(); } -void Window_DisableRawMouse(void) { - CGAssociateMouseAndMouseCursorPosition(1); - Window_DefaultDisableRawMouse(); -} - /*########################################################################################################################* *-------------------------------------------------------AGL OpenGL--------------------------------------------------------* @@ -2371,7 +2382,6 @@ void GLContext_Update(void) { GLContext_SetDrawable(); aglUpdateContext(ctx_handle); } -bool GLContext_TryRestore(void) { return true; } void GLContext_Free(void) { if (!ctx_handle) return; @@ -2380,11 +2390,6 @@ void GLContext_Free(void) { ctx_handle = NULL; } -void* GLContext_GetAddress(const char* function) { - void* address = DynamicLib_GetFrom("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", function); - return GLContext_IsInvalidAddress(address) ? NULL : address; -} - bool GLContext_SwapBuffers(void) { aglSwapBuffers(ctx_handle); GLContext_Check(0, "Swapping buffers"); @@ -3885,15 +3890,9 @@ void Window_FreeFramebuffer(Bitmap* bmp) { Mem_Free(bmp->Scan0); } -void Window_EnableRawMouse(void) { } -void Window_UpdateRawMouse(void) { } -void Window_DisableRawMouse(void) { } - void GLContext_Init(struct GraphicsMode* mode) { } void GLContext_Update(void) { } -bool GLContext_TryRestore(void) { return true; } void GLContext_Free(void) { } -void* GLContext_GetAddress(const char* function) { return NULL; } bool GLContext_SwapBuffers(void) { return true; } void GLContext_SetFpsLimit(bool vsync, float minFrameMs) { } #endif