Skip to content

Commit

Permalink
fix windows build; initial easy Mouse impl (Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 19, 2024
1 parent 61fc41e commit 3dc9158
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/core/util_hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 3dc9158

Please sign in to comment.