Skip to content

Commit

Permalink
riscos: Add support for additional mouse events
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Sep 20, 2020
1 parent ba62b1c commit f59677f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/video/riscos/SDL_riscosevents.c
Expand Up @@ -262,6 +262,10 @@ void WIMP_PollMouse(_THIS)
static Sint16 last_x = -1, last_y = -1;
static int last_buttons = 0;

static inline void HandleMouseButton(int changed, int last, int mask, int button) {
if (changed & mask) SDL_PrivateMouseButton((last & mask) ? SDL_PRESSED : SDL_RELEASED, button, 0, 0);
}

/* Share routine between WIMP and FULLSCREEN for polling mouse and
passing on events */
void RISCOS_PollMouseHelper(_THIS, int fullscreen)
Expand Down Expand Up @@ -352,9 +356,14 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen)
{
int changed = last_buttons ^ regs.r[2];
last_buttons = regs.r[2];
if (changed & 4) SDL_PrivateMouseButton((last_buttons & 4) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
if (changed & 2) SDL_PrivateMouseButton((last_buttons & 2) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
if (changed & 1) SDL_PrivateMouseButton((last_buttons & 1) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
HandleMouseButton(changed, last_buttons, 1, SDL_BUTTON_RIGHT);
HandleMouseButton(changed, last_buttons, 2, SDL_BUTTON_MIDDLE);
HandleMouseButton(changed, last_buttons, 4, SDL_BUTTON_LEFT);
HandleMouseButton(changed, last_buttons, 8, SDL_BUTTON_X1);
HandleMouseButton(changed, last_buttons, 16, SDL_BUTTON_X2);
HandleMouseButton(changed, last_buttons, 32, SDL_BUTTON_X2 + 1);
HandleMouseButton(changed, last_buttons, 64, SDL_BUTTON_X2 + 2);
HandleMouseButton(changed, last_buttons, 128, SDL_BUTTON_X2 + 3);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/video/riscos/SDL_wimppoll.c
Expand Up @@ -219,6 +219,20 @@ void WIMP_Poll(_THIS, int waitTime)
*/
break;

case 10: /* Window scroll */
if (message[0] == sdlWindow)
{
if (message[9] < 0) {
SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
} else if (message[9] > 0) {
SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
}
} else
sysEvent = 1;
break;

case 11: /* Lose Caret */
hasFocus = 0;
if (message[0] == sdlWindow) SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
Expand Down
6 changes: 3 additions & 3 deletions src/video/riscos/SDL_wimpvideo.c
Expand Up @@ -231,16 +231,16 @@ unsigned int WIMP_SetupWindow(_THIS, SDL_Surface *surface)
window_block[5] = 0;
window_block[6] = -1; /* Open on top of window stack */

window_block[7] = 0x80040042; /* Window flags */
window_block[7] = 0x80040242; /* Window flags */
if (!(surface->flags & SDL_NOFRAME)) {
window_block[7] |= 0x5000000;
if (riscos_closeaction != 0) window_block[7] |= 0x2000000;
}

/* TODO: Take into account surface->flags */

window_block[8] = 0xff070207; /* Window colours */
window_block[9] = 0x000c0103;
window_block[8] = 0xff070207; /* Window colours and extra flags */
window_block[9] = 0x020c0103;
window_block[10] = 0; /* Work area minimum */
window_block[11] = -surface->h << 1;
window_block[12] = surface->w << 1; /* Work area maximum */
Expand Down

0 comments on commit f59677f

Please sign in to comment.