int Dialog::mouseRaise(int x, int y) { bool res = false; if (_pressedButton != -1) { if (matchButton(x, y) == _pressedButton) res = true; } return res; }
void Dialog::mouseClick(int x, int y) { int match = matchButton(x, y); if (match != -1) { _pressedButton = match; _mouseOverPressedButton = true; _needsRedraw = true; } }
void Dialog::mouseMove(int x, int y) { if (_pressedButton != -1) { int match = matchButton(x, y); if (_mouseOverPressedButton && match != _pressedButton) { _mouseOverPressedButton = false; _needsRedraw = true; } else if (!_mouseOverPressedButton && match == _pressedButton) { _mouseOverPressedButton = true; _needsRedraw = true; } } }
Action::ID Input::feedEvent(const sf::Event& event) { switch (event.type) { case sf::Event::KeyPressed: { Action::ID action = matchKey(event.key.code); if (action != Action::NONE) s_pressed[action] = true; return action; } case sf::Event::KeyReleased: { Action::ID action = matchKey(event.key.code); if (action != Action::NONE) s_pressed[action] = false; break; } case sf::Event::JoystickButtonPressed: { Action::ID action = matchButton(event.joystickButton.button); if (action != Action::NONE) s_pressed[action] = true; return action; } case sf::Event::JoystickButtonReleased: { Action::ID action = matchButton(event.joystickButton.button); if (action != Action::NONE) s_pressed[action] = false; break; } case sf::Event::JoystickMoved: if (event.joystickMove.axis == sf::Joystick::X) { if (event.joystickMove.position > s_joystick_deadzone) { s_pressed[Action::RIGHT] = true; return Action::RIGHT; } s_pressed[Action::RIGHT] = false; if (event.joystickMove.position < -s_joystick_deadzone) { s_pressed[Action::LEFT] = true; return Action::LEFT; } s_pressed[Action::LEFT] = false; } else if (event.joystickMove.axis == sf::Joystick::Y) { if (event.joystickMove.position > s_joystick_deadzone) { s_pressed[Action::DOWN] = true; return Action::DOWN; } s_pressed[Action::DOWN] = false; if (event.joystickMove.position < -s_joystick_deadzone) { s_pressed[Action::UP] = true; return Action::UP; } s_pressed[Action::UP] = false; } break; case sf::Event::Closed: return Action::EXIT_APP; default: break; } return Action::NONE; }