1 // SuperTux 2 // Copyright (C) 2021 A. Semphris <semphris@protonmail.com> 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 #ifndef HEADER_SUPERTUX_CONTROL_MOBILE_CONTROLLER_HPP 18 #define HEADER_SUPERTUX_CONTROL_MOBILE_CONTROLLER_HPP 19 20 #include "config.h" 21 22 #ifdef ENABLE_TOUCHSCREEN_SUPPORT 23 24 #include "math/rectf.hpp" 25 #include "video/surface_ptr.hpp" 26 27 class Controller; 28 class DrawingContext; 29 30 class MobileController final 31 { 32 public: 33 MobileController(); 34 void draw(DrawingContext& context); 35 void apply(Controller& controller) const; 36 void update(); 37 38 private: 39 void activate_widget_at_pos(float x, float y); 40 41 private: 42 bool m_up, m_down, m_left, m_right, m_jump, m_action, m_escape, m_bak_escape; 43 bool m_old_up, m_old_down, m_old_left, m_old_right, m_old_jump, m_old_action, m_old_escape; 44 45 const Rectf m_rect_directions, m_rect_jump, m_rect_action, m_rect_escape; 46 const SurfacePtr m_tex_dirs, m_tex_btn, m_tex_btn_press, m_tex_pause, 47 m_tex_up, m_tex_dwn, m_tex_lft, m_tex_rgt, 48 m_tex_jump, m_tex_action; 49 50 int m_screen_width, m_screen_height; 51 52 private: 53 MobileController(const MobileController&) = delete; 54 MobileController& operator=(const MobileController&) = delete; 55 }; 56 57 #endif 58 59 #endif 60 61 /* EOF */ 62