Touch input handling system for iPad and tablet browsers. More...
#include <touch_input.h>
Static Public Member Functions | |
| static void | Initialize () |
| Initialize the touch input system. | |
| static void | Shutdown () |
| Shutdown and cleanup touch input system. | |
| static void | Update () |
| Process touch events for the current frame. | |
| static bool | IsTouchActive () |
| Check if touch input is currently being used. | |
| static bool | IsTouchMode () |
| Check if we're in touch mode (vs mouse mode) | |
| static GestureState | GetCurrentGesture () |
| Get the current gesture state. | |
| static TouchPoint | GetTouchPoint (int index) |
| Get raw touch point data. | |
| static int | GetActiveTouchCount () |
| Get number of active touch points. | |
| static void | SetPanZoomEnabled (bool enabled) |
| Enable or disable pan/zoom gestures for canvas. | |
| static bool | IsPanZoomEnabled () |
| Check if pan/zoom is enabled. | |
| static ImVec2 | GetPanOffset () |
| Get cumulative pan offset from touch gestures. | |
| static float | GetZoomLevel () |
| Get cumulative zoom level from pinch gestures. | |
| static float | GetRotation () |
| Get rotation angle from two-finger rotation. | |
| static ImVec2 | GetZoomCenter () |
| Get the zoom center point in screen coordinates. | |
| static void | ApplyPanOffset (ImVec2 offset) |
| Apply pan offset to the current value. | |
| static void | SetZoomLevel (float zoom) |
| Set the zoom level directly. | |
| static void | SetPanOffset (ImVec2 offset) |
| Set the pan offset directly. | |
| static void | ResetCanvasState () |
| Reset canvas transform state. | |
| static TouchConfig & | GetConfig () |
| Get the current touch configuration. | |
| static void | SetGestureCallback (std::function< void(const GestureState &)> callback) |
| Set gesture callback. | |
Static Public Attributes | |
| static constexpr int | kMaxTouchPoints = 10 |
| Maximum number of simultaneous touch points supported. | |
Private Member Functions | |
| TouchInput ()=delete | |
Static Private Member Functions | |
| static void | UpdateGestureRecognition () |
| static void | ProcessInertia () |
| static void | TranslateToImGuiEvents () |
| static double | GetCurrentTime () |
| static void | InitializePlatform () |
| static void | ShutdownPlatform () |
Touch input handling system for iPad and tablet browsers.
Provides gesture recognition and touch event handling for the yaze editor. Integrates with ImGui's input system and the Canvas pan/zoom functionality.
Features:
Usage:
Definition at line 137 of file touch_input.h.
|
privatedelete |
|
static |
Initialize the touch input system.
Sets up touch event handlers. On web builds, this registers JavaScript callbacks for touch events. On native builds, it configures SDL touch support.
Definition at line 140 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::initialized, InitializePlatform(), LOG_INFO, and yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::touch_points.
Referenced by yaze::gui::CanvasTouchHandler::Initialize().

|
static |
Shutdown and cleanup touch input system.
Definition at line 160 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::initialized, LOG_INFO, and ShutdownPlatform().

|
static |
Process touch events for the current frame.
Call this once per frame, before ImGui::NewFrame(). Updates gesture recognition state and translates touch events to ImGui mouse events.
Definition at line 171 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::current_gesture, yaze::gui::GestureState::gesture, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::gesture_callback, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::inertia_active, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::initialized, yaze::gui::kNone, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::previous_gesture, ProcessInertia(), TranslateToImGuiEvents(), and UpdateGestureRecognition().

|
static |
Check if touch input is currently being used.
Definition at line 198 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::active_touch_count.
Referenced by yaze::gui::CanvasTouchHandler::IsTouchActive(), and yaze::gui::CanvasTouchHandler::Update().
|
static |
Check if we're in touch mode (vs mouse mode)
Returns true if the last input was from touch, even if no touches are currently active. Used for UI adaptation (larger hit targets, etc.)
Definition at line 202 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::touch_mode.
Referenced by yaze::gui::CanvasTouchHandler::IsTouchMode().
|
static |
Get the current gesture state.
Definition at line 206 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::current_gesture.
Referenced by yaze::gui::CanvasTouchHandler::Update().
|
static |
Get raw touch point data.
| index | Touch point index (0 to kMaxTouchPoints-1) |
Definition at line 210 of file touch_input.cc.
References kMaxTouchPoints, and yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::touch_points.
|
static |
Get number of active touch points.
Definition at line 217 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::active_touch_count.
|
static |
Enable or disable pan/zoom gestures for canvas.
| enabled | Whether to process pan/zoom gestures |
Definition at line 221 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_zoom_enabled.
|
static |
Check if pan/zoom is enabled.
Definition at line 225 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_zoom_enabled.
|
static |
Get cumulative pan offset from touch gestures.
This value accumulates pan translations. Reset with ResetCanvasState().
Definition at line 229 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_offset.
Referenced by yaze::gui::CanvasTouchHandler::ProcessGesture().
|
static |
Get cumulative zoom level from pinch gestures.
Starts at 1.0. Multiply your canvas scale by this value.
Definition at line 233 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::zoom_level.
Referenced by yaze::gui::CanvasTouchHandler::ProcessGesture().
|
static |
Get rotation angle from two-finger rotation.
Definition at line 237 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::rotation.
|
static |
Get the zoom center point in screen coordinates.
Use this as the pivot point when applying zoom transformations.
Definition at line 241 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::zoom_center.
Referenced by yaze::gui::CanvasTouchHandler::ProcessGesture().
|
static |
Apply pan offset to the current value.
| offset | Pan offset to apply |
Definition at line 245 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_offset.
|
static |
Set the zoom level directly.
| zoom | New zoom level |
Definition at line 250 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::config, and yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::zoom_level.
|
static |
Set the pan offset directly.
| offset | New pan offset |
Definition at line 255 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_offset.
|
static |
Reset canvas transform state.
Resets pan offset to (0,0), zoom to 1.0, rotation to 0.0
Definition at line 259 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::inertia_active, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::inertia_velocity, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::pan_offset, yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::rotation, and yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::zoom_level.
Referenced by yaze::gui::CanvasTouchHandler::Reset().
|
static |
Get the current touch configuration.
Definition at line 267 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::config.
|
static |
Set gesture callback.
Optional callback invoked when gestures are recognized.
| callback | Function to call with gesture state |
Definition at line 271 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::gesture_callback.
|
staticprivate |
Definition at line 278 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::current_gesture, yaze::gui::kBegan, yaze::gui::kChanged, yaze::gui::kDoubleTap, yaze::gui::kEnded, yaze::gui::kLongPress, yaze::gui::kNone, yaze::gui::kPan, yaze::gui::kPinchZoom, yaze::gui::kRotate, yaze::gui::kTap, M_PI, yaze::gui::TouchPoint::position, yaze::gui::TouchPoint::previous_position, yaze::gui::TouchPoint::start_position, and yaze::gui::TouchPoint::timestamp.
Referenced by Update().
|
staticprivate |
Definition at line 501 of file touch_input.cc.
References yaze::gui::anonymous_namespace{touch_input.cc}::TouchInputState::config.
Referenced by Update().
|
staticprivate |
Definition at line 525 of file touch_input.cc.
References yaze::gui::kDoubleTap, yaze::gui::kLongPress, yaze::gui::kTap, and yaze::gui::TouchPoint::position.
Referenced by Update().
|
staticprivate |
Definition at line 570 of file touch_input.cc.
|
staticprivate |
|
staticprivate |
Definition at line 738 of file touch_input.cc.
Referenced by Shutdown().
|
staticconstexpr |
Maximum number of simultaneous touch points supported.
Definition at line 142 of file touch_input.h.
Referenced by GetTouchPoint().