void draw(void *userData) { DemoData *d = (DemoData *) userData; char buf[256]; int x, y; /* Exit on key press */ if (getKey()) exitPolo(); /* Clear screen with right mouse button */ if (isMouseButtonPressed(1)) clearScreen(); /* Paint with left mouse button */ if (isMouseButtonPressed(0)) { if ((getMouseX() < 128) && (getMouseY() < 128)) setDrawTint(getColorFromHSVA(getMouseX() / 128, getMouseY() / 128, 1, BRUSH_ALPHA)); else drawImage(getMouseX() - getImageWidth(d->brush) / 2, getMouseY() - getImageHeight(d->brush) / 2, d->brush); } /* Draw left bar */ setPenColor(POLO_STEEL); setFillGradient(POLO_SILVER, POLO_TUNGSTEN); drawRect(-1, -1, TOOLBAR_WIDTH, getScreenHeight() + 2); /* Draw frames per second and time display */ setPenColor(POLO_BLACK); sprintf(buf, "FPS: %.3f", d->frame / (getTime() + 0.001)); drawText((TOOLBAR_WIDTH - getTextDrawWidth(buf)) / 2, getScreenHeight() - getTextDrawHeight(buf) - 10, buf); /* Increment frame number */ d->frame++; /* Paint color palette */ for (x = 0; x < 128; x++) for (y = 0; y < 128; y++) { setPenColor(getColorFromHSV(x / 128.0, y / 128.0, 1.0)); drawPoint(x, y); } }
void MainWindow::adjustSize() { //only do the real adjustSize when we are in StandAlone mode if( m_mode == StandAlone && isUpdatesEnabled()) { if(!isMouseButtonPressed() && m_shouldChangeDirection) changeDirection(m_changeToDirection); ScimDragableFrame::adjustSize(); if(m_autoSnap && !isMouseButtonPressed()) { // std::cout << "Successfully exited.\n" << screen.x() << " " <<screen.height() << " " << x() << "\n"; if(m_screen.width() - x() - width() < x()) move(m_screen.width() - width(), y()); else move(0, y()); } } // else // QFrame::adjustSize(); }
bool32 IsMouseButtonPressedAndReleased(MouseButton mb) { bool32 isPressed = isMouseButtonPressed(mb); if(isPressed) { pressedMbs[mb] = 1; } else if(pressedMbs[mb] == 1 && !isPressed) { pressedMbs[mb] = 0; return true; } return false; }
bool GLFWInput::isMouseButtonPressedOnce(int GLFW_MouseButton, GLFWwindow* window){ if (isMouseButtonPressed(GLFW_MouseButton, window)){ if (!_mouseButtonPressed[GLFW_MouseButton]){ _mouseButtonPressed[GLFW_MouseButton] = true; return true; } else { return false; } } else { _mouseButtonPressed[GLFW_MouseButton] = false; return false; } }
bool InputSystem::isMouseButtonPressed(int touchID) { if(touchID < 0 || touchID > INPUT_SUPPORTED_TOUCH_COUNT - 1) { for(int i = 0; i < INPUT_SUPPORTED_TOUCH_COUNT; ++i) { if(isMouseButtonPressed(i)) { return 1; } } return 0; } if(!m_oldTouchList[touchID] && isMouseButtonDown(touchID)) { return 1; } else { return 0; } }
void InputSystem::update() { #ifndef PLATFORM_WP8 m_keyboard->Poll(); if(!SUCCEEDED(m_keyboard->GetDeviceState(256, (LPVOID)&m_keyState))) { m_keyboard->Acquire(); } m_mouse->Poll(); if(!SUCCEEDED(m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), &m_mouseState))) { m_mouse->Acquire(); } m_mouseMove.x = m_mouseState.lX; m_mouseMove.y = m_mouseState.lY; m_wheelMove = m_mouseState.lZ; POINT mousePoint; GetCursorPos(&mousePoint); ScreenToClient(m_windowHandle, &mousePoint); m_mousePosition.x = mousePoint.x; m_mousePosition.y = mousePoint.y; if(m_joystickValidity) { if(!SUCCEEDED(m_joystick->GetDeviceState(sizeof(DIJOYSTATE2), &m_joystickState))) { m_joystick->Acquire(); } m_joystickAxis.x = (m_joystickState.lX - 32767) / 32767; m_joystickAxis.y = (m_joystickState.lY - 32767) / 32767; } float currentTime = eagle.getTimer()->getPassedTimeSeconds(); for(int i = 0; i < 256; ++i) { if(isKeyPressed((KeyboardKey)i)) { m_keyHoldDuration[i] = 0; m_keyHoldStart[i] = currentTime; m_keyTapCount[i]++; m_keyTotalPressCount[i]++; addToKeySequence(i); } else if(isKeyDown((KeyboardKey)i)) { m_keyHoldDuration[i] = currentTime - m_keyHoldStart[i]; } else { m_keyHoldDuration[i] = 0; } } for(int i = 0; i < 4; ++i) { if(isMouseButtonPressed((MouseButton)i)) { m_buttonHoldDuration[i] = 0; m_buttonHoldStart[i] = currentTime; m_buttonTapCount[i]++; m_buttonTotalPressCount[i]++; } else if(isMouseButtonDown((MouseButton)i)) { m_buttonHoldDuration[i] = currentTime - m_buttonHoldStart[i]; } else { m_buttonHoldDuration[i] = 0; } } if(m_tapTimer.stopWatch(1)) { for(int i = 0; i < 256; ++i) { m_keyTapFrequency[i] = m_keyTapCount[i]; m_keyTapCount[i] = 0; } for(int i = 0; i < 4; ++i) { m_buttonTapFrequency[i] = m_buttonTapCount[i]; m_buttonTapCount[i] = 0; } m_tapTimer.reset(); } #else int currentTime = eagle.getTimer()->getPassedTimeSeconds(); for(int i = 0; i < INPUT_SUPPORTED_TOUCH_COUNT; ++i) { if(isMouseButtonPressed(i)) { m_touchHoldDuration[i] = 0; m_touchHoldStart[i] = currentTime; m_touchTapCount[i]++; m_touchTotalPressCount[i]++; } else if(isMouseButtonDown(i)) { m_touchHoldDuration[i] = currentTime - m_touchHoldStart[i]; } else { m_touchHoldDuration[i] = 0; m_touchMoveList[i].set(0, 0); } } if(m_tapTimer.stopWatch(1)) { for(int i = 0; i < 4; ++i) { m_touchTapFrequency[i] = m_touchTapCount[i]; m_touchTapCount[i] = 0; } m_tapTimer.reset(); } #endif }