Skip to content

Commit

Permalink
atari:video:gem: map mouse buttons to correct SDL_BUTTON_*
Browse files Browse the repository at this point in the history
  • Loading branch information
th-otto authored and mikrosk committed Mar 20, 2024
1 parent ac5c29b commit 82325b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -374,6 +374,23 @@ static void do_mouse_motion(_THIS, short mx, short my)
prevmy = my;
}

static int atari_GetButton(int button)
{
switch(button)
{
case 0:
default:
return SDL_BUTTON_LEFT;
break;
case 1:
return SDL_BUTTON_RIGHT;
break;
case 2:
return SDL_BUTTON_MIDDLE;
break;
}
}

static void do_mouse_buttons(_THIS, short mb)
{
int i;
Expand All @@ -392,10 +409,10 @@ static void do_mouse_buttons(_THIS, short mb)
prevbutton = prevmb & (1<<i);

if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0);
SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
}
if (!curbutton && prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0);
SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
}
}

Expand Down
6 changes: 5 additions & 1 deletion test/checkkeys.c
Expand Up @@ -141,7 +141,11 @@ int main(int argc, char *argv[])
PrintKey(&event.key.keysym, 0);
break;
case SDL_MOUSEBUTTONDOWN:
/* Any button press quits the app... */
printf("mouse button down %d\n", event.button.button);
break;
case SDL_MOUSEBUTTONUP:
printf("mouse button up %d\n", event.button.button);
break;
case SDL_QUIT:
done = 1;
break;
Expand Down

3 comments on commit 82325b1

@sezero
Copy link
Collaborator

@sezero sezero commented on 82325b1 Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess test/checkkeys.c change was only to test the video/gem changes temporarily. Can we revert the test/checkkeys.c change?

@mikrosk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have overlooked this one. Sure, if you find the previous implementation more helpful, go ahead.

@sezero
Copy link
Collaborator

@sezero sezero commented on 82325b1 Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done as f5f2d38

Please sign in to comment.