summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <dscho>2004-06-07 11:21:51 +0000
committerdscho <dscho>2004-06-07 11:21:51 +0000
commitfc45b97d6503cf7fc72cdacd4611055c5554e77c (patch)
treef0b33e1f7bb5962129fc3bdba92dd2a1bcb042f6
parent2b8c2a5c3a71364e402b4df334a6f5aff5ed77a9 (diff)
downloadlibtdevnc-fc45b97d6503cf7fc72cdacd4611055c5554e77c.tar.gz
libtdevnc-fc45b97d6503cf7fc72cdacd4611055c5554e77c.zip
add mouse button handling
-rw-r--r--client_examples/SDLvncviewer.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 58884cf..e1fe3ff 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -208,9 +208,20 @@ int main(int argc,char** argv) {
case SDL_VIDEOEXPOSE:
SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE);
break;
+ case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION: {
int x,y;
- SDL_GetMouseState(&x,&y);
+ int state=SDL_GetMouseState(&x,&y);
+ struct { int sdl; int rfb; } buttonMapping[]={
+ {SDL_BUTTON_LEFT, rfbButton1Mask},
+ {SDL_BUTTON_RIGHT, rfbButton2Mask},
+ {SDL_BUTTON_MIDDLE, rfbButton3Mask},
+ {0,0}
+ };
+ int i;
+ 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;