touchTracker module
- class touchTracker.SingleTouchTracker(ID, x, y)
Bases:
object
Represents the lifetime of one single finger while its in contact with the touch device, tracking start and current coordinates, start and end times, and whether its complete (broken contact yet). It also calculates what kind of single action (tap, flick, hover) this finger is performing, once it has enough data. @ivar ID: the ID this finger has been assigned by the Operating System. @type ID: int @ivar x: The last known x screen coordinate of this finger @type x: int @ivar y: The last known y screen coordinate of this finger @type y: int @ivar startX: The x screen coordinate where the finger first made contact @type startX: int @ivar startY: The y screen coordinate where the finger first made contact @type startY: int @ivar startTime: the time at which the finger first made contact @type startTime: float @ivar endTime: the time at which the finger broke contact. Before breaking contact the value is -1 @type endTime: float @ivar maxAbsDeltaX: the maximum distance this finger has traveled on the x access while making contact @type maxAbsDeltaX: int @ivar maxAbsDeltaY: the maximum distance this finger has traveled on the y access while making contact @type maxAbsDeltaY: int @ivar action: the action this finger has performed (one of the action_* constants,E.g. tap, flickRight, hover etc). If not enough data has been collected yet the action will be unknown. @type action: string @ivar complete: If true then this finger has broken contact @type complete: bool
- ID
- x
- startX
- y
- startY
- startTime
- endTime
- maxAbsDeltaX
- maxAbsDeltaY
- action
- complete
- update(x, y, complete=False)
Called to alert this single tracker that the finger has moved or broken contact.
- class touchTracker.MultiTouchTracker(action: str, x: int, y: int, startTime: float, endTime: float, numFingers: int = 1, actionCount: int = 1, rawSingleTouchTracker: SingleTouchTracker | None = None, pluralTimeout: float | None = None)
Bases:
object
Represents an action jointly performed by 1 or more fingers.
- Parameters:
action – the action this finger has performed.
One of the action_* constants, e.g. tap, flickRight, hover etc. :param x: the x screen coordinate where the action was performed. For multi-finger actions it is the average position of each of the fingers. For plural actions it is based on the first occurrence :param y: the y screen coordinate where the action was performed. For multi-finger actions it is the average position of each of the fingers. For plural actions it is based on the first occurrence :param startTime: the time the action began :param endTime: the time the action was complete :param numFingers: the number of fingers that performed this action :param actionCount: the number of times this action was performed in quick succession (e.g. 2 for a double tap) :param rawSingleTouchTracker: if this tracker represents a 1-fingered non-plural action, then this will be the L{SingleTouchTracker} object for that 1 finger. If not then it is None. :param pluralTimeout: the time at which this tracker could no longer possibly be merged with another to be pluralized, thus it is allowed to be emitted
- action
- x
- y
- startTime
- endTime
- numFingers
- actionCount
- childTrackers: list[MultiTouchTracker]
a list of L{MultiTouchTracker} objects which represent the direct sub-actions of this action. e.g. a 2-finger triple tap’s childTrackers will contain 3 2-finger taps. Each of the 2-finger taps’ childTrackers will contain 2 taps.
- rawSingleTouchTracker
- pluralTimeout
- iterAllRawSingleTouchTrackers()
- getDevInfoString()
- class touchTracker.TrackerManager
Bases:
object
Tracks touch input by managing L{SingleTouchTracker} instances and emitting L{MultiTouchTracker} instances representing high-level multiFingered plural trackers.
- makePreheldTrackerFromSingleTouchTrackers(trackers)
- makePreheldTrackerForTracker(tracker)
- update(ID, x, y, complete=False)
Called to Alert the multiTouch tracker of a new, moved or completed contact (finger touch). It creates new single trackers or updates existing ones, and queues/processes multi trackers for later emition.
- makeMergedTrackerIfPossible(oldTracker, newTracker)
- processAndQueueMultiTouchTracker(tracker)
Queues the given tracker, replacing old trackers with a multiFingered plural action where possible
- pendingEmitInterval: float | None = None
If set: how long to wait before calling emitTrackers again as trackers are still in the queue
- emitTrackers()
Yields queued trackers that have existed in the queue for long enough to not be connected with other trackers. A part from a timeout, trackers are also not emitted if there are other fingers touching that still have an unknown action. If there are no queued trackers to yield but there is a hover tracker, a hover action is yielded instead.