Skip to content

Commit

Permalink
riscos: Mouse fixes
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
Phlamethrower committed Jun 1, 2019
1 parent e8f788c commit 64586a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/video/riscos/SDL_riscosevents.c
Expand Up @@ -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;

Expand All @@ -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
Expand Down
15 changes: 5 additions & 10 deletions src/video/riscos/SDL_riscosmouse.c
Expand Up @@ -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, &regs, &regs);

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;
Expand Down Expand Up @@ -233,6 +227,7 @@ void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
regs.r[1] = (unsigned int)window_state;
_kernel_swi(Wimp_GetWindowState, &regs, &regs);

/* 90 DPI mapping from SDL pixels to OS units */
osX = (x << 1) + window_state[1];
osY = window_state[4] - (y << 1);

Expand Down

0 comments on commit 64586a7

Please sign in to comment.