From 3dc91582d84fd0d5b4ca8c2713802816db4d47a8 Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Tue, 19 Nov 2024 01:04:16 -0800 Subject: [PATCH] fix windows build; initial easy Mouse impl (Windows) --- src/core/util_hid.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/core/util_hid.cpp b/src/core/util_hid.cpp index 2e0d9c1de..faee74c88 100644 --- a/src/core/util_hid.cpp +++ b/src/core/util_hid.cpp @@ -7808,7 +7808,8 @@ const char * Keyboard_name( int k ) //----------------------------------------------------------------------------- t_CKVEC2 ck_get_mouse_xy_normalize() { - t_CKVEC2 retval; + t_CKVEC2 retval; retval.x = retval.y = 0; + #ifdef __PLATFORM_APPLE__ // get screen coords CGEventRef cg_event = CGEventCreate(NULL); @@ -7829,9 +7830,13 @@ t_CKVEC2 ck_get_mouse_xy_normalize() // reclaim CFRelease( cg_event ); -#elif #defined(__PLATFORM_WINDOWS__) -#elif #defined(__PLATFORM_LINUX__) +#elif defined(__PLATFORM_WINDOWS__) + // multiple monitors info + // https://stackoverflow.com/questions/4631292/how-to-detect-the-current-screen-resolution + +#elif defined(__PLATFORM_LINUX__) #else + // unsupported, for now; return 0,0 #endif // done @@ -7843,7 +7848,7 @@ t_CKVEC2 ck_get_mouse_xy_normalize() //----------------------------------------------------------------------------- t_CKVEC2 ck_get_mouse_xy_absolute() { - t_CKVEC2 retval; + t_CKVEC2 retval; retval.x = retval.y = 0; #ifdef __PLATFORM_APPLE__ // get screen coords CGEventRef cg_event = CGEventCreate(NULL); @@ -7853,8 +7858,15 @@ t_CKVEC2 ck_get_mouse_xy_absolute() retval.y = (t_CKFLOAT)mouseLocation.y; // reclaim CFRelease( cg_event ); -#elif #defined(__PLATFORM_WINDOWS__) -#elif #defined(__PLATFORM_LINUX__) +#elif defined(__PLATFORM_WINDOWS__) + // get screen coords + POINT pt; + if( GetCursorPos( &pt ) ) + { + retval.x = pt.x; + retval.y = pt.y; + } +#elif defined(__PLATFORM_LINUX__) #else #endif return retval;