|
|
|||
File indexing completed on 2026-06-02 08:58:15
0001 //////////////////////////////////////////////////////////// 0002 // 0003 // SFML - Simple and Fast Multimedia Library 0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) 0005 // 0006 // This software is provided 'as-is', without any express or implied warranty. 0007 // In no event will the authors be held liable for any damages arising from the use of this software. 0008 // 0009 // Permission is granted to anyone to use this software for any purpose, 0010 // including commercial applications, and to alter it and redistribute it freely, 0011 // subject to the following restrictions: 0012 // 0013 // 1. The origin of this software must not be misrepresented; 0014 // you must not claim that you wrote the original software. 0015 // If you use this software in a product, an acknowledgment 0016 // in the product documentation would be appreciated but is not required. 0017 // 0018 // 2. Altered source versions must be plainly marked as such, 0019 // and must not be misrepresented as being the original software. 0020 // 0021 // 3. This notice may not be removed or altered from any source distribution. 0022 // 0023 //////////////////////////////////////////////////////////// 0024 0025 #ifndef SFML_TOUCH_HPP 0026 #define SFML_TOUCH_HPP 0027 0028 //////////////////////////////////////////////////////////// 0029 // Headers 0030 //////////////////////////////////////////////////////////// 0031 #include <SFML/Window/Export.hpp> 0032 #include <SFML/System/Vector2.hpp> 0033 0034 0035 namespace sf 0036 { 0037 class WindowBase; 0038 0039 //////////////////////////////////////////////////////////// 0040 /// \brief Give access to the real-time state of the touches 0041 /// 0042 //////////////////////////////////////////////////////////// 0043 class SFML_WINDOW_API Touch 0044 { 0045 public: 0046 0047 //////////////////////////////////////////////////////////// 0048 /// \brief Check if a touch event is currently down 0049 /// 0050 /// \param finger Finger index 0051 /// 0052 /// \return True if \a finger is currently touching the screen, false otherwise 0053 /// 0054 //////////////////////////////////////////////////////////// 0055 static bool isDown(unsigned int finger); 0056 0057 //////////////////////////////////////////////////////////// 0058 /// \brief Get the current position of a touch in desktop coordinates 0059 /// 0060 /// This function returns the current touch position 0061 /// in global (desktop) coordinates. 0062 /// 0063 /// \param finger Finger index 0064 /// 0065 /// \return Current position of \a finger, or undefined if it's not down 0066 /// 0067 //////////////////////////////////////////////////////////// 0068 static Vector2i getPosition(unsigned int finger); 0069 0070 //////////////////////////////////////////////////////////// 0071 /// \brief Get the current position of a touch in window coordinates 0072 /// 0073 /// This function returns the current touch position 0074 /// relative to the given window. 0075 /// 0076 /// \param finger Finger index 0077 /// \param relativeTo Reference window 0078 /// 0079 /// \return Current position of \a finger, or undefined if it's not down 0080 /// 0081 //////////////////////////////////////////////////////////// 0082 static Vector2i getPosition(unsigned int finger, const WindowBase& relativeTo); 0083 }; 0084 0085 } // namespace sf 0086 0087 0088 #endif // SFML_TOUCH_HPP 0089 0090 0091 //////////////////////////////////////////////////////////// 0092 /// \class sf::Touch 0093 /// \ingroup window 0094 /// 0095 /// sf::Touch provides an interface to the state of the 0096 /// touches. It only contains static functions, so it's not 0097 /// meant to be instantiated. 0098 /// 0099 /// This class allows users to query the touches state at any 0100 /// time and directly, without having to deal with a window and 0101 /// its events. Compared to the TouchBegan, TouchMoved 0102 /// and TouchEnded events, sf::Touch can retrieve the 0103 /// state of the touches at any time (you don't need to store and 0104 /// update a boolean on your side in order to know if a touch is down), 0105 /// and you always get the real state of the touches, even if they 0106 /// happen when your window is out of focus and no event is triggered. 0107 /// 0108 /// The getPosition function can be used to retrieve the current 0109 /// position of a touch. There are two versions: one that operates 0110 /// in global coordinates (relative to the desktop) and one that 0111 /// operates in window coordinates (relative to a specific window). 0112 /// 0113 /// Touches are identified by an index (the "finger"), so that in 0114 /// multi-touch events, individual touches can be tracked correctly. 0115 /// As long as a finger touches the screen, it will keep the same index 0116 /// even if other fingers start or stop touching the screen in the 0117 /// meantime. As a consequence, active touch indices may not always be 0118 /// sequential (i.e. touch number 0 may be released while touch number 1 0119 /// is still down). 0120 /// 0121 /// Usage example: 0122 /// \code 0123 /// if (sf::Touch::isDown(0)) 0124 /// { 0125 /// // touch 0 is down 0126 /// } 0127 /// 0128 /// // get global position of touch 1 0129 /// sf::Vector2i globalPos = sf::Touch::getPosition(1); 0130 /// 0131 /// // get position of touch 1 relative to a window 0132 /// sf::Vector2i relativePos = sf::Touch::getPosition(1, window); 0133 /// \endcode 0134 /// 0135 /// \see sf::Joystick, sf::Keyboard, sf::Mouse 0136 /// 0137 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|