void sdl::DispatchEvent(const SDL_Event &event, IInputEventAcceptor &acceptor) { int x, y; SDL_GetMouseState(&x, &y); glm::vec2 mousePosition = { float(x), float(y) }; switch (event.type) { case SDL_KEYDOWN: acceptor.OnKeyDown(event.key, mousePosition); break; case SDL_KEYUP: acceptor.OnKeyUp(event.key, mousePosition); break; case SDL_MOUSEBUTTONDOWN: acceptor.OnDragBegin(GetMousePosition(event.button)); break; case SDL_MOUSEBUTTONUP: acceptor.OnDragEnd(GetMousePosition(event.button)); break; case SDL_MOUSEMOTION: acceptor.OnDragMotion(GetMousePosition(event.motion)); break; } }
extern "C" _declspec(dllexport) void __cdecl FastClick( TClickType button ) { int x = 0, y = 0; GetMousePosition( x, y ); HoldMouse( x, y, button ); Sleep( RandomRange( 60, 150 ) ); GetMousePosition( x, y ); ReleaseMouse( x, y, button ); }
extern "C" _declspec(dllexport) void __cdecl DragMouse(int x, int y, TClickType button) { GetMousePosition(x, y); HoldMouse(x, y, button); Sleep( 50 + rand()% 50); Mouse(x,y,0,0,button); GetMousePosition(x, y); Sleep( 50 + rand()% 50); ReleaseMouse(x, y, button); }
extern "C" _declspec(dllexport) void __cdecl HumanDragMouse( int StartX, int StartY, int SRandX, int SRandY, int EndX, int EndY, int ERandX, int ERandY ) { MMouse( StartX, StartY, SRandX, SRandY ); Sleep( 150 + rand()% 20 ); GetMousePosition( StartX, StartY ); HoldMouse( StartX, StartY, mouse_Left ); Sleep( 250 + rand()% 320 ); MMouse( EndX, EndY, ERandX, ERandY ); Sleep( 250 + rand()% 120 ); GetMousePosition( EndX, EndY ); ReleaseMouse( EndX, EndY, mouse_Left ); }
/*------------------------------------------------------------------------------ process mouse input ------------------------------------------------------------------------------*/ void InputManager::OnMouseMove( int16_t x, int16_t y ) { Point oldPosition = GetMousePosition(); m_mousePosition = Point( x, y ); m_mouseDelta = GetMousePosition() - oldPosition; #if 0 if( g_uiManager.IsMouseOver() ) { m_currentGameMouseState[ Button::kLeft ] = InputState::kUp; m_currentGameMouseState[ Button::kRight ] = InputState::kUp; } #endif }
static void PollMouse() { if(IsKeyDown(192)) g_bDebugMode = !g_bDebugMode; if(g_bDebugMode) SetCursorVisibility(1); else { SetCursorVisibility(0); int winX, winY; winX = winY = 0; s_window_placement wp = GetWindowLocation(); int dw = (wp.left + wp.right) / 2; int dh = (wp.top + wp.bottom) / 2; int mx, my; GetMousePosition(mx, my); g_globalCam.RotateByMouse(mx - dw, my - dh, dw, dh); SetMousePosition(dw, dh); } }
extern "C" _declspec(dllexport) void __cdecl ClickMouse( TClickType button ) { int a = 0, b = 0, c = 0; /* Eventually, should be made to just use Integers */ GetMousePosition( b, c ); HoldMouse( b, c, button ); do { Sleep( 20 + rand()% 30); a = a + 1; } while ( ! ( a > 4 ) ); GetMousePosition( b, c ); ReleaseMouse( b, c, button ); Sleep( 50 + rand() % 50); }
bool wxUIActionSimulator::MouseDblClick(int button) { CGEventType downtype = CGEventTypeForMouseButton(button, true); CGEventType uptype = CGEventTypeForMouseButton(button, false); wxCFRef<CGEventRef> event( CGEventCreateMouseEvent(NULL, downtype, GetMousePosition(), CGButtonForMouseButton(button))); if ( !event ) return false; CGEventSetType(event,downtype); CGEventPost(tap, event); CGEventSetType(event, uptype); CGEventPost(tap, event); CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2); CGEventSetType(event, downtype); CGEventPost(tap, event); CGEventSetType(event, uptype); CGEventPost(tap, event); wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive()); if (loop) loop->SetShouldWaitForEvent(true); return true; }
/** Wake up components that need to run at certain times. */ void Signal(void) { static TimeType last = ZERO_TIME; CallbackNode *cp; TimeType now; Window w; int x, y; GetCurrentTime(&now); if(GetTimeDifference(&now, &last) < MIN_TIME_DELTA) { return; } last = now; GetMousePosition(&x, &y, &w); for(cp = callbacks; cp; cp = cp->next) { if(cp->freq == 0 || GetTimeDifference(&now, &cp->last) >= cp->freq) { cp->last = now; (cp->callback)(&now, x, y, w, cp->data); } } }
HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMOUSESTATE lpvdata) { HRESULT res; POINT p = {0, 0}; OutTraceD("GetDeviceState cbData:%i %i\n", cbdata, dxw.bActive); res = (*pGetDeviceState)(lpdid, cbdata, lpvdata); if(res) return res; if(cbdata == sizeof(DIMOUSESTATE) || cbdata == sizeof(DIMOUSESTATE2)){ GetMousePosition((int *)&p.x, (int *)&p.y); lpvdata->lX = p.x; lpvdata->lY = p.y; if(!dxw.bDInputAbs){ if(p.x < iCurMinX) p.x = iCurMinX; if(p.x > iCurMaxX) p.x = iCurMaxX; if(p.y < iCurMinY) p.y = iCurMinY; if(p.y > iCurMaxY) p.y = iCurMaxY; lpvdata->lX = p.x - iCursorX; lpvdata->lY = p.y - iCursorY; iCursorX = p.x; iCursorY = p.y; } if(!dxw.bActive){ lpvdata->lZ = 0; *(DWORD *)lpvdata->rgbButtons = 0; } OutTraceD("DEBUG: directinput mousestate=(%d,%d)\n", p.x, p.y); } if(cbdata == 256 && !dxw.bActive) ZeroMemory(lpvdata, 256); return 0; }
void Window::MouseDown() { if (!_mouseDragging) { _mouseDragging = true; _mouseDragStart = GetMousePosition(); } }
extern "C" _declspec(dllexport) void __cdecl HumanMMouse( int eX, int eY) { int A = MouseSpeed; int x = 0; int y = 0; GetMousePosition(x,y); int Dist = Distance(x,y,eX,eY); int MP = rnd(Dist/100); if (MP < 0) MP =1; float randSpeed = ((rand()%MouseSpeed) / 2.0 + MouseSpeed) / 10.0; WindMouse(x, y, RandomRange(eX-(A*MP), eX+(A*MP)), RandomRange(eY-(A*MP), eY+(A*MP)), 30, 55, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed); GetMousePosition(x, y); WindMouse(x, y, eX, eY, 30, 55, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed); MouseSpeed = A; }
void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); this->AdjustRenderWindowMenuVisibility(me->pos()); mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, displayPos, worldPos, GetButtonState(me), GetModifiers(me)); if (!this->HandleEvent(mMoveEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mouseMoveMitkEvent(&myevent); QVTKWidget::mouseMoveEvent(me); } }
extern "C" _declspec(dllexport) void __cdecl MissMouse( int eX, int eY, int ranx, int rany ) { float randSpeed = 0.0; int x = 0, y = 0, x2 = 0, y2 = 0, a = 0, dist = 0, MP = 0; a = MouseSpeed; GetMousePosition( x, y ); dist = Distance( x, y, eX, eY ); MP = rnd( dist / 150 ); if ( MP < 0 ) MP = 1; randSpeed = ( rand()% MouseSpeed / 2.0 + MouseSpeed ) / 10.0; x2 = RandomRange( eX - ( a * MP ), eX + ( a * MP ) ); y2 = RandomRange( eY - ( a * MP ), eY + ( a * MP ) ); ShiftWindMouse( x, y, x2, y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed ); GetMousePosition( x, y ); MMouse( eX, eY, ranx, rany ); MouseSpeed = a; }
void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { mitk::Point2D displayPos = GetMousePosition(we); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(we)); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos,worldPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(m_Renderer, we)); this->wheelMitkEvent(&myevent); QVTKWidget::wheelEvent(we); } if (m_ResendQtEvents) we->ignore(); }
void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); mitk::MouseReleaseEvent::Pointer mReleaseEvent = mitk::MouseReleaseEvent::New(m_Renderer, displayPos,worldPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mReleaseEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mouseReleaseMitkEvent(&myevent); QVTKWidget::mouseReleaseEvent(me); } if (m_ResendQtEvents) me->ignore(); }
void Input::Update() { for (int i = 0; i < (int)KEY_MAX; i++) { previousKeys[i] = currentKeys[i]; currentKeys[i] = Platform::keys[i]; if(currentKeys[i] != previousKeys[i] && handlers.size() > 0) { if( currentKeys[i] ) { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnKeyPress((KeyCode)i); }else { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnKeyRelease((KeyCode)i); } } } for (int i = 0; i < MOUSE_BUTTON_MAX; i++) { previousMouseButtons[i] = currentMouseButtons[i]; currentMouseButtons[i] = Platform::mouseButtons[i]; if( previousMouseButtons[i] != currentMouseButtons[i] && handlers.size() > 0 ) { Vector2 mousePos = GetMousePosition(); if(currentMouseButtons[i]) { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnMousePress(mousePos, (MouseButton)i); } else { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnMouseRelease(mousePos, (MouseButton)i); } } } if(Platform::mouseScroll != 0 && handlers.size() > 0) { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnMouseScroll(Platform::mouseScroll); } lastMouseScroll = Platform::mouseScroll; if(lastMousePos != Platform::mousePosition && handlers.size() > 0) { for(std::list<EventHandler*>::iterator it = handlers.begin(); it != handlers.end(); it++) (*it)->OnMouseMove(Platform::mousePosition); } lastMousePos = Platform::mousePosition; }
void QmlMitkRenderWindowItem::wheelEvent(QWheelEvent *we) { mitk::Point2D mousePosition = GetMousePosition(we); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, GetButtonState(we), GetModifiers(we), we->delta()); mitk::RenderWindowBase::HandleEvent(mWheelEvent.GetPointer()); QVTKQuickItem::wheelEvent(we); }
void QmlMitkRenderWindowItem::mouseMoveEvent(QMouseEvent* me) { mitk::Point2D mousePosition = GetMousePosition(me); //mousePosition[1] = this->GetRenderer()->GetSizeY() - mousePosition[1]; mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, GetButtonState(me), GetModifiers(me)); mitk::RenderWindowBase::HandleEvent(mMoveEvent.GetPointer()); QVTKQuickItem::mouseMoveEvent(me); }
void AMapPlayerController::RightClickPressed() { PressingRightClick = true; /** Camera draggin' **/ float x; float y; GetMousePosition(x, y); CameraFirstRightClick.X = x; CameraFirstRightClick.Y = y; CameraInitialPosition = GetPawn()->GetActorLocation(); }
extern "C" _declspec(dllexport) void __cdecl BrakeMMouse( int eX, int eY, int ranx, int rany ) { float randSpeed = 0.0; int x = 0, y = 0, MS = 0; srand(time(NULL)); MS = MouseSpeed; randSpeed = ( double( rand()% MouseSpeed ) / 2.0 + MouseSpeed ) / 10.0; GetMousePosition( x, y ); BrakeWindMouse( x, y, eX, eY, 9, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed ); MouseSpeed = MS; }
void sdl::DispatchEvent(const SDL_Event &event, IInputEventAcceptor &acceptor) { switch (event.type) { case SDL_KEYDOWN: acceptor.OnKeyDown(event.key); break; case SDL_KEYUP: acceptor.OnKeyUp(event.key); break; case SDL_MOUSEBUTTONDOWN: acceptor.OnDragBegin(GetMousePosition(event.button)); break; case SDL_MOUSEBUTTONUP: acceptor.OnDragEnd(GetMousePosition(event.button)); break; case SDL_MOUSEMOTION: acceptor.OnDragMotion(GetMousePosition(event.motion)); break; } }
// Level06 Screen Update logic void UpdateLevel06Screen(void) { // Update Level06 screen variables here! framesCounter++; if (!done) { for (int i = 0; i < 4; i++) { if (!stoppedRec[i]) movingRecs[i].x += speedRecs[i]; if (movingRecs[i].x >= GetScreenWidth()) movingRecs[i].x = -movingRecs[i].width; if (CheckCollisionPointRec(GetMousePosition(), movingRecs[i])) { mouseOverNum = i; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { if (i == 0) stoppedRec[3] = !stoppedRec[3]; else if (i == 1) stoppedRec[2] = !stoppedRec[2]; else if (i == 2) stoppedRec[0] = !stoppedRec[0]; else if (i == 3) stoppedRec[1] = !stoppedRec[1]; } } } // Check if all boxes are aligned if (((movingRecs[0].x > centerRec.x) && ((movingRecs[0].x + movingRecs[0].width) < (centerRec.x + centerRec.width))) && ((movingRecs[1].x > centerRec.x) && ((movingRecs[1].x + movingRecs[1].width) < (centerRec.x + centerRec.width))) && ((movingRecs[2].x > centerRec.x) && ((movingRecs[2].x + movingRecs[2].width) < (centerRec.x + centerRec.width))) && ((movingRecs[3].x > centerRec.x) && ((movingRecs[3].x + movingRecs[3].width) < (centerRec.x + centerRec.width)))) { done = true; PlaySound(levelWin); } } if (done && !levelFinished) { levelTimeSec = framesCounter/60; levelFinished = true; framesCounter = 0; } if (levelFinished) { framesCounter++; if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true; } }
void CDebugger::Update(const CPlayer& Player, CBullets& Bullets, CEnemies& Enemies) { static std::stringstream ss; static int mouse_x, mouse_y; static SDL_Surface* debug = NULL; static SDL_Color white = create_color(WHITE); if(this->IsDebug()) { GetMousePosition(mouse_x, mouse_y); /* First, place (x, y) coordinates next to the player sprite. */ ss << "(" << (int)Player.GetX() << ", " << (int)Player.GetY() << ")"; debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG); this->Display.Blit(debug, (int)Player.GetX(), (int)Player.GetY() - get_text_height(this->debug_font, ss.str())); SDL_FreeSurface(debug); // Free memory ss.str(std::string()); /* Then, place (x, y) coordinates next to the mouse. */ ss << "(" << mouse_x << ", " << mouse_y << ")"; debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG); this->Display.Blit(debug, mouse_x, mouse_y - get_text_height(this->debug_font, ss.str())); SDL_FreeSurface(debug); // Free memory ss.str(std::string()); /* Every bullet also gets (x, y) info next to it. */ for(CBullets::iterator i = Bullets.begin(); i != Bullets.end(); i++) { ss << "(" << (int)(*i)->GetX() << ", " << (int)(*i)->GetY() << ")"; debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG); this->Display.Blit(debug, (int)(*i)->GetX(), (int)(*i)->GetY() - get_text_height(this->debug_font, ss.str())); SDL_FreeSurface(debug); // Free memory ss.str(std::string()); } ss.str(std::string()); /* And finally, every enemy gets (x, y) as well. */ for(CEnemies::iterator i = Enemies.begin(); i != Enemies.end(); i++) { ss << "(" << (int)(*i)->GetX() << ", " << (int)(*i)->GetY() << ")"; debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG); this->Display.Blit(debug, (int)(*i)->GetX(), (int)(*i)->GetY() - get_text_height(this->debug_font, ss.str())); SDL_FreeSurface(debug); ss.str(std::string()); } } }
extern "C" _declspec(dllexport) void __cdecl MMouse( int x, int y, int rx, int ry ) { int cx = 0, cy = 0; float randSpeed = 0.0; srand(time(NULL)); GetMousePosition( cx, cy ); randSpeed = ( rand()% MouseSpeed / 2.0 + MouseSpeed ) / 10.0; if ( randSpeed<=0.0 ) randSpeed = 0.1; x = x + rand()% rx; y = y + rand()% ry; WindMouse( cx, cy, x, y, 9.0, 3.0, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed ); }
bool wxUIActionSimulator::MouseDown(int button) { CGEventType type = CGEventTypeForMouseButton(button, true); wxCFRef<CGEventRef> event( CGEventCreateMouseEvent(NULL, type, GetMousePosition(), button)); if ( !event ) return false; CGEventSetType(event, type); CGEventPost(tap, event); return true; }
void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { mitk::Point2D displayPos = GetMousePosition(we); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { QVTKWidget::wheelEvent(we); } if (m_ResendQtEvents) we->ignore(); }
void AutotestingSystem::Draw() { if(!isInit) return; if(!touches.empty()) { for(Map<int32, UIEvent>::iterator it = touches.begin(); it != touches.end(); ++it) { Vector2 point = it->second.point; RenderHelper::Instance()->DrawCircle(point, 25.0f, RenderState::RENDERSTATE_2D_BLEND); } } RenderHelper::Instance()->DrawCircle(GetMousePosition(), 15.0f, RenderState::RENDERSTATE_2D_BLEND); }
/** Get the screen the mouse is currently on. */ const ScreenType *GetMouseScreen() { #ifdef USE_XINERAMA int x, y; GetMousePosition(&x, &y); return GetCurrentScreen(x, y); #else return &screens[0]; #endif }
bool InputManager::MouseOver(sf::FloatRect Rect) { sf::Vector2i mousePos = GetMousePosition(); if (mousePos.x <= Rect.left + Rect.width && mousePos.x >= Rect.left && mousePos.y <= Rect.top + Rect.height && mousePos.y >= Rect.top) { return true; } else { return false; } }