riscos: Mouse fixes SDL-1.2
authorJeffrey Lee
Sat, 01 Jun 2019 19:26:50 +0100
branchSDL-1.2
changeset 12783de7c0427180c
parent 12782 600cbd188a36
child 12784 76a69405319c
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
src/video/riscos/SDL_riscosmouse.c
     1.1 --- a/src/video/riscos/SDL_riscosevents.c	Sun May 26 12:02:02 2019 +0100
     1.2 +++ b/src/video/riscos/SDL_riscosevents.c	Sat Jun 01 19:26:50 2019 +0100
     1.3 @@ -299,7 +299,7 @@
     1.4            x = new_x - topLeftX;
     1.5            y = topLeftY - new_y; /* Y goes from top of window/screen */
     1.6  
     1.7 -          /* Convert OS units to pixels */
     1.8 +          /* Convert OS units to pixels (with 90 DPI mapping from OS units to SDL pixels) */
     1.9            x >>= 1;
    1.10            y >>= 1;
    1.11  
    1.12 @@ -313,8 +313,8 @@
    1.13                  if (centre_x != x || centre_y != y)
    1.14                  {
    1.15                     if (SDL_VideoSurface) SDL_PrivateMouseMotion(0,1,x - centre_x, y - centre_y);
    1.16 -                   last_x = topLeftX + (centre_x << this->hidden->xeig);
    1.17 -                   last_y = topLeftY - (centre_y << this->hidden->yeig);
    1.18 +                   last_x = topLeftX + (centre_x << 1);
    1.19 +                   last_y = topLeftY - (centre_y << 1);
    1.20  
    1.21                     /* Re-centre the mouse pointer, so we still get relative
    1.22                        movement when the mouse is at the edge of the window
     2.1 --- a/src/video/riscos/SDL_riscosmouse.c	Sun May 26 12:02:02 2019 +0100
     2.2 +++ b/src/video/riscos/SDL_riscosmouse.c	Sat Jun 01 19:26:50 2019 +0100
     2.3 @@ -188,20 +188,14 @@
     2.4  void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
     2.5  {
     2.6  	Uint8 move_block[5];
     2.7 -	int eig_block[3];
     2.8  	_kernel_swi_regs regs;
     2.9  	int os_x, os_y;
    2.10 -
    2.11 -	eig_block[0] = 4;  /* X eig factor */
    2.12 -	eig_block[1] = 5;  /* Y eig factor */
    2.13 -	eig_block[2] = -1;  /* End of list of variables to request */
    2.14 +	int topLeftY;
    2.15  
    2.16 -    regs.r[0] = (int)eig_block;
    2.17 -    regs.r[1] = (int)eig_block;
    2.18 -    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
    2.19 +	topLeftY = (this->hidden->height << this->hidden->yeig) - 1; /* As per RISCOS_PollMouseHelper */
    2.20  
    2.21 -	os_x = x << eig_block[0];
    2.22 -	os_y = y << eig_block[1];
    2.23 +	os_x = x << this->hidden->xeig;
    2.24 +	os_y = topLeftY - (y << this->hidden->yeig);
    2.25  
    2.26  	move_block[0] = 3; /* Move cursor */
    2.27  	move_block[1] = os_x & 0xFF;
    2.28 @@ -233,6 +227,7 @@
    2.29  	regs.r[1] = (unsigned int)window_state;
    2.30  	_kernel_swi(Wimp_GetWindowState, &regs, &regs);
    2.31  
    2.32 +	/* 90 DPI mapping from SDL pixels to OS units */
    2.33  	 osX = (x << 1) + window_state[1];
    2.34  	 osY = window_state[4] - (y << 1);
    2.35