summaryrefslogtreecommitdiffstats
path: root/client_examples/SDLvncviewer.c
diff options
context:
space:
mode:
authordscho <dscho>2009-03-12 00:07:48 +0000
committerdscho <dscho>2009-03-12 00:07:48 +0000
commite2874d343a58e5f5f94739d864545a9d80c4cd87 (patch)
tree25c755ab7f296e241bc7f749d96d416162af48e7 /client_examples/SDLvncviewer.c
parent76db22022cd4adcc9265edb2a87d99bf1eb1fbf6 (diff)
downloadlibtdevnc-e2874d343a58e5f5f94739d864545a9d80c4cd87.tar.gz
libtdevnc-e2874d343a58e5f5f94739d864545a9d80c4cd87.zip
Teach SDLvncviewer about scroll wheel events
Signed-off-by: Johannes Schindelin <[email protected]>
Diffstat (limited to 'client_examples/SDLvncviewer.c')
-rw-r--r--client_examples/SDLvncviewer.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index d905f74..a0fd1d9 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -6,6 +6,8 @@ struct { int sdl; int rfb; } buttonMapping[]={
{1, rfbButton1Mask},
{2, rfbButton2Mask},
{3, rfbButton3Mask},
+ {4, rfbButton4Mask},
+ {5, rfbButton5Mask},
{0,0}
};
@@ -357,22 +359,39 @@ static void handleSDLEvent(rfbClient *cl, SDL_Event *e)
#endif
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
- case SDL_MOUSEMOTION: {
+ case SDL_MOUSEMOTION:
+ {
int x, y, state, i;
if (viewOnly)
break;
- state = SDL_GetMouseState(&x, &y);
+ if (e->type == SDL_MOUSEMOTION) {
+ x = e->motion.x;
+ y = e->motion.y;
+ state = e->motion.state;
+ }
+ else {
+ x = e->button.x;
+ y = e->button.y;
+ state = e->button.button;
+ for (i = 0; buttonMapping[i].sdl; i++)
+ if (state == buttonMapping[i].sdl) {
+ state = buttonMapping[i].rfb;
+ if (e->type == SDL_MOUSEBUTTONDOWN)
+ buttonMask |= state;
+ else
+ buttonMask &= ~state;
+ break;
+ }
+ }
if (sdlPixels) {
x = x * cl->width / realWidth;
y = y * cl->height / realHeight;
}
- for (buttonMask = 0, i = 0; buttonMapping[i].sdl; i++)
- if (state & SDL_BUTTON(buttonMapping[i].sdl))
- buttonMask |= buttonMapping[i].rfb;
- SendPointerEvent(cl, x, y, buttonMask);
- break;
- }
+ SendPointerEvent(cl, x, y, buttonMask);
+ buttonMask &= ~(rfbButton4Mask | rfbButton5Mask);
+ break;
+ }
case SDL_KEYUP:
case SDL_KEYDOWN:
if (viewOnly)