SDL offers touch input, on platforms that support it.
More...
It can manage multiple touch devices and track multiple fingers on those devices.
Touches are mostly dealt with through the event system, in the EVENT_FINGER_DOWN, EVENT_FINGER_MOTION, and EVENT_FINGER_UP events, but there are also functions to query for hardware details, etc.
The touch system, by default, will also send virtual mouse events; this can be useful for making a some desktop apps work on a phone without significant changes. For apps that care about mouse and touch input separately, they should ignore mouse events that have a which
field of TOUCH_MOUSEID.
◆ FingerID
This ID is valid for the time the finger (stylus, etc) is touching and will be unique for all fingers currently in contact, so this ID tracks the lifetime of a single continuous touch. This value may represent an index, a pointer, or some other unique ID, depending on the platform.
The value 0 is an invalid ID.
- Since
- This datatype is available since SDL 3.2.0.
◆ TouchDeviceType
- Since
- This enum is available since SDL 3.2.0.
◆ TouchID
This ID is valid for the time the device is connected to the system, and is never reused for the lifetime of the application.
The value 0 is an invalid ID.
- Since
- This datatype is available since SDL 3.2.0.
◆ GetTouchDeviceName()
const char * SDL::GetTouchDeviceName |
( |
TouchID |
touchID | ) |
|
|
inline |
- Parameters
-
touchID | the touch device instance ID. |
- Returns
- touch device name, or nullptr on failure; call GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
◆ GetTouchDevices()
On some platforms SDL first sees the touch device if it was actually used. Therefore the returned list might be empty, although devices are available. After using all devices at least once the number will be correct.
- Returns
- a 0 terminated array of touch device IDs or nullptr on failure; call GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
◆ GetTouchDeviceType()
- Parameters
-
touchID | the ID of a touch device. |
- Returns
- touch device type.
- Since
- This function is available since SDL 3.2.0.
◆ GetTouchFingers()
- Parameters
-
touchID | the ID of a touch device. |
- Returns
- a nullptr terminated array of Finger pointers or nullptr on failure; call GetError() for more information.
- Since
- This function is available since SDL 3.2.0.
◆ MOUSE_TOUCHID
constexpr TouchID SDL::MOUSE_TOUCHID = SDL_MOUSE_TOUCHID |
|
constexpr |
- Since
- This macro is available since SDL 3.2.0.
◆ TOUCH_DEVICE_DIRECT
Initial value:=
SDL_TOUCH_DEVICE_DIRECT
◆ TOUCH_DEVICE_INDIRECT_ABSOLUTE
Initial value:=
SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE
◆ TOUCH_DEVICE_INDIRECT_RELATIVE
Initial value:=
SDL_TOUCH_DEVICE_INDIRECT_RELATIVE
◆ TOUCH_DEVICE_INVALID
Initial value:=
SDL_TOUCH_DEVICE_INVALID
◆ TOUCH_MOUSEID
constexpr MouseID SDL::TOUCH_MOUSEID = SDL_TOUCH_MOUSEID |
|
constexpr |
- Since
- This macro is available since SDL 3.2.0.