int vnc_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; SendPointerEvent(rfb_client, x, y, mask); return 0; }
bool LibVncImage::sendPointerEvent(int x, int y, int buttonMask) { if (_client) { SendPointerEvent(_client ,x, y, buttonMask); return true; } return false; }
int guac_vnc_user_mouse_handler(guac_user* user, int x, int y, int mask) { guac_client* client = user->client; guac_vnc_client* vnc_client = (guac_vnc_client*) client->data; /* Store current mouse location */ guac_common_cursor_move(vnc_client->display->cursor, user, x, y); SendPointerEvent(vnc_client->rfb_client, x, y, mask); return 0; }
/* * Handle all X events (keyboard and mouse). */ Bool HandleXEvents(GR_EVENT *ev) { GR_BOOL ret = GR_TRUE; int buttons; #if 0 printf("H"); fflush(stdout); #endif switch (ev->type) { case GR_EVENT_TYPE_NONE: ret = GR_TRUE; break; case GR_EVENT_TYPE_MOUSE_POSITION: buttons = (ev->mouse.buttons & GR_BUTTON_R) << 2; buttons |= ev->mouse.buttons & GR_BUTTON_M; buttons |= (ev->mouse.buttons & GR_BUTTON_L) >> 2; ret = SendPointerEvent(ev->mouse.x, ev->mouse.y, buttons); break; case GR_EVENT_TYPE_BUTTON_DOWN: case GR_EVENT_TYPE_BUTTON_UP: buttons = (ev->button.buttons & GR_BUTTON_R) << 2; buttons |= ev->button.buttons & GR_BUTTON_M; buttons |= (ev->button.buttons & GR_BUTTON_L) >> 2; ret = SendPointerEvent(ev->button.x, ev->button.y, buttons); break; case GR_EVENT_TYPE_KEY_DOWN: case GR_EVENT_TYPE_KEY_UP: ret = SendKeyEvent(kmap[ev->keystroke.ch & 0x7f], (ev->type == GR_EVENT_TYPE_KEY_DOWN)); break; default: break; } return(ret); }
static gboolean button_event (GtkWidget *widget, GdkEventButton *event) { int x, y; GdkModifierType state; int i, buttonMask; gdk_window_get_pointer (event->window, &x, &y, &state); for (buttonMask = 0, i = 0; buttonMapping[i].gdk; i++) if (state & buttonMapping[i].gdk) buttonMask |= buttonMapping[i].rfb; SendPointerEvent (cl, x, y, buttonMask); return TRUE; }
static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { int x, y; GdkModifierType state; int i, buttonMask; if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state); else { x = event->x; y = event->y; state = event->state; } for (buttonMask = 0, i = 0; buttonMapping[i].gdk; i++) if (state & buttonMapping[i].gdk) buttonMask |= buttonMapping[i].rfb; SendPointerEvent (cl, x, y, buttonMask); return TRUE; }
void PointerClientEvent::fire(rfbClient* cl) { SendPointerEvent(cl, m_x, m_y, m_buttonMask); }
static void ParseRawInputMS(RAWMOUSE &m, HIDState *hs) { int b = 0, z = 0; InputEvent ev{}; if (m.usButtonFlags & RI_MOUSE_WHEEL) z = (short)m.usButtonData / WHEEL_DELTA; //OSDebugOut(TEXT("mouse: %d %d %u %hd\n"), m.lLastX, m.lLastY, m.ulButtons, z); ev.type = INPUT_EVENT_KIND_BTN; if (m.ulButtons & RI_MOUSE_LEFT_BUTTON_DOWN) { ev.u.btn.button = INPUT_BUTTON_LEFT; ev.u.btn.down = true; SendPointerEvent(ev, hs); } if (m.ulButtons & RI_MOUSE_LEFT_BUTTON_UP) { ev.u.btn.button = INPUT_BUTTON_LEFT; ev.u.btn.down = false; SendPointerEvent(ev, hs); } if (m.ulButtons & RI_MOUSE_RIGHT_BUTTON_DOWN) { ev.u.btn.button = INPUT_BUTTON_RIGHT; ev.u.btn.down = true; SendPointerEvent(ev, hs); } if (m.ulButtons & RI_MOUSE_RIGHT_BUTTON_UP) { ev.u.btn.button = INPUT_BUTTON_RIGHT; ev.u.btn.down = false; SendPointerEvent(ev, hs); } if (m.ulButtons & RI_MOUSE_MIDDLE_BUTTON_DOWN) { ev.u.btn.button = INPUT_BUTTON_MIDDLE; ev.u.btn.down = true; SendPointerEvent(ev, hs); } if (m.ulButtons & RI_MOUSE_MIDDLE_BUTTON_UP) { ev.u.btn.button = INPUT_BUTTON_MIDDLE; ev.u.btn.down = false; SendPointerEvent(ev, hs); } if (z != 0) { ev.u.btn.button = (z < 0) ? INPUT_BUTTON_WHEEL_DOWN : INPUT_BUTTON_WHEEL_UP; for (int i = 0; i < z; i++) { ev.u.btn.down = true; SendPointerEvent(ev, hs); ev.u.btn.down = false; // TODO needs an UP event? SendPointerEvent(ev, hs); } } if (m.usFlags & MOUSE_MOVE_ABSOLUTE) { /*ev.type = INPUT_EVENT_KIND_ABS; ev.u.abs.axis = INPUT_AXIS_X; ev.u.abs.value = m.lLastX; SendPointerEvent(ev, hs); ev.u.abs.axis = INPUT_AXIS_Y; ev.u.abs.value = m.lLastY; SendPointerEvent(ev, hs);*/ } else { ev.type = INPUT_EVENT_KIND_REL; ev.u.rel.axis = INPUT_AXIS_X; ev.u.rel.value = m.lLastX; SendPointerEvent(ev, hs); ev.u.rel.axis = INPUT_AXIS_Y; ev.u.rel.value = m.lLastY; SendPointerEvent(ev, hs); } if (hs->ptr.eh_sync) hs->ptr.eh_sync(hs); }
virtual void fire( rfbClient *cl ) { SendPointerEvent( cl, m_x, m_y, m_buttonMask ); }
void Process_DRC_Input(rfbClient *cl, drc::InputData& input_data) { static int prev_x, prev_y, prev_buttons; static int prev_lbutton, prev_rbutton, prev_pwrbutton; // BUG: pressing a button without having had a touchscreen event sends the // cursor to (0,0) as prev_x, prev_y are uninitialised. // New unique button event if (input_data.buttons != prev_buttons) { int lbutton = input_data.buttons & (drc::InputData::kBtnZL | drc::InputData::kBtnZR); int rbutton = input_data.buttons & (drc::InputData::kBtnL | drc::InputData::kBtnR); int pwrbutton = input_data.buttons & drc::InputData::kBtnPower; // emulate mouse clicks with trigger buttons if (!drcJoystickMode) { if(lbutton != prev_lbutton) { if (lbutton) buttonMask |= rfbButton1Mask; else buttonMask &= ~rfbButton1Mask; SendPointerEvent(cl, prev_x, prev_y, buttonMask); } if(rbutton != prev_rbutton) { if (rbutton) buttonMask |= rfbButton3Mask; else buttonMask &= ~rfbButton3Mask; SendPointerEvent(cl, prev_x, prev_y, buttonMask); } } // if input feeder mode is on, push power button to toggle between // full joystick mode (all buttons go to input feeder) or // mouse only mode, where trigger buttons are mouse clicks if (drcInputFeeder) { if(pwrbutton != prev_pwrbutton) { if (pwrbutton) { drcJoystickMode = !drcJoystickMode; if (!drcJoystickMode) { printf("Mouse button mode\n"); g_streamer->PauseSystemInputFeeder(); } else { printf("Joystick mode\n"); g_streamer->ResumeSystemInputFeeder(); } } } } prev_lbutton = lbutton; prev_rbutton = rbutton; prev_pwrbutton = pwrbutton; prev_buttons = input_data.buttons; } // Handle touchscreen press if (input_data.ts_pressed) { int x = (input_data.ts_x * drc::kScreenWidth) - 1; int y = (input_data.ts_y * drc::kScreenHeight) - 1; if (x != prev_x || y != prev_y) { SendPointerEvent(cl, x, y, buttonMask); prev_x = x; prev_y = y; } } }
static rfbBool handleSDLEvent(rfbClient *cl, SDL_Event *e) { rfbKeySym rfbkey; switch(e->type) { case SDL_WINDOWEVENT: switch (e->window.event) { case SDL_WINDOWEVENT_EXPOSED: SendFramebufferUpdateRequest(cl, 0, 0, cl->width, cl->height, FALSE); break; default: break; } break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEMOTION: { int x, y, state, i; if (viewOnly) break; 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; } if (e->type == SDL_MOUSEBUTTONDOWN) buttonMask |= SDL_BUTTON(state); if (e->type == SDL_MOUSEBUTTONUP) buttonMask &= ~SDL_BUTTON(state); SendPointerEvent(cl, x, y, buttonMask); break; } case SDL_MOUSEWHEEL: // mouse coords need to be sent along with button presses int x, y; SDL_GetMouseState(&x, &y); if (e->wheel.y == 1) { buttonMask |= SDL_BUTTON(SDL_BUTTON_X1); SendPointerEvent(cl, x, y, buttonMask); buttonMask &= ~SDL_BUTTON(SDL_BUTTON_X1); SendPointerEvent(cl, x, y, buttonMask); } if (e->wheel.y == -1) { buttonMask |= SDL_BUTTON(SDL_BUTTON_X2); SendPointerEvent(cl, x, y, buttonMask); buttonMask &= ~SDL_BUTTON(SDL_BUTTON_X2); SendPointerEvent(cl, x, y, buttonMask); } break; case SDL_KEYDOWN: if (viewOnly) break; rfbkey = SDL_key2rfbKeySym(&e->key); if (rfbkey > 0) { SendKeyEvent(cl, rfbkey, TRUE); } else { symDown = e->key.keysym.sym; } break; case SDL_KEYUP: if (viewOnly) break; rfbkey = SDL_key2rfbKeySym(&e->key); if (rfbkey > 0) { SendKeyEvent(cl, rfbkey, FALSE); } else { SDL_Keycode sym = e->key.keysym.sym; if (keysDown.find(sym) != keysDown.end()) { SendKeyEvent(cl, keysDown[sym], FALSE); keysDown.erase(sym); } } break; case SDL_TEXTINPUT: keysDown[symDown] = e->text.text[0]; symDown = 0; SendKeyEvent(cl, e->text.text[0], TRUE); break; case SDL_QUIT: if(listenLoop) { cleanup(cl); Quit_DRC(); return FALSE; } else { rfbClientCleanup(cl); exit(0); } default: rfbClientLog("ignore SDL event: 0x%x\n", e->type); } return TRUE; }