Class TouchDevice
Special case of an InputDevice identifying itself as a Touch. Defines convenience methods to access the touch buttons and axes.
Inherited Members
Namespace: Fusee.Engine.Core
Assembly: Fusee.Engine.Core.dll
Syntax
public class TouchDevice : InputDevice
Remarks
A touch device represents input typically performed by fingers or a stylus. Touch devices support simultaneous presence of multiple touchpoints (performed by multiple fingers). Each touchpoint is captured by four axes and one button. The button state (pressed or not pressed) signals the presence of the respective axis. Two positional axes for each touchpoint reveal the position in X/Y screen space and two velocity axes represent the current velocity along X and Y.
In Addition to tracking individual touchpoints, this device also tracks the simultaneous movements of the first two active touchpoints and generates derived information, like two-point-move, pinch or rotate.
Constructors
TouchDevice(IInputDeviceImp)
Initializes a new instance of the TouchDevice class.
Declaration
public TouchDevice(IInputDeviceImp inpDeviceImp)
Parameters
Type | Name | Description |
---|---|---|
IInputDeviceImp | inpDeviceImp | The "driver". |
Properties
ActiveTouchpoints
Retrieves the number of currently active touchpoints (e.g. the number of fingers currently touching the screen).
Declaration
public int ActiveTouchpoints { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of active touchpoints. |
TwoPoint
Gets a value indicating whether two touchpoints are active.
Declaration
public bool TwoPoint { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
TwoPointAngle
Gets the angle of a line between the first two active touchpoints measured from the positive screen x-axis. Use this value if you want to implement rotation-like actions based on the current absolute angle.
Declaration
public float TwoPointAngle { get; }
Property Value
Type | Description |
---|---|
System.Single | The angle value in radians. Ranges between -PI and PI. An angle of zero denotes the positive x-axis. |
TwoPointAngleVel
Gets the angular velocity of a line between the first two active touchpoints measured from the positive screen x-axis. Use this value if you want to implement rotation-like actions based on the current rotation speed of the first two touchpoints.
Declaration
public float TwoPointAngleVel { get; }
Property Value
Type | Description |
---|---|
System.Single | The angular velocity of the rotation movement of the first two touchpoints. Positive values mean counter-clockwise rotation, negative values mean clockwise rotation. |
TwoPointDistance
Gets the distance between the first two touchpoints. Use this value if you want to implement pinch-like actions based on the current absolute distance.
Declaration
public float TwoPointDistance { get; }
Property Value
Type | Description |
---|---|
System.Single | The distance between the first two active touchpoints, or zero, if no two touchpoints are active. |
TwoPointDistanceVel
Gets velocity of the distance between the first two touchpoints. Use this value if you want to implement pinch-like actions based on the current speed of the distance.
Declaration
public float TwoPointDistanceVel { get; }
Property Value
Type | Description |
---|---|
System.Single | The distance velocity. Positive values mean fingers move away from each others (Zoom-In), negative values mean fingers approach each others (Zoom-Out). |
TwoPointGesture
Gets a value indicating the TwoPointAction currently performed with the highest intensity.
Declaration
public TwoPointAction TwoPointGesture { get; }
Property Value
Type | Description |
---|---|
TwoPointAction | The double touch action currently performed by the user with the highest intensity. |
Remarks
Two moving touchpoints on the screen can be interpreted in various ways. It's up to the application to interpret the two individual changes in position as Move , as a Rotate or as a Pinch . Use this method to retrieve a symbolic value which of these three possibilities is currently performed with the highest intensity. Applications should sensibly decide whether to allow to change their behavior during a two-point-gesture (as long as TwoPoint holds true) or to check this value only initially whenever a two-point gesture starts, or do something in-between. As a practice: Investigate how the Google Earth mobile app handles this question!
TwoPointMidPoint
Gets midpoint between the first two active touch points. Use this value if you want to implement two-finger movement-like actions based on the current averaged absolute position of the first two touchpoints
Declaration
public float2 TwoPointMidPoint { get; }
Property Value
Type | Description |
---|---|
float2 | The midpoint (halfway between) touchpoint 0 and touchpoint 1. |
TwoPointMidPointVel
Gets speed of the midpoint between the first two active touch points. Use this value if you want to implement two-finger movement-like actions based on the current averaged speed of the first two touchpoints.
Declaration
public float2 TwoPointMidPointVel { get; }
Property Value
Type | Description |
---|---|
float2 | The two-dimensional speed vector of the midpoint between touchpoint 0 and touchpoint 1. |
Methods
GetPosition(TouchPoints)
Returns the current position of the given touchpoint. The returned values are only valid if GetTouchActive(TouchPoints) holds true for the same touchpoint.
Declaration
public float2 GetPosition(TouchPoints touch)
Parameters
Type | Name | Description |
---|---|---|
TouchPoints | touch | The touchpoint. |
Returns
Type | Description |
---|---|
float2 | The X/Y position of the given touchpoint. |
GetTouchActive(TouchPoints)
Returns a value signaling if the given touchpoint is currently active (if something hits the screen).
Declaration
public bool GetTouchActive(TouchPoints touch)
Parameters
Type | Name | Description |
---|---|---|
TouchPoints | touch | The touchpoint to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if this touch is active (a finger is on the screen), otherwise false. |
GetVelocity(TouchPoints)
Retrieves the current velocity (in pixels per second) of the given touch point. The returned values are only valid if GetTouchActive(TouchPoints) holds true for the same touchpoint.
Declaration
public float2 GetVelocity(TouchPoints touch)
Parameters
Type | Name | Description |
---|---|---|
TouchPoints | touch | The touchpoint. |
Returns
Type | Description |
---|---|
float2 | The two-dimensional velocity of the touchpoint. |
RegisterTtpAngleAxis()
Registers a new (Two-) touch point angle and returns the id.
Declaration
protected int RegisterTtpAngleAxis()
Returns
Type | Description |
---|---|
System.Int32 | The id of the newly registered angle axis. |
RegisterTtpDistanceAxis()
Registers a new (Two-) touch point distance and returns its id.
Declaration
protected int RegisterTtpDistanceAxis()
Returns
Type | Description |
---|---|
System.Int32 | The id of the newly registered distance. |
RegisterTtpMidpointAxis(Int32, Int32, Int32, Int32, AxisDirection, String)
Registers a new (Two-) touch point midpoint and returns its id.
Declaration
protected int RegisterTtpMidpointAxis(int axId0, int axId1, int axIdMin, int axIdMax, AxisDirection dir, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | axId0 | The first point. |
System.Int32 | axId1 | The second point. |
System.Int32 | axIdMin | The minimum value of the chosen axis. |
System.Int32 | axIdMax | The maximum value of the chosen axis. |
AxisDirection | dir | The direction of the axis. |
System.String | name | The name of the axis. |
Returns
Type | Description |
---|---|
System.Int32 | The id of the registered midpoint. |