Commit fc45b97d authored by dscho's avatar dscho

add mouse button handling

parent 2b8c2a5c
...@@ -208,9 +208,20 @@ int main(int argc,char** argv) { ...@@ -208,9 +208,20 @@ int main(int argc,char** argv) {
case SDL_VIDEOEXPOSE: case SDL_VIDEOEXPOSE:
SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE); SendFramebufferUpdateRequest(cl,0,0,cl->width,cl->height,FALSE);
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION: { case SDL_MOUSEMOTION: {
int x,y; 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); SendPointerEvent(cl,x,y,buttonMask);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment