diff --git a/src/Game.cpp b/src/Game.cpp index cc7c968a..b3f845d5 100755 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -119,6 +119,17 @@ void Game::processEvents() case sf::Event::MouseMoved: onMouseMoved(evt.mouseMove); break; +#ifdef __ANDROID__ + case sf::Event::TouchBegan: + onTouchBegan(evt.touch); + break; + case sf::Event::TouchMoved: + onTouchMoved(evt.touch); + break; + case sf::Event::TouchEnded: + onTouchEnded(evt.touch); + break; +#endif default: break; } @@ -232,6 +243,9 @@ void Game::onKeyPressed(const sf::Event::KeyEvent& evt) if (disableInput == false) { keyPressed = evt; +#ifdef __ANDROID__ + keyPressed.system = false; +#endif } } @@ -269,7 +283,33 @@ void Game::onMouseMoved(const sf::Event::MouseMoveEvent& evt) updateMouse(sf::Vector2i(evt.x, evt.y)); mouseMoved = true; } +#ifdef __ANDROID__ +void Game::onTouchBegan(const sf::Event::TouchEvent& evt) +{ + updateMouse(sf::Vector2i(evt.x, evt.y)); + sf::Event::MouseButtonEvent mouseEvt; + mouseEvt.button = sf::Mouse::Left; + mouseEvt.x = evt.x; + mouseEvt.y = evt.y; + onMouseButtonPressed(mouseEvt); +} + +void Game::onTouchMoved(const sf::Event::TouchEvent& evt) +{ + updateMouse(sf::Vector2i(evt.x, evt.y)); + mouseMoved = true; +} +void Game::onTouchEnded(const sf::Event::TouchEvent& evt) +{ + updateMouse(sf::Vector2i(evt.x, evt.y)); + sf::Event::MouseButtonEvent mouseEvt; + mouseEvt.button = sf::Mouse::Left; + mouseEvt.x = evt.x; + mouseEvt.y = evt.y; + onMouseButtonReleased(mouseEvt); +} +#endif void Game::updateMouse() { updateMouse(sf::Mouse::getPosition(window)); diff --git a/src/Game.h b/src/Game.h index a82fd8ab..48a5bdef 100755 --- a/src/Game.h +++ b/src/Game.h @@ -75,6 +75,11 @@ class Game : public sf::NonCopyable void onMouseButtonPressed(const sf::Event::MouseButtonEvent& evt); void onMouseButtonReleased(const sf::Event::MouseButtonEvent& evt); void onMouseMoved(const sf::Event::MouseMoveEvent& evt); +#ifdef __ANDROID__ + void onTouchBegan(const sf::Event::TouchEvent& evt); + void onTouchMoved(const sf::Event::TouchEvent& evt); + void onTouchEnded(const sf::Event::TouchEvent& evt); +#endif void updateMouse(const sf::Vector2i mousePos); void checkKeyPress(); diff --git a/src/Parser/ParseKeyboard.cpp b/src/Parser/ParseKeyboard.cpp index 89a36a03..6046a0c6 100755 --- a/src/Parser/ParseKeyboard.cpp +++ b/src/Parser/ParseKeyboard.cpp @@ -20,8 +20,11 @@ namespace Parser evt.alt = getBool(elem, "alt"); evt.control = getBool(elem, "control"); evt.shift = getBool(elem, "shift"); +#ifdef __ANDROID__ + evt.system = false; +#else evt.system = getBool(elem, "system"); - +#endif const auto& keyElem = elem["key"]; if (keyElem.IsArray() == true)