From 64586a7f8afc688d895324c077cb6a9c682df984 Mon Sep 17 00:00:00 2001 From: Jeffrey Lee Date: Sat, 1 Jun 2019 19:26:50 +0100 Subject: [PATCH] riscos: Mouse fixes * FULLSCREEN_WarpWMCursor pixel to OS unit conversion fixed to invert Y axis. Also, avoid redundant SWI to read eigen values * RISCOS_PollMouseHelper mouse re-centreing fixed to use 90 DPI coordinate scaling * Added some extra comments for clarity (fullscreen & windowed modes are always handled as 90 DPI) --- src/video/riscos/SDL_riscosevents.c | 6 +++--- src/video/riscos/SDL_riscosmouse.c | 15 +++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index ca5e637d4..f085994dd 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -299,7 +299,7 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen) x = new_x - topLeftX; y = topLeftY - new_y; /* Y goes from top of window/screen */ - /* Convert OS units to pixels */ + /* Convert OS units to pixels (with 90 DPI mapping from OS units to SDL pixels) */ x >>= 1; y >>= 1; @@ -313,8 +313,8 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen) if (centre_x != x || centre_y != y) { if (SDL_VideoSurface) SDL_PrivateMouseMotion(0,1,x - centre_x, y - centre_y); - last_x = topLeftX + (centre_x << this->hidden->xeig); - last_y = topLeftY - (centre_y << this->hidden->yeig); + last_x = topLeftX + (centre_x << 1); + last_y = topLeftY - (centre_y << 1); /* Re-centre the mouse pointer, so we still get relative movement when the mouse is at the edge of the window diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index 5dba7b184..2730605c5 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -188,20 +188,14 @@ int RISCOS_ShowWMCursor(_THIS, WMcursor *cursor) void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { Uint8 move_block[5]; - int eig_block[3]; _kernel_swi_regs regs; int os_x, os_y; + int topLeftY; - eig_block[0] = 4; /* X eig factor */ - eig_block[1] = 5; /* Y eig factor */ - eig_block[2] = -1; /* End of list of variables to request */ + topLeftY = (this->hidden->height << this->hidden->yeig) - 1; /* As per RISCOS_PollMouseHelper */ - regs.r[0] = (int)eig_block; - regs.r[1] = (int)eig_block; - _kernel_swi(OS_ReadVduVariables, ®s, ®s); - - os_x = x << eig_block[0]; - os_y = y << eig_block[1]; + os_x = x << this->hidden->xeig; + os_y = topLeftY - (y << this->hidden->yeig); move_block[0] = 3; /* Move cursor */ move_block[1] = os_x & 0xFF; @@ -233,6 +227,7 @@ void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y) regs.r[1] = (unsigned int)window_state; _kernel_swi(Wimp_GetWindowState, ®s, ®s); + /* 90 DPI mapping from SDL pixels to OS units */ osX = (x << 1) + window_state[1]; osY = window_state[4] - (y << 1);