void keyEvent(rfbBool down, rfbKeySym key, rfbClientPtr cl) { int code; // L("Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down); setIdle(0); int sh = 0; int alt = 0; if ( inputfd == -1 ) return; if ((code = keysym2scancode(down, key, cl,&sh,&alt))) { int ret=0; if (key && down) { if (sh) suinput_press(inputfd, 42); //left shift if (alt) suinput_press(inputfd, 56); //left alt ret=suinput_press(inputfd,code); ret=suinput_release(inputfd,code); if (alt) suinput_release(inputfd, 56); //left alt if (sh) suinput_release(inputfd, 42); //left shift } else ;//ret=suinput_release(inputfd,code); // L("injectKey (%d, %d) ret=%d\n", code , down,ret); } }
static uSynergyBool uSynergyMouseUpCallback(uSynergyCookie cookie, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle) { int ret; if (!buttonLeft) ret = suinput_release(cookie->uinput_mouse, BTN_LEFT); if (!buttonRight) ret = suinput_release(cookie->uinput_mouse, BTN_RIGHT); if (!buttonMiddle) ret = suinput_release(cookie->uinput_mouse, BTN_MIDDLE); return USYNERGY_TRUE; }
static void uSynergyKeyboardCallback(uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat) { int ret; if (down) ret = suinput_press(cookie->uinput_keyboard, key); else ret = suinput_release(cookie->uinput_keyboard, key); }
void ptrEvent(int buttonMask, int x, int y, rfbClientPtr cl) { static int leftClicked=0,rightClicked=0,middleClicked=0; if ( inputfd == -1 ) return; setIdle(0); transformTouchCoordinates(&x,&y,cl->screen->width,cl->screen->height); if((buttonMask & 1)&& leftClicked) {//left btn clicked and moving static int i=0; i=i+1; if (i%10==1)//some tweak to not report every move event { suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } } else if (buttonMask & 1)//left btn clicked { leftClicked=1; suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd,EV_KEY,BTN_TOUCH,1); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } else if (leftClicked)//left btn released { leftClicked=0; suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd,EV_KEY,BTN_TOUCH,0); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } if (buttonMask & 4)//right btn clicked { rightClicked=1; suinput_press(inputfd,158); //back key } else if (rightClicked)//right button released { rightClicked=0; suinput_release(inputfd,158); } if (buttonMask & 2)//mid btn clicked { middleClicked=1; suinput_press( inputfd,KEY_END); } else if (middleClicked)// mid btn released { middleClicked=0; suinput_release( inputfd,KEY_END); } }
int suinput_click(int uinput_fd, uint16_t code) { if (suinput_press(uinput_fd, code)) return -1; return suinput_release(uinput_fd, code); }