300
311
const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh,
301
312
utouch_frame_time_t time);
315
* utouch_coordinate_transform_cb - user-definable callback that transforms a touch point
316
* @x: pointer to an x coordinate (in, out)
317
* @y: pointer to a y coordinate (in, out)
318
* @user_data: opaque pointer, passed by the user when setting the callback
320
typedef void (*utouch_coordinate_transform_cb)(float *x, float *y, void *user_data);
323
* utouch_frame_set_coordinate_transform_callback - set a callback to obtain a transformation
324
* to apply to every touch point
325
* @fh: the frame engine in use
326
* @callback: the callback that transforms x and y
327
* @user_data: opaque pointer to user data for the callback
329
void utouch_frame_set_coordinate_transform_callback(utouch_frame_handle fh,
330
utouch_coordinate_transform_cb callback,
335
* @defgroup v2 uTouch-Frame 2.x
339
/** An object for the context of the uTouch Frame instance */
340
typedef struct UFHandle_* UFHandle;
341
/** An object for an event */
342
typedef struct UFEvent_* UFEvent;
343
/** An object for a frame of touches */
344
typedef struct UFFrame_* UFFrame;
345
/** An object for a touch */
346
typedef struct UFTouch_* UFTouch;
347
/** An object for a device */
348
typedef struct UFDevice_* UFDevice;
349
/** An object for a device axis */
350
typedef struct UFAxis_* UFAxis;
351
/** An object for a window ID */
352
typedef uint64_t UFWindowId;
353
/** An object for a touch ID */
354
typedef uint64_t UFTouchId;
356
/** The status code denoting the result of a function call */
357
typedef enum UFStatus {
358
UFStatusSuccess = 0, /**< The call was successful */
359
UFStatusErrorGeneric, /**< A platform-dependent error occurred */
360
UFStatusErrorResources, /**< An error occurred due to insufficient resources */
361
UFStatusErrorNoEvent, /**< No events were available to get */
362
UFStatusErrorUnknownProperty, /**< The requested property value was not set */
363
UFStatusErrorInvalidTouch, /**< The requested touch does not exist */
364
UFStatusErrorInvalidAxis, /**< The requested axis does not exist */
365
UFStatusErrorUnsupported, /**< The requested function is not supported by the
369
/** Properties of a device */
370
typedef enum UFDeviceProperty {
372
* The name of the device
374
* Value type: const char *
376
* The uTouch frame library owns the string. The string is valid until an
377
* event notifying removal of the device is released.
379
UFDevicePropertyName = 0,
381
* Whether the device is a direct touch device
383
* Value type: int with boolean semantics
385
* A direct touch device is a device where there is a direct transformation
386
* from the touch location to the event location on the screen. An indirect
387
* touch device is a device where the touch has meaning relative to a position
388
* on the screen, such as the location of a cursor. A touchscreens is an
389
* example of a direct device, and a trackpad is an example of an indirect
392
UFDevicePropertyDirect,
394
* Whether the device is an independent touch device
396
* Value type: int with boolean semantics
398
* An independent device is an indirect device whose cursor moves
399
* independently of the touches on the device. A mouse with a touch area for
400
* gestures is an example of an independent device, and a trackpad is an
401
* example of a dependent device.
403
UFDevicePropertyIndependent,
405
* Whether the device is a semi-multitouch device
407
* Value type: int with boolean semantics
409
* A semi-multitouch device provides a bounding box of some touches on the
410
* touch surface. In contrast, a full-multitouch device provides accurate
411
* locations of each individual touch.
413
UFDevicePropertySemiMT,
415
* The maximum number of touches supported by the device
417
* Value type: unsigned int
419
UFDevicePropertyMaxTouches,
421
* The number of touch axes provided by the device
423
* Value type: unsigned int
425
UFDevicePropertyNumAxes,
428
/** Device touch axis types */
429
typedef enum UFAxisType {
430
UFAxisTypeX = 0, /**< X coordinate */
431
UFAxisTypeY, /**< Y coordinate */
432
UFAxisTypeTouchMajor, /**< Width along major axis of contact area of touch */
433
UFAxisTypeTouchMinor, /**< Width along minor axis of contact area of touch */
434
UFAxisTypeWidthMajor, /**< Width along major axis of touch tool */
435
UFAxisTypeWidthMinor, /**< Width along minor axis of touch tool */
436
UFAxisTypeOrientation, /**< Orientation of major axis of contact ellipse */
437
UFAxisTypeTool, /**< Tool type */
438
UFAxisTypeBlobId, /**< Blob ID of group of touches */
439
UFAxisTypeTrackingId, /**< Tracking ID */
440
UFAxisTypePressure, /**< Pressure */
441
UFAxisTypeDistance, /**< Hover distance */
444
/** Event properties */
445
typedef enum UFEventProperty {
449
* Value type: UFEventType
451
UFEventPropertyType = 0,
453
* Device added or removed
455
* Value type: UFDevice
457
* This property is set only when the event type is UFEventTypeDeviceAdded
458
* or UFEventTypeDeviceRemoved. The object is owned by the library and is
459
* valid until an event notifying removal of the device is released.
461
UFEventPropertyDevice,
465
* Value type: UFFrame
467
* This property is set only when the event type is UFEventTypeFrame. The
468
* object is owned by the library and is valid until the event is released.
470
UFEventPropertyFrame,
474
* Value type: 64-bit unsigned int
476
* This property holds the time the event occurred in display server
477
* timespace. The time is provided in milliseconds (ms). If the event, such as
478
* device addition, occurred before the uTouch Frame context was created, the
485
typedef enum UFEventType {
486
UFEventTypeDeviceAdded = 0, /**< A new device has been added */
487
UFEventTypeDeviceRemoved, /**< An existing device has been removed */
488
UFEventTypeFrame, /**< The state of one or more touches has changed */
491
/** Touch frame properties */
492
typedef enum UFFrameProperty {
494
* The device for the frame
496
* Value type: UFDevice
498
UFFramePropertyDevice = 0,
500
* The window server ID of the window for the frame
502
* Value type: UFWindowId
504
UFFramePropertyWindowId,
506
* Number of touches in the frame
508
* Value type: unsigned int
510
* Some devices can track more touches than they can report data for. Only
511
* touches with X and Y position are provided in the frame.
513
UFFramePropertyNumTouches,
515
* Total number of active touches on the device
517
* Value type: unsigned int
519
* Some devices can track more touches than they can report data for. This
520
* value includes the number of reported and unreported touches.
522
UFFramePropertyActiveTouches,
525
/** State of an individual touch */
526
typedef enum UFTouchState {
527
UFTouchStateBegin = 0, /**< The touch began */
528
UFTouchStateUpdate, /**< A value or property of the touch changed */
529
UFTouchStateEnd, /**< The touch ended */
532
/** Touch properties */
533
typedef enum UFTouchProperty {
535
* Window server ID of the touch
537
* Value type: UFTouchId
539
UFTouchPropertyId = 0,
543
* Value type: UFTouchState
545
UFTouchPropertyState,
547
* Location along X axis of touch relative to event window
551
* The window server may provide touch location in window coordinate space.
552
* This property will be set where available.
554
UFTouchPropertyWindowX,
556
* Location along Y axis of touch relative to event window
560
* The window server may provide touch location in window coordinate space.
561
* This property will be set where available.
563
UFTouchPropertyWindowY,
565
* Time of last touch state change
567
* Value type: 64-bit unsigned int
569
* See UFEventPropertyTime for the semantics of the value. If the touch has
570
* not changed during this frame, the value of this property will be less than
571
* the value of the UFEventPropertyTime event property for this frame.
575
* Start time of touch
577
* Value type: 64-bit unsigned int
579
* See UFEventPropertyTime for the semantics of the value.
581
UFTouchPropertyStartTime,
583
* Whether the touch is owned by the client
585
* Value type: int with boolean semantics
587
* Some window servers have the concept of touch ownership. This property
588
* is only valid when the server supports touch ownership.
590
UFTouchPropertyOwned,
592
* Whether the touch has physically ended before the touch sequence has ended
594
* Value type: int with boolean semantics
596
* Some window servers have the concept of touch ownership. If a touch has
597
* ended before the client receives ownership, this property will be set to
598
* true. The property will also be set to true when the touch has ended before
599
* the client has accepted or rejected ownership of the touch sequence.
601
UFTouchPropertyPendingEnd,
605
* Get the event file descriptor for the uTouch Frame context
607
* @param [in] handle The uTouch Frame context object
608
* @return A file descriptor for the context
610
* When events are available for processing, the file descriptor will be
611
* readable. Perform an 8-byte read from the file descriptor to clear the state.
612
* Refer to the EVENTFD(2) man page for more details.
614
int frame_get_fd(UFHandle handle);
617
* Get an event from the uTouch Frame context
619
* @param [in] handle The context object
620
* @param [out] event The retrieved event
621
* @return UFStatusSuccess or UFStatusErrorNoEvent
623
* The reference count of the returned event is implicity incremented once.
625
UFStatus frame_get_event(UFHandle handle, UFEvent *event);
628
* Get the value of a property of a device
630
* @param [in] device The device object (const)
631
* @param [in] property The property to retrieve a value for
632
* @param [out] value The value retrieved
633
* @return UFStatusSuccess or UFStatusErrorUnknownProperty
635
UFStatus frame_device_get_property(UFDevice device, UFDeviceProperty property,
639
* Get a device touch axis by index
641
* @param [in] device The device object (const)
642
* @param [in] index The index of the axis to get
643
* @param [out] axis The axis retrieved
644
* @return UFStatusSuccess or UFStatusErrorInvalidAxis
646
* The index value must be greater than or equal to 0 and less than the number
647
* axes of the device.
649
UFStatus frame_device_get_axis_by_index(UFDevice device, unsigned int index,
653
* Get a device touch axis by axis type
655
* @param [in] device The device object (const)
656
* @param [in] type The axis type
657
* @param [out] axis The axis retrieved
658
* @return UFStatusSuccess or UFStatusErrorInvalidAxis
660
* UFStatusErrorInvalidAxis is returned if the device does not have an axis of
661
* the type requested.
663
UFStatus frame_device_get_axis_by_type(UFDevice device, UFAxisType type,
667
* Get the type of a touch device axis
669
* @param [in] axis The touch device axis (const)
670
* @return The type of the axis
672
UFAxisType frame_axis_get_type(UFAxis axis);
675
* Get the minimum value of a touch device axis
677
* @param [in] axis The touch device axis (const)
678
* @return The minimum value of the axis
680
float frame_axis_get_minimum(UFAxis axis);
683
* Get the maximum value of a touch device axis
685
* @param [in] axis The touch device axis (const)
686
* @return The maximum value of the axis
688
float frame_axis_get_maximum(UFAxis axis);
691
* Get the resolution of a touch device axis
693
* @param [in] axis The touch device axis (const)
694
* @return The resolution of the axis
696
float frame_axis_get_resolution(UFAxis axis);
699
* Increment the reference count of an event
701
* @param [in] event The event object
703
void frame_event_ref(UFEvent event);
706
* Decrement the reference count of an event
708
* @param [in] event The event object
710
* When the reference count reaches zero, the event is freed.
712
void frame_event_unref(UFEvent event);
715
* Get the value of a property of an event
717
* @param [in] event The event object (const)
718
* @param [in] property The property to retrieve a value for
719
* @param [out] value The value retrieved
720
* @return UFStatusSuccess or UFStatusErrorUnknownProperty
722
UFStatus frame_event_get_property(UFEvent event, UFEventProperty property,
726
* Get the value of a property of a frame
728
* @param [in] frame The frame object (const)
729
* @param [in] property The property to retrieve a value for
730
* @param [out] value The value retrieved
731
* @return UFStatusSuccess or UFStatusErrorUnknownProperty
733
UFStatus frame_frame_get_property(UFFrame frame, UFFrameProperty property,
737
* Get a touch of a frame by index
739
* @param [in] frame The frame object (const)
740
* @param [in] index The index of the touch to get
741
* @param [out] touch The touch retrieved
742
* @return UFStatusSuccess or UFStatusErrorInvalidTouch
744
* The index value must be greater than or equal to 0 and less than the number
745
* touches reported in the frame.
747
UFStatus frame_frame_get_touch_by_index(UFFrame frame, unsigned int index,
751
* Get a touch from a frame by the window server ID
753
* @param [in] frame The frame object (const)
754
* @param [in] touch_id The window server ID of the touch
755
* The value type of the touch ID is window server dependent. See
756
* UFTouchPropertyId for more details.
757
* @param [out] touch The touch object
758
* @return UFStatusSuccess or UFStatusErrorInvalidTouch
760
UFStatus frame_frame_get_touch_by_id(UFFrame frame, UFTouchId touch_id,
764
* Get the previous value of a property of a touch
766
* @param [in] frame The current frame object (const)
767
* @param [in] touch The current touch object (const)
768
* @param [in] property The property to retrieve a value for
769
* @param [out] value The value retrieved
770
* @return UFStatusSuccess, UFStatusErrorUnknownProperty, or
771
* UFStatusErrorInvalidTouch
773
* The previous value is the value of the property in the previous frame.
774
* UFStatusErrorInvalidTouch is returned if the touch did not exist in the
777
UFStatus frame_frame_get_previous_touch_property(UFFrame frame, UFTouch touch,
778
UFTouchProperty property,
782
* Get the previous value of an axis of a touch
784
* @param [in] frame The current frame object (const)
785
* @param [in] touch The current touch object (const)
786
* @param [in] type The axis to retrieve a value for
787
* @param [out] value The value retrieved
788
* @return UFStatusSuccess, UFStatusErrorInvalidAxis, or
789
* UFStatusErrorInvalidTouch
791
* The previous value is the value of the axis in the previous frame.
792
* UFStatusErrorInvalidTouch is returned if the touch did not exist in the
795
UFStatus frame_frame_get_previous_touch_value(UFFrame frame, UFTouch touch,
796
UFAxisType type, float* value);
799
* Get the value of a property of a touch
801
* @param [in] touch The touch object (const)
802
* @param [in] property The property to retrieve a value for
803
* @param [out] value The value retrieved
804
* @return UFStatusSuccess or UFStatusErrorUnknownProperty
806
UFStatus frame_touch_get_property(UFTouch touch, UFTouchProperty property,
810
* Get the value of an axis of a touch
812
* @param [in] touch The touch object (const)
813
* @param [in] type The axis to retrieve a value for
814
* @param [out] value The value retrieved
815
* @return UFStatusSuccess or UFStatusErrorInvalidAxis
817
UFStatus frame_touch_get_value(UFTouch touch, UFAxisType type, float *value);
820
* @defgroup v2-helpers Helper Functions
821
* These helper functions may be used in place of the generic property getters.
822
* They are limited to properties that are guaranteed to exist in all instances
828
* Get the type of an event
830
* @param [in] event The event object (const)
831
* @return The type of the event
833
UFEventType frame_event_get_type(UFEvent event);
836
* Get the time of an event
838
* @param [in] event The event object (const)
839
* @return The time of the event
841
uint64_t frame_event_get_time(UFEvent event);
844
* Get the number of axes of a device
846
* @param [in] device The device object (const)
847
* @return The number of axes
849
unsigned int frame_device_get_num_axes(UFDevice device);
852
* Get the number of touches in the frame
854
* @param [in] frame The frame object (const)
855
* @return The number of touches
857
uint32_t frame_frame_get_num_touches(UFFrame frame);
860
* Get the device of a frame
862
* @param [in] frame The frame context object (const)
863
* return The device of the window context
865
UFDevice frame_frame_get_device(UFFrame frame);
868
* Get the window ID of a frame
870
* @param [in] frame The frame context object (const)
871
* @return The window server ID of the window of the frame
873
UFWindowId frame_frame_get_window_id(UFFrame frame);
876
* Get the window server ID of a touch
878
* @param [in] touch The touch context object (const)
879
* @return The window server ID of the touch
881
UFTouchId frame_touch_get_id(UFTouch touch);
884
* Get the state of a touch
886
* @param [in] touch The touch object (const)
887
* @return The state of the touch
889
UFTouchState frame_touch_get_state(UFTouch touch);
892
* Get the X window coordinate of a touch
894
* @param [in] touch The touch object (const)
895
* @return The X window coordinate of the touch
897
float frame_touch_get_window_x(UFTouch touch);
900
* Get the Y window coordinate of a touch
902
* @param [in] touch The touch object (const)
903
* @return The Y window coordinate of the touch
905
float frame_touch_get_window_y(UFTouch touch);
908
* Get the X device coordinate of a touch
910
* @param [in] touch The touch object (const)
911
* @return The X device coordinate of the touch
913
float frame_touch_get_device_x(UFTouch touch);
916
* Get the Y device coordinate of a touch
918
* @param [in] touch The touch object (const)
919
* @return The Y device coordinate of the touch
921
float frame_touch_get_device_y(UFTouch touch);
924
* Get the time of a touch state change
926
* @param [in] touch The touch object (const)
927
* @return The time of the touch state change
929
uint64_t frame_touch_get_time(UFTouch touch);
932
* Get the start time of a touch
934
* @param [in] touch The touch object (const)
935
* @return The start time of the touch
937
uint64_t frame_touch_get_start_time(UFTouch touch);
303
943
#ifdef __cplusplus
947
#endif // UTOUCH_FRAME_UTOUCH_FRAME_H_