summaryrefslogtreecommitdiffstats
path: root/client_examples
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2018-07-30 18:58:28 +0200
committerChristian Beier <dontmind@freeshell.org>2018-07-30 19:15:27 +0200
commit97c9b6c5d7959df3ea18c397a01db2b266ce204a (patch)
tree45d5ec41f4e6a6d340582446334a2275ea7207fa /client_examples
parentb0957702a88e6547ecca252165cef4a653239fec (diff)
downloadlibtdevnc-97c9b6c5d7959df3ea18c397a01db2b266ce204a.tar.gz
libtdevnc-97c9b6c5d7959df3ea18c397a01db2b266ce204a.zip
SDLvncviewer: handle mouse wheel events
Diffstat (limited to 'client_examples')
-rw-r--r--client_examples/SDLvncviewer.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 67820a8..e2d4357 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -29,6 +29,8 @@ int sdlFlags;
SDL_Texture *sdlTexture;
SDL_Renderer *sdlRenderer;
SDL_Window *sdlWindow;
+/* client's pointer position */
+int x,y;
static int rightAltKeyDown, leftAltKeyDown;
@@ -316,11 +318,39 @@ static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e)
break;
}
break;
+ case SDL_MOUSEWHEEL:
+ {
+ int steps;
+ if (viewOnly)
+ break;
+
+ if(e->wheel.y > 0)
+ for(steps = 0; steps < e->wheel.y; ++steps) {
+ SendPointerEvent(cl, x, y, rfbButton4Mask);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.y < 0)
+ for(steps = 0; steps > e->wheel.y; --steps) {
+ SendPointerEvent(cl, x, y, rfbButton5Mask);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.x > 0)
+ for(steps = 0; steps < e->wheel.x; ++steps) {
+ SendPointerEvent(cl, x, y, 0b01000000);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ if(e->wheel.x < 0)
+ for(steps = 0; steps > e->wheel.x; --steps) {
+ SendPointerEvent(cl, x, y, 0b00100000);
+ SendPointerEvent(cl, x, y, 0);
+ }
+ break;
+ }
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION:
{
- int x, y, state, i;
+ int state, i;
if (viewOnly)
break;