void OSystem_Android::hideOverlay() { ENTER(); _show_overlay = false; updateEventScale(); warpMouse(_game_texture->width() / 2, _game_texture->height() / 2); // double buffered, flip twice clearScreen(kClearUpdate, 2); GLCALL(glEnable(GL_SCISSOR_TEST)); }
void TestApp::mouseButtonDown(const SDL_MouseButtonEvent &m) { if(m.button==SDL_BUTTON_RIGHT) mouseMode = (mouseMode+1)%MOUSELAST; switch(mouseMode) { case MOUSEFPS: hideCursor(true); grabInput(true); warpMouse(width/2, height/2); break; case MOUSEFREE: grabInput(false); hideCursor(false); break; } }
bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y) { if (_lastDragPosX == x && _lastDragPosY == y) return false; _lastDragPosX = x; _lastDragPosY = y; //printf("Mouse dragged at (%u, %u)\n", x, y); int mouseNewPosX; int mouseNewPosY; if (_touchpadModeEnabled) { int deltaX = _lastPadX - x; int deltaY = _lastPadY - y; _lastPadX = x; _lastPadY = y; mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f); mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f); int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth; int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight; if (mouseNewPosX < 0) mouseNewPosX = 0; else if (mouseNewPosX > widthCap) mouseNewPosX = widthCap; if (mouseNewPosY < 0) mouseNewPosY = 0; else if (mouseNewPosY > heightCap) mouseNewPosY = heightCap; } else { mouseNewPosX = x; mouseNewPosY = y; } event.type = Common::EVENT_MOUSEMOVE; event.mouse.x = mouseNewPosX; event.mouse.y = mouseNewPosY; warpMouse(mouseNewPosX, mouseNewPosY); return true; }
void OSystem_3DS::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { _cursorScalable = !dontScale; _cursorHotspotX = hotspotX; _cursorHotspotY = hotspotY; _cursorKeyColor = keycolor; _pfCursor = !format ? Graphics::PixelFormat::createFormatCLUT8() : *format; if (w != _cursor.w || h != _cursor.h || _cursor.format != _pfCursor) { _cursor.create(w, h, _pfCursor); _cursorTexture.create(w, h, _pfGameTexture); } _cursor.copyRectToSurface(buf, w, 0, 0, w, h); flushCursor(); warpMouse(_cursorX, _cursorY); }
/// \brief Wrap the mouse to the viewport void InputWrapper::_wrapMousePointer(const SDL_MouseMotionEvent& evt) { //don't wrap if we don't want relative movements, support relative //movements natively, or aren't grabbing anyways if(!mMouseRelative || !mWrapPointer || !mGrabPointer) return; int width = 0; int height = 0; SDL_GetWindowSize(mSDLWindow, &width, &height); const int FUDGE_FACTOR_X = width/4; const int FUDGE_FACTOR_Y = height/4; //warp the mouse if it's about to go outside the window if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width || evt.y - FUDGE_FACTOR_Y < 0 || evt.y + FUDGE_FACTOR_Y > height) { warpMouse(width / 2, height / 2); } }
//----------------------------------------------------------------------------------- void SdlInputHandler::wrapMousePointer( const SDL_MouseMotionEvent& evt ) { //Don't wrap if we don't want relative movements, support //relative movements natively, or aren't grabbing anyways if( mIsMouseRelative || !mWrapPointerManually || !mGrabPointer ) return; int width = 0; int height = 0; SDL_GetWindowSize( mSdlWindow, &width, &height ); const int FUDGE_FACTOR_X = width; const int FUDGE_FACTOR_Y = height; //Warp the mouse if it's about to go outside the window if( evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width || evt.y - FUDGE_FACTOR_Y < 0 || evt.y + FUDGE_FACTOR_Y > height ) { warpMouse( width / 2, height / 2 ); } }
void OSystem_SDL::showOverlay() { assert (_transactionMode == kTransactionNone); int x, y; if (_overlayVisible) return; _overlayVisible = true; // Since resolution could change, put mouse to adjusted position // Fixes bug #1349059 x = _mouseCurState.x * _scaleFactor; if (_adjustAspectRatio) y = real2Aspect(_mouseCurState.y) * _scaleFactor; else y = _mouseCurState.y * _scaleFactor; warpMouse(x, y); clearOverlay(); }
bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) { //printf("Mouse down at (%u, %u)\n", x, y); // Workaround: kInputMouseSecondToggled isn't always sent when the // secondary finger is lifted. Need to make sure we get out of that mode. _secondaryTapped = false; if (_touchpadModeEnabled) { _lastPadX = x; _lastPadY = y; } else warpMouse(x, y); if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONDOWN; event.mouse.x = _videoContext->mouseX; event.mouse.y = _videoContext->mouseY; return true; } else { _lastMouseDown = getMillis(); } return false; }
void OSystem_SDL::hideOverlay() { assert (_transactionMode == kTransactionNone); if (!_overlayVisible) return; int x, y; _overlayVisible = false; // Since resolution could change, put mouse to adjusted position // Fixes bug #1349059 x = _mouseCurState.x / _scaleFactor; y = _mouseCurState.y / _scaleFactor; if (_adjustAspectRatio) y = aspect2Real(y); warpMouse(x, y); clearOverlay(); _forceFull = true; }
void PonscripterLabel::leaveSystemCall(bool restore_flag) { int i; current_font = &sentence_font; display_mode = shelter_display_mode; system_menu_mode = SYSTEM_NULL; system_menu_enter_flag = false; yesno_caller = SYSTEM_NULL; key_pressed_flag = false; // textbufferchange if (restore_flag) { for (i = 0; i < 2; i++) { current_text_buffer[i] = cached_text_buffer[i]; } restoreTextBuffer(); buttons.swap(shelter_buttons); shelter_buttons.clear(); select_links.swap(shelter_select_links); shelter_select_links.clear(); event_mode = shelter_event_mode; draw_cursor_flag = shelter_draw_cursor_flag; if (event_mode & WAIT_BUTTON_MODE) { warpMouse(shelter_mouse_state.x, shelter_mouse_state.y); } } dirty_rect.fill(screen_width, screen_height); flush(refreshMode()); //printf("leaveSystemCall %d %d\n",event_mode, clickstr_state); refreshMouseOverButton(); advancePhase(); }
bool OSystem_PalmBase::pollEvent(Event &event) { ::EventType ev; Boolean handled; UInt32 keyCurrentState; Coord x, y; battery_handler(); timer_handler(); sound_handler(); for(;;) { #if defined(COMPILE_OS5) && defined(PALMOS_ARM) SysEventGet(&ev, evtNoWait); #else EvtGetEvent(&ev, evtNoWait); #endif // check for hardkey repeat for mouse emulation keyCurrentState = KeyCurrentState(); // check_hard_keys(); if (!(keyCurrentState & _keyMouseMask)) { _lastKeyRepeat = 0; } else { if (getMillis() >= (_keyMouseRepeat + _keyMouseDelay)) { _keyMouseRepeat = getMillis(); if (gVars->arrowKeys) { if (keyCurrentState & _keyMouse.bitUp) event.kbd.keycode = 273; else if (keyCurrentState & _keyMouse.bitDown) event.kbd.keycode = 274; else if (keyCurrentState & _keyMouse.bitLeft) event.kbd.keycode = 276; else if (keyCurrentState & _keyMouse.bitRight) event.kbd.keycode = 275; else if (keyCurrentState & _keyMouse.bitButLeft) event.kbd.keycode = chrLineFeed; event.type = EVENT_KEYDOWN; event.kbd.ascii = event.kbd.keycode; event.kbd.flags = 0; } else { Int8 sx = 0; Int8 sy = 0; if (keyCurrentState & _keyMouse.bitUp) sy = -1; else if (keyCurrentState & _keyMouse.bitDown) sy = +1; if (keyCurrentState & _keyMouse.bitLeft) sx = -1; else if (keyCurrentState & _keyMouse.bitRight) sx = +1; if (sx || sy) { simulate_mouse(event, sx, sy, &x, &y); event.type = EVENT_MOUSEMOVE; _lastKey = kKeyMouseMove; } else { x = _mouseCurState.x; y = _mouseCurState.y; if (keyCurrentState & _keyMouse.bitButLeft) { event.type = EVENT_LBUTTONDOWN; _lastKey = kKeyMouseLButton; } else if (_lastKey == kKeyMouseLButton) { event.type = EVENT_LBUTTONUP; _lastKey = kKeyNone; } } event.mouse.x = x; event.mouse.y = y; warpMouse(x, y); // updateCD(); } return true; } } if (ev.eType == keyDownEvent) { switch (ev.data.keyDown.chr) { // ESC key case vchrLaunch: _lastKey = kKeyNone; event.type = EVENT_KEYDOWN; event.kbd.keycode = 27; event.kbd.ascii = 27; event.kbd.flags = 0; return true; // F5 = menu case vchrMenu: _lastKey = kKeyNone; event.type = EVENT_KEYDOWN; event.kbd.keycode = 319; event.kbd.ascii = 319; event.kbd.flags = 0; return true; // if hotsync pressed, etc... case vchrHardCradle: case vchrHardCradle2: case vchrLowBattery: case vchrFind: // case vchrBrightness: // volume control on Zodiac, let other backends disable it case vchrContrast: // do nothing _lastKey = kKeyNone; return true; } } if (check_event(event, &ev)) return true; _lastKey = kKeyNone; // prevent crash when alarm is raised handled = ((ev.eType == keyDownEvent) && (ev.data.keyDown.modifiers & commandKeyMask) && ((ev.data.keyDown.chr == vchrAttnStateChanged) || (ev.data.keyDown.chr == vchrAttnUnsnooze))); // graffiti strokes, auto-off, etc... if (!handled) if (SysHandleEvent(&ev)) continue; switch(ev.eType) { case penMoveEvent: get_coordinates(&ev, x, y); if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return false; if (_lastEvent != penMoveEvent && (abs(y - event.mouse.y) <= 2 || abs(x - event.mouse.x) <= 2)) // move only if return false; _lastEvent = penMoveEvent; event.type = EVENT_MOUSEMOVE; event.mouse.x = x; event.mouse.y = y; warpMouse(x, y); return true; case penDownEvent: get_coordinates(&ev, x, y); // indy fight mode if (_useNumPad && !_overlayVisible) { char num = '1'; num += 9 - (3 - (3 * x / _screenWidth )) - (3 * (3 * y / _screenHeight)); event.type = EVENT_KEYDOWN; event.kbd.keycode = num; event.kbd.ascii = num; event.kbd.flags = 0; _lastEvent = keyDownEvent; return true; } _lastEvent = penDownEvent; if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return false; event.type = ((gVars->stylusClick || _overlayVisible) ? EVENT_LBUTTONDOWN : EVENT_MOUSEMOVE); event.mouse.x = x; event.mouse.y = y; warpMouse(x, y); return true; case penUpEvent: get_coordinates(&ev, x, y); event.type = ((gVars->stylusClick || _overlayVisible) ? EVENT_LBUTTONUP : EVENT_MOUSEMOVE); if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return false; event.mouse.x = x; event.mouse.y = y; warpMouse(x, y); return true; case keyDownEvent: if (ev.data.keyDown.chr == vchrCommand && (ev.data.keyDown.modifiers & commandKeyMask)) { _lastKeyModifier++; _lastKeyModifier %= kModifierCount; if (_lastKeyModifier) draw_osd((kDrawKeyState + _lastKeyModifier - 1), 2, _screenDest.h + 2, true); else draw_osd(kDrawKeyState, 2, _screenDest.h + 2, false); return false; } char mask = 0; UInt16 key = ev.data.keyDown.chr; if (_lastKeyModifier == kModifierNone) { // for keyboard mode if (ev.data.keyDown.modifiers & shiftKeyMask) mask |= KBD_SHIFT; if (ev.data.keyDown.modifiers & controlKeyMask) mask |= KBD_CTRL; if (ev.data.keyDown.modifiers & optionKeyMask) mask |= KBD_ALT; if (ev.data.keyDown.modifiers & commandKeyMask) mask |= KBD_CTRL|KBD_ALT; } else { // for grafiti mode if (_lastKeyModifier == kModifierCommand) mask = KBD_CTRL|KBD_ALT; if (_lastKeyModifier == kModifierAlt) mask = KBD_ALT; if (_lastKeyModifier == kModifierCtrl) mask = KBD_CTRL; } if (_lastKeyModifier) draw_osd(kDrawKeyState, 2, _screenDest.h + 2, false); _lastKeyModifier = kModifierNone; // F1 -> F10 key if (key >= '0' && key <= '9' && mask == (KBD_CTRL|KBD_ALT)) { key = (key == '0') ? 324 : (315 + key - '1'); mask = 0; // exit } else if ((key == 'z' && mask == KBD_CTRL) || (mask == KBD_ALT && key == 'x')) { event.type = EVENT_QUIT; return true; // num pad (indy fight mode) } else if (key == 'n' && mask == (KBD_CTRL|KBD_ALT) && !_overlayVisible) { _useNumPad = !_useNumPad; draw_osd(kDrawFight, _screenDest.w - 34, _screenDest.h + 2, _useNumPad, 1); displayMessageOnOSD(_useNumPad ? "Fight mode on." : "Fight mode off."); return false; } // other keys event.type = EVENT_KEYDOWN; event.kbd.keycode = key; event.kbd.ascii = key; event.kbd.flags = mask; return true; default: return false; }; } }
void OSystem_GP32::handleKbdMouse() { uint32 curTime = getMillis(); if (curTime >= _km.last_time + _km.delay_time) { _km.last_time = curTime; if (_km.x_down_count == 1) { _km.x_down_time = curTime; _km.x_down_count = 2; } if (_km.y_down_count == 1) { _km.y_down_time = curTime; _km.y_down_count = 2; } if (_km.x_vel || _km.y_vel) { if (_km.x_down_count) { if (curTime > _km.x_down_time + _km.delay_time * 12) { if (_km.x_vel > 0) _km.x_vel++; else _km.x_vel--; } else if (curTime > _km.x_down_time + _km.delay_time * 8) { if (_km.x_vel > 0) _km.x_vel = 5; else _km.x_vel = -5; } } if (_km.y_down_count) { if (curTime > _km.y_down_time + _km.delay_time * 12) { if (_km.y_vel > 0) _km.y_vel++; else _km.y_vel--; } else if (curTime > _km.y_down_time + _km.delay_time * 8) { if (_km.y_vel > 0) _km.y_vel = 5; else _km.y_vel = -5; } } //GPDEBUG("%d %d - %d %d", _km.x, _km.y, _km.x_vel, _km.y_vel); _km.x += _km.x_vel; _km.y += _km.y_vel; if (_km.x < 0) { _km.x = 0; _km.x_vel = -1; _km.x_down_count = 1; } else if (_km.x > _km.x_max) { _km.x = _km.x_max; _km.x_vel = 1; _km.x_down_count = 1; } if (_km.y < 0) { _km.y = 0; _km.y_vel = -1; _km.y_down_count = 1; } else if (_km.y > _km.y_max) { _km.y = _km.y_max; _km.y_vel = 1; _km.y_down_count = 1; } warpMouse(_km.x, _km.y); } } }
void Events::warpMouse() { Screen &screen = *_vm->_screen; warpMouse(Common::Point(screen._currentScroll.x + SHERLOCK_SCREEN_WIDTH / 2, screen._currentScroll.y + SHERLOCK_SCREEN_HEIGHT / 2)); }
void X11Device::processEvent(const XEvent &event) { DeviceEvent deviceEvent(ENoEvent); X11Session *session = static_cast<X11Session *>(getSession()); if (m_callbacks.size() == 0) return; switch (event.type) { case ClientMessage: /* The window close button pressed */ if ((event.xclient.format == 32) && ((unsigned) event.xclient.data.l[0] == m_deleteWindow)) { deviceEvent.setType(EQuitEvent); } break; case FocusIn: /* Deactivate auto-repeat */ XAutoRepeatOff(session->m_display); deviceEvent.setType(EGainFocusEvent); m_modifierState = 0; m_buttonState = 0; break; case FocusOut: /* Reactivate auto-repeat */ XAutoRepeatOn(session->m_display); deviceEvent.setType(ELoseFocusEvent); m_modifierState = 0; m_buttonState = 0; break; case ButtonPress: deviceEvent.setType(EMouseButtonDownEvent); translateMouse(event, deviceEvent); m_buttonState |= deviceEvent.getMouseButton(); break; case ButtonRelease: deviceEvent.setType(EMouseButtonUpEvent); translateMouse(event, deviceEvent); m_buttonState &= ~deviceEvent.getMouseButton(); break; case MotionNotify: { deviceEvent.setType(m_buttonState == 0 ? EMouseMotionEvent : EMouseDragEvent); translateMouse(event, deviceEvent); deviceEvent.setMouseButton(m_buttonState); if (m_grab) warpMouse(Point2i(getSize().x / 2, getSize().y/2)); int xpos = deviceEvent.getMousePosition().x; int ypos = deviceEvent.getMousePosition().y; if (xpos > m_size.x || xpos < 0 || ypos > m_size.y || ypos < 0) return; } break; case KeyPress: if (translateKeyboard(event, deviceEvent)) { deviceEvent.setType(EKeyDownEvent); int special = deviceEvent.getKeyboardSpecial(); /* Update the current modifier state */ if (special == EKeyLShift || special == EKeyRShift) { m_modifierState |= EShiftModifier; } else if (special == EKeyLAlt || special == EKeyRAlt) { m_modifierState |= EAltModifier; } else if (special == EKeyLControl || special == EKeyRControl) { m_modifierState |= EControlModifier; } deviceEvent.setKeyboardModifiers(m_modifierState); } break; case KeyRelease: if (translateKeyboard(event, deviceEvent)) { deviceEvent.setType(EKeyUpEvent); int special = deviceEvent.getKeyboardSpecial(); /* Update the current modifier state */ if (special == EKeyLShift || special == EKeyRShift) { m_modifierState = m_modifierState & (~EShiftModifier); } else if (special == EKeyLAlt || special == EKeyRAlt) { m_modifierState = m_modifierState & (~EAltModifier); } else if (special == EKeyLControl || special == EKeyRControl) { m_modifierState = m_modifierState & (~EControlModifier); } deviceEvent.setKeyboardModifiers(m_modifierState); } break; case MapNotify: case UnmapNotify: m_modifierState = 0; break; case ConfigureNotify: { Vector2i size(event.xconfigure.width, event.xconfigure.height); if (m_size != size) { m_size = size; deviceEvent.setType(EResizeEvent); } } break; case ReparentNotify: case Expose: break; default: Log(EWarn, "Unknown event %i received", event.type); } if (deviceEvent.getType() != ENoEvent) fireDeviceEvent(deviceEvent); }