Skip to content

Commit

Permalink
ogc: hide default mouse cursor when not pointing at screen
Browse files Browse the repository at this point in the history
Applications not explicitly requesting a mouse cursor don't have any
benefit in rendering the default cursor when the wiimote is not pointed
at the screen; on the contrary, the wiimote might be held sideways, and
the cursor would just be disturbing.
  • Loading branch information
mardy authored and WinterMute committed Nov 16, 2024
1 parent fad294d commit 76b9c04
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/video/ogc/SDL_ogcmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,21 @@ void OGC_draw_cursor(_THIS)
OGC_CursorData *curdata;
Mtx mv;
int screen_w, screen_h;
float angle = 0.0f;

if (!mouse || !mouse->cursor_shown ||
!mouse->cur_cursor || !mouse->cur_cursor->driverdata) {
return;
}

/* If this is the default cursor, rotate it, and if it's not pointed at the
* screen, hide it */
if (mouse->cur_cursor == mouse->def_cursor) {
WPADData *data = WPAD_Data(mouse->mouseID);
angle = data->ir.angle;
if (!data->ir.valid) return;
}

screen_w = _this->displays[0].current_mode.w;
screen_h = _this->displays[0].current_mode.h;

Expand All @@ -191,13 +200,8 @@ void OGC_draw_cursor(_THIS)

guMtxIdentity(mv);
guMtxScaleApply(mv, mv, screen_w / 640.0f, screen_h / 480.0f, 1.0f);
/* If this is the default cursor, rotate it too */
if (mouse->cur_cursor == mouse->def_cursor) {
if (angle != 0.0f) {
Mtx rot;
float angle;
WPADData *data = WPAD_Data(mouse->mouseID);

angle = data->ir.angle;
guMtxRotDeg(rot, 'z', angle);
guMtxConcat(mv, rot, mv);
}
Expand Down

0 comments on commit 76b9c04

Please sign in to comment.