Skip to content

Commit

Permalink
ogc: rotate mouse cursor to match wiimote orientation
Browse files Browse the repository at this point in the history
Set a rotation on the mouse cursor to match the wiimote angle. Note that
we do this only with the default hand-shaped cursor: if the application
has set a different cursor, we should not rotate it.

Fixes: #63
  • Loading branch information
mardy authored and WinterMute committed Mar 30, 2024
1 parent 3f99df1 commit 4f26b2b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/video/ogc/SDL_ogcmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <malloc.h>
#include <ogc/cache.h>
#include <ogc/gx.h>
#include <wiiuse/wpad.h>

typedef struct _OGC_CursorData
{
Expand Down Expand Up @@ -189,6 +190,16 @@ 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) {
Mtx rot;
float angle;
WPADData *data = WPAD_Data(mouse->mouseID);

angle = data->ir.angle;
guMtxRotDeg(rot, 'z', angle);
guMtxConcat(mv, rot, mv);
}
guMtxTransApply(mv, mv, mouse->x, mouse->y, 0);
GX_LoadPosMtxImm(mv, GX_PNMTX1);

Expand Down

0 comments on commit 4f26b2b

Please sign in to comment.